blob: 4397b32d4f386e36df24d55814af2cd6497403c4 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -08002 * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
Govind Singh5eb51532016-03-09 11:34:12 +05304 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Govind Singh5eb51532016-03-09 11:34:12 +053019#include "wmi_unified_api.h"
20#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053021#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053022#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053023#include "wmi_version_whitelist.h"
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080024#include <qdf_module.h>
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053025#include <wlan_defs.h>
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053026#include <htc_services.h>
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053027#ifdef FEATURE_WLAN_APF
Nachiket Kukade7d4f04b2018-05-21 17:28:32 +053028#include "wmi_unified_apf_tlv.h"
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053029#endif
Wu Gaocd3a8512017-03-13 20:17:34 +080030#ifdef CONVERGED_P2P_ENABLE
31#include "wlan_p2p_public_struct.h"
32#endif
Wu Gao52c0b772018-05-17 16:14:00 +080033#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Dustin Brownf31f88b2017-05-12 14:01:44 -070034#include "wlan_pmo_hw_filter_public_struct.h"
35#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053036#include <wlan_utility.h>
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053037#ifdef WLAN_SUPPORT_GREEN_AP
38#include "wlan_green_ap_api.h"
39#endif
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053040
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080041#ifdef WLAN_FEATURE_NAN_CONVERGENCE
42#include "nan_public_structs.h"
43#endif
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070044#include "wmi_unified_twt_api.h"
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080045
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080046#ifdef WLAN_POLICY_MGR_ENABLE
47#include "wlan_policy_mgr_public_struct.h"
48#endif
49
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053050/* HTC service ids for WMI for multi-radio */
51static const uint32_t multi_svc_ids[] = {WMI_CONTROL_SVC,
52 WMI_CONTROL_SVC_WMAC1,
53 WMI_CONTROL_SVC_WMAC2};
54
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053055/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
56 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053057 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053058 * @cmd: pointer target vdev create command buffer
59 * @param: pointer host params for vdev create
60 *
61 * Return: None
62 */
63#ifdef CONFIG_MCL
64static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053065 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053066 wmi_vdev_create_cmd_fixed_param * cmd,
67 struct vdev_create_params *param)
68{
69 cmd->pdev_id = WMI_PDEV_ID_SOC;
70}
71#else
72static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053073 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053074 wmi_vdev_create_cmd_fixed_param * cmd,
75 struct vdev_create_params *param)
76{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053077 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
78 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053079}
80#endif
81
Govind Singh5eb51532016-03-09 11:34:12 +053082/**
83 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
84 * @wmi_handle: wmi handle
85 * @param: pointer to hold vdev create parameter
86 * @macaddr: vdev mac address
87 *
Govind Singhe7f2f342016-05-23 12:12:52 +053088 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053089 */
Sathish Kumarfd347372017-02-13 12:29:09 +053090static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053091 uint8_t macaddr[IEEE80211_ADDR_LEN],
92 struct vdev_create_params *param)
93{
94 wmi_vdev_create_cmd_fixed_param *cmd;
95 wmi_buf_t buf;
96 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053097 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070098 int num_bands = 2;
99 uint8_t *buf_ptr;
100 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +0530101
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700102 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +0530103 buf = wmi_buf_alloc(wmi_handle, len);
104 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530105 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530106 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530107 }
108 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
109 WMITLV_SET_HDR(&cmd->tlv_header,
110 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
111 WMITLV_GET_STRUCT_TLVLEN
112 (wmi_vdev_create_cmd_fixed_param));
113 cmd->vdev_id = param->if_id;
114 cmd->vdev_type = param->type;
115 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700116 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530117 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530118 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Neil Zhao98ec4c42017-08-10 11:51:33 -0700119 WMI_LOGD("%s: ID = %d[pdev:%d] VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
120 __func__, param->if_id, cmd->pdev_id,
Govind Singh5eb51532016-03-09 11:34:12 +0530121 macaddr[0], macaddr[1], macaddr[2],
122 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700123 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
124 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
125 (num_bands * sizeof(wmi_vdev_txrx_streams)));
126 buf_ptr += WMI_TLV_HDR_SIZE;
127
Govind Singh224a7312016-06-21 14:33:26 +0530128 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700129 param->type, param->subtype,
130 param->nss_2g, param->nss_5g);
131 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
132 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
133 txrx_streams->supported_tx_streams = param->nss_2g;
134 txrx_streams->supported_rx_streams = param->nss_2g;
135 WMITLV_SET_HDR(&txrx_streams->tlv_header,
136 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
137 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
138
139 txrx_streams++;
140 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
141 txrx_streams->supported_tx_streams = param->nss_5g;
142 txrx_streams->supported_rx_streams = param->nss_5g;
143 WMITLV_SET_HDR(&txrx_streams->tlv_header,
144 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
145 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530146 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530147 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530148 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530149 wmi_buf_free(buf);
150 }
151
152 return ret;
153}
154
155/**
156 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
157 * @wmi_handle: wmi handle
158 * @if_id: vdev id
159 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530160 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530161 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530162static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530163 uint8_t if_id)
164{
165 wmi_vdev_delete_cmd_fixed_param *cmd;
166 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530167 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530168
169 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
170 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530171 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530172 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530173 }
174
175 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
176 WMITLV_SET_HDR(&cmd->tlv_header,
177 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
178 WMITLV_GET_STRUCT_TLVLEN
179 (wmi_vdev_delete_cmd_fixed_param));
180 cmd->vdev_id = if_id;
181 ret = wmi_unified_cmd_send(wmi_handle, buf,
182 sizeof(wmi_vdev_delete_cmd_fixed_param),
183 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530184 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530185 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530186 wmi_buf_free(buf);
187 }
Govind Singhb53420c2016-03-09 14:32:57 +0530188 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530189
190 return ret;
191}
192
193/**
194 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
195 * @wmi: wmi handle
196 * @vdev_id: vdev id
197 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530198 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530199 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530200static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530201 uint8_t vdev_id)
202{
203 wmi_vdev_stop_cmd_fixed_param *cmd;
204 wmi_buf_t buf;
205 int32_t len = sizeof(*cmd);
206
207 buf = wmi_buf_alloc(wmi, len);
208 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530209 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530210 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530211 }
212 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
213 WMITLV_SET_HDR(&cmd->tlv_header,
214 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
215 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
216 cmd->vdev_id = vdev_id;
217 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530218 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530219 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530220 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530221 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530222 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530223
224 return 0;
225}
226
227/**
228 * send_vdev_down_cmd_tlv() - send vdev down command to fw
229 * @wmi: wmi handle
230 * @vdev_id: vdev id
231 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530232 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530233 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530234static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530235{
236 wmi_vdev_down_cmd_fixed_param *cmd;
237 wmi_buf_t buf;
238 int32_t len = sizeof(*cmd);
239
240 buf = wmi_buf_alloc(wmi, len);
241 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530242 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530243 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530244 }
245 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
246 WMITLV_SET_HDR(&cmd->tlv_header,
247 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
248 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
249 cmd->vdev_id = vdev_id;
250 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530251 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530252 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530253 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530254 }
Govind Singhb53420c2016-03-09 14:32:57 +0530255 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530256
257 return 0;
258}
259
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530260#ifdef CONFIG_MCL
261static inline void copy_channel_info(
262 wmi_vdev_start_request_cmd_fixed_param * cmd,
263 wmi_channel *chan,
264 struct vdev_start_params *req)
265{
266 chan->mhz = req->chan_freq;
267
268 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
269
270 chan->band_center_freq1 = req->band_center_freq1;
271 chan->band_center_freq2 = req->band_center_freq2;
272
273 if (req->is_half_rate)
274 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
275 else if (req->is_quarter_rate)
276 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
277
Naveen Rawat44f2f432016-12-01 12:58:57 -0800278 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530279 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
280 cmd->disable_hw_ack = req->dis_hw_ack;
281 }
282
283 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
284 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
285
286}
287#else
288static inline void copy_channel_info(
289 wmi_vdev_start_request_cmd_fixed_param * cmd,
290 wmi_channel *chan,
291 struct vdev_start_params *req)
292{
293 chan->mhz = req->channel.mhz;
294
295 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
296
297 chan->band_center_freq1 = req->channel.cfreq1;
298 chan->band_center_freq2 = req->channel.cfreq2;
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800299 WMI_LOGI("%s: req->channel.phy_mode: %d ", req->channel.phy_mode);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530300
301 if (req->channel.half_rate)
302 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
303 else if (req->channel.quarter_rate)
304 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
305
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800306 WMI_LOGI("%s: req->channel.dfs_set: %d ", req->channel.dfs_set);
307
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530308 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530309 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530310 cmd->disable_hw_ack = req->disable_hw_ack;
311 }
312
Krishna Rao0b952ea2017-03-20 13:30:10 +0530313 if (req->channel.dfs_set_cfreq2)
314 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
315
Kai Chen4710d462017-12-15 14:06:06 -0800316 /* According to firmware both reg power and max tx power
317 * on set channel power is used and set it to max reg
318 * power from regulatory.
319 */
320 WMI_SET_CHANNEL_MIN_POWER(chan, req->channel.minpower);
321 WMI_SET_CHANNEL_MAX_POWER(chan, req->channel.maxpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530322 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
Kai Chen4710d462017-12-15 14:06:06 -0800323 WMI_SET_CHANNEL_ANTENNA_MAX(chan, req->channel.antennamax);
324 WMI_SET_CHANNEL_REG_CLASSID(chan, req->channel.reg_class_id);
325 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxregpower);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530326
327}
328#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530329/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530330 * send_vdev_start_cmd_tlv() - send vdev start request to fw
331 * @wmi_handle: wmi handle
332 * @req: vdev start params
333 *
334 * Return: QDF status
335 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530336static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530337 struct vdev_start_params *req)
338{
339 wmi_vdev_start_request_cmd_fixed_param *cmd;
340 wmi_buf_t buf;
341 wmi_channel *chan;
342 int32_t len, ret;
343 uint8_t *buf_ptr;
344
345 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
346 buf = wmi_buf_alloc(wmi_handle, len);
347 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530348 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530349 return QDF_STATUS_E_NOMEM;
350 }
351 buf_ptr = (uint8_t *) wmi_buf_data(buf);
352 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
353 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
354 WMITLV_SET_HDR(&cmd->tlv_header,
355 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
356 WMITLV_GET_STRUCT_TLVLEN
357 (wmi_vdev_start_request_cmd_fixed_param));
358 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
359 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
360 cmd->vdev_id = req->vdev_id;
361
362 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530363 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530364
365 cmd->beacon_interval = req->beacon_intval;
366 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530367
Jiachao Wub89e3bf2017-08-23 15:27:11 +0800368 cmd->bcn_tx_rate = req->bcn_tx_rate_code;
369 if (req->bcn_tx_rate_code)
370 cmd->flags |= WMI_UNIFIED_VDEV_START_BCN_TX_RATE_PRESENT;
371
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530372 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530373 cmd->beacon_interval = req->beacon_intval;
374 cmd->dtim_period = req->dtim_period;
375
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530376 /* Copy the SSID */
377 if (req->ssid.length) {
378 if (req->ssid.length < sizeof(cmd->ssid.ssid))
379 cmd->ssid.ssid_len = req->ssid.length;
380 else
381 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
382 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
383 cmd->ssid.ssid_len);
384 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530385
386 if (req->hidden_ssid)
387 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
388
389 if (req->pmf_enabled)
390 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530391 }
392
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700393 cmd->flags |= WMI_UNIFIED_VDEV_START_LDPC_RX_ENABLED;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530394 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530395 cmd->preferred_rx_streams = req->preferred_rx_streams;
396 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700397 cmd->cac_duration_ms = req->cac_duration_ms;
398 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700399 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530400
401 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
402 sizeof(wmi_channel));
403 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
404 cmd->num_noa_descriptors *
405 sizeof(wmi_p2p_noa_descriptor));
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -0800406 WMI_LOGI("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530407 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
408 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800409 "Tx SS %d, Rx SS %d, ldpc_rx: %d, cac %d, regd %d, HE ops: %d"
410 "req->dis_hw_ack: %d ", __func__, req->vdev_id,
411 chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530412 req->is_dfs, req->beacon_intval, cmd->dtim_period,
413 chan->band_center_freq1, chan->band_center_freq2,
414 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700415 req->preferred_tx_streams, req->preferred_rx_streams,
Varun Reddy Yeturu3e4d8192017-03-20 17:28:42 -0700416 req->ldpc_rx_enabled, req->cac_duration_ms,
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -0800417 req->regdomain, req->he_ops,
418 req->dis_hw_ack);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530419
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530420 if (req->is_restart)
421 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
422 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530423 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530424 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
425 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530426 if (ret) {
427 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530428 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530429 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530430 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530431
432 return QDF_STATUS_SUCCESS;
433}
434
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530435/**
436 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
437 * @wmi_handle: wmi handle
438 * @restart_params: vdev restart params
439 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530440 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530441 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530442static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530443 struct hidden_ssid_vdev_restart_params *restart_params)
444{
445 wmi_vdev_start_request_cmd_fixed_param *cmd;
446 wmi_buf_t buf;
447 wmi_channel *chan;
448 int32_t len;
449 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530450 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530451
452 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
453 buf = wmi_buf_alloc(wmi_handle, len);
454 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530455 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530456 return QDF_STATUS_E_NOMEM;
457 }
458 buf_ptr = (uint8_t *) wmi_buf_data(buf);
459 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
460 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
461
462 WMITLV_SET_HDR(&cmd->tlv_header,
463 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
464 WMITLV_GET_STRUCT_TLVLEN
465 (wmi_vdev_start_request_cmd_fixed_param));
466
467 WMITLV_SET_HDR(&chan->tlv_header,
468 WMITLV_TAG_STRUC_wmi_channel,
469 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
470
471 cmd->vdev_id = restart_params->session_id;
472 cmd->ssid.ssid_len = restart_params->ssid_len;
473 qdf_mem_copy(cmd->ssid.ssid,
474 restart_params->ssid,
475 cmd->ssid.ssid_len);
476 cmd->flags = restart_params->flags;
477 cmd->requestor_id = restart_params->requestor_id;
478 cmd->disable_hw_ack = restart_params->disable_hw_ack;
479
480 chan->mhz = restart_params->mhz;
481 chan->band_center_freq1 =
482 restart_params->band_center_freq1;
483 chan->band_center_freq2 =
484 restart_params->band_center_freq2;
485 chan->info = restart_params->info;
486 chan->reg_info_1 = restart_params->reg_info_1;
487 chan->reg_info_2 = restart_params->reg_info_2;
488
489 cmd->num_noa_descriptors = 0;
490 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
491 sizeof(wmi_channel));
492 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
493 cmd->num_noa_descriptors *
494 sizeof(wmi_p2p_noa_descriptor));
495
496 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
497 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530498 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530499 wmi_buf_free(buf);
500 return QDF_STATUS_E_FAILURE;
501 }
502 return QDF_STATUS_SUCCESS;
503}
504
505
506/**
Govind Singh5eb51532016-03-09 11:34:12 +0530507 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
508 * @wmi: wmi handle
509 * @peer_addr: peer mac address
510 * @param: pointer to hold peer flush tid parameter
511 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -0700512 * Return: 0 for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530513 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530514static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530515 uint8_t peer_addr[IEEE80211_ADDR_LEN],
516 struct peer_flush_params *param)
517{
518 wmi_peer_flush_tids_cmd_fixed_param *cmd;
519 wmi_buf_t buf;
520 int32_t len = sizeof(*cmd);
521
522 buf = wmi_buf_alloc(wmi, len);
523 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530524 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530525 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530526 }
527 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
528 WMITLV_SET_HDR(&cmd->tlv_header,
529 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
530 WMITLV_GET_STRUCT_TLVLEN
531 (wmi_peer_flush_tids_cmd_fixed_param));
532 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
533 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
534 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530535 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530536 peer_addr, param->vdev_id,
537 param->peer_tid_bitmap);
538 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530539 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530540 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530541 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530542 }
543
544 return 0;
545}
546
547/**
548 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
549 * @wmi: wmi handle
550 * @peer_addr: peer mac addr
551 * @vdev_id: vdev id
552 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530553 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530554 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530555static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530556 uint8_t peer_addr[IEEE80211_ADDR_LEN],
557 uint8_t vdev_id)
558{
559 wmi_peer_delete_cmd_fixed_param *cmd;
560 wmi_buf_t buf;
561 int32_t len = sizeof(*cmd);
562 buf = wmi_buf_alloc(wmi, len);
563 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530564 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530565 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530566 }
567 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
568 WMITLV_SET_HDR(&cmd->tlv_header,
569 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
570 WMITLV_GET_STRUCT_TLVLEN
571 (wmi_peer_delete_cmd_fixed_param));
572 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
573 cmd->vdev_id = vdev_id;
574
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800575 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530576 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530577 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530578 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530579 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530580 }
Govind Singh5eb51532016-03-09 11:34:12 +0530581
582 return 0;
583}
584
585/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530586 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
587 * to target id.
588 * @targ_paramid: Target parameter id to hold the result.
589 * @peer_param_id: host param id.
590 *
591 * Return: QDF_STATUS_SUCCESS for success
592 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
593 */
594#ifdef CONFIG_MCL
595static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
596 uint32_t *targ_paramid,
597 uint32_t peer_param_id)
598{
599 *targ_paramid = peer_param_id;
600 return QDF_STATUS_SUCCESS;
601}
602#else
603static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
604 uint32_t *targ_paramid,
605 uint32_t peer_param_id)
606{
607 switch (peer_param_id) {
608 case WMI_HOST_PEER_MIMO_PS_STATE:
609 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
610 break;
611 case WMI_HOST_PEER_AMPDU:
612 *targ_paramid = WMI_PEER_AMPDU;
613 break;
614 case WMI_HOST_PEER_AUTHORIZE:
615 *targ_paramid = WMI_PEER_AUTHORIZE;
616 break;
617 case WMI_HOST_PEER_CHWIDTH:
618 *targ_paramid = WMI_PEER_CHWIDTH;
619 break;
620 case WMI_HOST_PEER_NSS:
621 *targ_paramid = WMI_PEER_NSS;
622 break;
623 case WMI_HOST_PEER_USE_4ADDR:
624 *targ_paramid = WMI_PEER_USE_4ADDR;
625 break;
626 case WMI_HOST_PEER_MEMBERSHIP:
627 *targ_paramid = WMI_PEER_MEMBERSHIP;
628 break;
629 case WMI_HOST_PEER_USERPOS:
630 *targ_paramid = WMI_PEER_USERPOS;
631 break;
632 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
633 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
634 break;
635 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
636 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
637 break;
638 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
639 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
640 break;
641 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
642 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
643 break;
644 case WMI_HOST_PEER_PHYMODE:
645 *targ_paramid = WMI_PEER_PHYMODE;
646 break;
647 case WMI_HOST_PEER_USE_FIXED_PWR:
648 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
649 break;
650 case WMI_HOST_PEER_PARAM_FIXED_RATE:
651 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
652 break;
653 case WMI_HOST_PEER_SET_MU_WHITELIST:
654 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
655 break;
656 case WMI_HOST_PEER_SET_MAC_TX_RATE:
657 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
658 break;
659 case WMI_HOST_PEER_SET_MIN_TX_RATE:
660 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
661 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530662 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
663 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
664 break;
Soumya Bhat8db697d2017-08-29 18:49:13 +0530665 case WMI_HOST_PEER_NSS_VHT160:
666 *targ_paramid = WMI_PEER_NSS_VHT160;
667 break;
668 case WMI_HOST_PEER_NSS_VHT80_80:
669 *targ_paramid = WMI_PEER_NSS_VHT80_80;
670 break;
Venkateswara Swamy Bandaru65745ba2018-01-09 15:52:37 +0530671 case WMI_HOST_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL:
672 *targ_paramid = WMI_PEER_PARAM_SU_TXBF_SOUNDING_INTERVAL;
673 break;
674 case WMI_HOST_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL:
675 *targ_paramid = WMI_PEER_PARAM_MU_TXBF_SOUNDING_INTERVAL;
676 break;
677 case WMI_HOST_PEER_PARAM_TXBF_SOUNDING_ENABLE:
678 *targ_paramid = WMI_PEER_PARAM_TXBF_SOUNDING_ENABLE;
679 break;
Venkateswara Swamy Bandaru094bc7a2018-01-09 15:56:56 +0530680 case WMI_HOST_PEER_PARAM_MU_ENABLE:
681 *targ_paramid = WMI_PEER_PARAM_MU_ENABLE;
682 break;
683 case WMI_HOST_PEER_PARAM_OFDMA_ENABLE:
684 *targ_paramid = WMI_PEER_PARAM_OFDMA_ENABLE;
685 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530686 default:
687 return QDF_STATUS_E_NOSUPPORT;
688 }
689
690 return QDF_STATUS_SUCCESS;
691}
692#endif
693/**
Govind Singh5eb51532016-03-09 11:34:12 +0530694 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530695 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530696 * @peer_addr: peer mac address
697 * @param : pointer to hold peer set parameter
698 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530699 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530700 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530701static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530702 uint8_t peer_addr[IEEE80211_ADDR_LEN],
703 struct peer_set_params *param)
704{
705 wmi_peer_set_param_cmd_fixed_param *cmd;
706 wmi_buf_t buf;
707 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530708 uint32_t param_id;
709
710 if (convert_host_peer_id_to_target_id_tlv(&param_id,
711 param->param_id) != QDF_STATUS_SUCCESS)
712 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530713
714 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
715 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530716 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530717 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530718 }
719 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
720 WMITLV_SET_HDR(&cmd->tlv_header,
721 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
722 WMITLV_GET_STRUCT_TLVLEN
723 (wmi_peer_set_param_cmd_fixed_param));
724 cmd->vdev_id = param->vdev_id;
725 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530726 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530727 cmd->param_value = param->param_value;
728 err = wmi_unified_cmd_send(wmi, buf,
729 sizeof(wmi_peer_set_param_cmd_fixed_param),
730 WMI_PEER_SET_PARAM_CMDID);
731 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530732 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530733 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530734 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530735 }
736
737 return 0;
738}
739
740/**
741 * send_vdev_up_cmd_tlv() - send vdev up command in fw
742 * @wmi: wmi handle
743 * @bssid: bssid
744 * @vdev_up_params: pointer to hold vdev up parameter
745 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530746 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530747 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530748static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530749 uint8_t bssid[IEEE80211_ADDR_LEN],
750 struct vdev_up_params *params)
751{
752 wmi_vdev_up_cmd_fixed_param *cmd;
753 wmi_buf_t buf;
754 int32_t len = sizeof(*cmd);
755
Govind Singhb53420c2016-03-09 14:32:57 +0530756 WMI_LOGD("%s: VDEV_UP", __func__);
757 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530758 params->vdev_id, params->assoc_id, bssid);
759 buf = wmi_buf_alloc(wmi, len);
760 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530761 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530762 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530763 }
764 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
765 WMITLV_SET_HDR(&cmd->tlv_header,
766 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
767 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
768 cmd->vdev_id = params->vdev_id;
769 cmd->vdev_assoc_id = params->assoc_id;
770 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
771 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530772 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530773 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530774 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530775 }
776
777 return 0;
778}
779
780/**
781 * send_peer_create_cmd_tlv() - send peer create command to fw
782 * @wmi: wmi handle
783 * @peer_addr: peer mac address
784 * @peer_type: peer type
785 * @vdev_id: vdev id
786 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530787 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530788 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530789static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530790 struct peer_create_params *param)
791{
792 wmi_peer_create_cmd_fixed_param *cmd;
793 wmi_buf_t buf;
794 int32_t len = sizeof(*cmd);
795
796 buf = wmi_buf_alloc(wmi, len);
797 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530798 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530799 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530800 }
801 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
802 WMITLV_SET_HDR(&cmd->tlv_header,
803 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
804 WMITLV_GET_STRUCT_TLVLEN
805 (wmi_peer_create_cmd_fixed_param));
806 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
807 cmd->peer_type = param->peer_type;
808 cmd->vdev_id = param->vdev_id;
809
810 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530811 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530812 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530813 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530814 }
Govind Singhb53420c2016-03-09 14:32:57 +0530815 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530816 param->vdev_id);
817
818 return 0;
819}
820
821/**
Leo Changeee40872016-09-28 13:43:36 -0700822 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
823 * command to fw
824 * @wmi: wmi handle
825 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
826 *
827 * Return: 0 for success or error code
828 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700829static
Leo Changeee40872016-09-28 13:43:36 -0700830QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
831 struct rx_reorder_queue_setup_params *param)
832{
833 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
834 wmi_buf_t buf;
835 int32_t len = sizeof(*cmd);
836
837 buf = wmi_buf_alloc(wmi, len);
838 if (!buf) {
839 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
840 return QDF_STATUS_E_NOMEM;
841 }
842 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
843 WMITLV_SET_HDR(&cmd->tlv_header,
844 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
845 WMITLV_GET_STRUCT_TLVLEN
846 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
847 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
848 cmd->vdev_id = param->vdev_id;
849 cmd->tid = param->tid;
850 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
851 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
852 cmd->queue_no = param->queue_no;
853
854 if (wmi_unified_cmd_send(wmi, buf, len,
855 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
856 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
857 __func__);
858 qdf_nbuf_free(buf);
859 return QDF_STATUS_E_FAILURE;
860 }
861 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
862 param->peer_macaddr, param->vdev_id, param->tid);
863
864 return QDF_STATUS_SUCCESS;
865}
866
867/**
868 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
869 * command to fw
870 * @wmi: wmi handle
871 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
872 *
873 * Return: 0 for success or error code
874 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700875static
Leo Changeee40872016-09-28 13:43:36 -0700876QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
877 struct rx_reorder_queue_remove_params *param)
878{
879 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
880 wmi_buf_t buf;
881 int32_t len = sizeof(*cmd);
882
883 buf = wmi_buf_alloc(wmi, len);
884 if (!buf) {
885 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
886 return QDF_STATUS_E_NOMEM;
887 }
888 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
889 wmi_buf_data(buf);
890 WMITLV_SET_HDR(&cmd->tlv_header,
891 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
892 WMITLV_GET_STRUCT_TLVLEN
893 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
894 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
895 cmd->vdev_id = param->vdev_id;
896 cmd->tid_mask = param->peer_tid_bitmap;
897
898 if (wmi_unified_cmd_send(wmi, buf, len,
899 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
900 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
901 __func__);
902 qdf_nbuf_free(buf);
903 return QDF_STATUS_E_FAILURE;
904 }
905 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
906 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
907
908 return QDF_STATUS_SUCCESS;
909}
910
911/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530912 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
913 * @wmi_handle: wmi handle
914 * @param: pointer holding peer details
915 *
916 * Return: 0 for success or error code
917 */
918static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
919 struct peer_add_wds_entry_params *param)
920{
921 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
922 wmi_buf_t buf;
923 int len = sizeof(*cmd);
924
925 buf = wmi_buf_alloc(wmi_handle, len);
926 if (!buf) {
927 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
928 return QDF_STATUS_E_FAILURE;
929 }
930 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
931 WMITLV_SET_HDR(&cmd->tlv_header,
932 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
933 WMITLV_GET_STRUCT_TLVLEN
934 (wmi_peer_add_wds_entry_cmd_fixed_param));
935 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
936 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800937 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
938 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530939
940 return wmi_unified_cmd_send(wmi_handle, buf, len,
941 WMI_PEER_ADD_WDS_ENTRY_CMDID);
942}
943
944/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530945 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530946 * @wmi_handle: wmi handle
947 * @param: pointer holding peer details
948 *
949 * Return: 0 for success or error code
950 */
951static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
952 struct peer_del_wds_entry_params *param)
953{
954 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
955 wmi_buf_t buf;
956 int len = sizeof(*cmd);
957
958 buf = wmi_buf_alloc(wmi_handle, len);
959 if (!buf) {
960 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
961 return QDF_STATUS_E_NOMEM;
962 }
963 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
964 WMITLV_SET_HDR(&cmd->tlv_header,
965 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
966 WMITLV_GET_STRUCT_TLVLEN
967 (wmi_peer_remove_wds_entry_cmd_fixed_param));
968 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
Kris Muthusamyc2e54712018-01-17 19:08:08 -0800969 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530970 return wmi_unified_cmd_send(wmi_handle, buf, len,
971 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
972}
973
974/**
975 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
976 * @wmi_handle: wmi handle
977 * @param: pointer holding peer details
978 *
979 * Return: 0 for success or error code
980 */
981static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
982 struct peer_update_wds_entry_params *param)
983{
984 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
985 wmi_buf_t buf;
986 int len = sizeof(*cmd);
987
988 buf = wmi_buf_alloc(wmi_handle, len);
989 if (!buf) {
990 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
991 return QDF_STATUS_E_NOMEM;
992 }
993
994 /* wmi_buf_alloc returns zeroed command buffer */
995 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
996 WMITLV_SET_HDR(&cmd->tlv_header,
997 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
998 WMITLV_GET_STRUCT_TLVLEN
999 (wmi_peer_update_wds_entry_cmd_fixed_param));
Kris Muthusamyc2e54712018-01-17 19:08:08 -08001000 cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ? WMI_WDS_FLAG_STATIC : 0;
1001 cmd->vdev_id = param->vdev_id;
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301002 if (param->wds_macaddr)
1003 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
1004 &cmd->wds_macaddr);
1005 if (param->peer_macaddr)
1006 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
1007 &cmd->peer_macaddr);
1008 return wmi_unified_cmd_send(wmi_handle, buf, len,
1009 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
1010}
1011
Shaakir Mohamed75208c32018-02-15 14:30:21 -08001012/**
1013 * send_pdev_get_tpc_config_cmd_tlv() - send get tpc config command to fw
1014 * @wmi_handle: wmi handle
1015 * @param: pointer to get tpc config params
1016 *
1017 * Return: 0 for success or error code
1018 */
1019static QDF_STATUS
1020send_pdev_get_tpc_config_cmd_tlv(wmi_unified_t wmi_handle,
1021 uint32_t param)
1022{
1023 wmi_pdev_get_tpc_config_cmd_fixed_param *cmd;
1024 wmi_buf_t buf;
1025 int32_t len = sizeof(wmi_pdev_get_tpc_config_cmd_fixed_param);
1026
1027 buf = wmi_buf_alloc(wmi_handle, len);
1028 if (!buf) {
1029 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
1030 return QDF_STATUS_E_NOMEM;
1031 }
1032 cmd = (wmi_pdev_get_tpc_config_cmd_fixed_param *)wmi_buf_data(buf);
1033 WMITLV_SET_HDR(&cmd->tlv_header,
1034 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_config_cmd_fixed_param,
1035 WMITLV_GET_STRUCT_TLVLEN
1036 (wmi_pdev_get_tpc_config_cmd_fixed_param));
1037
1038 cmd->param = param;
1039 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1040 WMI_PDEV_GET_TPC_CONFIG_CMDID)) {
1041 WMI_LOGE("Send pdev get tpc config cmd failed");
1042 wmi_buf_free(buf);
1043 return QDF_STATUS_E_FAILURE;
1044
1045 }
1046 WMI_LOGD("%s:send success", __func__);
1047
1048 return QDF_STATUS_SUCCESS;
1049}
1050
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301051#ifdef WLAN_SUPPORT_GREEN_AP
Ishank Jainf4b8a7a2017-02-23 22:38:42 +05301052/**
Govind Singh5eb51532016-03-09 11:34:12 +05301053 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
1054 * @wmi_handle: wmi handle
1055 * @value: value
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301056 * @pdev_id: pdev id to have radio context
Govind Singh5eb51532016-03-09 11:34:12 +05301057 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301058 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301059 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301060static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301061 uint32_t value, uint8_t pdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +05301062{
1063 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
1064 wmi_buf_t buf;
1065 int32_t len = sizeof(*cmd);
1066
Govind Singhb53420c2016-03-09 14:32:57 +05301067 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +05301068
1069 buf = wmi_buf_alloc(wmi_handle, len);
1070 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301071 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301072 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301073 }
1074
1075 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
1076 WMITLV_SET_HDR(&cmd->tlv_header,
1077 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
1078 WMITLV_GET_STRUCT_TLVLEN
1079 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301080 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301081 cmd->enable = value;
1082
1083 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1084 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301085 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301086 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301087 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301088 }
1089
1090 return 0;
1091}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05301092#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301093
1094/**
1095 * send_pdev_utf_cmd_tlv() - send utf command to fw
1096 * @wmi_handle: wmi handle
1097 * @param: pointer to pdev_utf_params
1098 * @mac_id: mac id to have radio context
1099 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301100 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301101 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301102static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301103send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1104 struct pdev_utf_params *param,
1105 uint8_t mac_id)
1106{
1107 wmi_buf_t buf;
1108 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001109 /* if param->len is 0 no data is sent, return error */
1110 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301111 static uint8_t msgref = 1;
1112 uint8_t segNumber = 0, segInfo, numSegments;
1113 uint16_t chunk_len, total_bytes;
1114 uint8_t *bufpos;
1115 struct seg_hdr_info segHdrInfo;
1116
1117 bufpos = param->utf_payload;
1118 total_bytes = param->len;
1119 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1120 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1121 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1122
1123 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1124 numSegments++;
1125
1126 while (param->len) {
1127 if (param->len > MAX_WMI_UTF_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -07001128 chunk_len = MAX_WMI_UTF_LEN; /* MAX message */
Govind Singh5eb51532016-03-09 11:34:12 +05301129 else
1130 chunk_len = param->len;
1131
1132 buf = wmi_buf_alloc(wmi_handle,
1133 (chunk_len + sizeof(segHdrInfo) +
1134 WMI_TLV_HDR_SIZE));
1135 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301136 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301137 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301138 }
1139
1140 cmd = (uint8_t *) wmi_buf_data(buf);
1141
1142 segHdrInfo.len = total_bytes;
1143 segHdrInfo.msgref = msgref;
1144 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1145 segHdrInfo.segmentInfo = segInfo;
1146 segHdrInfo.pad = 0;
1147
Govind Singhb53420c2016-03-09 14:32:57 +05301148 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301149 " segHdrInfo.segmentInfo = %d",
1150 __func__, segHdrInfo.len, segHdrInfo.msgref,
1151 segHdrInfo.segmentInfo);
1152
Govind Singhb53420c2016-03-09 14:32:57 +05301153 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301154 "chunk len %d", __func__, total_bytes, segNumber,
1155 numSegments, chunk_len);
1156
1157 segNumber++;
1158
1159 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1160 (chunk_len + sizeof(segHdrInfo)));
1161 cmd += WMI_TLV_HDR_SIZE;
1162 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1163 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1164
1165 ret = wmi_unified_cmd_send(wmi_handle, buf,
1166 (chunk_len + sizeof(segHdrInfo) +
1167 WMI_TLV_HDR_SIZE),
1168 WMI_PDEV_UTF_CMDID);
1169
Govind Singh67922e82016-04-01 16:48:57 +05301170 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301171 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301172 wmi_buf_free(buf);
1173 break;
1174 }
1175
1176 param->len -= chunk_len;
1177 bufpos += chunk_len;
1178 }
1179
1180 msgref++;
1181
1182 return ret;
1183}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301184#ifdef CONFIG_MCL
1185static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1186 uint32_t host_param)
1187{
1188 return host_param;
1189}
1190#else
1191static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1192 uint32_t host_param)
1193{
1194 if (host_param < wmi_pdev_param_max)
1195 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301196
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301197 return WMI_UNAVAILABLE_PARAM;
1198}
1199#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301200/**
1201 * send_pdev_param_cmd_tlv() - set pdev parameters
1202 * @wmi_handle: wmi handle
1203 * @param: pointer to pdev parameter
1204 * @mac_id: radio context
1205 *
1206 * Return: 0 on success, errno on failure
1207 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301208static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301209send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1210 struct pdev_params *param,
1211 uint8_t mac_id)
1212{
Govind Singh67922e82016-04-01 16:48:57 +05301213 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301214 wmi_pdev_set_param_cmd_fixed_param *cmd;
1215 wmi_buf_t buf;
1216 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301217 uint32_t pdev_param;
1218
1219 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1220 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1221 WMI_LOGW("%s: Unavailable param %d\n",
1222 __func__, param->param_id);
1223 return QDF_STATUS_E_INVAL;
1224 }
Govind Singh5eb51532016-03-09 11:34:12 +05301225
1226 buf = wmi_buf_alloc(wmi_handle, len);
1227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301228 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301229 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301230 }
1231 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1232 WMITLV_SET_HDR(&cmd->tlv_header,
1233 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1234 WMITLV_GET_STRUCT_TLVLEN
1235 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301236 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301237 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301238 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301239 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301240 param->param_value);
1241 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1242 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301243 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301244 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301245 wmi_buf_free(buf);
1246 }
1247 return ret;
1248}
1249
1250/**
1251 * send_suspend_cmd_tlv() - WMI suspend function
1252 * @param wmi_handle : handle to WMI.
1253 * @param param : pointer to hold suspend parameter
1254 * @mac_id: radio context
1255 *
1256 * Return 0 on success and -ve on failure.
1257 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301258static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301259 struct suspend_params *param,
1260 uint8_t mac_id)
1261{
1262 wmi_pdev_suspend_cmd_fixed_param *cmd;
1263 wmi_buf_t wmibuf;
1264 uint32_t len = sizeof(*cmd);
1265 int32_t ret;
1266
1267 /*
Jeff Johnson19a59fe2018-05-06 16:10:43 -07001268 * send the command to Target to ignore the
Govind Singh5eb51532016-03-09 11:34:12 +05301269 * PCIE reset so as to ensure that Host and target
1270 * states are in sync
1271 */
1272 wmibuf = wmi_buf_alloc(wmi_handle, len);
1273 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301274 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301275
1276 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1277 WMITLV_SET_HDR(&cmd->tlv_header,
1278 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1279 WMITLV_GET_STRUCT_TLVLEN
1280 (wmi_pdev_suspend_cmd_fixed_param));
1281 if (param->disable_target_intr)
1282 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1283 else
1284 cmd->suspend_opt = WMI_PDEV_SUSPEND;
Kiran Venkatappa330179c2017-06-13 20:44:54 +05301285
1286 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
1287
Govind Singh5eb51532016-03-09 11:34:12 +05301288 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1289 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301290 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301291 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301292 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301293 }
1294
1295 return ret;
1296}
1297
1298/**
1299 * send_resume_cmd_tlv() - WMI resume function
1300 * @param wmi_handle : handle to WMI.
1301 * @mac_id: radio context
1302 *
1303 * Return: 0 on success and -ve on failure.
1304 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301305static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301306 uint8_t mac_id)
1307{
1308 wmi_buf_t wmibuf;
1309 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301310 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301311
1312 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1313 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301314 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301315 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1316 WMITLV_SET_HDR(&cmd->tlv_header,
1317 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1318 WMITLV_GET_STRUCT_TLVLEN
1319 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301320 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301321 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1322 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301323 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301324 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301325 wmi_buf_free(wmibuf);
1326 }
1327
1328 return ret;
1329}
1330
Will Huang422ac9a2017-11-17 13:19:16 +08001331#ifdef FEATURE_WLAN_D0WOW
1332/**
1333 * send_d0wow_enable_cmd_tlv() - WMI d0 wow enable function
1334 * @param wmi_handle: handle to WMI.
1335 * @mac_id: radio context
1336 *
1337 * Return: 0 on success and error code on failure.
1338 */
1339static QDF_STATUS send_d0wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
1340 uint8_t mac_id)
1341{
1342 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1343 wmi_buf_t buf;
1344 int32_t len;
1345 QDF_STATUS status;
1346
1347 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1348
1349 buf = wmi_buf_alloc(wmi_handle, len);
1350 if (!buf) {
1351 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1352 return QDF_STATUS_E_NOMEM;
1353 }
1354 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1355 WMITLV_SET_HDR(&cmd->tlv_header,
1356 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1357 WMITLV_GET_STRUCT_TLVLEN
1358 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1359
1360 cmd->enable = true;
1361
1362 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1363 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1364 if (QDF_IS_STATUS_ERROR(status))
1365 wmi_buf_free(buf);
1366
1367 return status;
1368}
1369
1370/**
1371 * send_d0wow_disable_cmd_tlv() - WMI d0 wow disable function
1372 * @param wmi_handle: handle to WMI.
1373 * @mac_id: radio context
1374 *
1375 * Return: 0 on success and error code on failure.
1376 */
1377static QDF_STATUS send_d0wow_disable_cmd_tlv(wmi_unified_t wmi_handle,
1378 uint8_t mac_id)
1379{
1380 wmi_d0_wow_enable_disable_cmd_fixed_param *cmd;
1381 wmi_buf_t buf;
1382 int32_t len;
1383 QDF_STATUS status;
1384
1385 len = sizeof(wmi_d0_wow_enable_disable_cmd_fixed_param);
1386
1387 buf = wmi_buf_alloc(wmi_handle, len);
1388 if (!buf) {
1389 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1390 return QDF_STATUS_E_NOMEM;
1391 }
1392 cmd = (wmi_d0_wow_enable_disable_cmd_fixed_param *) wmi_buf_data(buf);
1393 WMITLV_SET_HDR(&cmd->tlv_header,
1394 WMITLV_TAG_STRUC_wmi_d0_wow_enable_disable_cmd_fixed_param,
1395 WMITLV_GET_STRUCT_TLVLEN
1396 (wmi_d0_wow_enable_disable_cmd_fixed_param));
1397
1398 cmd->enable = false;
1399
1400 status = wmi_unified_cmd_send(wmi_handle, buf, len,
1401 WMI_D0_WOW_ENABLE_DISABLE_CMDID);
1402 if (QDF_IS_STATUS_ERROR(status))
1403 wmi_buf_free(buf);
1404
1405 return status;
1406}
1407#endif
1408
Govind Singh5eb51532016-03-09 11:34:12 +05301409/**
1410 * send_wow_enable_cmd_tlv() - WMI wow enable function
1411 * @param wmi_handle : handle to WMI.
1412 * @param param : pointer to hold wow enable parameter
1413 * @mac_id: radio context
1414 *
1415 * Return: 0 on success and -ve on failure.
1416 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301417static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301418 struct wow_cmd_params *param,
1419 uint8_t mac_id)
1420{
1421 wmi_wow_enable_cmd_fixed_param *cmd;
1422 wmi_buf_t buf;
1423 int32_t len;
1424 int32_t ret;
1425
1426 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1427
1428 buf = wmi_buf_alloc(wmi_handle, len);
1429 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301430 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1431 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301432 }
1433 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1434 WMITLV_SET_HDR(&cmd->tlv_header,
1435 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1436 WMITLV_GET_STRUCT_TLVLEN
1437 (wmi_wow_enable_cmd_fixed_param));
1438 cmd->enable = param->enable;
1439 if (param->can_suspend_link)
1440 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1441 else
1442 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001443 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301444
Govind Singhb53420c2016-03-09 14:32:57 +05301445 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301446 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1447 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1448
1449 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1450 WMI_WOW_ENABLE_CMDID);
1451 if (ret)
1452 wmi_buf_free(buf);
1453
1454 return ret;
1455}
1456
1457/**
1458 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301459 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301460 * @peer_addr: peer mac address
1461 * @param: pointer to ap_ps parameter structure
1462 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301463 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301464 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301465static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301466 uint8_t *peer_addr,
1467 struct ap_ps_params *param)
1468{
1469 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1470 wmi_buf_t buf;
1471 int32_t err;
1472
1473 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1474 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301475 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301476 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301477 }
1478 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1479 WMITLV_SET_HDR(&cmd->tlv_header,
1480 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1481 WMITLV_GET_STRUCT_TLVLEN
1482 (wmi_ap_ps_peer_cmd_fixed_param));
1483 cmd->vdev_id = param->vdev_id;
1484 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1485 cmd->param = param->param;
1486 cmd->value = param->value;
1487 err = wmi_unified_cmd_send(wmi_handle, buf,
1488 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1489 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301490 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301491 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301492 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301493 }
1494
1495 return 0;
1496}
1497
1498/**
1499 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301500 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301501 * @peer_addr: peer mac address
1502 * @param: pointer to sta_ps parameter structure
1503 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301504 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301505 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301506static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301507 struct sta_ps_params *param)
1508{
1509 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1510 wmi_buf_t buf;
1511 int32_t len = sizeof(*cmd);
1512
1513 buf = wmi_buf_alloc(wmi_handle, len);
1514 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301515 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301516 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301517 }
1518
1519 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1520 WMITLV_SET_HDR(&cmd->tlv_header,
1521 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1522 WMITLV_GET_STRUCT_TLVLEN
1523 (wmi_sta_powersave_param_cmd_fixed_param));
1524 cmd->vdev_id = param->vdev_id;
1525 cmd->param = param->param;
1526 cmd->value = param->value;
1527
1528 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1529 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301530 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301531 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301532 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301533 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301534 }
1535
1536 return 0;
1537}
1538
1539/**
1540 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301541 * @wmi_handle: wmi handle
Jeff Johnsonbbd428c2018-05-06 17:02:16 -07001542 * @param: ponirt to crash inject parameter structure
Govind Singh5eb51532016-03-09 11:34:12 +05301543 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301544 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301545 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301546static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301547 struct crash_inject *param)
1548{
1549 int32_t ret = 0;
1550 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1551 uint16_t len = sizeof(*cmd);
1552 wmi_buf_t buf;
1553
1554 buf = wmi_buf_alloc(wmi_handle, len);
1555 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301556 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301557 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301558 }
1559
1560 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1561 WMITLV_SET_HDR(&cmd->tlv_header,
1562 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1563 WMITLV_GET_STRUCT_TLVLEN
1564 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1565 cmd->type = param->type;
1566 cmd->delay_time_ms = param->delay_time_ms;
1567
1568 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1569 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301570 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301571 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301572 __func__, ret);
1573 wmi_buf_free(buf);
1574 }
1575
1576 return ret;
1577}
1578
Wen Gongca174012018-04-20 16:56:28 +08001579#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +05301580/**
1581 * send_dbglog_cmd_tlv() - set debug log level
1582 * @param wmi_handle : handle to WMI.
1583 * @param param : pointer to hold dbglog level parameter
1584 *
1585 * Return: 0 on success and -ve on failure.
1586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301587 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301588send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1589 struct dbglog_params *dbglog_param)
1590{
1591 wmi_buf_t buf;
1592 wmi_debug_log_config_cmd_fixed_param *configmsg;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001593 QDF_STATUS status;
Govind Singh5eb51532016-03-09 11:34:12 +05301594 int32_t i;
1595 int32_t len;
1596 int8_t *buf_ptr;
1597 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1598
Alok Kumar240afea2017-08-30 14:45:34 +05301599 ASSERT(dbglog_param->bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301600
1601 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1602 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1603 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1604 buf = wmi_buf_alloc(wmi_handle, len);
1605 if (buf == NULL)
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001606 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301607
1608 configmsg =
1609 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1610 buf_ptr = (int8_t *) configmsg;
1611 WMITLV_SET_HDR(&configmsg->tlv_header,
1612 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1613 WMITLV_GET_STRUCT_TLVLEN
1614 (wmi_debug_log_config_cmd_fixed_param));
1615 configmsg->dbg_log_param = dbglog_param->param;
1616 configmsg->value = dbglog_param->val;
1617 /* Filling in the data part of second tlv -- should
1618 * follow first tlv _ WMI_TLV_HDR_SIZE */
Vivekc5823092018-03-22 23:27:21 +05301619 module_id_bitmap_array = (uint32_t *) (buf_ptr +
Govind Singh5eb51532016-03-09 11:34:12 +05301620 sizeof
1621 (wmi_debug_log_config_cmd_fixed_param)
1622 + WMI_TLV_HDR_SIZE);
1623 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1624 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +05301625 sizeof(uint32_t) * MAX_MODULE_ID_BITMAP_WORDS);
Govind Singh5eb51532016-03-09 11:34:12 +05301626 if (dbglog_param->module_id_bitmap) {
1627 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1628 module_id_bitmap_array[i] =
1629 dbglog_param->module_id_bitmap[i];
1630 }
1631 }
1632
1633 status = wmi_unified_cmd_send(wmi_handle, buf,
1634 len, WMI_DBGLOG_CFG_CMDID);
1635
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -07001636 if (status != QDF_STATUS_SUCCESS)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301637 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301638
1639 return status;
1640}
Wen Gongca174012018-04-20 16:56:28 +08001641#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301642
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
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303042#ifdef CONFIG_HL_SUPPORT
3043/**
3044 * send_mgmt_cmd_tlv() - WMI scan start function
3045 * @wmi_handle : handle to WMI.
3046 * @param : pointer to hold mgmt cmd parameter
3047 *
3048 * Return: 0 on success and -ve on failure.
3049 */
3050static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
3051 struct wmi_mgmt_params *param)
3052{
3053 wmi_buf_t buf;
3054 uint8_t *bufp;
3055 int32_t cmd_len;
3056 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3057 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3058 mgmt_tx_dl_frm_len;
3059
3060 if (param->frm_len > mgmt_tx_dl_frm_len) {
3061 WMI_LOGE("%s:mgmt frame len %u exceeds %u",
3062 __func__, param->frm_len, mgmt_tx_dl_frm_len);
3063 return QDF_STATUS_E_INVAL;
3064 }
3065
3066 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
3067 WMI_TLV_HDR_SIZE +
3068 roundup(bufp_len, sizeof(uint32_t));
3069
3070 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
3071 if (!buf) {
3072 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3073 return QDF_STATUS_E_NOMEM;
3074 }
3075
3076 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3077 bufp = (uint8_t *) cmd;
3078 WMITLV_SET_HDR(&cmd->tlv_header,
3079 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3080 WMITLV_GET_STRUCT_TLVLEN
3081 (wmi_mgmt_tx_send_cmd_fixed_param));
3082
3083 cmd->vdev_id = param->vdev_id;
3084
3085 cmd->desc_id = param->desc_id;
3086 cmd->chanfreq = param->chanfreq;
3087 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3088 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3089 sizeof(uint32_t)));
3090 bufp += WMI_TLV_HDR_SIZE;
3091 qdf_mem_copy(bufp, param->pdata, bufp_len);
3092
3093 cmd->frame_len = param->frm_len;
3094 cmd->buf_len = bufp_len;
3095 cmd->tx_params_valid = param->tx_params_valid;
3096
3097 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
3098 bufp, cmd->vdev_id, cmd->chanfreq);
3099
3100 bufp += roundup(bufp_len, sizeof(uint32_t));
3101 if (param->tx_params_valid) {
3102 if (populate_tx_send_params(bufp, param->tx_param) !=
3103 QDF_STATUS_SUCCESS) {
3104 WMI_LOGE("%s: Populate TX send params failed",
3105 __func__);
3106 goto free_buf;
3107 }
3108 cmd_len += sizeof(wmi_tx_send_params);
3109 }
3110
3111 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3112 WMI_MGMT_TX_SEND_CMDID)) {
3113 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
3114 goto free_buf;
3115 }
3116 return QDF_STATUS_SUCCESS;
3117
3118free_buf:
3119 wmi_buf_free(buf);
3120 return QDF_STATUS_E_FAILURE;
3121}
3122#else
Govind Singhd3156eb2016-02-26 17:50:39 +05303123/**
3124 * send_mgmt_cmd_tlv() - WMI scan start function
3125 * @wmi_handle : handle to WMI.
3126 * @param : pointer to hold mgmt cmd parameter
3127 *
3128 * Return: 0 on success and -ve on failure.
3129 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303130static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05303131 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05303132{
Govind Singh427ee5a2016-02-26 18:09:36 +05303133 wmi_buf_t buf;
3134 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
3135 int32_t cmd_len;
3136 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05303137 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05303138 uint8_t *bufp;
Sathish Kumar5b636932017-06-28 14:40:32 +05303139 QDF_STATUS status = QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303140 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
3141 mgmt_tx_dl_frm_len;
3142
3143 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303144 WMI_TLV_HDR_SIZE +
3145 roundup(bufp_len, sizeof(uint32_t));
Govind Singh427ee5a2016-02-26 18:09:36 +05303146
Sathish Kumar5b636932017-06-28 14:40:32 +05303147 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303148 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303149 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3150 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303151 }
3152
3153 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
3154 bufp = (uint8_t *) cmd;
3155 WMITLV_SET_HDR(&cmd->tlv_header,
3156 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
3157 WMITLV_GET_STRUCT_TLVLEN
3158 (wmi_mgmt_tx_send_cmd_fixed_param));
3159
3160 cmd->vdev_id = param->vdev_id;
3161
Govind Singh224a7312016-06-21 14:33:26 +05303162 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05303163 cmd->chanfreq = param->chanfreq;
3164 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
3165 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3166 sizeof(uint32_t)));
3167 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303168 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303169
3170 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
3171 QDF_DMA_TO_DEVICE);
3172 if (status != QDF_STATUS_SUCCESS) {
3173 WMI_LOGE("%s: wmi buf map failed", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303174 goto free_buf;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05303175 }
3176
Govind Singhb53420c2016-03-09 14:32:57 +05303177 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05303178 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08003179#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05303180 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3181#endif
3182 cmd->frame_len = param->frm_len;
3183 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303184 cmd->tx_params_valid = param->tx_params_valid;
Govind Singh427ee5a2016-02-26 18:09:36 +05303185
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003186 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07003187 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07003188
Sathish Kumar5b636932017-06-28 14:40:32 +05303189 bufp += roundup(bufp_len, sizeof(uint32_t));
3190 if (param->tx_params_valid) {
3191 status = populate_tx_send_params(bufp, param->tx_param);
3192 if (status != QDF_STATUS_SUCCESS) {
3193 WMI_LOGE("%s: Populate TX send params failed",
3194 __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303195 goto unmap_tx_frame;
Sathish Kumar5b636932017-06-28 14:40:32 +05303196 }
3197 cmd_len += sizeof(wmi_tx_send_params);
3198 }
3199
Govind Singh427ee5a2016-02-26 18:09:36 +05303200 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3201 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303202 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303203 goto unmap_tx_frame;
Govind Singh427ee5a2016-02-26 18:09:36 +05303204 }
Govind Singhb53420c2016-03-09 14:32:57 +05303205 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303206
Himanshu Agarwalf06d9e32018-02-12 19:09:12 +05303207unmap_tx_frame:
3208 qdf_nbuf_unmap_single(qdf_ctx, param->tx_frame,
3209 QDF_DMA_TO_DEVICE);
3210free_buf:
Govind Singh427ee5a2016-02-26 18:09:36 +05303211 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303212 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303213}
Madhvapathi Sriram9130ff22018-04-20 09:22:51 +05303214#endif /* CONFIG_HL_SUPPORT */
Govind Singh427ee5a2016-02-26 18:09:36 +05303215
3216/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303217 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
3218 * @wmi_handle : handle to WMI.
3219 * @param : pointer to offchan data tx cmd parameter
3220 *
3221 * Return: QDF_STATUS_SUCCESS on success and error on failure.
3222 */
3223static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
3224 struct wmi_offchan_data_tx_params *param)
3225{
3226 wmi_buf_t buf;
3227 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
3228 int32_t cmd_len;
3229 uint64_t dma_addr;
3230 void *qdf_ctx = param->qdf_ctx;
3231 uint8_t *bufp;
3232 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
3233 param->frm_len : mgmt_tx_dl_frm_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303234 QDF_STATUS status = QDF_STATUS_SUCCESS;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303235
3236 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
Sathish Kumar5b636932017-06-28 14:40:32 +05303237 WMI_TLV_HDR_SIZE +
3238 roundup(bufp_len, sizeof(uint32_t));
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303239
Sathish Kumar5b636932017-06-28 14:40:32 +05303240 buf = wmi_buf_alloc(wmi_handle, sizeof(wmi_tx_send_params) + cmd_len);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303241 if (!buf) {
3242 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
3243 return QDF_STATUS_E_NOMEM;
3244 }
3245
3246 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
3247 bufp = (uint8_t *) cmd;
3248 WMITLV_SET_HDR(&cmd->tlv_header,
3249 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
3250 WMITLV_GET_STRUCT_TLVLEN
3251 (wmi_offchan_data_tx_send_cmd_fixed_param));
3252
3253 cmd->vdev_id = param->vdev_id;
3254
3255 cmd->desc_id = param->desc_id;
3256 cmd->chanfreq = param->chanfreq;
3257 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
3258 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
3259 sizeof(uint32_t)));
3260 bufp += WMI_TLV_HDR_SIZE;
3261 qdf_mem_copy(bufp, param->pdata, bufp_len);
3262 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
3263 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
3264 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
3265#if defined(HTT_PADDR64)
3266 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
3267#endif
3268 cmd->frame_len = param->frm_len;
3269 cmd->buf_len = bufp_len;
Sathish Kumar5b636932017-06-28 14:40:32 +05303270 cmd->tx_params_valid = param->tx_params_valid;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303271
3272 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
3273 bufp, cmd->vdev_id, cmd->chanfreq);
3274
Sathish Kumar5b636932017-06-28 14:40:32 +05303275 bufp += roundup(bufp_len, sizeof(uint32_t));
3276 if (param->tx_params_valid) {
3277 status = populate_tx_send_params(bufp, param->tx_param);
3278 if (status != QDF_STATUS_SUCCESS) {
3279 WMI_LOGE("%s: Populate TX send params failed",
3280 __func__);
3281 goto err1;
3282 }
3283 cmd_len += sizeof(wmi_tx_send_params);
3284 }
3285
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303286 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3287 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
3288 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
Sathish Kumar5b636932017-06-28 14:40:32 +05303289 goto err1;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303290 }
3291
3292 return QDF_STATUS_SUCCESS;
Sathish Kumar5b636932017-06-28 14:40:32 +05303293
3294err1:
3295 wmi_buf_free(buf);
3296 return QDF_STATUS_E_FAILURE;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05303297}
3298
3299/**
Govind Singh427ee5a2016-02-26 18:09:36 +05303300 * send_modem_power_state_cmd_tlv() - set modem power state to fw
3301 * @wmi_handle: wmi handle
3302 * @param_value: parameter value
3303 *
Govind Singhe7f2f342016-05-23 12:12:52 +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_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303307 uint32_t param_value)
3308{
Govind Singh67922e82016-04-01 16:48:57 +05303309 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303310 wmi_modem_power_state_cmd_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_modem_power_state_cmd_param *) wmi_buf_data(buf);
3320 WMITLV_SET_HDR(&cmd->tlv_header,
3321 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
3322 WMITLV_GET_STRUCT_TLVLEN
3323 (wmi_modem_power_state_cmd_param));
3324 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05303325 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05303326 param_value);
3327 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3328 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303329 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303330 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303331 wmi_buf_free(buf);
3332 }
Govind Singh67922e82016-04-01 16:48:57 +05303333
Govind Singh427ee5a2016-02-26 18:09:36 +05303334 return ret;
3335}
3336
3337/**
3338 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
3339 * @wmi_handle: wmi handle
3340 * @vdev_id: vdev id
3341 * @val: value
3342 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303343 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303344 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303345static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303346 uint32_t vdev_id, uint8_t val)
3347{
3348 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
3349 wmi_buf_t buf;
3350 int32_t len = sizeof(*cmd);
3351
Govind Singhb53420c2016-03-09 14:32:57 +05303352 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05303353
3354 buf = wmi_buf_alloc(wmi_handle, len);
3355 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303356 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303357 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303358 }
3359 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
3360 WMITLV_SET_HDR(&cmd->tlv_header,
3361 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
3362 WMITLV_GET_STRUCT_TLVLEN
3363 (wmi_sta_powersave_mode_cmd_fixed_param));
3364 cmd->vdev_id = vdev_id;
3365 if (val)
3366 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
3367 else
3368 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
3369
3370 if (wmi_unified_cmd_send(wmi_handle, buf, len,
3371 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303372 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303373 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303374 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05303375 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303376 }
Govind Singh5eb51532016-03-09 11:34:12 +05303377 return 0;
3378}
3379
Govind Singh427ee5a2016-02-26 18:09:36 +05303380/**
3381 * send_set_mimops_cmd_tlv() - set MIMO powersave
3382 * @wmi_handle: wmi handle
3383 * @vdev_id: vdev id
3384 * @value: value
3385 *
Govind Singhb53420c2016-03-09 14:32:57 +05303386 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303387 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303388static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303389 uint8_t vdev_id, int value)
3390{
Govind Singh67922e82016-04-01 16:48:57 +05303391 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303392 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
3393 wmi_buf_t buf;
3394 uint16_t len = sizeof(*cmd);
3395
3396 buf = wmi_buf_alloc(wmi_handle, len);
3397 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303398 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303399 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303400 }
3401 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
3402 WMITLV_SET_HDR(&cmd->tlv_header,
3403 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
3404 WMITLV_GET_STRUCT_TLVLEN
3405 (wmi_sta_smps_force_mode_cmd_fixed_param));
3406
3407 cmd->vdev_id = vdev_id;
3408
Houston Hoffmanb5168052016-04-14 02:18:01 -07003409 /* WMI_SMPS_FORCED_MODE values do not directly map
3410 * to SM power save values defined in the specification.
3411 * Make sure to send the right mapping.
3412 */
Govind Singh427ee5a2016-02-26 18:09:36 +05303413 switch (value) {
3414 case 0:
3415 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
3416 break;
3417 case 1:
3418 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
3419 break;
3420 case 2:
3421 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
3422 break;
3423 case 3:
3424 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
3425 break;
3426 default:
Govind Singhb53420c2016-03-09 14:32:57 +05303427 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
Surabhi Vishnoi83f677e2018-04-26 09:46:39 +05303428 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303429 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303430 }
3431
Govind Singhb53420c2016-03-09 14:32:57 +05303432 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05303433
3434 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3435 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303436 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303437 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303438 wmi_buf_free(buf);
3439 }
3440
3441 return ret;
3442}
3443
3444/**
3445 * send_set_smps_params_cmd_tlv() - set smps params
3446 * @wmi_handle: wmi handle
3447 * @vdev_id: vdev id
3448 * @value: value
3449 *
Govind Singhb53420c2016-03-09 14:32:57 +05303450 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303451 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303452static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05303453 int value)
3454{
Govind Singh67922e82016-04-01 16:48:57 +05303455 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303456 wmi_sta_smps_param_cmd_fixed_param *cmd;
3457 wmi_buf_t buf;
3458 uint16_t len = sizeof(*cmd);
3459
3460 buf = wmi_buf_alloc(wmi_handle, len);
3461 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303462 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303463 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303464 }
3465 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
3466 WMITLV_SET_HDR(&cmd->tlv_header,
3467 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
3468 WMITLV_GET_STRUCT_TLVLEN
3469 (wmi_sta_smps_param_cmd_fixed_param));
3470
3471 cmd->vdev_id = vdev_id;
3472 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
3473 cmd->param =
3474 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
3475
Govind Singhb53420c2016-03-09 14:32:57 +05303476 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05303477 cmd->param);
3478
3479 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3480 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303481 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303482 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303483 wmi_buf_free(buf);
3484 }
3485
3486 return ret;
3487}
3488
3489/**
3490 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
3491 * @wmi_handle: wmi handle
3492 * @noa: p2p power save parameters
3493 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303494 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303495 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303496static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303497 struct p2p_ps_params *noa)
3498{
3499 wmi_p2p_set_noa_cmd_fixed_param *cmd;
3500 wmi_p2p_noa_descriptor *noa_discriptor;
3501 wmi_buf_t buf;
3502 uint8_t *buf_ptr;
3503 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05303504 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303505 uint32_t duration;
3506
Govind Singhb53420c2016-03-09 14:32:57 +05303507 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303508 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
3509 buf = wmi_buf_alloc(wmi_handle, len);
3510 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303511 WMI_LOGE("Failed to allocate memory");
3512 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303513 goto end;
3514 }
3515
3516 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3517 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
3518 WMITLV_SET_HDR(&cmd->tlv_header,
3519 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
3520 WMITLV_GET_STRUCT_TLVLEN
3521 (wmi_p2p_set_noa_cmd_fixed_param));
3522 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
3523 cmd->vdev_id = noa->session_id;
3524 cmd->enable = (duration) ? true : false;
3525 cmd->num_noa = 1;
3526
3527 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
3528 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
3529 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
3530 sizeof
3531 (wmi_p2p_set_noa_cmd_fixed_param)
3532 + WMI_TLV_HDR_SIZE);
3533 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
3534 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
3535 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
3536 noa_discriptor->type_count = noa->count;
3537 noa_discriptor->duration = duration;
3538 noa_discriptor->interval = noa->interval;
3539 noa_discriptor->start_time = 0;
3540
Govind Singhb53420c2016-03-09 14:32:57 +05303541 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303542 cmd->vdev_id, noa->count, noa_discriptor->duration,
3543 noa->interval);
3544 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3545 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303546 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303547 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303548 wmi_buf_free(buf);
3549 }
3550
3551end:
Govind Singhb53420c2016-03-09 14:32:57 +05303552 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303553 return status;
3554}
3555
3556
3557/**
3558 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
3559 * @wmi_handle: wmi handle
3560 * @noa: p2p opp power save parameters
3561 *
Govind Singh2edc80f2016-03-01 15:30:53 +05303562 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05303563 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303564static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303565 struct p2p_ps_params *oppps)
3566{
3567 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
3568 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303569 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05303570
Govind Singhb53420c2016-03-09 14:32:57 +05303571 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303572 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3573 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303574 WMI_LOGE("Failed to allocate memory");
3575 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303576 goto end;
3577 }
3578
3579 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
3580 WMITLV_SET_HDR(&cmd->tlv_header,
3581 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
3582 WMITLV_GET_STRUCT_TLVLEN
3583 (wmi_p2p_set_oppps_cmd_fixed_param));
3584 cmd->vdev_id = oppps->session_id;
3585 if (oppps->ctwindow)
3586 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
3587
3588 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05303589 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05303590 cmd->vdev_id, oppps->ctwindow);
3591 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
3592 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303593 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303594 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05303595 wmi_buf_free(buf);
3596 }
3597
3598end:
Govind Singhb53420c2016-03-09 14:32:57 +05303599 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05303600 return status;
3601}
3602
Wu Gaocd3a8512017-03-13 20:17:34 +08003603#ifdef CONVERGED_P2P_ENABLE
3604/**
3605 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
3606 * @wmi_handle: wmi handle
3607 * @param: p2p listen offload start parameters
3608 *
3609 * Return: QDF status
3610 */
3611static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
3612 struct p2p_lo_start *param)
3613{
3614 wmi_buf_t buf;
3615 wmi_p2p_lo_start_cmd_fixed_param *cmd;
3616 int32_t len = sizeof(*cmd);
3617 uint8_t *buf_ptr;
3618 QDF_STATUS status;
3619 int device_types_len_aligned;
3620 int probe_resp_len_aligned;
3621
3622 if (!param) {
3623 WMI_LOGE("lo start param is null");
3624 return QDF_STATUS_E_INVAL;
3625 }
3626
3627 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
3628
3629 device_types_len_aligned =
3630 qdf_roundup(param->dev_types_len,
Vivekc5823092018-03-22 23:27:21 +05303631 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003632 probe_resp_len_aligned =
3633 qdf_roundup(param->probe_resp_len,
Vivekc5823092018-03-22 23:27:21 +05303634 sizeof(uint32_t));
Wu Gaocd3a8512017-03-13 20:17:34 +08003635
3636 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3637 probe_resp_len_aligned;
3638
3639 buf = wmi_buf_alloc(wmi_handle, len);
3640 if (!buf) {
3641 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3642 __func__);
3643 return QDF_STATUS_E_NOMEM;
3644 }
3645
3646 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3647 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3648
3649 WMITLV_SET_HDR(&cmd->tlv_header,
3650 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3651 WMITLV_GET_STRUCT_TLVLEN(
3652 wmi_p2p_lo_start_cmd_fixed_param));
3653
3654 cmd->vdev_id = param->vdev_id;
3655 cmd->ctl_flags = param->ctl_flags;
3656 cmd->channel = param->freq;
3657 cmd->period = param->period;
3658 cmd->interval = param->interval;
3659 cmd->count = param->count;
3660 cmd->device_types_len = param->dev_types_len;
3661 cmd->prob_resp_len = param->probe_resp_len;
3662
3663 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3664 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3665 device_types_len_aligned);
3666 buf_ptr += WMI_TLV_HDR_SIZE;
3667 qdf_mem_copy(buf_ptr, param->device_types,
3668 param->dev_types_len);
3669
3670 buf_ptr += device_types_len_aligned;
3671 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3672 probe_resp_len_aligned);
3673 buf_ptr += WMI_TLV_HDR_SIZE;
3674 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3675 param->probe_resp_len);
3676
3677 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3678 cmd->channel, cmd->period, cmd->interval, cmd->count);
3679
3680 status = wmi_unified_cmd_send(wmi_handle,
3681 buf, len,
3682 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3683 if (status != QDF_STATUS_SUCCESS) {
3684 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3685 __func__, status);
3686 wmi_buf_free(buf);
3687 return status;
3688 }
3689
3690 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3691
3692 return QDF_STATUS_SUCCESS;
3693}
3694
3695/**
3696 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3697 * @wmi_handle: wmi handle
3698 * @param: p2p listen offload stop parameters
3699 *
3700 * Return: QDF status
3701 */
3702static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3703 uint8_t vdev_id)
3704{
3705 wmi_buf_t buf;
3706 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3707 int32_t len;
3708 QDF_STATUS status;
3709
3710 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3711
3712 len = sizeof(*cmd);
3713 buf = wmi_buf_alloc(wmi_handle, len);
3714 if (!buf) {
3715 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3716 __func__);
3717 return QDF_STATUS_E_NOMEM;
3718 }
3719 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3720
3721 WMITLV_SET_HDR(&cmd->tlv_header,
3722 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3723 WMITLV_GET_STRUCT_TLVLEN(
3724 wmi_p2p_lo_stop_cmd_fixed_param));
3725
3726 cmd->vdev_id = vdev_id;
3727
3728 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3729
3730 status = wmi_unified_cmd_send(wmi_handle,
3731 buf, len,
3732 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3733 if (status != QDF_STATUS_SUCCESS) {
3734 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3735 __func__, status);
3736 wmi_buf_free(buf);
3737 return status;
3738 }
3739
3740 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3741
3742 return QDF_STATUS_SUCCESS;
3743}
3744#endif /* End of CONVERGED_P2P_ENABLE */
3745
Govind Singh427ee5a2016-02-26 18:09:36 +05303746/**
3747 * send_get_temperature_cmd_tlv() - get pdev temperature req
3748 * @wmi_handle: wmi handle
3749 *
Govind Singhb53420c2016-03-09 14:32:57 +05303750 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303751 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303752static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303753{
3754 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3755 wmi_buf_t wmi_buf;
3756 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3757 uint8_t *buf_ptr;
3758
3759 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303760 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3761 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303762 }
3763
3764 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3765 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303766 WMI_LOGE(FL("wmi_buf_alloc failed"));
3767 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303768 }
3769
3770 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3771
3772 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3773 WMITLV_SET_HDR(&cmd->tlv_header,
3774 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3775 WMITLV_GET_STRUCT_TLVLEN
3776 (wmi_pdev_get_temperature_cmd_fixed_param));
3777
3778 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3779 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303780 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303781 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303782 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303783 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303784
Govind Singhb53420c2016-03-09 14:32:57 +05303785 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303786}
3787
3788/**
3789 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3790 * @wmi_handle: wmi handle
3791 * @vdevid: vdev id
3792 * @peer_addr: peer mac address
3793 * @auto_triggerparam: auto trigger parameters
3794 * @num_ac: number of access category
3795 *
3796 * This function sets the trigger
3797 * uapsd params such as service interval, delay interval
3798 * and suspend interval which will be used by the firmware
3799 * to send trigger frames periodically when there is no
3800 * traffic on the transmit side.
3801 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303802 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303803 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303804static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303805 struct sta_uapsd_trig_params *param)
3806{
3807 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303808 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303809 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3810 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3811 uint32_t i;
3812 wmi_buf_t buf;
3813 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003814 struct sta_uapsd_params *uapsd_param;
3815 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303816
3817 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3818 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303819 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303820 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303821 }
3822
3823 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3824 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3825 WMITLV_SET_HDR(&cmd->tlv_header,
3826 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3827 WMITLV_GET_STRUCT_TLVLEN
3828 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3829 cmd->vdev_id = param->vdevid;
3830 cmd->num_ac = param->num_ac;
3831 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3832
3833 /* TLV indicating array of structures to follow */
3834 buf_ptr += sizeof(*cmd);
3835 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3836
3837 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303838
3839 /*
3840 * Update tag and length for uapsd auto trigger params (this will take
3841 * care of updating tag and length if it is not pre-filled by caller).
3842 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003843 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3844 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303845 for (i = 0; i < param->num_ac; i++) {
3846 WMITLV_SET_HDR((buf_ptr +
3847 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3848 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3849 WMITLV_GET_STRUCT_TLVLEN
3850 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003851 trig_param->wmm_ac = uapsd_param->wmm_ac;
3852 trig_param->user_priority = uapsd_param->user_priority;
3853 trig_param->service_interval = uapsd_param->service_interval;
3854 trig_param->suspend_interval = uapsd_param->suspend_interval;
3855 trig_param->delay_interval = uapsd_param->delay_interval;
3856 trig_param++;
3857 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303858 }
3859
3860 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3861 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303862 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303863 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303864 wmi_buf_free(buf);
3865 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303866
Govind Singh427ee5a2016-02-26 18:09:36 +05303867 return ret;
3868}
3869
Zhang Qian11c0de32018-01-05 16:50:53 +08003870#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +05303871/**
3872 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3873 * @wmi_handle: pointer to the wmi handle
3874 * @utc: pointer to the UTC time struct
3875 *
3876 * Return: 0 on succes
3877 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303878static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303879 struct ocb_utc_param *utc)
3880{
Govind Singh67922e82016-04-01 16:48:57 +05303881 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303882 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3883 uint8_t *buf_ptr;
3884 uint32_t len, i;
3885 wmi_buf_t buf;
3886
3887 len = sizeof(*cmd);
3888 buf = wmi_buf_alloc(wmi_handle, len);
3889 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303890 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303891 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303892 }
3893
3894 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3895 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3896 WMITLV_SET_HDR(&cmd->tlv_header,
3897 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3898 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3899 cmd->vdev_id = utc->vdev_id;
3900
3901 for (i = 0; i < SIZE_UTC_TIME; i++)
3902 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3903
3904 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3905 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3906
3907 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3908 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303909 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303910 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303911 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303912 }
3913
Govind Singh67922e82016-04-01 16:48:57 +05303914 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303915}
3916
3917/**
3918 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3919 * frames on a channel
3920 * @wmi_handle: pointer to the wmi handle
3921 * @timing_advert: pointer to the timing advertisement struct
3922 *
3923 * Return: 0 on succes
3924 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303925static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303926 struct ocb_timing_advert_param *timing_advert)
3927{
Govind Singh67922e82016-04-01 16:48:57 +05303928 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303929 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3930 uint8_t *buf_ptr;
3931 uint32_t len, len_template;
3932 wmi_buf_t buf;
3933
3934 len = sizeof(*cmd) +
3935 WMI_TLV_HDR_SIZE;
3936
3937 len_template = timing_advert->template_length;
3938 /* Add padding to the template if needed */
3939 if (len_template % 4 != 0)
3940 len_template += 4 - (len_template % 4);
3941 len += len_template;
3942
3943 buf = wmi_buf_alloc(wmi_handle, len);
3944 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303945 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303946 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303947 }
3948
3949 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3950 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3951 WMITLV_SET_HDR(&cmd->tlv_header,
3952 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3953 WMITLV_GET_STRUCT_TLVLEN(
3954 wmi_ocb_start_timing_advert_cmd_fixed_param));
3955 cmd->vdev_id = timing_advert->vdev_id;
3956 cmd->repeat_rate = timing_advert->repeat_rate;
3957 cmd->channel_freq = timing_advert->chan_freq;
3958 cmd->timestamp_offset = timing_advert->timestamp_offset;
3959 cmd->time_value_offset = timing_advert->time_value_offset;
3960 cmd->timing_advert_template_length = timing_advert->template_length;
3961 buf_ptr += sizeof(*cmd);
3962
3963 /* Add the timing advert template */
3964 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3965 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303966 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303967 (uint8_t *)timing_advert->template_value,
3968 timing_advert->template_length);
3969
3970 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3971 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303972 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303973 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303974 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303975 }
3976
Govind Singh67922e82016-04-01 16:48:57 +05303977 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303978}
3979
3980/**
3981 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3982 * on a channel
3983 * @wmi_handle: pointer to the wmi handle
3984 * @timing_advert: pointer to the timing advertisement struct
3985 *
3986 * Return: 0 on succes
3987 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303988static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303989 struct ocb_timing_advert_param *timing_advert)
3990{
Govind Singh67922e82016-04-01 16:48:57 +05303991 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303992 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3993 uint8_t *buf_ptr;
3994 uint32_t len;
3995 wmi_buf_t buf;
3996
3997 len = sizeof(*cmd);
3998 buf = wmi_buf_alloc(wmi_handle, len);
3999 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304000 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304001 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304002 }
4003
4004 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4005 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
4006 WMITLV_SET_HDR(&cmd->tlv_header,
4007 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
4008 WMITLV_GET_STRUCT_TLVLEN(
4009 wmi_ocb_stop_timing_advert_cmd_fixed_param));
4010 cmd->vdev_id = timing_advert->vdev_id;
4011 cmd->channel_freq = timing_advert->chan_freq;
4012
4013 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4014 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304015 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304016 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304017 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304018 }
4019
Govind Singh67922e82016-04-01 16:48:57 +05304020 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304021}
4022
4023/**
4024 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
4025 * @wmi_handle: pointer to the wmi handle
4026 * @request: pointer to the request
4027 *
4028 * Return: 0 on succes
4029 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304030static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304031 uint8_t vdev_id)
4032{
Govind Singhb53420c2016-03-09 14:32:57 +05304033 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304034 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
4035 uint8_t *buf_ptr;
4036 wmi_buf_t buf;
4037 int32_t len;
4038
4039 len = sizeof(*cmd);
4040 buf = wmi_buf_alloc(wmi_handle, len);
4041 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304042 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304043 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304044 }
4045 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4046
4047 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304048 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304049 WMITLV_SET_HDR(&cmd->tlv_header,
4050 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
4051 WMITLV_GET_STRUCT_TLVLEN(
4052 wmi_ocb_get_tsf_timer_cmd_fixed_param));
4053 cmd->vdev_id = vdev_id;
4054
4055 /* Send the WMI command */
4056 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4057 WMI_OCB_GET_TSF_TIMER_CMDID);
4058 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304059 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304060 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304061 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304062 }
4063
Govind Singh67922e82016-04-01 16:48:57 +05304064 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304065}
4066
4067/**
4068 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
4069 * @wmi_handle: pointer to the wmi handle
4070 * @get_stats_param: pointer to the dcc stats
4071 *
4072 * Return: 0 on succes
4073 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304074static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004075 struct ocb_dcc_get_stats_param *get_stats_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304076{
Govind Singh67922e82016-04-01 16:48:57 +05304077 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304078 wmi_dcc_get_stats_cmd_fixed_param *cmd;
4079 wmi_dcc_channel_stats_request *channel_stats_array;
4080 wmi_buf_t buf;
4081 uint8_t *buf_ptr;
4082 uint32_t len;
4083 uint32_t i;
4084
4085 /* Validate the input */
4086 if (get_stats_param->request_array_len !=
4087 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304088 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05304089 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304090 }
4091
4092 /* Allocate memory for the WMI command */
4093 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
4094 get_stats_param->request_array_len;
4095
4096 buf = wmi_buf_alloc(wmi_handle, len);
4097 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304098 WMI_LOGE(FL("wmi_buf_alloc failed"));
4099 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304100 }
4101
4102 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304103 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304104
4105 /* Populate the WMI command */
4106 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
4107 buf_ptr += sizeof(*cmd);
4108
4109 WMITLV_SET_HDR(&cmd->tlv_header,
4110 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
4111 WMITLV_GET_STRUCT_TLVLEN(
4112 wmi_dcc_get_stats_cmd_fixed_param));
4113 cmd->vdev_id = get_stats_param->vdev_id;
4114 cmd->num_channels = get_stats_param->channel_count;
4115
4116 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4117 get_stats_param->request_array_len);
4118 buf_ptr += WMI_TLV_HDR_SIZE;
4119
4120 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304121 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304122 get_stats_param->request_array_len);
4123 for (i = 0; i < cmd->num_channels; i++)
4124 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
4125 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
4126 WMITLV_GET_STRUCT_TLVLEN(
4127 wmi_dcc_channel_stats_request));
4128
4129 /* Send the WMI command */
4130 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4131 WMI_DCC_GET_STATS_CMDID);
4132
Govind Singh67922e82016-04-01 16:48:57 +05304133 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304134 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05304135 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304136 }
4137
Govind Singh67922e82016-04-01 16:48:57 +05304138 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304139}
4140
4141/**
4142 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
4143 * @wmi_handle: pointer to the wmi handle
4144 * @vdev_id: vdev id
4145 * @dcc_stats_bitmap: dcc status bitmap
4146 *
4147 * Return: 0 on succes
4148 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304149static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05304150 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
4151{
Govind Singh67922e82016-04-01 16:48:57 +05304152 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304153 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
4154 wmi_buf_t buf;
4155 uint8_t *buf_ptr;
4156 uint32_t len;
4157
4158 /* Allocate memory for the WMI command */
4159 len = sizeof(*cmd);
4160
4161 buf = wmi_buf_alloc(wmi_handle, len);
4162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304163 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304164 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304165 }
4166
4167 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304168 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304169
4170 /* Populate the WMI command */
4171 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
4172
4173 WMITLV_SET_HDR(&cmd->tlv_header,
4174 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
4175 WMITLV_GET_STRUCT_TLVLEN(
4176 wmi_dcc_clear_stats_cmd_fixed_param));
4177 cmd->vdev_id = vdev_id;
4178 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
4179
4180 /* Send the WMI command */
4181 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4182 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304183 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304184 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05304185 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304186 }
4187
Govind Singh67922e82016-04-01 16:48:57 +05304188 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304189}
4190
4191/**
4192 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
4193 * @wmi_handle: pointer to the wmi handle
4194 * @update_ndl_param: pointer to the request parameters
4195 *
4196 * Return: 0 on success
4197 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304198static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004199 struct ocb_dcc_update_ndl_param *update_ndl_param)
Govind Singh2edc80f2016-03-01 15:30:53 +05304200{
Govind Singhb53420c2016-03-09 14:32:57 +05304201 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304202 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
4203 wmi_dcc_ndl_chan *ndl_chan_array;
4204 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
4205 uint32_t active_state_count;
4206 wmi_buf_t buf;
4207 uint8_t *buf_ptr;
4208 uint32_t len;
4209 uint32_t i;
4210
4211 /* validate the input */
4212 if (update_ndl_param->dcc_ndl_chan_list_len !=
4213 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304214 WMI_LOGE(FL("Invalid parameter"));
4215 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304216 }
4217 active_state_count = 0;
4218 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
4219 for (i = 0; i < update_ndl_param->channel_count; i++)
4220 active_state_count +=
4221 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
4222 if (update_ndl_param->dcc_ndl_active_state_list_len !=
4223 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304224 WMI_LOGE(FL("Invalid parameter"));
4225 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304226 }
4227
4228 /* Allocate memory for the WMI command */
4229 len = sizeof(*cmd) +
4230 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
4231 WMI_TLV_HDR_SIZE +
4232 update_ndl_param->dcc_ndl_active_state_list_len;
4233
4234 buf = wmi_buf_alloc(wmi_handle, len);
4235 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304236 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304237 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304238 }
4239
4240 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304241 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05304242
4243 /* Populate the WMI command */
4244 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
4245 buf_ptr += sizeof(*cmd);
4246
4247 WMITLV_SET_HDR(&cmd->tlv_header,
4248 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
4249 WMITLV_GET_STRUCT_TLVLEN(
4250 wmi_dcc_update_ndl_cmd_fixed_param));
4251 cmd->vdev_id = update_ndl_param->vdev_id;
4252 cmd->num_channel = update_ndl_param->channel_count;
4253
4254 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4255 update_ndl_param->dcc_ndl_chan_list_len);
4256 buf_ptr += WMI_TLV_HDR_SIZE;
4257
4258 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304259 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304260 update_ndl_param->dcc_ndl_chan_list_len);
4261 for (i = 0; i < cmd->num_channel; i++)
4262 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
4263 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4264 WMITLV_GET_STRUCT_TLVLEN(
4265 wmi_dcc_ndl_chan));
4266 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
4267
4268 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4269 update_ndl_param->dcc_ndl_active_state_list_len);
4270 buf_ptr += WMI_TLV_HDR_SIZE;
4271
4272 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304273 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05304274 update_ndl_param->dcc_ndl_active_state_list,
4275 update_ndl_param->dcc_ndl_active_state_list_len);
4276 for (i = 0; i < active_state_count; i++) {
4277 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
4278 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4279 WMITLV_GET_STRUCT_TLVLEN(
4280 wmi_dcc_ndl_active_state_config));
4281 }
4282 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
4283
4284 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05304285 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05304286 WMI_DCC_UPDATE_NDL_CMDID);
4287 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05304288 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304289 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05304290 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304291 }
4292
Govind Singh67922e82016-04-01 16:48:57 +05304293 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05304294}
4295
4296/**
4297 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
4298 * @wmi_handle: pointer to the wmi handle
4299 * @config: the OCB configuration
4300 *
4301 * Return: 0 on success
4302 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304303static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Zhang Qian11c0de32018-01-05 16:50:53 +08004304 struct ocb_config *config)
Govind Singh2edc80f2016-03-01 15:30:53 +05304305{
Govind Singh67922e82016-04-01 16:48:57 +05304306 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304307 wmi_ocb_set_config_cmd_fixed_param *cmd;
4308 wmi_channel *chan;
4309 wmi_ocb_channel *ocb_chan;
4310 wmi_qos_parameter *qos_param;
4311 wmi_dcc_ndl_chan *ndl_chan;
4312 wmi_dcc_ndl_active_state_config *ndl_active_config;
4313 wmi_ocb_schedule_element *sched_elem;
4314 uint8_t *buf_ptr;
4315 wmi_buf_t buf;
4316 int32_t len;
4317 int32_t i, j, active_state_count;
4318
4319 /*
4320 * Validate the dcc_ndl_chan_list_len and count the number of active
4321 * states. Validate dcc_ndl_active_state_list_len.
4322 */
4323 active_state_count = 0;
4324 if (config->dcc_ndl_chan_list_len) {
4325 if (!config->dcc_ndl_chan_list ||
4326 config->dcc_ndl_chan_list_len !=
4327 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304328 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05304329 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05304330 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304331 }
4332
4333 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
4334 i < config->channel_count; ++i, ++ndl_chan)
4335 active_state_count +=
4336 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
4337
4338 if (active_state_count) {
4339 if (!config->dcc_ndl_active_state_list ||
4340 config->dcc_ndl_active_state_list_len !=
4341 active_state_count *
4342 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304343 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05304344 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05304345 }
4346 }
4347 }
4348
4349 len = sizeof(*cmd) +
4350 WMI_TLV_HDR_SIZE + config->channel_count *
4351 sizeof(wmi_channel) +
4352 WMI_TLV_HDR_SIZE + config->channel_count *
4353 sizeof(wmi_ocb_channel) +
4354 WMI_TLV_HDR_SIZE + config->channel_count *
4355 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
4356 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
4357 WMI_TLV_HDR_SIZE + active_state_count *
4358 sizeof(wmi_dcc_ndl_active_state_config) +
4359 WMI_TLV_HDR_SIZE + config->schedule_size *
4360 sizeof(wmi_ocb_schedule_element);
4361 buf = wmi_buf_alloc(wmi_handle, len);
4362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304363 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304364 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05304365 }
4366
4367 buf_ptr = (uint8_t *)wmi_buf_data(buf);
4368 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
4369 WMITLV_SET_HDR(&cmd->tlv_header,
4370 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
4371 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
Zhang Qian11c0de32018-01-05 16:50:53 +08004372 cmd->vdev_id = config->vdev_id;
Govind Singh2edc80f2016-03-01 15:30:53 +05304373 cmd->channel_count = config->channel_count;
4374 cmd->schedule_size = config->schedule_size;
4375 cmd->flags = config->flags;
4376 buf_ptr += sizeof(*cmd);
4377
4378 /* Add the wmi_channel info */
4379 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4380 config->channel_count*sizeof(wmi_channel));
4381 buf_ptr += WMI_TLV_HDR_SIZE;
4382 for (i = 0; i < config->channel_count; i++) {
4383 chan = (wmi_channel *)buf_ptr;
4384 WMITLV_SET_HDR(&chan->tlv_header,
4385 WMITLV_TAG_STRUC_wmi_channel,
4386 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
4387 chan->mhz = config->channels[i].chan_freq;
4388 chan->band_center_freq1 = config->channels[i].chan_freq;
4389 chan->band_center_freq2 = 0;
4390 chan->info = 0;
4391
Zhang Qian11c0de32018-01-05 16:50:53 +08004392 WMI_SET_CHANNEL_MODE(chan, config->channels[i].ch_mode);
Govind Singh2edc80f2016-03-01 15:30:53 +05304393 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
4394 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
4395 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
4396 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
4397 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
4398 config->channels[i].antenna_max);
4399
4400 if (config->channels[i].bandwidth < 10)
4401 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
4402 else if (config->channels[i].bandwidth < 20)
4403 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
4404 buf_ptr += sizeof(*chan);
4405 }
4406
4407 /* Add the wmi_ocb_channel info */
4408 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4409 config->channel_count*sizeof(wmi_ocb_channel));
4410 buf_ptr += WMI_TLV_HDR_SIZE;
4411 for (i = 0; i < config->channel_count; i++) {
4412 ocb_chan = (wmi_ocb_channel *)buf_ptr;
4413 WMITLV_SET_HDR(&ocb_chan->tlv_header,
4414 WMITLV_TAG_STRUC_wmi_ocb_channel,
4415 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
4416 ocb_chan->bandwidth = config->channels[i].bandwidth;
4417 WMI_CHAR_ARRAY_TO_MAC_ADDR(
4418 config->channels[i].mac_address.bytes,
4419 &ocb_chan->mac_address);
4420 buf_ptr += sizeof(*ocb_chan);
4421 }
4422
4423 /* Add the wmi_qos_parameter info */
4424 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4425 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
4426 buf_ptr += WMI_TLV_HDR_SIZE;
4427 /* WMI_MAX_NUM_AC parameters for each channel */
4428 for (i = 0; i < config->channel_count; i++) {
4429 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
4430 qos_param = (wmi_qos_parameter *)buf_ptr;
4431 WMITLV_SET_HDR(&qos_param->tlv_header,
4432 WMITLV_TAG_STRUC_wmi_qos_parameter,
4433 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
4434 qos_param->aifsn =
4435 config->channels[i].qos_params[j].aifsn;
4436 qos_param->cwmin =
4437 config->channels[i].qos_params[j].cwmin;
4438 qos_param->cwmax =
4439 config->channels[i].qos_params[j].cwmax;
4440 buf_ptr += sizeof(*qos_param);
4441 }
4442 }
4443
4444 /* Add the wmi_dcc_ndl_chan (per channel) */
4445 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4446 config->dcc_ndl_chan_list_len);
4447 buf_ptr += WMI_TLV_HDR_SIZE;
4448 if (config->dcc_ndl_chan_list_len) {
4449 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304450 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05304451 config->dcc_ndl_chan_list_len);
4452 for (i = 0; i < config->channel_count; i++)
4453 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
4454 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
4455 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
4456 buf_ptr += config->dcc_ndl_chan_list_len;
4457 }
4458
4459 /* Add the wmi_dcc_ndl_active_state_config */
4460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
4461 sizeof(wmi_dcc_ndl_active_state_config));
4462 buf_ptr += WMI_TLV_HDR_SIZE;
4463 if (active_state_count) {
4464 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05304465 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05304466 config->dcc_ndl_active_state_list,
4467 active_state_count * sizeof(*ndl_active_config));
4468 for (i = 0; i < active_state_count; ++i)
4469 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
4470 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
4471 WMITLV_GET_STRUCT_TLVLEN(
4472 wmi_dcc_ndl_active_state_config));
4473 buf_ptr += active_state_count *
4474 sizeof(*ndl_active_config);
4475 }
4476
4477 /* Add the wmi_ocb_schedule_element info */
4478 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4479 config->schedule_size * sizeof(wmi_ocb_schedule_element));
4480 buf_ptr += WMI_TLV_HDR_SIZE;
4481 for (i = 0; i < config->schedule_size; i++) {
4482 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
4483 WMITLV_SET_HDR(&sched_elem->tlv_header,
4484 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
4485 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
4486 sched_elem->channel_freq = config->schedule[i].chan_freq;
4487 sched_elem->total_duration = config->schedule[i].total_duration;
4488 sched_elem->guard_interval = config->schedule[i].guard_interval;
4489 buf_ptr += sizeof(*sched_elem);
4490 }
4491
4492
4493 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4494 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304495 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304496 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05304497 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05304498 }
4499
Govind Singh67922e82016-04-01 16:48:57 +05304500 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05304501}
Govind Singh17a9cfa2016-03-01 15:54:59 +05304502
4503/**
Zhang Qian11c0de32018-01-05 16:50:53 +08004504 * extract_ocb_channel_config_resp_tlv() - extract ocb channel config resp
4505 * @wmi_handle: wmi handle
4506 * @evt_buf: wmi event buffer
4507 * @status: status buffer
4508 *
4509 * Return: QDF_STATUS_SUCCESS on success
4510 */
4511static QDF_STATUS extract_ocb_channel_config_resp_tlv(wmi_unified_t wmi_handle,
4512 void *evt_buf,
4513 uint32_t *status)
4514{
4515 WMI_OCB_SET_CONFIG_RESP_EVENTID_param_tlvs *param_tlvs;
4516 wmi_ocb_set_config_resp_event_fixed_param *fix_param;
4517
4518 param_tlvs = evt_buf;
4519 fix_param = param_tlvs->fixed_param;
4520
4521 *status = fix_param->status;
4522 return QDF_STATUS_SUCCESS;
4523}
4524
4525/**
4526 * extract_ocb_tsf_timer_tlv() - extract TSF timer from event buffer
4527 * @wmi_handle: wmi handle
4528 * @evt_buf: wmi event buffer
4529 * @resp: response buffer
4530 *
4531 * Return: QDF_STATUS_SUCCESS on success
4532 */
4533static QDF_STATUS extract_ocb_tsf_timer_tlv(wmi_unified_t wmi_handle,
4534 void *evt_buf, struct ocb_get_tsf_timer_response *resp)
4535{
4536 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID_param_tlvs *param_tlvs;
4537 wmi_ocb_get_tsf_timer_resp_event_fixed_param *fix_param;
4538
4539 param_tlvs = evt_buf;
4540 fix_param = param_tlvs->fixed_param;
4541 resp->vdev_id = fix_param->vdev_id;
4542 resp->timer_high = fix_param->tsf_timer_high;
4543 resp->timer_low = fix_param->tsf_timer_low;
4544
4545 return QDF_STATUS_SUCCESS;
4546}
4547
4548/**
4549 * extract_ocb_ndl_resp_tlv() - extract TSF timer from event buffer
4550 * @wmi_handle: wmi handle
4551 * @evt_buf: wmi event buffer
4552 * @resp: response buffer
4553 *
4554 * Return: QDF_STATUS_SUCCESS on success
4555 */
4556static QDF_STATUS extract_ocb_ndl_resp_tlv(wmi_unified_t wmi_handle,
4557 void *evt_buf, struct ocb_dcc_update_ndl_response *resp)
4558{
4559 WMI_DCC_UPDATE_NDL_RESP_EVENTID_param_tlvs *param_tlvs;
4560 wmi_dcc_update_ndl_resp_event_fixed_param *fix_param;
4561
4562 param_tlvs = evt_buf;
4563 fix_param = param_tlvs->fixed_param;
4564 resp->vdev_id = fix_param->vdev_id;
4565 resp->status = fix_param->status;
4566 return QDF_STATUS_SUCCESS;
4567}
4568
4569/**
4570 * extract_ocb_dcc_stats_tlv() - extract DCC stats from event buffer
4571 * @wmi_handle: wmi handle
4572 * @evt_buf: wmi event buffer
4573 * @resp: response buffer
4574 *
4575 * Since length of stats is variable, buffer for DCC stats will be allocated
4576 * in this function. The caller must free the buffer.
4577 *
4578 * Return: QDF_STATUS_SUCCESS on success
4579 */
4580static QDF_STATUS extract_ocb_dcc_stats_tlv(wmi_unified_t wmi_handle,
4581 void *evt_buf, struct ocb_dcc_get_stats_response **resp)
4582{
4583 struct ocb_dcc_get_stats_response *response;
4584 WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *param_tlvs;
4585 wmi_dcc_get_stats_resp_event_fixed_param *fix_param;
4586
4587 param_tlvs = (WMI_DCC_GET_STATS_RESP_EVENTID_param_tlvs *)evt_buf;
4588 fix_param = param_tlvs->fixed_param;
4589
4590 /* Allocate and populate the response */
4591 if (fix_param->num_channels > ((WMI_SVC_MSG_MAX_SIZE -
4592 sizeof(*fix_param)) / sizeof(wmi_dcc_ndl_stats_per_channel))) {
4593 WMI_LOGE("%s: too many channels:%d", __func__,
4594 fix_param->num_channels);
4595 QDF_ASSERT(0);
4596 *resp = NULL;
4597 return QDF_STATUS_E_INVAL;
4598 }
4599 response = qdf_mem_malloc(sizeof(*response) + fix_param->num_channels *
4600 sizeof(wmi_dcc_ndl_stats_per_channel));
4601 *resp = response;
4602 if (!response)
4603 return QDF_STATUS_E_NOMEM;
4604
4605 response->vdev_id = fix_param->vdev_id;
4606 response->num_channels = fix_param->num_channels;
4607 response->channel_stats_array_len =
4608 fix_param->num_channels *
4609 sizeof(wmi_dcc_ndl_stats_per_channel);
4610 response->channel_stats_array = ((uint8_t *)response) +
4611 sizeof(*response);
4612 qdf_mem_copy(response->channel_stats_array,
4613 param_tlvs->stats_per_channel_list,
4614 response->channel_stats_array_len);
4615
4616 return QDF_STATUS_SUCCESS;
4617}
4618#endif
4619
4620/**
Govind Singh17a9cfa2016-03-01 15:54:59 +05304621 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
4622 * @wmi_handle: wmi handle
4623 * @mcc_adaptive_scheduler: enable/disable
4624 *
4625 * This function enable/disable mcc adaptive scheduler in fw.
4626 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07004627 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05304628 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304629static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07004630 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
4631 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05304632{
Govind Singh67922e82016-04-01 16:48:57 +05304633 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304634 wmi_buf_t buf = 0;
4635 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
4636 uint16_t len =
4637 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
4638
4639 buf = wmi_buf_alloc(wmi_handle, len);
4640 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304641 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
4642 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304643 }
4644 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
4645 wmi_buf_data(buf);
4646
4647 WMITLV_SET_HDR(&cmd->tlv_header,
4648 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
4649 WMITLV_GET_STRUCT_TLVLEN
4650 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
4651 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05304652 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304653
4654 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4655 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304656 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304657 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05304658 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304659 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304660 }
Govind Singh67922e82016-04-01 16:48:57 +05304661
4662 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304663}
4664
4665/**
4666 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
4667 * @wmi: wmi handle
4668 * @mcc_channel: mcc channel
4669 * @mcc_channel_time_latency: MCC channel time latency.
4670 *
4671 * Currently used to set time latency for an MCC vdev/adapter using operating
4672 * channel of it and channel number. The info is provided run time using
4673 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
4674 *
4675 * Return: CDF status
4676 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304677static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304678 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
4679{
Govind Singh67922e82016-04-01 16:48:57 +05304680 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304681 wmi_buf_t buf = 0;
4682 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
4683 uint16_t len = 0;
4684 uint8_t *buf_ptr = NULL;
4685 wmi_resmgr_chan_latency chan_latency;
4686 /* Note: we only support MCC time latency for a single channel */
4687 uint32_t num_channels = 1;
4688 uint32_t chan1_freq = mcc_channel_freq;
4689 uint32_t latency_chan1 = mcc_channel_time_latency;
4690
4691
4692 /* If 0ms latency is provided, then FW will set to a default.
4693 * Otherwise, latency must be at least 30ms.
4694 */
4695 if ((latency_chan1 > 0) &&
4696 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304697 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304698 "Minimum is 30ms (or 0 to use default value by "
4699 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304700 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304701 }
4702
4703 /* Set WMI CMD for channel time latency here */
4704 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
4705 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
4706 num_channels * sizeof(wmi_resmgr_chan_latency);
4707 buf = wmi_buf_alloc(wmi_handle, len);
4708 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304709 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4710 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304711 }
4712 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4713 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
4714 wmi_buf_data(buf);
4715 WMITLV_SET_HDR(&cmdTL->tlv_header,
4716 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
4717 WMITLV_GET_STRUCT_TLVLEN
4718 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
4719 cmdTL->num_chans = num_channels;
4720 /* Update channel time latency information for home channel(s) */
4721 buf_ptr += sizeof(*cmdTL);
4722 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4723 num_channels * sizeof(wmi_resmgr_chan_latency));
4724 buf_ptr += WMI_TLV_HDR_SIZE;
4725 chan_latency.chan_mhz = chan1_freq;
4726 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304727 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304728 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4729 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304730 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304731 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304732 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304733 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304734 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304735 }
Govind Singh67922e82016-04-01 16:48:57 +05304736
4737 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304738}
4739
4740/**
4741 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
4742 * @wmi: wmi handle
4743 * @adapter_1_chan_number: adapter 1 channel number
4744 * @adapter_1_quota: adapter 1 quota
4745 * @adapter_2_chan_number: adapter 2 channel number
4746 *
4747 * Return: CDF status
4748 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304749static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304750 uint32_t adapter_1_chan_freq,
4751 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4752{
Govind Singh67922e82016-04-01 16:48:57 +05304753 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304754 wmi_buf_t buf = 0;
4755 uint16_t len = 0;
4756 uint8_t *buf_ptr = NULL;
4757 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4758 wmi_resmgr_chan_time_quota chan_quota;
4759 uint32_t quota_chan1 = adapter_1_quota;
4760 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4761 uint32_t quota_chan2 = 100 - quota_chan1;
4762 /* Note: setting time quota for MCC requires info for 2 channels */
4763 uint32_t num_channels = 2;
4764 uint32_t chan1_freq = adapter_1_chan_freq;
4765 uint32_t chan2_freq = adapter_2_chan_freq;
4766
Govind Singhb53420c2016-03-09 14:32:57 +05304767 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304768 "freq2:%dMHz, Quota2:%dms", __func__,
4769 chan1_freq, quota_chan1, chan2_freq,
4770 quota_chan2);
4771
4772 /*
4773 * Perform sanity check on time quota values provided.
4774 */
4775 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4776 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304777 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304778 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304779 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304780 }
4781 /* Set WMI CMD for channel time quota here */
4782 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4783 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4784 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4785 buf = wmi_buf_alloc(wmi_handle, len);
4786 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304787 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4788 QDF_ASSERT(0);
4789 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304790 }
4791 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4792 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4793 wmi_buf_data(buf);
4794 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4795 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4796 WMITLV_GET_STRUCT_TLVLEN
4797 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4798 cmdTQ->num_chans = num_channels;
4799
4800 /* Update channel time quota information for home channel(s) */
4801 buf_ptr += sizeof(*cmdTQ);
4802 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4803 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4804 buf_ptr += WMI_TLV_HDR_SIZE;
4805 chan_quota.chan_mhz = chan1_freq;
4806 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304807 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304808 /* Construct channel and quota record for the 2nd MCC mode. */
4809 buf_ptr += sizeof(chan_quota);
4810 chan_quota.chan_mhz = chan2_freq;
4811 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304812 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304813
4814 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4815 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304816 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304817 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304818 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304819 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304820 }
Govind Singh67922e82016-04-01 16:48:57 +05304821
4822 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304823}
4824
4825/**
4826 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4827 * @wmi_handle: Pointer to wmi handle
4828 * @thermal_info: Thermal command information
4829 *
4830 * This function sends the thermal management command
4831 * to the firmware
4832 *
Govind Singhb53420c2016-03-09 14:32:57 +05304833 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304834 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304835static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304836 struct thermal_cmd_params *thermal_info)
4837{
4838 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4839 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304840 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304841 uint32_t len = 0;
4842
4843 len = sizeof(*cmd);
4844
4845 buf = wmi_buf_alloc(wmi_handle, len);
4846 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304847 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4848 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304849 }
4850
4851 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4852
4853 WMITLV_SET_HDR(&cmd->tlv_header,
4854 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4855 WMITLV_GET_STRUCT_TLVLEN
4856 (wmi_thermal_mgmt_cmd_fixed_param));
4857
4858 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4859 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4860 cmd->enable = thermal_info->thermal_enable;
4861
Govind Singhb53420c2016-03-09 14:32:57 +05304862 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304863 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4864
4865 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4866 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304867 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304868 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304869 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304870 }
4871
Govind Singh67922e82016-04-01 16:48:57 +05304872 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304873}
4874
4875
4876/**
4877 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304878 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304879 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4880 *
4881 * This function sends down the LRO configuration parameters to
4882 * the firmware to enable LRO, sets the TCP flags and sets the
4883 * seed values for the toeplitz hash generation
4884 *
Govind Singhb53420c2016-03-09 14:32:57 +05304885 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304886 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304887static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304888 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4889{
4890 wmi_lro_info_cmd_fixed_param *cmd;
4891 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304892 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304893
4894
4895 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4896 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304897 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4898 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304899 }
4900
4901 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4902
4903 WMITLV_SET_HDR(&cmd->tlv_header,
4904 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4905 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4906
4907 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4908 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4909 wmi_lro_cmd->tcp_flag);
4910 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4911 wmi_lro_cmd->tcp_flag_mask);
4912 cmd->toeplitz_hash_ipv4_0_3 =
4913 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4914 cmd->toeplitz_hash_ipv4_4_7 =
4915 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4916 cmd->toeplitz_hash_ipv4_8_11 =
4917 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4918 cmd->toeplitz_hash_ipv4_12_15 =
4919 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4920 cmd->toeplitz_hash_ipv4_16 =
4921 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4922
4923 cmd->toeplitz_hash_ipv6_0_3 =
4924 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4925 cmd->toeplitz_hash_ipv6_4_7 =
4926 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4927 cmd->toeplitz_hash_ipv6_8_11 =
4928 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4929 cmd->toeplitz_hash_ipv6_12_15 =
4930 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4931 cmd->toeplitz_hash_ipv6_16_19 =
4932 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4933 cmd->toeplitz_hash_ipv6_20_23 =
4934 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4935 cmd->toeplitz_hash_ipv6_24_27 =
4936 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4937 cmd->toeplitz_hash_ipv6_28_31 =
4938 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4939 cmd->toeplitz_hash_ipv6_32_35 =
4940 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4941 cmd->toeplitz_hash_ipv6_36_39 =
4942 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4943 cmd->toeplitz_hash_ipv6_40 =
4944 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4945
Govind Singhb53420c2016-03-09 14:32:57 +05304946 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304947 cmd->lro_enable, cmd->tcp_flag_u32);
4948
4949 status = wmi_unified_cmd_send(wmi_handle, buf,
4950 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304951 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304952 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304953 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304954 }
4955
Govind Singh67922e82016-04-01 16:48:57 +05304956 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304957}
4958
Govind Singh4eacd2b2016-03-07 14:24:22 +05304959/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304960 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4961 * @wmi_handle: Pointer to wmi handle
4962 * @rate_report_params: Pointer to peer rate report parameters
4963 *
4964 *
4965 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4966 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304967static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304968 struct wmi_peer_rate_report_params *rate_report_params)
4969{
4970 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4971 wmi_buf_t buf = NULL;
4972 QDF_STATUS status = 0;
4973 uint32_t len = 0;
4974 uint32_t i, j;
4975
4976 len = sizeof(*cmd);
4977
4978 buf = wmi_buf_alloc(wmi_handle, len);
4979 if (!buf) {
4980 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4981 return QDF_STATUS_E_FAILURE;
4982 }
4983
4984 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4985 wmi_buf_data(buf);
4986
4987 WMITLV_SET_HDR(
4988 &cmd->tlv_header,
4989 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4990 WMITLV_GET_STRUCT_TLVLEN(
4991 wmi_peer_set_rate_report_condition_fixed_param));
4992
4993 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4994 cmd->report_backoff_time = rate_report_params->backoff_time;
4995 cmd->report_timer_period = rate_report_params->timer_period;
4996 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4997 cmd->cond_per_phy[i].val_cond_flags =
4998 rate_report_params->report_per_phy[i].cond_flags;
4999 cmd->cond_per_phy[i].rate_delta.min_delta =
5000 rate_report_params->report_per_phy[i].delta.delta_min;
5001 cmd->cond_per_phy[i].rate_delta.percentage =
5002 rate_report_params->report_per_phy[i].delta.percent;
5003 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
5004 cmd->cond_per_phy[i].rate_threshold[j] =
5005 rate_report_params->report_per_phy[i].
5006 report_rate_threshold[j];
5007 }
5008 }
5009
5010 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
5011 cmd->enable_rate_report,
5012 cmd->report_backoff_time, cmd->report_timer_period);
5013
5014 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5015 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
5016 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05305017 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05305018 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
5019 __func__);
5020 }
5021 return status;
5022}
5023
5024/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05305025 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
5026 * @wmi_handle: wmi handle
5027 * @param: bcn ll cmd parameter
5028 *
Govind Singhb53420c2016-03-09 14:32:57 +05305029 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305030 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305031static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305032 wmi_bcn_send_from_host_cmd_fixed_param *param)
5033{
5034 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
5035 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05305036 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305037
5038 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
5039 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305040 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5041 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305042 }
5043
5044 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
5045 WMITLV_SET_HDR(&cmd->tlv_header,
5046 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
5047 WMITLV_GET_STRUCT_TLVLEN
5048 (wmi_bcn_send_from_host_cmd_fixed_param));
5049 cmd->vdev_id = param->vdev_id;
5050 cmd->data_len = param->data_len;
5051 cmd->frame_ctrl = param->frame_ctrl;
5052 cmd->frag_ptr = param->frag_ptr;
5053 cmd->dtim_flag = param->dtim_flag;
5054
5055 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
5056 WMI_PDEV_SEND_BCN_CMDID);
5057
Govind Singh67922e82016-04-01 16:48:57 +05305058 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305059 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305060 wmi_buf_free(wmi_buf);
5061 }
5062
5063 return ret;
5064}
5065
5066/**
5067 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
5068 * @wmi_handle: wmi handle
5069 * @vdev_id: vdev id
5070 * @max_retries: max retries
5071 * @retry_interval: retry interval
5072 * This function sets sta query related parameters in fw.
5073 *
Govind Singhb53420c2016-03-09 14:32:57 +05305074 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05305075 */
5076
Sathish Kumarfd347372017-02-13 12:29:09 +05305077static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305078 uint8_t vdev_id, uint32_t max_retries,
5079 uint32_t retry_interval)
5080{
5081 wmi_buf_t buf;
5082 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
5083 int len;
5084
5085 len = sizeof(*cmd);
5086 buf = wmi_buf_alloc(wmi_handle, len);
5087 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305088 WMI_LOGE(FL("wmi_buf_alloc failed"));
5089 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305090 }
5091
5092 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
5093 WMITLV_SET_HDR(&cmd->tlv_header,
5094 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
5095 WMITLV_GET_STRUCT_TLVLEN
5096 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
5097
5098
5099 cmd->vdev_id = vdev_id;
5100 cmd->sa_query_max_retry_count = max_retries;
5101 cmd->sa_query_retry_interval = retry_interval;
5102
Govind Singhb53420c2016-03-09 14:32:57 +05305103 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305104 vdev_id, retry_interval, max_retries);
5105
5106 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5107 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305108 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05305109 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305110 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305111 }
5112
Govind Singhb53420c2016-03-09 14:32:57 +05305113 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305114 return 0;
5115}
5116
5117/**
5118 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
5119 * @wmi_handle: wmi handle
5120 * @params: sta keep alive parameter
5121 *
5122 * This function sets keep alive related parameters in fw.
5123 *
5124 * Return: CDF status
5125 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305126static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305127 struct sta_params *params)
5128{
5129 wmi_buf_t buf;
5130 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
5131 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
5132 uint8_t *buf_ptr;
5133 int len;
Govind Singh67922e82016-04-01 16:48:57 +05305134 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305135
Govind Singhb53420c2016-03-09 14:32:57 +05305136 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305137
Govind Singh4eacd2b2016-03-07 14:24:22 +05305138 len = sizeof(*cmd) + sizeof(*arp_rsp);
5139 buf = wmi_buf_alloc(wmi_handle, len);
5140 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305141 WMI_LOGE("wmi_buf_alloc failed");
5142 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305143 }
5144
5145 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
5146 buf_ptr = (uint8_t *) cmd;
5147 WMITLV_SET_HDR(&cmd->tlv_header,
5148 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
5149 WMITLV_GET_STRUCT_TLVLEN
5150 (WMI_STA_KEEPALIVE_CMD_fixed_param));
5151 cmd->interval = params->timeperiod;
5152 cmd->enable = (params->timeperiod) ? 1 : 0;
5153 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305154 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305155 params->timeperiod, params->method);
5156 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
5157 WMITLV_SET_HDR(&arp_rsp->tlv_header,
5158 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
5159 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
5160
c_manjee2772b9c2017-01-23 15:14:13 +05305161 if ((params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) ||
5162 (params->method ==
5163 WMI_STA_KEEPALIVE_METHOD_GRATUITOUS_ARP_REQUEST)) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05305164 if ((NULL == params->hostv4addr) ||
5165 (NULL == params->destv4addr) ||
5166 (NULL == params->destmac)) {
Jeff Johnson58fd0c62017-09-18 10:05:06 -07005167 WMI_LOGE("%s: received null pointer, hostv4addr:%pK "
5168 "destv4addr:%pK destmac:%pK ", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305169 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305170 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305171 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305172 }
c_manjee2772b9c2017-01-23 15:14:13 +05305173 cmd->method = params->method;
Govind Singhb53420c2016-03-09 14:32:57 +05305174 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305175 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305176 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305177 WMI_IPV4_ADDR_LEN);
5178 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
5179 } else {
5180 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
5181 }
5182
Govind Singh67922e82016-04-01 16:48:57 +05305183 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5184 WMI_STA_KEEPALIVE_CMDID);
5185 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305186 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05305187 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305188 }
5189
Govind Singhb53420c2016-03-09 14:32:57 +05305190 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305191 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305192}
5193
5194/**
5195 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
5196 * @wmi_handle: wmi handle
5197 * @if_id: vdev id
5198 * @gtx_info: GTX config params
5199 *
5200 * This function set GTX related params in firmware.
5201 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305202 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305203 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305204static 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 +05305205 struct wmi_gtx_config *gtx_info)
5206{
5207 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
5208 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05305209 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305210 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305211
Govind Singh4eacd2b2016-03-07 14:24:22 +05305212 buf = wmi_buf_alloc(wmi_handle, len);
5213 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305214 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305215 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305216 }
5217 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
5218 WMITLV_SET_HDR(&cmd->tlv_header,
5219 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
5220 WMITLV_GET_STRUCT_TLVLEN
5221 (wmi_vdev_set_gtx_params_cmd_fixed_param));
5222 cmd->vdev_id = if_id;
5223
5224 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
5225 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
5226 cmd->userGtxMask = gtx_info->gtx_usrcfg;
5227 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
5228 cmd->gtxPERMargin = gtx_info->gtx_margin;
5229 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
5230 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
5231 cmd->gtxBWMask = gtx_info->gtx_bwmask;
5232
Govind Singhb53420c2016-03-09 14:32:57 +05305233 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05305234 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
5235 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
5236 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
5237 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
5238
Abhishek Singh716c46c2016-05-04 16:24:07 +05305239 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305240 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305241 if (QDF_IS_STATUS_ERROR(ret)) {
5242 WMI_LOGE("Failed to set GTX PARAMS");
5243 wmi_buf_free(buf);
5244 }
5245 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305246}
5247
5248/**
5249 * send_process_update_edca_param_cmd_tlv() - update EDCA params
5250 * @wmi_handle: wmi handle
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305251 * @vdev_id: vdev id.
5252 * @wmm_vparams: edca parameters
Govind Singh4eacd2b2016-03-07 14:24:22 +05305253 *
5254 * This function updates EDCA parameters to the target
5255 *
5256 * Return: CDF Status
5257 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305258static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005259 uint8_t vdev_id, bool mu_edca_param,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305260 struct wmi_host_wme_vparams wmm_vparams[WMI_MAX_NUM_AC])
Govind Singh4eacd2b2016-03-07 14:24:22 +05305261{
5262 uint8_t *buf_ptr;
5263 wmi_buf_t buf;
5264 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305265 wmi_wmm_vparams *wmm_param;
5266 struct wmi_host_wme_vparams *twmm_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305267 int len = sizeof(*cmd);
5268 int ac;
5269
5270 buf = wmi_buf_alloc(wmi_handle, len);
5271
5272 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305273 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5274 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305275 }
5276
5277 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5278 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
5279 WMITLV_SET_HDR(&cmd->tlv_header,
5280 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5281 WMITLV_GET_STRUCT_TLVLEN
5282 (wmi_vdev_set_wmm_params_cmd_fixed_param));
5283 cmd->vdev_id = vdev_id;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005284 cmd->wmm_param_type = mu_edca_param;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305285
5286 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
5287 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305288 twmm_param = (struct wmi_host_wme_vparams *) (&wmm_vparams[ac]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305289 WMITLV_SET_HDR(&wmm_param->tlv_header,
5290 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
5291 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
5292 wmm_param->cwmin = twmm_param->cwmin;
5293 wmm_param->cwmax = twmm_param->cwmax;
5294 wmm_param->aifs = twmm_param->aifs;
Kiran Kumar Lokerea536eac2018-04-06 16:56:47 -07005295 if (mu_edca_param)
5296 wmm_param->mu_edca_timer = twmm_param->mu_edca_timer;
5297 else
5298 wmm_param->txoplimit = twmm_param->txoplimit;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305299 wmm_param->acm = twmm_param->acm;
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +05305300 wmm_param->no_ack = twmm_param->noackpolicy;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305301 }
5302
5303 if (wmi_unified_cmd_send(wmi_handle, buf, len,
5304 WMI_VDEV_SET_WMM_PARAMS_CMDID))
5305 goto fail;
5306
Govind Singhb53420c2016-03-09 14:32:57 +05305307 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305308
5309fail:
5310 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305311 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
5312 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305313}
5314
5315/**
5316 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
5317 * @wmi_handle: wmi handle
5318 * @vdev_id: vdev id
5319 * @probe_rsp_info: probe response info
5320 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305321 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305323static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305324 uint8_t vdev_id,
Krunal Soni89426862017-11-14 15:42:48 -08005325 struct wmi_probe_resp_params *probe_rsp_info)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305326{
5327 wmi_prb_tmpl_cmd_fixed_param *cmd;
5328 wmi_bcn_prb_info *bcn_prb_info;
5329 wmi_buf_t wmi_buf;
5330 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
5331 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05305332 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305333
Govind Singhb53420c2016-03-09 14:32:57 +05305334 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305335
Krunal Soni89426862017-11-14 15:42:48 -08005336 tmpl_len = probe_rsp_info->prb_rsp_template_len;
Vivekc5823092018-03-22 23:27:21 +05305337 tmpl_len_aligned = roundup(tmpl_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305338
5339 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
5340 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
5341 tmpl_len_aligned;
5342
5343 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05305344 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05305345 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05305346 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305347 }
5348
5349 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5350 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305351 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05305352 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305353 }
5354
5355 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5356
5357 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
5358 WMITLV_SET_HDR(&cmd->tlv_header,
5359 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
5360 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
5361 cmd->vdev_id = vdev_id;
5362 cmd->buf_len = tmpl_len;
5363 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
5364
5365 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
5366 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
5367 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
5368 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
5369 bcn_prb_info->caps = 0;
5370 bcn_prb_info->erp = 0;
5371 buf_ptr += sizeof(wmi_bcn_prb_info);
5372
5373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
5374 buf_ptr += WMI_TLV_HDR_SIZE;
Krunal Soni89426862017-11-14 15:42:48 -08005375 qdf_mem_copy(buf_ptr, probe_rsp_info->prb_rsp_template_frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305376
5377 ret = wmi_unified_cmd_send(wmi_handle,
5378 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305379 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305380 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305381 wmi_buf_free(wmi_buf);
5382 }
5383
5384 return ret;
5385}
5386
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305387#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305388#define WPI_IV_LEN 16
5389
5390/**
5391 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
5392 *
5393 * @dest_tx: destination address of tsc key counter
5394 * @src_tx: source address of tsc key counter
5395 * @dest_rx: destination address of rsc key counter
5396 * @src_rx: source address of rsc key counter
5397 *
5398 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
5399 *
5400 * Return: None
5401 *
5402 */
5403static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5404 uint8_t *dest_rx, uint8_t *src_rx)
5405{
5406 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
5407 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
5408}
5409#else
5410static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
5411 uint8_t *dest_rx, uint8_t *src_rx)
5412{
5413 return;
5414}
5415#endif
5416
5417/**
5418 * send_setup_install_key_cmd_tlv() - set key parameters
5419 * @wmi_handle: wmi handle
5420 * @key_params: key parameters
5421 *
5422 * This function fills structure from information
5423 * passed in key_params.
5424 *
5425 * Return: QDF_STATUS_SUCCESS - success
5426 * QDF_STATUS_E_FAILURE - failure
5427 * QDF_STATUS_E_NOMEM - not able to allocate buffer
5428 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305429static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305430 struct set_key_params *key_params)
5431{
5432 wmi_vdev_install_key_cmd_fixed_param *cmd;
5433 wmi_buf_t buf;
5434 uint8_t *buf_ptr;
5435 uint32_t len;
5436 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05305437 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305438
5439 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
5440 WMI_TLV_HDR_SIZE;
5441
5442 buf = wmi_buf_alloc(wmi_handle, len);
5443 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305444 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305445 return QDF_STATUS_E_NOMEM;
5446 }
5447
5448 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5449 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
5450 WMITLV_SET_HDR(&cmd->tlv_header,
5451 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
5452 WMITLV_GET_STRUCT_TLVLEN
5453 (wmi_vdev_install_key_cmd_fixed_param));
5454 cmd->vdev_id = key_params->vdev_id;
5455 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305456
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05305457
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305458 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
5459 cmd->key_flags |= key_params->key_flags;
5460 cmd->key_cipher = key_params->key_cipher;
5461 if ((key_params->key_txmic_len) &&
5462 (key_params->key_rxmic_len)) {
5463 cmd->key_txmic_len = key_params->key_txmic_len;
5464 cmd->key_rxmic_len = key_params->key_rxmic_len;
5465 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05305466#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305467 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
5468 key_params->tx_iv,
5469 cmd->wpi_key_rsc_counter,
5470 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05305471#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305472 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
5473 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5474 roundup(key_params->key_len, sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +05305475 key_data = (uint8_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305476 qdf_mem_copy((void *)key_data,
5477 (const void *)key_params->key_data, key_params->key_len);
Krunal Soni3a0fd852017-10-24 23:33:05 -07005478 if (key_params->key_rsc_counter)
5479 qdf_mem_copy(&cmd->key_rsc_counter, key_params->key_rsc_counter,
5480 sizeof(wmi_key_seq_counter));
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305481 cmd->key_len = key_params->key_len;
5482
5483 status = wmi_unified_cmd_send(wmi_handle, buf, len,
5484 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305485 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05305486 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305487
Govind Singh67922e82016-04-01 16:48:57 +05305488 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305489}
5490
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305491/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005492 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
5493 * @wmi_handle: wmi handle
5494 * @params: sar limit params
5495 *
5496 * Return: QDF_STATUS_SUCCESS for success or error code
5497 */
5498static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
5499 struct sar_limit_cmd_params *sar_limit_params)
5500{
5501 wmi_buf_t buf;
5502 QDF_STATUS qdf_status;
5503 wmi_sar_limits_cmd_fixed_param *cmd;
5504 int i;
5505 uint8_t *buf_ptr;
5506 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
5507 struct sar_limit_cmd_row *sar_rows_list;
5508 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
5509
5510 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
5511 buf = wmi_buf_alloc(wmi_handle, len);
5512 if (!buf) {
5513 WMI_LOGE("Failed to allocate memory");
5514 qdf_status = QDF_STATUS_E_NOMEM;
5515 goto end;
5516 }
5517
5518 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5519 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
5520 WMITLV_SET_HDR(&cmd->tlv_header,
5521 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
5522 WMITLV_GET_STRUCT_TLVLEN
5523 (wmi_sar_limits_cmd_fixed_param));
5524 cmd->sar_enable = sar_limit_params->sar_enable;
5525 cmd->commit_limits = sar_limit_params->commit_limits;
5526 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
5527
5528 WMI_LOGD("no of sar rows = %d, len = %d",
5529 sar_limit_params->num_limit_rows, len);
5530 buf_ptr += sizeof(*cmd);
5531 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5532 sizeof(wmi_sar_limit_cmd_row) *
5533 sar_limit_params->num_limit_rows);
5534 if (cmd->num_limit_rows == 0)
5535 goto send_sar_limits;
5536
5537 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
5538 (buf_ptr + WMI_TLV_HDR_SIZE);
5539 sar_rows_list = sar_limit_params->sar_limit_row_list;
5540
5541 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
5542 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
5543 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
5544 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
5545 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
5546 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
5547 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
5548 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
5549 wmi_sar_rows_list->validity_bitmap =
5550 sar_rows_list->validity_bitmap;
5551 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
5552 i, wmi_sar_rows_list->band_id,
5553 wmi_sar_rows_list->chain_id,
5554 wmi_sar_rows_list->mod_id,
5555 wmi_sar_rows_list->limit_value,
5556 wmi_sar_rows_list->validity_bitmap);
5557 sar_rows_list++;
5558 wmi_sar_rows_list++;
5559 }
5560send_sar_limits:
5561 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
5562 WMI_SAR_LIMITS_CMDID);
5563
5564 if (QDF_IS_STATUS_ERROR(qdf_status)) {
5565 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
5566 wmi_buf_free(buf);
5567 }
5568
5569end:
5570 return qdf_status;
5571}
5572
Jeff Johnson4783f902017-12-14 15:50:16 -08005573static QDF_STATUS get_sar_limit_cmd_tlv(wmi_unified_t wmi_handle)
5574{
5575 wmi_sar_get_limits_cmd_fixed_param *cmd;
5576 wmi_buf_t wmi_buf;
5577 uint32_t len;
5578 QDF_STATUS status;
5579
5580 WMI_LOGD(FL("Enter"));
5581
5582 len = sizeof(*cmd);
5583 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5584 if (!wmi_buf) {
5585 WMI_LOGP(FL("failed to allocate memory for msg"));
5586 return QDF_STATUS_E_NOMEM;
5587 }
5588
5589 cmd = (wmi_sar_get_limits_cmd_fixed_param *)wmi_buf_data(wmi_buf);
5590
5591 WMITLV_SET_HDR(&cmd->tlv_header,
5592 WMITLV_TAG_STRUC_wmi_sar_get_limits_cmd_fixed_param,
5593 WMITLV_GET_STRUCT_TLVLEN
5594 (wmi_sar_get_limits_cmd_fixed_param));
5595
5596 cmd->reserved = 0;
5597
5598 status = wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5599 WMI_SAR_GET_LIMITS_CMDID);
5600 if (QDF_IS_STATUS_ERROR(status)) {
5601 WMI_LOGE(FL("Failed to send get SAR limit cmd: %d"), status);
5602 wmi_buf_free(wmi_buf);
5603 }
5604
5605 WMI_LOGD(FL("Exit"));
5606
5607 return status;
5608}
5609
5610static QDF_STATUS extract_sar_limit_event_tlv(wmi_unified_t wmi_handle,
5611 uint8_t *evt_buf,
5612 struct sar_limit_event *event)
5613{
5614 wmi_sar_get_limits_event_fixed_param *fixed_param;
5615 WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *param_buf;
5616 wmi_sar_get_limit_event_row *row_in;
5617 struct sar_limit_event_row *row_out;
5618 uint32_t row;
5619
5620 if (!evt_buf) {
5621 WMI_LOGE(FL("input event is NULL"));
5622 return QDF_STATUS_E_INVAL;
5623 }
5624 if (!event) {
5625 WMI_LOGE(FL("output event is NULL"));
5626 return QDF_STATUS_E_INVAL;
5627 }
5628
5629 param_buf = (WMI_SAR_GET_LIMITS_EVENTID_param_tlvs *)evt_buf;
5630
5631 fixed_param = param_buf->fixed_param;
5632 if (!fixed_param) {
5633 WMI_LOGE(FL("Invalid fixed param"));
5634 return QDF_STATUS_E_INVAL;
5635 }
5636
5637 event->sar_enable = fixed_param->sar_enable;
5638 event->num_limit_rows = fixed_param->num_limit_rows;
5639
5640 if (event->num_limit_rows > MAX_SAR_LIMIT_ROWS_SUPPORTED) {
5641 QDF_ASSERT(0);
5642 WMI_LOGE(FL("Num rows %d exceeds max of %d"),
5643 event->num_limit_rows,
5644 MAX_SAR_LIMIT_ROWS_SUPPORTED);
5645 event->num_limit_rows = MAX_SAR_LIMIT_ROWS_SUPPORTED;
5646 }
5647
5648 row_in = param_buf->sar_get_limits;
5649 row_out = &event->sar_limit_row[0];
5650 for (row = 0; row < event->num_limit_rows; row++) {
5651 row_out->band_id = row_in->band_id;
5652 row_out->chain_id = row_in->chain_id;
5653 row_out->mod_id = row_in->mod_id;
5654 row_out->limit_value = row_in->limit_value;
5655 row_out++;
5656 row_in++;
5657 }
5658
5659 return QDF_STATUS_SUCCESS;
5660}
5661
Nachiket Kukadeab4cbc22017-12-15 12:36:58 +05305662#ifdef WLAN_FEATURE_DISA
Manikandan Mohan31a13e22016-12-13 13:14:06 -08005663/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305664 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
5665 * @wmi_handle: wmi handle
5666 * @params: encrypt/decrypt params
5667 *
5668 * Return: QDF_STATUS_SUCCESS for success or error code
5669 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005670static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305671QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305672 struct disa_encrypt_decrypt_req_params *encrypt_decrypt_params)
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305673{
5674 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
5675 wmi_buf_t wmi_buf;
5676 uint8_t *buf_ptr;
5677 QDF_STATUS ret;
5678 uint32_t len;
5679
5680 WMI_LOGD(FL("Send encrypt decrypt cmd"));
5681
5682 len = sizeof(*cmd) +
Vivekc5823092018-03-22 23:27:21 +05305683 roundup(encrypt_decrypt_params->data_len, sizeof(uint32_t)) +
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305684 WMI_TLV_HDR_SIZE;
5685 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5686 if (!wmi_buf) {
5687 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
5688 __func__);
5689 return QDF_STATUS_E_NOMEM;
5690 }
5691
5692 buf_ptr = wmi_buf_data(wmi_buf);
5693 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
5694
5695 WMITLV_SET_HDR(&cmd->tlv_header,
5696 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
5697 WMITLV_GET_STRUCT_TLVLEN(
5698 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
5699
5700 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
5701 cmd->key_flag = encrypt_decrypt_params->key_flag;
5702 cmd->key_idx = encrypt_decrypt_params->key_idx;
5703 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
5704 cmd->key_len = encrypt_decrypt_params->key_len;
5705 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
5706 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
5707
5708 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
5709 encrypt_decrypt_params->key_len);
5710
5711 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
5712 MAX_MAC_HEADER_LEN);
5713
5714 cmd->data_len = encrypt_decrypt_params->data_len;
5715
5716 if (cmd->data_len) {
5717 buf_ptr += sizeof(*cmd);
5718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5719 roundup(encrypt_decrypt_params->data_len,
Vivekc5823092018-03-22 23:27:21 +05305720 sizeof(uint32_t)));
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305721 buf_ptr += WMI_TLV_HDR_SIZE;
5722 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
5723 encrypt_decrypt_params->data_len);
5724 }
5725
5726 /* This conversion is to facilitate data to FW in little endian */
5727 cmd->pn[5] = encrypt_decrypt_params->pn[0];
5728 cmd->pn[4] = encrypt_decrypt_params->pn[1];
5729 cmd->pn[3] = encrypt_decrypt_params->pn[2];
5730 cmd->pn[2] = encrypt_decrypt_params->pn[3];
5731 cmd->pn[1] = encrypt_decrypt_params->pn[4];
5732 cmd->pn[0] = encrypt_decrypt_params->pn[5];
5733
5734 ret = wmi_unified_cmd_send(wmi_handle,
5735 wmi_buf, len,
5736 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
5737 if (QDF_IS_STATUS_ERROR(ret)) {
5738 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
5739 wmi_buf_free(wmi_buf);
5740 }
5741
5742 return ret;
5743}
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05305744
Nachiket Kukade03e7ab22017-12-20 17:28:29 +05305745/**
5746 * extract_encrypt_decrypt_resp_event_tlv() - extract encrypt decrypt resp
5747 * params from event
5748 * @wmi_handle: wmi handle
5749 * @evt_buf: pointer to event buffer
5750 * @resp: Pointer to hold resp parameters
5751 *
5752 * Return: QDF_STATUS_SUCCESS for success or error code
5753 */
5754static
5755QDF_STATUS extract_encrypt_decrypt_resp_event_tlv(wmi_unified_t wmi_handle,
5756 void *evt_buf, struct disa_encrypt_decrypt_resp_params *resp)
5757{
5758 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID_param_tlvs *param_buf;
5759 wmi_vdev_encrypt_decrypt_data_resp_event_fixed_param *data_event;
5760
5761 param_buf = evt_buf;
5762 if (!param_buf) {
5763 WMI_LOGE("encrypt decrypt resp evt_buf is NULL");
5764 return QDF_STATUS_E_INVAL;
5765 }
5766
5767 data_event = param_buf->fixed_param;
5768
5769 resp->vdev_id = data_event->vdev_id;
5770 resp->status = data_event->status;
5771
5772 if (data_event->data_length > param_buf->num_enc80211_frame) {
5773 WMI_LOGE("FW msg data_len %d more than TLV hdr %d",
5774 data_event->data_length,
5775 param_buf->num_enc80211_frame);
5776 return QDF_STATUS_E_INVAL;
5777 }
5778
5779 resp->data_len = data_event->data_length;
5780
5781 if (resp->data_len)
5782 resp->data = (uint8_t *)param_buf->enc80211_frame;
5783
5784 return QDF_STATUS_SUCCESS;
5785}
5786#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05305787
Govind Singh4eacd2b2016-03-07 14:24:22 +05305788/**
5789 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
5790 * @wmi_handle: wmi handle
5791 * @vdev_id: vdev id
5792 * @p2p_ie: p2p IE
5793 *
Govind Singhe7f2f342016-05-23 12:12:52 +05305794 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05305795 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305796static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05305797 uint32_t vdev_id, uint8_t *p2p_ie)
Govind Singh4eacd2b2016-03-07 14:24:22 +05305798{
Govind Singh67922e82016-04-01 16:48:57 +05305799 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305800 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
5801 wmi_buf_t wmi_buf;
5802 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
5803 uint8_t *buf_ptr;
5804
5805 ie_len = (uint32_t) (p2p_ie[1] + 2);
5806
5807 /* More than one P2P IE may be included in a single frame.
5808 If multiple P2P IEs are present, the complete P2P attribute
5809 data consists of the concatenation of the P2P Attribute
5810 fields of the P2P IEs. The P2P Attributes field of each
5811 P2P IE may be any length up to the maximum (251 octets).
5812 In this case host sends one P2P IE to firmware so the length
5813 should not exceed more than 251 bytes
5814 */
5815 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05305816 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05305817 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305818 }
5819
Vivekc5823092018-03-22 23:27:21 +05305820 ie_len_aligned = roundup(ie_len, sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305821
5822 wmi_buf_len =
5823 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
5824 WMI_TLV_HDR_SIZE;
5825
5826 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
5827 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305828 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05305829 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305830 }
5831
5832 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5833
5834 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
5835 WMITLV_SET_HDR(&cmd->tlv_header,
5836 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
5837 WMITLV_GET_STRUCT_TLVLEN
5838 (wmi_p2p_go_set_beacon_ie_fixed_param));
5839 cmd->vdev_id = vdev_id;
5840 cmd->ie_buf_len = ie_len;
5841
5842 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
5843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
5844 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05305845 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305846
Govind Singhb53420c2016-03-09 14:32:57 +05305847 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305848
5849 ret = wmi_unified_cmd_send(wmi_handle,
5850 wmi_buf, wmi_buf_len,
5851 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05305852 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305853 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305854 wmi_buf_free(wmi_buf);
5855 }
5856
Govind Singhb53420c2016-03-09 14:32:57 +05305857 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305858 return ret;
5859}
5860
5861/**
5862 * send_set_gateway_params_cmd_tlv() - set gateway parameters
5863 * @wmi_handle: wmi handle
5864 * @req: gateway parameter update request structure
5865 *
5866 * This function reads the incoming @req and fill in the destination
5867 * WMI structure and sends down the gateway configs down to the firmware
5868 *
Govind Singhb53420c2016-03-09 14:32:57 +05305869 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05305870 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305871static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305872 struct gateway_update_req_param *req)
5873{
5874 wmi_roam_subnet_change_config_fixed_param *cmd;
5875 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305876 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305877 int len = sizeof(*cmd);
5878
5879 buf = wmi_buf_alloc(wmi_handle, len);
5880 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305881 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5882 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305883 }
5884
5885 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
5886 WMITLV_SET_HDR(&cmd->tlv_header,
5887 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
5888 WMITLV_GET_STRUCT_TLVLEN(
5889 wmi_roam_subnet_change_config_fixed_param));
5890
5891 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305892 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5893 QDF_IPV4_ADDR_SIZE);
5894 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5895 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305896 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5897 &cmd->inet_gw_mac_addr);
5898 cmd->max_retries = req->max_retries;
5899 cmd->timeout = req->timeout;
5900 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5901 cmd->flag = 0;
5902 if (req->ipv4_addr_type)
5903 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5904
5905 if (req->ipv6_addr_type)
5906 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5907
5908 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5909 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305910 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305911 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305912 ret);
5913 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305914 }
5915
Govind Singh67922e82016-04-01 16:48:57 +05305916 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305917}
5918
5919/**
5920 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5921 * @wmi_handle: wmi handle
5922 * @req: rssi monitoring request structure
5923 *
5924 * This function reads the incoming @req and fill in the destination
5925 * WMI structure and send down the rssi monitoring configs down to the firmware
5926 *
5927 * Return: 0 on success; error number otherwise
5928 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305929static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305930 struct rssi_monitor_param *req)
5931{
5932 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5933 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305934 QDF_STATUS ret;
5935 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305936
5937 buf = wmi_buf_alloc(wmi_handle, len);
5938 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305939 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5940 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305941 }
5942
5943 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5944 WMITLV_SET_HDR(&cmd->tlv_header,
5945 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5946 WMITLV_GET_STRUCT_TLVLEN(
5947 wmi_rssi_breach_monitor_config_fixed_param));
5948
5949 cmd->vdev_id = req->session_id;
5950 cmd->request_id = req->request_id;
5951 cmd->lo_rssi_reenable_hysteresis = 0;
5952 cmd->hi_rssi_reenable_histeresis = 0;
5953 cmd->min_report_interval = 0;
5954 cmd->max_num_report = 1;
5955 if (req->control) {
5956 /* enable one threshold for each min/max */
5957 cmd->enabled_bitmap = 0x09;
5958 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5959 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5960 } else {
5961 cmd->enabled_bitmap = 0;
5962 cmd->low_rssi_breach_threshold[0] = 0;
5963 cmd->hi_rssi_breach_threshold[0] = 0;
5964 }
5965
5966 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5967 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305968 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305969 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305970 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305971 }
5972
Rajeev Kumarca1de3e2017-06-14 10:34:00 -07005973 WMI_LOGD("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
5974
Govind Singh67922e82016-04-01 16:48:57 +05305975 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305976}
5977
5978/**
5979 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5980 * @wmi_handle: wmi handle
5981 * @psetoui: OUI parameters
5982 *
5983 * set scan probe OUI parameters in firmware
5984 *
5985 * Return: CDF status
5986 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305987static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305988 struct scan_mac_oui *psetoui)
5989{
5990 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5991 wmi_buf_t wmi_buf;
5992 uint32_t len;
5993 uint8_t *buf_ptr;
5994 uint32_t *oui_buf;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305995 struct probe_req_whitelist_attr *ie_whitelist = &psetoui->ie_whitelist;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305996
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05305997 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
5998 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui);
5999
Govind Singh4eacd2b2016-03-07 14:24:22 +05306000 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6001 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306002 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6003 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306004 }
6005 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6006 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
6007 WMITLV_SET_HDR(&cmd->tlv_header,
6008 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
6009 WMITLV_GET_STRUCT_TLVLEN
6010 (wmi_scan_prob_req_oui_cmd_fixed_param));
6011
6012 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05306013 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05306014 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
6015 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05306016 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306017 cmd->prob_req_oui);
6018
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05306019 cmd->vdev_id = psetoui->vdev_id;
6020 cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
6021 if (psetoui->enb_probe_req_sno_randomization)
6022 cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
6023
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05306024 if (ie_whitelist->white_list) {
6025 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
6026 &cmd->num_vendor_oui,
6027 ie_whitelist);
6028 cmd->flags |=
6029 WMI_SCAN_PROBE_OUI_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
6030 }
6031
6032 buf_ptr += sizeof(*cmd);
6033 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6034 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
6035 buf_ptr += WMI_TLV_HDR_SIZE;
6036
6037 if (cmd->num_vendor_oui != 0) {
6038 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
6039 ie_whitelist->voui);
6040 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
6041 }
6042
Govind Singh4eacd2b2016-03-07 14:24:22 +05306043 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6044 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306045 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306046 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306047 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306048 }
Govind Singhb53420c2016-03-09 14:32:57 +05306049 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306050}
6051
Sridhar Selvaraj411833a2017-08-21 16:35:45 +05306052#if defined(WLAN_FEATURE_FILS_SK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306053/**
6054 * wmi_add_fils_tlv() - Add FILS TLV to roam scan offload command
6055 * @wmi_handle: wmi handle
6056 * @roam_req: Roam scan offload params
6057 * @buf_ptr: command buffer to send
6058 * @fils_tlv_len: fils tlv length
6059 *
6060 * Return: Updated buffer pointer
6061 */
6062static uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6063 struct roam_offload_scan_params *roam_req,
6064 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6065{
6066 wmi_roam_fils_offload_tlv_param *fils_tlv;
6067 wmi_erp_info *erp_info;
6068 struct roam_fils_params *roam_fils_params;
6069
6070 if (!roam_req->add_fils_tlv)
6071 return buf_ptr;
6072
6073 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6074 sizeof(*fils_tlv));
6075 buf_ptr += WMI_TLV_HDR_SIZE;
6076
6077 fils_tlv = (wmi_roam_fils_offload_tlv_param *)buf_ptr;
6078 WMITLV_SET_HDR(&fils_tlv->tlv_header,
6079 WMITLV_TAG_STRUC_wmi_roam_fils_offload_tlv_param,
6080 WMITLV_GET_STRUCT_TLVLEN
6081 (wmi_roam_fils_offload_tlv_param));
6082
6083 roam_fils_params = &roam_req->roam_fils_params;
6084 erp_info = (wmi_erp_info *)(&fils_tlv->vdev_erp_info);
6085
6086 erp_info->username_length = roam_fils_params->username_length;
6087 qdf_mem_copy(erp_info->username, roam_fils_params->username,
6088 erp_info->username_length);
6089
6090 erp_info->next_erp_seq_num = roam_fils_params->next_erp_seq_num;
6091
6092 erp_info->rRk_length = roam_fils_params->rrk_length;
6093 qdf_mem_copy(erp_info->rRk, roam_fils_params->rrk,
6094 erp_info->rRk_length);
6095
6096 erp_info->rIk_length = roam_fils_params->rik_length;
6097 qdf_mem_copy(erp_info->rIk, roam_fils_params->rik,
6098 erp_info->rIk_length);
6099
6100 erp_info->realm_len = roam_fils_params->realm_len;
6101 qdf_mem_copy(erp_info->realm, roam_fils_params->realm,
6102 erp_info->realm_len);
6103
6104 buf_ptr += sizeof(*fils_tlv);
6105 return buf_ptr;
6106}
6107#else
6108static inline uint8_t *wmi_add_fils_tlv(wmi_unified_t wmi_handle,
6109 struct roam_offload_scan_params *roam_req,
6110 uint8_t *buf_ptr, uint32_t fils_tlv_len)
6111{
6112 return buf_ptr;
6113}
6114#endif
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306115/**
6116 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
6117 * @wmi_handle: wmi handle
6118 * @scan_cmd_fp: start scan command ptr
6119 * @roam_req: roam request param
6120 *
6121 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
6122 * of WMI_ROAM_SCAN_MODE.
6123 *
6124 * Return: QDF status
6125 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306126static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306127 wmi_start_scan_cmd_fixed_param *
6128 scan_cmd_fp,
6129 struct roam_offload_scan_params *roam_req)
6130{
6131 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306132 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306133 int len;
6134 uint8_t *buf_ptr;
6135 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05306136
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306137#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6138 int auth_mode = roam_req->auth_mode;
6139 wmi_roam_offload_tlv_param *roam_offload_params;
6140 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
6141 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
6142 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306143 wmi_tlv_buf_len_param *assoc_ies;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306144 uint32_t fils_tlv_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306145#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6146 /* Need to create a buf with roam_scan command at
6147 * front and piggyback with scan command */
6148 len = sizeof(wmi_roam_scan_mode_fixed_param) +
6149#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6150 (2 * WMI_TLV_HDR_SIZE) +
6151#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6152 sizeof(wmi_start_scan_cmd_fixed_param);
6153#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006154 WMI_LOGD("auth_mode = %d", auth_mode);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306155 if (roam_req->is_roam_req_valid &&
6156 roam_req->roam_offload_enabled) {
6157 len += sizeof(wmi_roam_offload_tlv_param);
6158 len += WMI_TLV_HDR_SIZE;
6159 if ((auth_mode != WMI_AUTH_NONE) &&
6160 ((auth_mode != WMI_AUTH_OPEN) ||
6161 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306162 roam_req->mdid.mdie_present &&
6163 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306164 roam_req->is_ese_assoc)) {
6165 len += WMI_TLV_HDR_SIZE;
6166 if (roam_req->is_ese_assoc)
6167 len +=
6168 sizeof(wmi_roam_ese_offload_tlv_param);
6169 else if (auth_mode == WMI_AUTH_FT_RSNA ||
6170 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
6171 (auth_mode == WMI_AUTH_OPEN &&
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306172 roam_req->mdid.mdie_present &&
6173 roam_req->is_11r_assoc))
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306174 len +=
6175 sizeof(wmi_roam_11r_offload_tlv_param);
6176 else
6177 len +=
6178 sizeof(wmi_roam_11i_offload_tlv_param);
6179 } else {
6180 len += WMI_TLV_HDR_SIZE;
6181 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306182
6183 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
6184 + roundup(roam_req->assoc_ie_length,
6185 sizeof(uint32_t)));
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306186
6187 if (roam_req->add_fils_tlv) {
6188 fils_tlv_len = sizeof(
6189 wmi_roam_fils_offload_tlv_param);
6190 len += WMI_TLV_HDR_SIZE + fils_tlv_len;
6191 }
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306192 } else {
6193 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05306194 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306195 __func__, roam_req->roam_offload_enabled);
6196 else
Govind Singhe7f2f342016-05-23 12:12:52 +05306197 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306198 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306199 }
6200 if (roam_req->is_roam_req_valid &&
6201 roam_req->roam_offload_enabled) {
6202 roam_req->mode = roam_req->mode |
6203 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
6204 }
6205#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
6206
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306207 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
6208 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
6209 len = sizeof(wmi_roam_scan_mode_fixed_param);
6210
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306211 buf = wmi_buf_alloc(wmi_handle, len);
6212 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306213 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306214 return QDF_STATUS_E_NOMEM;
6215 }
6216
6217 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6218 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
6219 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
6220 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
6221 WMITLV_GET_STRUCT_TLVLEN
6222 (wmi_roam_scan_mode_fixed_param));
6223
Abhinav Kumar334355f2018-04-06 17:18:52 +05306224 roam_scan_mode_fp->min_delay_roam_trigger_reason_bitmask =
6225 roam_req->roam_trigger_reason_bitmask;
6226 roam_scan_mode_fp->min_delay_btw_scans =
6227 WMI_SEC_TO_MSEC(roam_req->min_delay_btw_roam_scans);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306228 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
6229 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306230 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
6231 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
6232 roam_scan_mode_fp->flags |=
6233 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306234 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05306235 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306236
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306237 /* Fill in scan parameters suitable for roaming scan */
6238 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306239
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306240 qdf_mem_copy(buf_ptr, scan_cmd_fp,
6241 sizeof(wmi_start_scan_cmd_fixed_param));
6242 /* Ensure there is no additional IEs */
6243 scan_cmd_fp->ie_len = 0;
6244 WMITLV_SET_HDR(buf_ptr,
6245 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
6246 WMITLV_GET_STRUCT_TLVLEN
6247 (wmi_start_scan_cmd_fixed_param));
6248#ifdef WLAN_FEATURE_ROAM_OFFLOAD
6249 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
6250 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
6251 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6252 sizeof(wmi_roam_offload_tlv_param));
6253 buf_ptr += WMI_TLV_HDR_SIZE;
6254 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
6255 WMITLV_SET_HDR(buf_ptr,
6256 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
6257 WMITLV_GET_STRUCT_TLVLEN
6258 (wmi_roam_offload_tlv_param));
6259 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
6260 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
6261 roam_offload_params->select_5g_margin =
6262 roam_req->select_5ghz_margin;
Abhinav Kumare158b1c2018-04-05 18:53:39 +05306263 roam_offload_params->handoff_delay_for_rx =
6264 roam_req->roam_offload_params.ho_delay_for_rx;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306265 roam_offload_params->reassoc_failure_timeout =
6266 roam_req->reassoc_failure_timeout;
6267
6268 /* Fill the capabilities */
6269 roam_offload_params->capability =
6270 roam_req->roam_offload_params.capability;
6271 roam_offload_params->ht_caps_info =
6272 roam_req->roam_offload_params.ht_caps_info;
6273 roam_offload_params->ampdu_param =
6274 roam_req->roam_offload_params.ampdu_param;
6275 roam_offload_params->ht_ext_cap =
6276 roam_req->roam_offload_params.ht_ext_cap;
6277 roam_offload_params->ht_txbf =
6278 roam_req->roam_offload_params.ht_txbf;
6279 roam_offload_params->asel_cap =
6280 roam_req->roam_offload_params.asel_cap;
6281 roam_offload_params->qos_caps =
6282 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08006283 roam_offload_params->qos_enabled =
6284 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306285 roam_offload_params->wmm_caps =
6286 roam_req->roam_offload_params.wmm_caps;
6287 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
6288 (uint8_t *)roam_req->roam_offload_params.mcsset,
6289 ROAM_OFFLOAD_NUM_MCS_SET);
6290
6291 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
6292 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
6293 * they are filled in the same order.Depending on the
6294 * authentication type, the other mode TLV's are nullified
6295 * and only headers are filled.*/
6296 if ((auth_mode != WMI_AUTH_NONE) &&
6297 ((auth_mode != WMI_AUTH_OPEN) ||
6298 (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306299 && roam_req->mdid.mdie_present &&
6300 roam_req->is_11r_assoc) ||
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306301 roam_req->is_ese_assoc)) {
6302 if (roam_req->is_ese_assoc) {
6303 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6304 WMITLV_GET_STRUCT_TLVLEN(0));
6305 buf_ptr += WMI_TLV_HDR_SIZE;
6306 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6307 WMITLV_GET_STRUCT_TLVLEN(0));
6308 buf_ptr += WMI_TLV_HDR_SIZE;
6309 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6310 sizeof(wmi_roam_ese_offload_tlv_param));
6311 buf_ptr += WMI_TLV_HDR_SIZE;
6312 roam_offload_ese =
6313 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
6314 qdf_mem_copy(roam_offload_ese->krk,
6315 roam_req->krk,
6316 sizeof(roam_req->krk));
6317 qdf_mem_copy(roam_offload_ese->btk,
6318 roam_req->btk,
6319 sizeof(roam_req->btk));
6320 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
6321 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
6322 WMITLV_GET_STRUCT_TLVLEN
6323 (wmi_roam_ese_offload_tlv_param));
6324 buf_ptr +=
6325 sizeof(wmi_roam_ese_offload_tlv_param);
6326 } else if (auth_mode == WMI_AUTH_FT_RSNA
6327 || auth_mode == WMI_AUTH_FT_RSNA_PSK
6328 || (auth_mode == WMI_AUTH_OPEN
Abhinav Kumar7c0e99b2018-03-27 17:06:59 +05306329 && roam_req->mdid.mdie_present &&
6330 roam_req->is_11r_assoc)) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306331 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6332 0);
6333 buf_ptr += WMI_TLV_HDR_SIZE;
6334 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6335 sizeof(wmi_roam_11r_offload_tlv_param));
6336 buf_ptr += WMI_TLV_HDR_SIZE;
6337 roam_offload_11r =
6338 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
6339 roam_offload_11r->r0kh_id_len =
6340 roam_req->rokh_id_length;
6341 qdf_mem_copy(roam_offload_11r->r0kh_id,
6342 roam_req->rokh_id,
6343 roam_offload_11r->r0kh_id_len);
6344 qdf_mem_copy(roam_offload_11r->psk_msk,
6345 roam_req->psk_pmk,
6346 sizeof(roam_req->psk_pmk));
6347 roam_offload_11r->psk_msk_len =
6348 roam_req->pmk_len;
6349 roam_offload_11r->mdie_present =
6350 roam_req->mdid.mdie_present;
6351 roam_offload_11r->mdid =
6352 roam_req->mdid.mobility_domain;
6353 if (auth_mode == WMI_AUTH_OPEN) {
6354 /* If FT-Open ensure pmk length
6355 and r0khid len are zero */
6356 roam_offload_11r->r0kh_id_len = 0;
6357 roam_offload_11r->psk_msk_len = 0;
6358 }
6359 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
6360 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
6361 WMITLV_GET_STRUCT_TLVLEN
6362 (wmi_roam_11r_offload_tlv_param));
6363 buf_ptr +=
6364 sizeof(wmi_roam_11r_offload_tlv_param);
6365 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6366 WMITLV_GET_STRUCT_TLVLEN(0));
6367 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006368 WMI_LOGD("psk_msk_len = %d",
6369 roam_offload_11r->psk_msk_len);
6370 if (roam_offload_11r->psk_msk_len)
6371 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6372 QDF_TRACE_LEVEL_DEBUG,
6373 roam_offload_11r->psk_msk,
6374 roam_offload_11r->psk_msk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306375 } else {
6376 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6377 sizeof(wmi_roam_11i_offload_tlv_param));
6378 buf_ptr += WMI_TLV_HDR_SIZE;
6379 roam_offload_11i =
6380 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006381
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07006382 if (roam_req->roam_key_mgmt_offload_enabled &&
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006383 roam_req->fw_okc) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306384 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
6385 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006386 WMI_LOGI("LFR3:OKC enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306387 } else {
6388 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
6389 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006390 WMI_LOGI("LFR3:OKC disabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006391 }
6392 if (roam_req->roam_key_mgmt_offload_enabled &&
6393 roam_req->fw_pmksa_cache) {
6394 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_ENABLED
6395 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006396 WMI_LOGI("LFR3:PMKSA caching enabled");
Deepak Dhamdhere2eff0122017-02-09 19:40:26 -08006397 } else {
6398 WMI_SET_ROAM_OFFLOAD_PMK_CACHE_DISABLED
6399 (roam_offload_11i->flags);
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07006400 WMI_LOGI("LFR3:PMKSA caching disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306401 }
6402
6403 qdf_mem_copy(roam_offload_11i->pmk,
6404 roam_req->psk_pmk,
6405 sizeof(roam_req->psk_pmk));
6406 roam_offload_11i->pmk_len = roam_req->pmk_len;
6407 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
6408 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
6409 WMITLV_GET_STRUCT_TLVLEN
6410 (wmi_roam_11i_offload_tlv_param));
6411 buf_ptr +=
6412 sizeof(wmi_roam_11i_offload_tlv_param);
6413 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6414 0);
6415 buf_ptr += WMI_TLV_HDR_SIZE;
6416 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6417 0);
6418 buf_ptr += WMI_TLV_HDR_SIZE;
Varun Reddy Yeturu13399282017-09-21 21:10:43 -07006419 WMI_LOGD("pmk_len = %d",
6420 roam_offload_11i->pmk_len);
6421 if (roam_offload_11i->pmk_len)
6422 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI,
6423 QDF_TRACE_LEVEL_DEBUG,
6424 roam_offload_11i->pmk,
6425 roam_offload_11i->pmk_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306426 }
6427 } else {
6428 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6429 WMITLV_GET_STRUCT_TLVLEN(0));
6430 buf_ptr += WMI_TLV_HDR_SIZE;
6431 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6432 WMITLV_GET_STRUCT_TLVLEN(0));
6433 buf_ptr += WMI_TLV_HDR_SIZE;
6434 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6435 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306436 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306437 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306438
6439 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6440 sizeof(*assoc_ies));
6441 buf_ptr += WMI_TLV_HDR_SIZE;
6442
6443 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
6444 WMITLV_SET_HDR(&assoc_ies->tlv_header,
6445 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
6446 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
6447 assoc_ies->buf_len = roam_req->assoc_ie_length;
6448
6449 buf_ptr += sizeof(*assoc_ies);
6450
6451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6452 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
6453 buf_ptr += WMI_TLV_HDR_SIZE;
6454
6455 if (assoc_ies->buf_len != 0) {
6456 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
6457 assoc_ies->buf_len);
6458 }
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306459 buf_ptr += qdf_roundup(assoc_ies->buf_len, sizeof(uint32_t));
6460 buf_ptr = wmi_add_fils_tlv(wmi_handle, roam_req,
6461 buf_ptr, fils_tlv_len);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306462 } else {
6463 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6464 WMITLV_GET_STRUCT_TLVLEN(0));
6465 buf_ptr += WMI_TLV_HDR_SIZE;
6466 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6467 WMITLV_GET_STRUCT_TLVLEN(0));
6468 buf_ptr += WMI_TLV_HDR_SIZE;
6469 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6470 WMITLV_GET_STRUCT_TLVLEN(0));
6471 buf_ptr += WMI_TLV_HDR_SIZE;
6472 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6473 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05306474 buf_ptr += WMI_TLV_HDR_SIZE;
6475 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6476 WMITLV_GET_STRUCT_TLVLEN(0));
6477 buf_ptr += WMI_TLV_HDR_SIZE;
6478 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6479 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306480 }
6481#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05306482
6483send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306484 status = wmi_unified_cmd_send(wmi_handle, buf,
6485 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05306486 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306487 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306488 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
6489 status);
6490 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306491 }
6492
Govind Singh67922e82016-04-01 16:48:57 +05306493 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306494}
6495
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006496static QDF_STATUS send_roam_mawc_params_cmd_tlv(wmi_unified_t wmi_handle,
6497 struct wmi_mawc_roam_params *params)
6498{
6499 wmi_buf_t buf = NULL;
6500 QDF_STATUS status;
6501 int len;
6502 uint8_t *buf_ptr;
6503 wmi_roam_configure_mawc_cmd_fixed_param *wmi_roam_mawc_params;
6504
6505 len = sizeof(*wmi_roam_mawc_params);
6506 buf = wmi_buf_alloc(wmi_handle, len);
6507 if (!buf) {
6508 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
6509 return QDF_STATUS_E_NOMEM;
6510 }
6511
6512 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6513 wmi_roam_mawc_params =
6514 (wmi_roam_configure_mawc_cmd_fixed_param *) buf_ptr;
6515 WMITLV_SET_HDR(&wmi_roam_mawc_params->tlv_header,
6516 WMITLV_TAG_STRUC_wmi_roam_configure_mawc_cmd_fixed_param,
6517 WMITLV_GET_STRUCT_TLVLEN
6518 (wmi_roam_configure_mawc_cmd_fixed_param));
6519 wmi_roam_mawc_params->vdev_id = params->vdev_id;
6520 if (params->enable)
6521 wmi_roam_mawc_params->enable = 1;
6522 else
6523 wmi_roam_mawc_params->enable = 0;
6524 wmi_roam_mawc_params->traffic_load_threshold =
6525 params->traffic_load_threshold;
6526 wmi_roam_mawc_params->best_ap_rssi_threshold =
6527 params->best_ap_rssi_threshold;
6528 wmi_roam_mawc_params->rssi_stationary_high_adjust =
6529 params->rssi_stationary_high_adjust;
6530 wmi_roam_mawc_params->rssi_stationary_low_adjust =
6531 params->rssi_stationary_low_adjust;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07006532 WMI_LOGD(FL("MAWC roam en=%d, vdev=%d, tr=%d, ap=%d, high=%d, low=%d"),
6533 wmi_roam_mawc_params->enable, wmi_roam_mawc_params->vdev_id,
6534 wmi_roam_mawc_params->traffic_load_threshold,
6535 wmi_roam_mawc_params->best_ap_rssi_threshold,
6536 wmi_roam_mawc_params->rssi_stationary_high_adjust,
6537 wmi_roam_mawc_params->rssi_stationary_low_adjust);
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006538
6539 status = wmi_unified_cmd_send(wmi_handle, buf,
6540 len, WMI_ROAM_CONFIGURE_MAWC_CMDID);
6541 if (QDF_IS_STATUS_ERROR(status)) {
6542 WMI_LOGE("WMI_ROAM_CONFIGURE_MAWC_CMDID failed, Error %d",
6543 status);
6544 wmi_buf_free(buf);
6545 return status;
6546 }
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -07006547
6548 return QDF_STATUS_SUCCESS;
6549}
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306550
6551/**
6552 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
6553 * rssi threashold
6554 * @wmi_handle: wmi handle
6555 * @roam_req: Roaming request buffer
6556 *
6557 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
6558 *
6559 * Return: QDF status
6560 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306561static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306562 struct roam_offload_scan_rssi_params *roam_req)
6563{
6564 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306565 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306566 int len;
6567 uint8_t *buf_ptr;
6568 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
6569 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
6570 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05306571 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006572 wmi_roam_bg_scan_roaming_param *bg_scan_params = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306573
6574 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6575 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6576 len += sizeof(wmi_roam_scan_extended_threshold_param);
6577 len += WMI_TLV_HDR_SIZE;
6578 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05306579 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
6580 len += sizeof(wmi_roam_dense_thres_param);
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006581 len += WMI_TLV_HDR_SIZE; /* TLV for BG Scan*/
6582 len += sizeof(wmi_roam_bg_scan_roaming_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306583 buf = wmi_buf_alloc(wmi_handle, len);
6584 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306585 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306586 return QDF_STATUS_E_NOMEM;
6587 }
6588
6589 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6590 rssi_threshold_fp =
6591 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
6592 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
6593 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
6594 WMITLV_GET_STRUCT_TLVLEN
6595 (wmi_roam_scan_rssi_threshold_fixed_param));
6596 /* fill in threshold values */
6597 rssi_threshold_fp->vdev_id = roam_req->session_id;
6598 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
6599 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
6600 rssi_threshold_fp->hirssi_scan_max_count =
6601 roam_req->hi_rssi_scan_max_count;
6602 rssi_threshold_fp->hirssi_scan_delta =
6603 roam_req->hi_rssi_scan_rssi_delta;
6604 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
Varun Reddy Yeturu6ef9a652017-06-26 13:53:17 -07006605 rssi_threshold_fp->rssi_thresh_offset_5g =
6606 roam_req->rssi_thresh_offset_5g;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306607
6608 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
6609 WMITLV_SET_HDR(buf_ptr,
6610 WMITLV_TAG_ARRAY_STRUC,
6611 sizeof(wmi_roam_scan_extended_threshold_param));
6612 buf_ptr += WMI_TLV_HDR_SIZE;
6613 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
6614
6615 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
6616 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
6617 ext_thresholds->boost_threshold_5g =
6618 roam_req->boost_threshold_5g;
6619
6620 ext_thresholds->boost_algorithm_5g =
6621 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6622 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
6623 ext_thresholds->penalty_algorithm_5g =
6624 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
6625 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
6626 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
6627 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
6628 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
6629
6630 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
6631 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
6632 WMITLV_GET_STRUCT_TLVLEN
6633 (wmi_roam_scan_extended_threshold_param));
6634 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
6635 WMITLV_SET_HDR(buf_ptr,
6636 WMITLV_TAG_ARRAY_STRUC,
6637 sizeof(wmi_roam_earlystop_rssi_thres_param));
6638 buf_ptr += WMI_TLV_HDR_SIZE;
6639 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
6640 early_stop_thresholds->roam_earlystop_thres_min =
6641 roam_req->roam_earlystop_thres_min;
6642 early_stop_thresholds->roam_earlystop_thres_max =
6643 roam_req->roam_earlystop_thres_max;
6644 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
6645 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
6646 WMITLV_GET_STRUCT_TLVLEN
6647 (wmi_roam_earlystop_rssi_thres_param));
6648
Gupta, Kapil7e652922016-04-12 15:02:00 +05306649 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
6650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6651 sizeof(wmi_roam_dense_thres_param));
6652 buf_ptr += WMI_TLV_HDR_SIZE;
6653 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
6654 dense_thresholds->roam_dense_rssi_thres_offset =
6655 roam_req->dense_rssi_thresh_offset;
6656 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
6657 dense_thresholds->roam_dense_traffic_thres =
6658 roam_req->traffic_threshold;
6659 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
6660 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
6661 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
6662 WMITLV_GET_STRUCT_TLVLEN
6663 (wmi_roam_dense_thres_param));
6664
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006665 buf_ptr += sizeof(wmi_roam_dense_thres_param);
6666 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6667 sizeof(wmi_roam_bg_scan_roaming_param));
6668 buf_ptr += WMI_TLV_HDR_SIZE;
6669 bg_scan_params = (wmi_roam_bg_scan_roaming_param *) buf_ptr;
6670 bg_scan_params->roam_bg_scan_bad_rssi_thresh =
6671 roam_req->bg_scan_bad_rssi_thresh;
6672 bg_scan_params->roam_bg_scan_client_bitmap =
6673 roam_req->bg_scan_client_bitmap;
Vignesh Viswanathan5f1ccf62017-09-07 18:58:08 +05306674 bg_scan_params->bad_rssi_thresh_offset_2g =
6675 roam_req->roam_bad_rssi_thresh_offset_2g;
6676 bg_scan_params->flags = roam_req->flags;
Varun Reddy Yeturu7f4cff82017-07-26 10:59:39 -07006677 WMITLV_SET_HDR(&bg_scan_params->tlv_header,
6678 WMITLV_TAG_STRUC_wmi_roam_bg_scan_roaming_param,
6679 WMITLV_GET_STRUCT_TLVLEN
6680 (wmi_roam_bg_scan_roaming_param));
6681
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306682 status = wmi_unified_cmd_send(wmi_handle, buf,
6683 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05306684 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306685 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306686 status);
6687 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306688 }
6689
Govind Singh67922e82016-04-01 16:48:57 +05306690 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306691}
6692
6693/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05306694 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
6695 * configuration params
6696 * @wma_handle: wma handler
6697 * @dwelltime_params: pointer to dwelltime_params
6698 *
6699 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6700 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006701static
Gupta, Kapil2e685982016-04-25 19:14:19 +05306702QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
6703 struct wmi_adaptive_dwelltime_params *dwelltime_params)
6704{
6705 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
6706 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
6707 wmi_buf_t buf;
6708 uint8_t *buf_ptr;
6709 int32_t err;
6710 int len;
6711
6712 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6713 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
6714 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
6715 buf = wmi_buf_alloc(wmi_handle, len);
6716 if (!buf) {
6717 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
6718 __func__);
6719 return QDF_STATUS_E_NOMEM;
6720 }
6721 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6722 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
6723 WMITLV_SET_HDR(&dwell_param->tlv_header,
6724 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
6725 WMITLV_GET_STRUCT_TLVLEN
6726 (wmi_scan_adaptive_dwell_config_fixed_param));
6727
6728 dwell_param->enable = dwelltime_params->is_enabled;
6729 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
6730 WMITLV_SET_HDR(buf_ptr,
6731 WMITLV_TAG_ARRAY_STRUC,
6732 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
6733 buf_ptr += WMI_TLV_HDR_SIZE;
6734
6735 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
6736 WMITLV_SET_HDR(&cmd->tlv_header,
6737 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
6738 WMITLV_GET_STRUCT_TLVLEN(
6739 wmi_scan_adaptive_dwell_parameters_tlv));
6740
6741 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
6742 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
6743 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
6744 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
6745 err = wmi_unified_cmd_send(wmi_handle, buf,
6746 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
6747 if (err) {
6748 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
6749 wmi_buf_free(buf);
6750 return QDF_STATUS_E_FAILURE;
6751 }
6752
6753 return QDF_STATUS_SUCCESS;
6754}
6755
Nitesh Shah52323d02017-05-22 15:49:00 +05306756/**
6757 * send_dbs_scan_sel_params_cmd_tlv() - send wmi cmd of DBS scan selection
6758 * configuration params
6759 * @wmi_handle: wmi handler
6760 * @dbs_scan_params: pointer to wmi_dbs_scan_sel_params
6761 *
6762 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
6763 */
6764static QDF_STATUS send_dbs_scan_sel_params_cmd_tlv(wmi_unified_t wmi_handle,
6765 struct wmi_dbs_scan_sel_params *dbs_scan_params)
6766{
6767 wmi_scan_dbs_duty_cycle_fixed_param *dbs_scan_param;
6768 wmi_scan_dbs_duty_cycle_tlv_param *cmd;
6769 wmi_buf_t buf;
6770 uint8_t *buf_ptr;
6771 QDF_STATUS err;
6772 uint32_t i;
6773 int len;
6774
6775 len = sizeof(*dbs_scan_param);
6776 len += WMI_TLV_HDR_SIZE;
6777 len += dbs_scan_params->num_clients * sizeof(*cmd);
6778
6779 buf = wmi_buf_alloc(wmi_handle, len);
6780 if (!buf) {
6781 WMI_LOGE("%s:Failed to allocate buffer to send cmd", __func__);
6782 return QDF_STATUS_E_NOMEM;
6783 }
6784
6785 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6786 dbs_scan_param = (wmi_scan_dbs_duty_cycle_fixed_param *) buf_ptr;
6787 WMITLV_SET_HDR(&dbs_scan_param->tlv_header,
6788 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_fixed_param,
6789 WMITLV_GET_STRUCT_TLVLEN
6790 (wmi_scan_dbs_duty_cycle_fixed_param));
6791
6792 dbs_scan_param->num_clients = dbs_scan_params->num_clients;
6793 dbs_scan_param->pdev_id = dbs_scan_params->pdev_id;
6794 buf_ptr += sizeof(*dbs_scan_param);
6795 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6796 (sizeof(*cmd) * dbs_scan_params->num_clients));
6797 buf_ptr = buf_ptr + (uint8_t) WMI_TLV_HDR_SIZE;
6798
6799 for (i = 0; i < dbs_scan_params->num_clients; i++) {
6800 cmd = (wmi_scan_dbs_duty_cycle_tlv_param *) buf_ptr;
6801 WMITLV_SET_HDR(&cmd->tlv_header,
6802 WMITLV_TAG_STRUC_wmi_scan_dbs_duty_cycle_param_tlv,
6803 WMITLV_GET_STRUCT_TLVLEN(
6804 wmi_scan_dbs_duty_cycle_tlv_param));
6805 cmd->module_id = dbs_scan_params->module_id[i];
6806 cmd->num_dbs_scans = dbs_scan_params->num_dbs_scans[i];
6807 cmd->num_non_dbs_scans = dbs_scan_params->num_non_dbs_scans[i];
6808 buf_ptr = buf_ptr + (uint8_t) sizeof(*cmd);
6809 }
6810
6811 err = wmi_unified_cmd_send(wmi_handle, buf,
6812 len, WMI_SET_SCAN_DBS_DUTY_CYCLE_CMDID);
6813 if (QDF_IS_STATUS_ERROR(err)) {
6814 WMI_LOGE("Failed to send dbs scan selection cmd err=%d", err);
6815 wmi_buf_free(buf);
6816 return QDF_STATUS_E_FAILURE;
6817 }
6818
6819 return QDF_STATUS_SUCCESS;
6820}
Gupta, Kapil2e685982016-04-25 19:14:19 +05306821
6822/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306823 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
6824 * @wmi_handle: wmi handle
6825 * @roam_req: Request which contains the filters
6826 *
6827 * There are filters such as whitelist, blacklist and preferred
6828 * list that need to be applied to the scan results to form the
6829 * probable candidates for roaming.
6830 *
Jeff Johnsonda263992018-05-12 14:22:00 -07006831 * Return: Return success upon successfully passing the
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306832 * parameters to the firmware, otherwise failure.
6833 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306834static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306835 struct roam_scan_filter_params *roam_req)
6836{
6837 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05306838 QDF_STATUS status;
6839 uint32_t i;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306840 uint32_t len, blist_len = 0;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306841 uint8_t *buf_ptr;
6842 wmi_roam_filter_fixed_param *roam_filter;
6843 uint8_t *bssid_src_ptr = NULL;
6844 wmi_mac_addr *bssid_dst_ptr = NULL;
6845 wmi_ssid *ssid_ptr = NULL;
6846 uint32_t *bssid_preferred_factor_ptr = NULL;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306847 wmi_roam_lca_disallow_config_tlv_param *blist_param;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306848 wmi_roam_rssi_rejection_oce_config_param *rssi_rej;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306849
6850 len = sizeof(wmi_roam_filter_fixed_param);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306851
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306852 len += WMI_TLV_HDR_SIZE;
Abhishek Singh54aa6202017-07-06 11:25:15 +05306853 if (roam_req->num_bssid_black_list)
6854 len += roam_req->num_bssid_black_list * sizeof(wmi_mac_addr);
6855 len += WMI_TLV_HDR_SIZE;
6856 if (roam_req->num_ssid_white_list)
6857 len += roam_req->num_ssid_white_list * sizeof(wmi_ssid);
6858 len += 2 * WMI_TLV_HDR_SIZE;
6859 if (roam_req->num_bssid_preferred_list) {
6860 len += roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr);
Vivekc5823092018-03-22 23:27:21 +05306861 len += roam_req->num_bssid_preferred_list * sizeof(uint32_t);
Abhishek Singh54aa6202017-07-06 11:25:15 +05306862 }
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306863 len += WMI_TLV_HDR_SIZE;
6864 if (roam_req->lca_disallow_config_present) {
6865 len += sizeof(*blist_param);
6866 blist_len = sizeof(*blist_param);
6867 }
6868
6869 len += WMI_TLV_HDR_SIZE;
6870 if (roam_req->num_rssi_rejection_ap)
6871 len += roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306872
6873 buf = wmi_buf_alloc(wmi_handle, len);
6874 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306875 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306876 return QDF_STATUS_E_NOMEM;
6877 }
6878
6879 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
6880 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
6881 WMITLV_SET_HDR(&roam_filter->tlv_header,
6882 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
6883 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
6884 /* fill in fixed values */
6885 roam_filter->vdev_id = roam_req->session_id;
6886 roam_filter->flags = 0;
6887 roam_filter->op_bitmap = roam_req->op_bitmap;
6888 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
6889 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
6890 roam_filter->num_bssid_preferred_list =
6891 roam_req->num_bssid_preferred_list;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306892 roam_filter->num_rssi_rejection_ap =
6893 roam_req->num_rssi_rejection_ap;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306894 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
6895
6896 WMITLV_SET_HDR((buf_ptr),
6897 WMITLV_TAG_ARRAY_FIXED_STRUC,
6898 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
6899 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
6900 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6901 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
6902 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
6903 bssid_src_ptr += ATH_MAC_LEN;
6904 bssid_dst_ptr++;
6905 }
6906 buf_ptr += WMI_TLV_HDR_SIZE +
6907 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
6908 WMITLV_SET_HDR((buf_ptr),
6909 WMITLV_TAG_ARRAY_FIXED_STRUC,
6910 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
6911 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
6912 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
6913 qdf_mem_copy(&ssid_ptr->ssid,
6914 &roam_req->ssid_allowed_list[i].mac_ssid,
6915 roam_req->ssid_allowed_list[i].length);
6916 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
6917 ssid_ptr++;
6918 }
6919 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
6920 sizeof(wmi_ssid));
6921 WMITLV_SET_HDR((buf_ptr),
6922 WMITLV_TAG_ARRAY_FIXED_STRUC,
6923 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
6924 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
6925 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
6926 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6927 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
6928 (wmi_mac_addr *)bssid_dst_ptr);
6929 bssid_src_ptr += ATH_MAC_LEN;
6930 bssid_dst_ptr++;
6931 }
6932 buf_ptr += WMI_TLV_HDR_SIZE +
6933 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
6934 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6935 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
6936 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
6937 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
6938 *bssid_preferred_factor_ptr =
6939 roam_req->bssid_favored_factor[i];
6940 bssid_preferred_factor_ptr++;
6941 }
6942 buf_ptr += WMI_TLV_HDR_SIZE +
6943 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
6944
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306945 WMITLV_SET_HDR(buf_ptr,
6946 WMITLV_TAG_ARRAY_STRUC, blist_len);
6947 buf_ptr += WMI_TLV_HDR_SIZE;
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306948 if (roam_req->lca_disallow_config_present) {
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306949 blist_param =
6950 (wmi_roam_lca_disallow_config_tlv_param *) buf_ptr;
6951 WMITLV_SET_HDR(&blist_param->tlv_header,
6952 WMITLV_TAG_STRUC_wmi_roam_lca_disallow_config_tlv_param,
6953 WMITLV_GET_STRUCT_TLVLEN(
6954 wmi_roam_lca_disallow_config_tlv_param));
6955
6956 blist_param->disallow_duration = roam_req->disallow_duration;
6957 blist_param->rssi_channel_penalization =
6958 roam_req->rssi_channel_penalization;
6959 blist_param->num_disallowed_aps = roam_req->num_disallowed_aps;
Vignesh Viswanathana9497fc2017-09-14 17:47:48 +05306960 blist_param->disallow_lca_enable_source_bitmap =
6961 (WMI_ROAM_LCA_DISALLOW_SOURCE_PER |
6962 WMI_ROAM_LCA_DISALLOW_SOURCE_BACKGROUND);
Selvaraj, Sridhar55f1d1e2017-05-29 18:38:52 +05306963 buf_ptr += (sizeof(wmi_roam_lca_disallow_config_tlv_param));
6964 }
6965
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306966 WMITLV_SET_HDR(buf_ptr,
6967 WMITLV_TAG_ARRAY_STRUC,
6968 (roam_req->num_rssi_rejection_ap * sizeof(*rssi_rej)));
6969 buf_ptr += WMI_TLV_HDR_SIZE;
6970 for (i = 0; i < roam_req->num_rssi_rejection_ap; i++) {
6971 rssi_rej =
6972 (wmi_roam_rssi_rejection_oce_config_param *) buf_ptr;
6973 WMITLV_SET_HDR(&rssi_rej->tlv_header,
6974 WMITLV_TAG_STRUC_wmi_roam_rssi_rejection_oce_config_param,
6975 WMITLV_GET_STRUCT_TLVLEN(
6976 wmi_roam_rssi_rejection_oce_config_param));
6977 WMI_CHAR_ARRAY_TO_MAC_ADDR(
6978 roam_req->rssi_rejection_ap[i].bssid.bytes,
6979 &rssi_rej->bssid);
6980 rssi_rej->remaining_disallow_duration =
6981 roam_req->rssi_rejection_ap[i].remaining_duration;
6982 rssi_rej->requested_rssi =
Vivekc5823092018-03-22 23:27:21 +05306983 (int32_t)roam_req->rssi_rejection_ap[i].expected_rssi;
Abhishek Singh7c7c0e72017-07-05 11:21:32 +05306984 buf_ptr +=
6985 (sizeof(wmi_roam_rssi_rejection_oce_config_param));
6986 }
6987
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306988 status = wmi_unified_cmd_send(wmi_handle, buf,
6989 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306990 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05306991 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306992 status);
6993 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306994 }
Govind Singh67922e82016-04-01 16:48:57 +05306995
6996 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05306997}
6998
Vignesh Viswanathan81bde492017-09-25 14:36:38 +05306999#if defined(WLAN_FEATURE_FILS_SK)
7000static QDF_STATUS send_roam_scan_send_hlp_cmd_tlv(wmi_unified_t wmi_handle,
7001 struct hlp_params *params)
7002{
7003 uint32_t len;
7004 uint8_t *buf_ptr;
7005 wmi_buf_t buf = NULL;
7006 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *hlp_params;
7007
7008 len = sizeof(wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param);
7009 len += WMI_TLV_HDR_SIZE;
7010 len += qdf_roundup(params->hlp_ie_len, sizeof(uint32_t));
7011
7012 buf = wmi_buf_alloc(wmi_handle, len);
7013 if (!buf) {
7014 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7015 return QDF_STATUS_E_NOMEM;
7016 }
7017
7018 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7019 hlp_params = (wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param *) buf_ptr;
7020 WMITLV_SET_HDR(&hlp_params->tlv_header,
7021 WMITLV_TAG_STRUC_wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param,
7022 WMITLV_GET_STRUCT_TLVLEN(
7023 wmi_pdev_update_fils_hlp_pkt_cmd_fixed_param));
7024
7025 hlp_params->vdev_id = params->vdev_id;
7026 hlp_params->size = params->hlp_ie_len;
7027 hlp_params->pkt_type = WMI_FILS_HLP_PKT_TYPE_DHCP_DISCOVER;
7028
7029 buf_ptr += sizeof(*hlp_params);
7030
7031 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
7032 round_up(params->hlp_ie_len,
7033 sizeof(uint32_t)));
7034 buf_ptr += WMI_TLV_HDR_SIZE;
7035 qdf_mem_copy(buf_ptr, params->hlp_ie, params->hlp_ie_len);
7036
7037 WMI_LOGD(FL("send FILS HLP pkt vdev %d len %d"),
7038 hlp_params->vdev_id, hlp_params->size);
7039 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7040 WMI_PDEV_UPDATE_FILS_HLP_PKT_CMDID)) {
7041 WMI_LOGE(FL("Failed to send FILS HLP pkt cmd"));
7042 wmi_buf_free(buf);
7043 return QDF_STATUS_E_FAILURE;
7044 }
7045
7046 return QDF_STATUS_SUCCESS;
7047}
7048#endif
7049
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307050#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307051/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
7052 * @wmi_handle: wmi handle
7053 * @ipa_offload: ipa offload control parameter
7054 *
7055 * Returns: 0 on success, error number otherwise
7056 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307057static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307058 struct ipa_uc_offload_control_params *ipa_offload)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307059{
7060 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
7061 wmi_buf_t wmi_buf;
7062 uint32_t len;
7063 u_int8_t *buf_ptr;
7064
7065 len = sizeof(*cmd);
7066 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7067 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307068 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
7069 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307070 }
7071
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08007072 WMI_LOGD("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307073 ipa_offload->offload_type, ipa_offload->enable);
7074
7075 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
7076
7077 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
7078 WMITLV_SET_HDR(&cmd->tlv_header,
7079 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
7080 WMITLV_GET_STRUCT_TLVLEN(
7081 wmi_ipa_offload_enable_disable_cmd_fixed_param));
7082
7083 cmd->offload_type = ipa_offload->offload_type;
7084 cmd->vdev_id = ipa_offload->vdev_id;
7085 cmd->enable = ipa_offload->enable;
7086
7087 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7088 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307089 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307090 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307091 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307092 }
7093
Govind Singhb53420c2016-03-09 14:32:57 +05307094 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307095}
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +05307096#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307097
7098/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307099 * send_plm_stop_cmd_tlv() - plm stop request
7100 * @wmi_handle: wmi handle
7101 * @plm: plm request parameters
7102 *
7103 * This function request FW to stop PLM.
7104 *
7105 * Return: CDF status
7106 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307107static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307108 const struct plm_req_params *plm)
7109{
7110 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
7111 int32_t len;
7112 wmi_buf_t buf;
7113 uint8_t *buf_ptr;
7114 int ret;
7115
7116 len = sizeof(*cmd);
7117 buf = wmi_buf_alloc(wmi_handle, len);
7118 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307119 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7120 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307121 }
7122
7123 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
7124
7125 buf_ptr = (uint8_t *) cmd;
7126
7127 WMITLV_SET_HDR(&cmd->tlv_header,
7128 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
7129 WMITLV_GET_STRUCT_TLVLEN
7130 (wmi_vdev_plmreq_stop_cmd_fixed_param));
7131
7132 cmd->vdev_id = plm->session_id;
7133
7134 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05307135 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307136
7137 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7138 WMI_VDEV_PLMREQ_STOP_CMDID);
7139 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307140 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307141 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307142 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307143 }
7144
Govind Singhb53420c2016-03-09 14:32:57 +05307145 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307146}
7147
7148/**
7149 * send_plm_start_cmd_tlv() - plm start request
7150 * @wmi_handle: wmi handle
7151 * @plm: plm request parameters
7152 *
7153 * This function request FW to start PLM.
7154 *
7155 * Return: CDF status
7156 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307157static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307158 const struct plm_req_params *plm,
7159 uint32_t *gchannel_list)
7160{
7161 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
7162 uint32_t *channel_list;
7163 int32_t len;
7164 wmi_buf_t buf;
7165 uint8_t *buf_ptr;
7166 uint8_t count;
7167 int ret;
7168
7169 /* TLV place holder for channel_list */
7170 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
7171 len += sizeof(uint32_t) * plm->plm_num_ch;
7172
7173 buf = wmi_buf_alloc(wmi_handle, len);
7174 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307175 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7176 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307177 }
7178 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
7179
7180 buf_ptr = (uint8_t *) cmd;
7181
7182 WMITLV_SET_HDR(&cmd->tlv_header,
7183 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
7184 WMITLV_GET_STRUCT_TLVLEN
7185 (wmi_vdev_plmreq_start_cmd_fixed_param));
7186
7187 cmd->vdev_id = plm->session_id;
7188
7189 cmd->meas_token = plm->meas_token;
7190 cmd->dialog_token = plm->diag_token;
7191 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05307192 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307193 cmd->off_duration = plm->meas_duration;
7194 cmd->burst_cycle = plm->burst_len;
7195 cmd->tx_power = plm->desired_tx_pwr;
7196 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
7197 cmd->num_chans = plm->plm_num_ch;
7198
7199 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
7200
Govind Singhb53420c2016-03-09 14:32:57 +05307201 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
7202 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
7203 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
7204 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
7205 WMI_LOGD("off_duration: %d", cmd->off_duration);
7206 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
7207 WMI_LOGD("tx_power: %d", cmd->tx_power);
7208 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307209
7210 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7211 (cmd->num_chans * sizeof(uint32_t)));
7212
7213 buf_ptr += WMI_TLV_HDR_SIZE;
7214 if (cmd->num_chans) {
7215 channel_list = (uint32_t *) buf_ptr;
7216 for (count = 0; count < cmd->num_chans; count++) {
7217 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307218 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307219 channel_list[count] =
7220 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05307221 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307222 }
7223 buf_ptr += cmd->num_chans * sizeof(uint32_t);
7224 }
7225
7226 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7227 WMI_VDEV_PLMREQ_START_CMDID);
7228 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307229 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307230 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307231 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307232 }
7233
Govind Singhb53420c2016-03-09 14:32:57 +05307234 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307235}
7236
7237/**
7238 * send_pno_stop_cmd_tlv() - PNO stop request
7239 * @wmi_handle: wmi handle
7240 * @vdev_id: vdev id
7241 *
7242 * This function request FW to stop ongoing PNO operation.
7243 *
7244 * Return: CDF status
7245 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307246static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307247{
7248 wmi_nlo_config_cmd_fixed_param *cmd;
7249 int32_t len = sizeof(*cmd);
7250 wmi_buf_t buf;
7251 uint8_t *buf_ptr;
7252 int ret;
7253
7254 /*
7255 * TLV place holder for array of structures nlo_configured_parameters
7256 * TLV place holder for array of uint32_t channel_list
7257 * TLV place holder for chnl prediction cfg
7258 */
7259 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
7260 buf = wmi_buf_alloc(wmi_handle, len);
7261 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307262 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7263 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307264 }
7265
7266 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7267 buf_ptr = (uint8_t *) cmd;
7268
7269 WMITLV_SET_HDR(&cmd->tlv_header,
7270 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7271 WMITLV_GET_STRUCT_TLVLEN
7272 (wmi_nlo_config_cmd_fixed_param));
7273
7274 cmd->vdev_id = vdev_id;
7275 cmd->flags = WMI_NLO_CONFIG_STOP;
7276 buf_ptr += sizeof(*cmd);
7277
7278 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7279 buf_ptr += WMI_TLV_HDR_SIZE;
7280
7281 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
7282 buf_ptr += WMI_TLV_HDR_SIZE;
7283
7284 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
7285 buf_ptr += WMI_TLV_HDR_SIZE;
7286
7287
7288 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7289 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7290 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307291 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307292 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307293 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307294 }
7295
Govind Singhb53420c2016-03-09 14:32:57 +05307296 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307297}
7298
7299/**
Govind Singhccb0c272016-04-01 16:30:08 +05307300 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
7301 * @buf_ptr: Buffer passed by upper layers
7302 * @pno: Buffer to be sent to the firmware
7303 *
7304 * Copy the PNO Channel prediction configuration parameters
7305 * passed by the upper layers to a WMI format TLV and send it
7306 * down to the firmware.
7307 *
7308 * Return: None
7309 */
7310static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
7311 struct pno_scan_req_params *pno)
7312{
7313 nlo_channel_prediction_cfg *channel_prediction_cfg =
7314 (nlo_channel_prediction_cfg *) buf_ptr;
7315 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
7316 WMITLV_TAG_ARRAY_BYTE,
7317 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05307318#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05307319 channel_prediction_cfg->enable = pno->pno_channel_prediction;
7320 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
7321 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
7322 channel_prediction_cfg->full_scan_period_ms =
7323 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05307324#endif
Govind Singhccb0c272016-04-01 16:30:08 +05307325 buf_ptr += sizeof(nlo_channel_prediction_cfg);
7326 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
7327 channel_prediction_cfg->enable,
7328 channel_prediction_cfg->top_k_num,
7329 channel_prediction_cfg->stationary_threshold,
7330 channel_prediction_cfg->full_scan_period_ms);
7331}
7332
7333/**
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007334 * send_nlo_mawc_cmd_tlv() - Send MAWC NLO configuration
7335 * @wmi_handle: wmi handle
7336 * @params: configuration parameters
7337 *
7338 * Return: QDF_STATUS
7339 */
7340static QDF_STATUS send_nlo_mawc_cmd_tlv(wmi_unified_t wmi_handle,
7341 struct nlo_mawc_params *params)
7342{
7343 wmi_buf_t buf = NULL;
7344 QDF_STATUS status;
7345 int len;
7346 uint8_t *buf_ptr;
7347 wmi_nlo_configure_mawc_cmd_fixed_param *wmi_nlo_mawc_params;
7348
7349 len = sizeof(*wmi_nlo_mawc_params);
7350 buf = wmi_buf_alloc(wmi_handle, len);
7351 if (!buf) {
7352 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7353 return QDF_STATUS_E_NOMEM;
7354 }
7355
7356 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7357 wmi_nlo_mawc_params =
7358 (wmi_nlo_configure_mawc_cmd_fixed_param *) buf_ptr;
7359 WMITLV_SET_HDR(&wmi_nlo_mawc_params->tlv_header,
7360 WMITLV_TAG_STRUC_wmi_nlo_configure_mawc_cmd_fixed_param,
7361 WMITLV_GET_STRUCT_TLVLEN
7362 (wmi_nlo_configure_mawc_cmd_fixed_param));
7363 wmi_nlo_mawc_params->vdev_id = params->vdev_id;
7364 if (params->enable)
7365 wmi_nlo_mawc_params->enable = 1;
7366 else
7367 wmi_nlo_mawc_params->enable = 0;
7368 wmi_nlo_mawc_params->exp_backoff_ratio = params->exp_backoff_ratio;
7369 wmi_nlo_mawc_params->init_scan_interval = params->init_scan_interval;
7370 wmi_nlo_mawc_params->max_scan_interval = params->max_scan_interval;
Varun Reddy Yeturu7a8c3372017-08-21 10:28:13 -07007371 WMI_LOGD(FL("MAWC NLO en=%d, vdev=%d, ratio=%d, SCAN init=%d, max=%d"),
7372 wmi_nlo_mawc_params->enable, wmi_nlo_mawc_params->vdev_id,
7373 wmi_nlo_mawc_params->exp_backoff_ratio,
7374 wmi_nlo_mawc_params->init_scan_interval,
7375 wmi_nlo_mawc_params->max_scan_interval);
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007376
7377 status = wmi_unified_cmd_send(wmi_handle, buf,
7378 len, WMI_NLO_CONFIGURE_MAWC_CMDID);
7379 if (QDF_IS_STATUS_ERROR(status)) {
7380 WMI_LOGE("WMI_NLO_CONFIGURE_MAWC_CMDID failed, Error %d",
7381 status);
7382 wmi_buf_free(buf);
7383 return QDF_STATUS_E_FAILURE;
7384 }
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -07007385
7386 return QDF_STATUS_SUCCESS;
7387}
7388
7389/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05307390 * send_pno_start_cmd_tlv() - PNO start request
7391 * @wmi_handle: wmi handle
7392 * @pno: PNO request
7393 *
7394 * This function request FW to start PNO request.
7395 * Request: CDF status
7396 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307397static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05307398 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05307399{
7400 wmi_nlo_config_cmd_fixed_param *cmd;
7401 nlo_configured_parameters *nlo_list;
7402 uint32_t *channel_list;
7403 int32_t len;
7404 wmi_buf_t buf;
7405 uint8_t *buf_ptr;
7406 uint8_t i;
7407 int ret;
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307408 struct probe_req_whitelist_attr *ie_whitelist = &pno->ie_whitelist;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307409 connected_nlo_rssi_params *nlo_relative_rssi;
7410 connected_nlo_bss_band_rssi_pref *nlo_band_rssi;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307411
7412 /*
7413 * TLV place holder for array nlo_configured_parameters(nlo_list)
7414 * TLV place holder for array of uint32_t channel_list
7415 * TLV place holder for chnnl prediction cfg
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307416 * TLV place holder for array of wmi_vendor_oui
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307417 * TLV place holder for array of connected_nlo_bss_band_rssi_pref
Govind Singh4eacd2b2016-03-07 14:24:22 +05307418 */
7419 len = sizeof(*cmd) +
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307420 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE +
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307421 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307422
Abhishek Singh5987b632017-03-03 22:09:07 +05307423 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307424 WMI_NLO_MAX_CHAN);
7425 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05307426 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307427 len += sizeof(nlo_channel_prediction_cfg);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307428 len += sizeof(enlo_candidate_score_params);
7429 len += sizeof(wmi_vendor_oui) * ie_whitelist->num_vendor_oui;
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307430 len += sizeof(connected_nlo_rssi_params);
7431 len += sizeof(connected_nlo_bss_band_rssi_pref);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307432
7433 buf = wmi_buf_alloc(wmi_handle, len);
7434 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307435 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7436 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307437 }
7438
7439 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
7440
7441 buf_ptr = (uint8_t *) cmd;
7442 WMITLV_SET_HDR(&cmd->tlv_header,
7443 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7444 WMITLV_GET_STRUCT_TLVLEN
7445 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307446 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307447 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7448
Govind Singh87542482016-06-08 19:40:11 +05307449#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307450 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307451 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307452#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307453 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307454 cmd->active_dwell_time = pno->active_dwell_time;
7455 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307456
Manjeet Singhcd2dc062016-08-11 15:31:34 +05307457 if (pno->do_passive_scan)
7458 cmd->flags |= WMI_NLO_CONFIG_SCAN_PASSIVE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307459 /* Copy scan interval */
7460 cmd->fast_scan_period = pno->fast_scan_period;
7461 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007462 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307463 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Dustin Brown9d865642017-04-24 10:47:42 -07007464 cmd->scan_backoff_multiplier = pno->scan_backoff_multiplier;
Govind Singhb53420c2016-03-09 14:32:57 +05307465 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307466 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307467 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307468
Rajeev Kumar Sirasanagandla0c5b3072017-06-08 18:12:50 +05307469 /* mac randomization attributes */
7470 if (pno->scan_random.randomize) {
7471 cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
7472 WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
7473 wmi_copy_scan_random_mac(pno->scan_random.mac_addr,
7474 pno->scan_random.mac_mask,
7475 &cmd->mac_addr,
7476 &cmd->mac_mask);
7477 }
7478
Govind Singh4eacd2b2016-03-07 14:24:22 +05307479 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7480
Abhishek Singh5987b632017-03-03 22:09:07 +05307481 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307482 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7484 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7485 buf_ptr += WMI_TLV_HDR_SIZE;
7486
7487 nlo_list = (nlo_configured_parameters *) buf_ptr;
7488 for (i = 0; i < cmd->no_of_ssids; i++) {
7489 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7490 WMITLV_TAG_ARRAY_BYTE,
7491 WMITLV_GET_STRUCT_TLVLEN
7492 (nlo_configured_parameters));
7493 /* Copy ssid and it's length */
7494 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307495 nlo_list[i].ssid.ssid.ssid_len =
7496 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307497 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307498 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307499 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307500 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307501 nlo_list[i].ssid.ssid.ssid_len,
7502 (char *)nlo_list[i].ssid.ssid.ssid,
7503 nlo_list[i].ssid.ssid.ssid_len);
7504
7505 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307506 if (pno->networks_list[i].rssi_thresh &&
7507 pno->networks_list[i].rssi_thresh >
7508 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307509 nlo_list[i].rssi_cond.valid = true;
7510 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307511 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307512 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307513 nlo_list[i].rssi_cond.rssi);
7514 }
7515 nlo_list[i].bcast_nw_type.valid = true;
7516 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307517 pno->networks_list[i].bc_new_type;
Srinivas Girigowda61e086f2017-06-19 17:20:20 -07007518 WMI_LOGD("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307519 nlo_list[i].bcast_nw_type.bcast_nw_type);
7520 }
7521 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7522
7523 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307524 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307525 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307526 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7528 (cmd->num_of_channels * sizeof(uint32_t)));
7529 buf_ptr += WMI_TLV_HDR_SIZE;
7530
7531 channel_list = (uint32_t *) buf_ptr;
7532 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307533 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307534
7535 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307536 channel_list[i] =
7537 wlan_chan_to_freq(pno->
7538 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307539
Govind Singhb53420c2016-03-09 14:32:57 +05307540 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307541 }
7542 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7543 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7544 sizeof(nlo_channel_prediction_cfg));
7545 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307546 wmi_set_pno_channel_prediction(buf_ptr, pno);
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307547 buf_ptr += sizeof(nlo_channel_prediction_cfg);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307548 /** TODO: Discrete firmware doesn't have command/option to configure
7549 * App IE which comes from wpa_supplicant as of part PNO start request.
7550 */
Rajeev Kumar Sirasanagandla0f8402c2017-06-21 12:01:22 +05307551 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_enlo_candidate_score_param,
7552 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
7553 buf_ptr += sizeof(enlo_candidate_score_params);
7554
7555 if (ie_whitelist->white_list) {
7556 cmd->flags |= WMI_NLO_CONFIG_ENABLE_IE_WHITELIST_IN_PROBE_REQ;
7557 wmi_fill_ie_whitelist_attrs(cmd->ie_bitmap,
7558 &cmd->num_vendor_oui,
7559 ie_whitelist);
7560 }
7561
7562 /* ie white list */
7563 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7564 ie_whitelist->num_vendor_oui * sizeof(wmi_vendor_oui));
7565 buf_ptr += WMI_TLV_HDR_SIZE;
7566 if (cmd->num_vendor_oui != 0) {
7567 wmi_fill_vendor_oui(buf_ptr, cmd->num_vendor_oui,
7568 ie_whitelist->voui);
7569 buf_ptr += cmd->num_vendor_oui * sizeof(wmi_vendor_oui);
7570 }
7571
Sreelakshmi Konamkid9bdeb72017-07-21 17:37:30 +05307572 if (pno->relative_rssi_set)
7573 cmd->flags |= WMI_NLO_CONFIG_ENABLE_CNLO_RSSI_CONFIG;
7574
7575 /*
7576 * Firmware calculation using connected PNO params:
7577 * New AP's RSSI >= (Connected AP's RSSI + relative_rssi +/- rssi_pref)
7578 * deduction of rssi_pref for chosen band_pref and
7579 * addition of rssi_pref for remaining bands (other than chosen band).
7580 */
7581 nlo_relative_rssi = (connected_nlo_rssi_params *) buf_ptr;
7582 WMITLV_SET_HDR(&nlo_relative_rssi->tlv_header,
7583 WMITLV_TAG_STRUC_wmi_connected_nlo_rssi_params,
7584 WMITLV_GET_STRUCT_TLVLEN(connected_nlo_rssi_params));
7585 nlo_relative_rssi->relative_rssi = pno->relative_rssi;
7586 WMI_LOGD("relative_rssi %d", nlo_relative_rssi->relative_rssi);
7587 buf_ptr += sizeof(*nlo_relative_rssi);
7588
7589 /*
7590 * As of now Kernel and Host supports one band and rssi preference.
7591 * Firmware supports array of band and rssi preferences
7592 */
7593 cmd->num_cnlo_band_pref = 1;
7594 WMITLV_SET_HDR(buf_ptr,
7595 WMITLV_TAG_ARRAY_STRUC,
7596 cmd->num_cnlo_band_pref *
7597 sizeof(connected_nlo_bss_band_rssi_pref));
7598 buf_ptr += WMI_TLV_HDR_SIZE;
7599
7600 nlo_band_rssi = (connected_nlo_bss_band_rssi_pref *) buf_ptr;
7601 for (i = 0; i < cmd->num_cnlo_band_pref; i++) {
7602 WMITLV_SET_HDR(&nlo_band_rssi[i].tlv_header,
7603 WMITLV_TAG_STRUC_wmi_connected_nlo_bss_band_rssi_pref,
7604 WMITLV_GET_STRUCT_TLVLEN(
7605 connected_nlo_bss_band_rssi_pref));
7606 nlo_band_rssi[i].band = pno->band_rssi_pref.band;
7607 nlo_band_rssi[i].rssi_pref = pno->band_rssi_pref.rssi;
7608 WMI_LOGI("band_pref %d, rssi_pref %d",
7609 nlo_band_rssi[i].band,
7610 nlo_band_rssi[i].rssi_pref);
7611 }
7612 buf_ptr += cmd->num_cnlo_band_pref * sizeof(*nlo_band_rssi);
7613
Govind Singh4eacd2b2016-03-07 14:24:22 +05307614 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7615 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7616 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307617 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307618 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307619 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307620 }
7621
Govind Singhb53420c2016-03-09 14:32:57 +05307622 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307623}
7624
7625/* send_set_ric_req_cmd_tlv() - set ric request element
7626 * @wmi_handle: wmi handle
7627 * @msg: message
7628 * @is_add_ts: is addts required
7629 *
7630 * This function sets ric request element for 11r roaming.
7631 *
7632 * Return: CDF status
7633 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307634static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307635 void *msg, uint8_t is_add_ts)
7636{
7637 wmi_ric_request_fixed_param *cmd;
7638 wmi_ric_tspec *tspec_param;
7639 wmi_buf_t buf;
7640 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307641 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307642 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7643 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7644
7645 buf = wmi_buf_alloc(wmi_handle, len);
7646 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307647 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7648 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307649 }
7650
7651 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7652
7653 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7654 WMITLV_SET_HDR(&cmd->tlv_header,
7655 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7656 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7657 if (is_add_ts)
Deepak Dhamdhere990df852017-04-24 16:17:48 -07007658 cmd->vdev_id = ((struct add_ts_param *) msg)->sme_session_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307659 else
7660 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7661 cmd->num_ric_request = 1;
7662 cmd->is_add_ric = is_add_ts;
7663
7664 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7665 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7666
7667 buf_ptr += WMI_TLV_HDR_SIZE;
7668 tspec_param = (wmi_ric_tspec *) buf_ptr;
7669 WMITLV_SET_HDR(&tspec_param->tlv_header,
7670 WMITLV_TAG_STRUC_wmi_ric_tspec,
7671 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7672
7673 if (is_add_ts)
7674 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307675#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307676 else
7677 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307678#endif
7679 if (ptspecIE) {
7680 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307681#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307682 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7683 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307684#else
Govind Singh87542482016-06-08 19:40:11 +05307685 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7686 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307687#endif /* ANI_LITTLE_BIT_ENDIAN */
7688
Govind Singh87542482016-06-08 19:40:11 +05307689 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7690 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7691 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7692 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7693 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7694 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7695 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7696 tspec_param->min_data_rate = ptspecIE->minDataRate;
7697 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7698 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7699 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7700 tspec_param->delay_bound = ptspecIE->delayBound;
7701 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7702 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7703 tspec_param->medium_time = 0;
7704 }
Govind Singhb53420c2016-03-09 14:32:57 +05307705 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307706
7707 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7708 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307709 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307710 __func__);
7711 if (is_add_ts)
7712 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307713 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307714 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307715 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307716 }
7717
Govind Singhb53420c2016-03-09 14:32:57 +05307718 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307719}
7720
Qiwei Cai1ccba222018-05-21 16:49:39 +08007721#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +05307722/**
7723 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7724 * @wmi_handle: wmi handle
7725 * @clear_req: ll stats clear request command params
7726 *
Govind Singhb53420c2016-03-09 14:32:57 +05307727 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307728 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307729static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307730 const struct ll_stats_clear_params *clear_req,
7731 uint8_t addr[IEEE80211_ADDR_LEN])
7732{
7733 wmi_clear_link_stats_cmd_fixed_param *cmd;
7734 int32_t len;
7735 wmi_buf_t buf;
7736 uint8_t *buf_ptr;
7737 int ret;
7738
7739 len = sizeof(*cmd);
7740 buf = wmi_buf_alloc(wmi_handle, len);
7741
7742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307743 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7744 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307745 }
7746
7747 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307748 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307749 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7750
7751 WMITLV_SET_HDR(&cmd->tlv_header,
7752 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7753 WMITLV_GET_STRUCT_TLVLEN
7754 (wmi_clear_link_stats_cmd_fixed_param));
7755
7756 cmd->stop_stats_collection_req = clear_req->stop_req;
7757 cmd->vdev_id = clear_req->sta_id;
7758 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7759
7760 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7761 &cmd->peer_macaddr);
7762
Govind Singhb53420c2016-03-09 14:32:57 +05307763 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7764 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7765 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7766 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7767 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307768 cmd->peer_macaddr); */
7769
7770 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7771 WMI_CLEAR_LINK_STATS_CMDID);
7772 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307773 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307774 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307775 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307776 }
7777
Govind Singhb53420c2016-03-09 14:32:57 +05307778 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7779 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307780}
7781
7782/**
7783 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7784 * @wmi_handle: wmi handle
7785 * @setReq: ll stats set request command params
7786 *
Govind Singhb53420c2016-03-09 14:32:57 +05307787 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307788 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307789static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307790 const struct ll_stats_set_params *set_req)
7791{
7792 wmi_start_link_stats_cmd_fixed_param *cmd;
7793 int32_t len;
7794 wmi_buf_t buf;
7795 uint8_t *buf_ptr;
7796 int ret;
7797
7798 len = sizeof(*cmd);
7799 buf = wmi_buf_alloc(wmi_handle, len);
7800
7801 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307802 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7803 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307804 }
7805
7806 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307807 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307808 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7809
7810 WMITLV_SET_HDR(&cmd->tlv_header,
7811 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7812 WMITLV_GET_STRUCT_TLVLEN
7813 (wmi_start_link_stats_cmd_fixed_param));
7814
7815 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7816 cmd->aggressive_statistics_gathering =
7817 set_req->aggressive_statistics_gathering;
7818
Govind Singhb53420c2016-03-09 14:32:57 +05307819 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7820 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7821 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307822
7823 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7824 WMI_START_LINK_STATS_CMDID);
7825 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307826 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307827 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307828 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307829 }
7830
Govind Singhb53420c2016-03-09 14:32:57 +05307831 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307832}
7833
7834/**
7835 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7836 * @wmi_handle:wmi handle
7837 * @get_req:ll stats get request command params
7838 * @addr: mac address
7839 *
Govind Singhb53420c2016-03-09 14:32:57 +05307840 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307841 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307842static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307843 const struct ll_stats_get_params *get_req,
7844 uint8_t addr[IEEE80211_ADDR_LEN])
7845{
7846 wmi_request_link_stats_cmd_fixed_param *cmd;
7847 int32_t len;
7848 wmi_buf_t buf;
7849 uint8_t *buf_ptr;
7850 int ret;
7851
7852 len = sizeof(*cmd);
7853 buf = wmi_buf_alloc(wmi_handle, len);
7854
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307855 if (!buf) {
7856 WMI_LOGE("%s: buf allocation failed", __func__);
7857 return QDF_STATUS_E_NOMEM;
7858 }
7859
Govind Singh4eacd2b2016-03-07 14:24:22 +05307860 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307861 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307862 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7863
7864 WMITLV_SET_HDR(&cmd->tlv_header,
7865 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7866 WMITLV_GET_STRUCT_TLVLEN
7867 (wmi_request_link_stats_cmd_fixed_param));
7868
7869 cmd->request_id = get_req->req_id;
7870 cmd->stats_type = get_req->param_id_mask;
7871 cmd->vdev_id = get_req->sta_id;
7872
7873 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7874 &cmd->peer_macaddr);
7875
Govind Singhb53420c2016-03-09 14:32:57 +05307876 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007877 WMI_LOGD("Request ID : %u", cmd->request_id);
7878 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307879 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7880 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307881
7882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7883 WMI_REQUEST_LINK_STATS_CMDID);
7884 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307885 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307886 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307887 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307888 }
7889
Govind Singhb53420c2016-03-09 14:32:57 +05307890 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307891}
Qiwei Cai1ccba222018-05-21 16:49:39 +08007892#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307893
Govind Singh20c5dac2016-03-07 15:33:31 +05307894/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307895 * send_congestion_cmd_tlv() - send request to fw to get CCA
7896 * @wmi_handle: wmi handle
7897 * @vdev_id: vdev id
7898 *
7899 * Return: CDF status
7900 */
7901static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
Vivekc5823092018-03-22 23:27:21 +05307902 uint8_t vdev_id)
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307903{
7904 wmi_buf_t buf;
7905 wmi_request_stats_cmd_fixed_param *cmd;
7906 uint8_t len;
7907 uint8_t *buf_ptr;
7908
7909 len = sizeof(*cmd);
7910 buf = wmi_buf_alloc(wmi_handle, len);
7911 if (!buf) {
7912 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7913 return QDF_STATUS_E_FAILURE;
7914 }
7915
7916 buf_ptr = wmi_buf_data(buf);
7917 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7918 WMITLV_SET_HDR(&cmd->tlv_header,
7919 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7920 WMITLV_GET_STRUCT_TLVLEN
7921 (wmi_request_stats_cmd_fixed_param));
7922
7923 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7924 cmd->vdev_id = vdev_id;
7925 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7926 cmd->vdev_id, cmd->stats_id);
7927
7928 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7929 WMI_REQUEST_STATS_CMDID)) {
7930 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7931 __func__);
7932 wmi_buf_free(buf);
7933 return QDF_STATUS_E_FAILURE;
7934 }
7935
7936 return QDF_STATUS_SUCCESS;
7937}
7938
7939/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307940 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7941 * @wmi_handle: wmi handle
7942 * @rssi_req: get RSSI request
7943 *
7944 * Return: CDF status
7945 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307946static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307947{
7948 wmi_buf_t buf;
7949 wmi_request_stats_cmd_fixed_param *cmd;
7950 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7951
7952 buf = wmi_buf_alloc(wmi_handle, len);
7953 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307954 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7955 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307956 }
7957
7958 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7959 WMITLV_SET_HDR(&cmd->tlv_header,
7960 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7961 WMITLV_GET_STRUCT_TLVLEN
7962 (wmi_request_stats_cmd_fixed_param));
7963 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7964 if (wmi_unified_cmd_send
7965 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307966 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307967 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307968 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307969 }
7970
Govind Singhb53420c2016-03-09 14:32:57 +05307971 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307972}
7973
7974/**
7975 * send_snr_cmd_tlv() - get RSSI from fw
7976 * @wmi_handle: wmi handle
7977 * @vdev_id: vdev id
7978 *
7979 * Return: CDF status
7980 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307981static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307982{
7983 wmi_buf_t buf;
7984 wmi_request_stats_cmd_fixed_param *cmd;
7985 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7986
7987 buf = wmi_buf_alloc(wmi_handle, len);
7988 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307989 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7990 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307991 }
7992
7993 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7994 cmd->vdev_id = vdev_id;
7995
7996 WMITLV_SET_HDR(&cmd->tlv_header,
7997 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7998 WMITLV_GET_STRUCT_TLVLEN
7999 (wmi_request_stats_cmd_fixed_param));
8000 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
8001 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8002 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308003 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308004 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308005 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308006 }
8007
Govind Singhb53420c2016-03-09 14:32:57 +05308008 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308009}
8010
8011/**
8012 * send_link_status_req_cmd_tlv() - process link status request from UMAC
8013 * @wmi_handle: wmi handle
8014 * @link_status: get link params
8015 *
8016 * Return: CDF status
8017 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308018static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308019 struct link_status_params *link_status)
8020{
8021 wmi_buf_t buf;
8022 wmi_request_stats_cmd_fixed_param *cmd;
8023 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
8024
8025 buf = wmi_buf_alloc(wmi_handle, len);
8026 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308027 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8028 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308029 }
8030
8031 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
8032 WMITLV_SET_HDR(&cmd->tlv_header,
8033 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
8034 WMITLV_GET_STRUCT_TLVLEN
8035 (wmi_request_stats_cmd_fixed_param));
8036 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
8037 cmd->vdev_id = link_status->session_id;
8038 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8039 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308040 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308041 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308042 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308043 }
8044
Govind Singhb53420c2016-03-09 14:32:57 +05308045 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308046}
8047
Govind Singh20c5dac2016-03-07 15:33:31 +05308048/**
8049 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
8050 * @wmi_handle: wmi handle
8051 * @ta_dhcp_ind: DHCP indication parameter
8052 *
8053 * Return: CDF Status
8054 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308055static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308056 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
8057{
Govind Singh67922e82016-04-01 16:48:57 +05308058 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308059 wmi_buf_t buf = NULL;
8060 uint8_t *buf_ptr;
8061 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
8062 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
8063
8064
8065 buf = wmi_buf_alloc(wmi_handle, len);
8066 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308067 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8068 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308069 }
8070
8071 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8072 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
8073 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
8074 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
8075 WMITLV_GET_STRUCT_TLVLEN
8076 (wmi_peer_set_param_cmd_fixed_param));
8077
8078 /* fill in values */
8079 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
8080 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
8081 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05308082 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308083 &ta_dhcp_ind->peer_macaddr,
8084 sizeof(ta_dhcp_ind->peer_macaddr));
8085
8086 status = wmi_unified_cmd_send(wmi_handle, buf,
8087 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308088 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308089 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308090 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05308091 wmi_buf_free(buf);
8092 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308093
Govind Singh67922e82016-04-01 16:48:57 +05308094 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308095}
8096
8097/**
8098 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
8099 * @wmi_handle: wmi handle
8100 * @pLinkSpeed: link speed info
8101 *
8102 * Return: CDF status
8103 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308104static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308105 wmi_mac_addr peer_macaddr)
8106{
8107 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
8108 wmi_buf_t wmi_buf;
8109 uint32_t len;
8110 uint8_t *buf_ptr;
8111
8112 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
8113 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8114 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308115 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8116 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308117 }
8118 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8119
8120 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
8121 WMITLV_SET_HDR(&cmd->tlv_header,
8122 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
8123 WMITLV_GET_STRUCT_TLVLEN
8124 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
8125
8126 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05308127 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05308128 &peer_macaddr,
8129 sizeof(peer_macaddr));
8130
8131
8132 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8133 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308134 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308135 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308136 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308137 }
Govind Singhb53420c2016-03-09 14:32:57 +05308138 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308139}
8140
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308141#ifdef WLAN_SUPPORT_GREEN_AP
Govind Singh20c5dac2016-03-07 15:33:31 +05308142/**
8143 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
8144 * @wmi_handle: wmi handler
8145 * @egap_params: pointer to egap_params
8146 *
8147 * Return: 0 for success, otherwise appropriate error code
8148 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308149static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308150 struct wlan_green_ap_egap_params *egap_params)
Govind Singh20c5dac2016-03-07 15:33:31 +05308151{
8152 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
8153 wmi_buf_t buf;
8154 int32_t err;
8155
8156 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8157 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308158 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
8159 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308160 }
8161 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
8162 WMITLV_SET_HDR(&cmd->tlv_header,
8163 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
8164 WMITLV_GET_STRUCT_TLVLEN(
8165 wmi_ap_ps_egap_param_cmd_fixed_param));
8166
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308167 cmd->enable = egap_params->host_enable_egap;
8168 cmd->inactivity_time = egap_params->egap_inactivity_time;
8169 cmd->wait_time = egap_params->egap_wait_time;
8170 cmd->flags = egap_params->egap_feature_flags;
Govind Singh20c5dac2016-03-07 15:33:31 +05308171 err = wmi_unified_cmd_send(wmi_handle, buf,
8172 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
8173 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308174 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308175 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308176 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308177 }
8178
Govind Singhb53420c2016-03-09 14:32:57 +05308179 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308180}
Himanshu Agarwal66d4a162018-01-10 14:21:53 +05308181#endif
Govind Singh20c5dac2016-03-07 15:33:31 +05308182
8183/**
8184 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
8185 * @wmi_handl: wmi handle
8186 * @cmd: Profiling command index
8187 * @value1: parameter1 value
8188 * @value2: parameter2 value
8189 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308190 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308191 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308192static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308193 uint32_t cmd, uint32_t value1, uint32_t value2)
8194{
8195 wmi_buf_t buf;
8196 int32_t len = 0;
8197 int ret;
8198 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
8199 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
8200 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
8201 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
8202
8203 switch (cmd) {
8204 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
8205 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
8206 buf = wmi_buf_alloc(wmi_handle, len);
8207 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308208 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308209 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308210 }
8211 prof_trig_cmd =
8212 (wmi_wlan_profile_trigger_cmd_fixed_param *)
8213 wmi_buf_data(buf);
8214 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
8215 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
8216 WMITLV_GET_STRUCT_TLVLEN
8217 (wmi_wlan_profile_trigger_cmd_fixed_param));
8218 prof_trig_cmd->enable = value1;
8219 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8220 WMI_WLAN_PROFILE_TRIGGER_CMDID);
8221 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308222 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308223 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308224 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308225 return ret;
8226 }
8227 break;
8228
8229 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
8230 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
8231 buf = wmi_buf_alloc(wmi_handle, len);
8232 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308233 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308234 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308235 }
8236 profile_getdata_cmd =
8237 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
8238 wmi_buf_data(buf);
8239 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
8240 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
8241 WMITLV_GET_STRUCT_TLVLEN
8242 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
8243 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8244 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
8245 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308246 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308247 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308248 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308249 return ret;
8250 }
8251 break;
8252
8253 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
8254 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
8255 buf = wmi_buf_alloc(wmi_handle, len);
8256 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308257 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308258 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308259 }
8260 hist_intvl_cmd =
8261 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
8262 wmi_buf_data(buf);
8263 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
8264 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
8265 WMITLV_GET_STRUCT_TLVLEN
8266 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
8267 hist_intvl_cmd->profile_id = value1;
8268 hist_intvl_cmd->value = value2;
8269 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8270 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
8271 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308272 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308274 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308275 return ret;
8276 }
8277 break;
8278
8279 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
8280 len =
8281 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
8282 buf = wmi_buf_alloc(wmi_handle, len);
8283 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308284 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308285 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308286 }
8287 profile_enable_cmd =
8288 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
8289 wmi_buf_data(buf);
8290 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
8291 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
8292 WMITLV_GET_STRUCT_TLVLEN
8293 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
8294 profile_enable_cmd->profile_id = value1;
8295 profile_enable_cmd->enable = value2;
8296 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8297 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
8298 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308299 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308300 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308301 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308302 return ret;
8303 }
8304 break;
8305
8306 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308307 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308308 break;
8309 }
8310
8311 return 0;
8312}
8313
Paul Zhang92ab8d32017-12-08 16:08:00 +08008314static QDF_STATUS send_wlm_latency_level_cmd_tlv(wmi_unified_t wmi_handle,
8315 struct wlm_latency_level_param *params)
8316{
8317 wmi_wlm_config_cmd_fixed_param *cmd;
8318 wmi_buf_t buf;
8319 uint32_t len = sizeof(*cmd);
8320 static uint32_t ll[4] = {100, 60, 40, 20};
8321
8322 buf = wmi_buf_alloc(wmi_handle, len);
8323 if (!buf) {
8324 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8325 return QDF_STATUS_E_NOMEM;
8326 }
8327 cmd = (wmi_wlm_config_cmd_fixed_param *)wmi_buf_data(buf);
8328 WMITLV_SET_HDR(&cmd->tlv_header,
8329 WMITLV_TAG_STRUC_wmi_wlm_config_cmd_fixed_param,
8330 WMITLV_GET_STRUCT_TLVLEN
8331 (wmi_wlm_config_cmd_fixed_param));
8332 cmd->vdev_id = params->vdev_id;
8333 cmd->latency_level = params->wlm_latency_level;
8334 cmd->ul_latency = ll[params->wlm_latency_level];
8335 cmd->dl_latency = ll[params->wlm_latency_level];
8336 cmd->flags = params->wlm_latency_flags;
8337 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8338 WMI_WLM_CONFIG_CMDID)) {
8339 WMI_LOGE("%s: Failed to send setting latency config command",
8340 __func__);
8341 wmi_buf_free(buf);
8342 return QDF_STATUS_E_FAILURE;
8343 }
8344
8345 return 0;
8346}
Govind Singh20c5dac2016-03-07 15:33:31 +05308347/**
8348 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
8349 * @wmi_handle: wmi handle
8350 * @vdev_id: vdev id
8351 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308352 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308353 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308354static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308355{
8356 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
8357 wmi_buf_t buf;
8358 int32_t len = sizeof(*cmd);
8359
Govind Singhb53420c2016-03-09 14:32:57 +05308360 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308361 buf = wmi_buf_alloc(wmi_handle, len);
8362 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308363 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308364 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308365 }
8366 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
8367 wmi_buf_data(buf);
8368 WMITLV_SET_HDR(&cmd->tlv_header,
8369 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
8370 WMITLV_GET_STRUCT_TLVLEN
8371 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
8372 cmd->vdev_id = vdev_id;
8373 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
8374 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8375 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308376 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308377 __func__);
8378 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308379 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308380 }
8381
8382 return 0;
8383}
8384
8385/**
8386 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
8387 * @wmi_handle: wmi handle
8388 * @vdev_id: vdev id
8389 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308390 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308391 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308392static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308393 uint8_t vdev_id)
8394{
8395 wmi_csa_offload_enable_cmd_fixed_param *cmd;
8396 wmi_buf_t buf;
8397 int32_t len = sizeof(*cmd);
8398
Govind Singhb53420c2016-03-09 14:32:57 +05308399 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05308400 buf = wmi_buf_alloc(wmi_handle, len);
8401 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308402 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308403 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308404 }
8405 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
8406 WMITLV_SET_HDR(&cmd->tlv_header,
8407 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
8408 WMITLV_GET_STRUCT_TLVLEN
8409 (wmi_csa_offload_enable_cmd_fixed_param));
8410 cmd->vdev_id = vdev_id;
8411 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
8412 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8413 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308414 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308415 __func__);
8416 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308417 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308418 }
8419
8420 return 0;
8421}
8422
Naveen Rawat42cd1e62017-05-13 15:56:57 -07008423#ifdef WLAN_FEATURE_CIF_CFR
8424/**
8425 * send_oem_dma_cfg_cmd_tlv() - configure OEM DMA rings
8426 * @wmi_handle: wmi handle
8427 * @data_len: len of dma cfg req
8428 * @data: dma cfg req
8429 *
8430 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8431 */
8432static QDF_STATUS send_oem_dma_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8433 wmi_oem_dma_ring_cfg_req_fixed_param *cfg)
8434{
8435 wmi_buf_t buf;
8436 uint8_t *cmd;
8437 QDF_STATUS ret;
8438
8439 WMITLV_SET_HDR(cfg,
8440 WMITLV_TAG_STRUC_wmi_oem_dma_ring_cfg_req_fixed_param,
8441 (sizeof(*cfg) - WMI_TLV_HDR_SIZE));
8442
8443 buf = wmi_buf_alloc(wmi_handle, sizeof(*cfg));
8444 if (!buf) {
8445 WMI_LOGE(FL("wmi_buf_alloc failed"));
8446 return QDF_STATUS_E_FAILURE;
8447 }
8448
8449 cmd = (uint8_t *) wmi_buf_data(buf);
8450 qdf_mem_copy(cmd, cfg, sizeof(*cfg));
8451 WMI_LOGI(FL("Sending OEM Data Request to target, data len %lu"),
8452 sizeof(*cfg));
8453 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cfg),
8454 WMI_OEM_DMA_RING_CFG_REQ_CMDID);
8455 if (QDF_IS_STATUS_ERROR(ret)) {
8456 WMI_LOGE(FL(":wmi cmd send failed"));
8457 wmi_buf_free(buf);
8458 }
8459
8460 return ret;
8461}
8462#endif
8463
Govind Singh20c5dac2016-03-07 15:33:31 +05308464/**
Sathish Kumarf396c722017-11-17 17:30:41 +05308465 * send_dbr_cfg_cmd_tlv() - configure DMA rings for Direct Buf RX
8466 * @wmi_handle: wmi handle
8467 * @data_len: len of dma cfg req
8468 * @data: dma cfg req
8469 *
8470 * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
8471 */
8472static QDF_STATUS send_dbr_cfg_cmd_tlv(wmi_unified_t wmi_handle,
8473 struct direct_buf_rx_cfg_req *cfg)
8474{
8475 wmi_buf_t buf;
8476 wmi_dma_ring_cfg_req_fixed_param *cmd;
8477 QDF_STATUS ret;
8478 int32_t len = sizeof(*cmd);
8479
8480 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8481 if (!buf) {
8482 WMI_LOGE(FL("wmi_buf_alloc failed"));
8483 return QDF_STATUS_E_FAILURE;
8484 }
8485
8486 cmd = (wmi_dma_ring_cfg_req_fixed_param *)wmi_buf_data(buf);
8487
8488 WMITLV_SET_HDR(&cmd->tlv_header,
8489 WMITLV_TAG_STRUC_wmi_dma_ring_cfg_req_fixed_param,
8490 WMITLV_GET_STRUCT_TLVLEN(wmi_dma_ring_cfg_req_fixed_param));
8491
8492 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8493 cfg->pdev_id);
8494 cmd->mod_id = cfg->mod_id;
8495 cmd->base_paddr_lo = cfg->base_paddr_lo;
8496 cmd->base_paddr_hi = cfg->base_paddr_hi;
8497 cmd->head_idx_paddr_lo = cfg->head_idx_paddr_lo;
8498 cmd->head_idx_paddr_hi = cfg->head_idx_paddr_hi;
8499 cmd->tail_idx_paddr_lo = cfg->tail_idx_paddr_lo;
8500 cmd->tail_idx_paddr_hi = cfg->tail_idx_paddr_hi;
8501 cmd->num_elems = cfg->num_elems;
8502 cmd->buf_size = cfg->buf_size;
8503 cmd->num_resp_per_event = cfg->num_resp_per_event;
8504 cmd->event_timeout_ms = cfg->event_timeout_ms;
8505
8506 WMI_LOGD("%s: wmi_dma_ring_cfg_req_fixed_param pdev id %d mod id %d"
8507 "base paddr lo %x base paddr hi %x head idx paddr lo %x"
8508 "head idx paddr hi %x tail idx paddr lo %x"
8509 "tail idx addr hi %x num elems %d buf size %d num resp %d"
8510 "event timeout %d\n", __func__, cmd->pdev_id,
8511 cmd->mod_id, cmd->base_paddr_lo, cmd->base_paddr_hi,
8512 cmd->head_idx_paddr_lo, cmd->head_idx_paddr_hi,
8513 cmd->tail_idx_paddr_lo, cmd->tail_idx_paddr_hi,
8514 cmd->num_elems, cmd->buf_size, cmd->num_resp_per_event,
8515 cmd->event_timeout_ms);
8516 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8517 WMI_PDEV_DMA_RING_CFG_REQ_CMDID);
8518 if (QDF_IS_STATUS_ERROR(ret)) {
8519 WMI_LOGE(FL(":wmi cmd send failed"));
8520 wmi_buf_free(buf);
8521 }
8522
8523 return ret;
8524}
8525
8526/**
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -07008527 * send_start_11d_scan_cmd_tlv() - start 11d scan request
8528 * @wmi_handle: wmi handle
8529 * @start_11d_scan: 11d scan start request parameters
8530 *
8531 * This function request FW to start 11d scan.
8532 *
8533 * Return: QDF status
8534 */
8535static QDF_STATUS send_start_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8536 struct reg_start_11d_scan_req *start_11d_scan)
8537{
8538 wmi_11d_scan_start_cmd_fixed_param *cmd;
8539 int32_t len;
8540 wmi_buf_t buf;
8541 int ret;
8542
8543 len = sizeof(*cmd);
8544 buf = wmi_buf_alloc(wmi_handle, len);
8545 if (!buf) {
8546 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8547 return QDF_STATUS_E_NOMEM;
8548 }
8549
8550 cmd = (wmi_11d_scan_start_cmd_fixed_param *)wmi_buf_data(buf);
8551
8552 WMITLV_SET_HDR(&cmd->tlv_header,
8553 WMITLV_TAG_STRUC_wmi_11d_scan_start_cmd_fixed_param,
8554 WMITLV_GET_STRUCT_TLVLEN
8555 (wmi_11d_scan_start_cmd_fixed_param));
8556
8557 cmd->vdev_id = start_11d_scan->vdev_id;
8558 cmd->scan_period_msec = start_11d_scan->scan_period_msec;
8559 cmd->start_interval_msec = start_11d_scan->start_interval_msec;
8560
8561 WMI_LOGD("vdev %d sending 11D scan start req", cmd->vdev_id);
8562
8563 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8564 WMI_11D_SCAN_START_CMDID);
8565 if (ret) {
8566 WMI_LOGE("%s: Failed to send start 11d scan wmi cmd", __func__);
8567 wmi_buf_free(buf);
8568 return QDF_STATUS_E_FAILURE;
8569 }
8570
8571 return QDF_STATUS_SUCCESS;
8572}
8573
8574/**
8575 * send_stop_11d_scan_cmd_tlv() - stop 11d scan request
8576 * @wmi_handle: wmi handle
8577 * @start_11d_scan: 11d scan stop request parameters
8578 *
8579 * This function request FW to stop 11d scan.
8580 *
8581 * Return: QDF status
8582 */
8583static QDF_STATUS send_stop_11d_scan_cmd_tlv(wmi_unified_t wmi_handle,
8584 struct reg_stop_11d_scan_req *stop_11d_scan)
8585{
8586 wmi_11d_scan_stop_cmd_fixed_param *cmd;
8587 int32_t len;
8588 wmi_buf_t buf;
8589 int ret;
8590
8591 len = sizeof(*cmd);
8592 buf = wmi_buf_alloc(wmi_handle, len);
8593 if (!buf) {
8594 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8595 return QDF_STATUS_E_NOMEM;
8596 }
8597
8598 cmd = (wmi_11d_scan_stop_cmd_fixed_param *)wmi_buf_data(buf);
8599
8600 WMITLV_SET_HDR(&cmd->tlv_header,
8601 WMITLV_TAG_STRUC_wmi_11d_scan_stop_cmd_fixed_param,
8602 WMITLV_GET_STRUCT_TLVLEN
8603 (wmi_11d_scan_stop_cmd_fixed_param));
8604
8605 cmd->vdev_id = stop_11d_scan->vdev_id;
8606
8607 WMI_LOGD("vdev %d sending 11D scan stop req", cmd->vdev_id);
8608
8609 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8610 WMI_11D_SCAN_STOP_CMDID);
8611 if (ret) {
8612 WMI_LOGE("%s: Failed to send stop 11d scan wmi cmd", __func__);
8613 wmi_buf_free(buf);
8614 return QDF_STATUS_E_FAILURE;
8615 }
8616
8617 return QDF_STATUS_SUCCESS;
8618}
8619
8620/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308621 * send_start_oem_data_cmd_tlv() - start OEM data request to target
8622 * @wmi_handle: wmi handle
8623 * @startOemDataReq: start request params
8624 *
8625 * Return: CDF status
8626 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308627static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07008628 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05308629 uint8_t *data)
8630{
8631 wmi_buf_t buf;
8632 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308633 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308634
8635 buf = wmi_buf_alloc(wmi_handle,
8636 (data_len + WMI_TLV_HDR_SIZE));
8637 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308638 WMI_LOGE(FL("wmi_buf_alloc failed"));
8639 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308640 }
8641
8642 cmd = (uint8_t *) wmi_buf_data(buf);
8643
8644 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
8645 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308646 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05308647 data_len);
8648
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -08008649 WMI_LOGD(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308650 data_len);
8651
8652 ret = wmi_unified_cmd_send(wmi_handle, buf,
8653 (data_len +
8654 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
8655
Govind Singh67922e82016-04-01 16:48:57 +05308656 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308657 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308658 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308659 }
8660
Govind Singh67922e82016-04-01 16:48:57 +05308661 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308662}
8663
8664/**
8665 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
8666 * @wmi_handle: wmi handle
8667 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
8668 *
8669 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
8670 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
8671 * to firmware based on phyerr filtering
8672 * offload status.
8673 *
8674 * Return: 1 success, 0 failure
8675 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308676static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05308677send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
8678 bool dfs_phyerr_filter_offload)
8679{
8680 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
8681 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
8682 wmi_buf_t buf;
8683 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05308684 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308685
8686
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07008687 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05308688 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308689 __func__);
8690 len = sizeof(*disable_phyerr_offload_cmd);
8691 buf = wmi_buf_alloc(wmi_handle, len);
8692 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308693 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308694 return 0;
8695 }
8696 disable_phyerr_offload_cmd =
8697 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
8698 wmi_buf_data(buf);
8699
8700 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
8701 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
8702 WMITLV_GET_STRUCT_TLVLEN
8703 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
8704
8705 /*
8706 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8707 * to the firmware to disable the phyerror
8708 * filtering offload.
8709 */
8710 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8711 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308712 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308713 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308714 __func__, ret);
8715 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308716 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308717 }
Govind Singhb53420c2016-03-09 14:32:57 +05308718 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308719 __func__);
8720 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308721 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308722 __func__);
8723
8724 len = sizeof(*enable_phyerr_offload_cmd);
8725 buf = wmi_buf_alloc(wmi_handle, len);
8726 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308727 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8728 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308729 }
8730
8731 enable_phyerr_offload_cmd =
8732 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8733 wmi_buf_data(buf);
8734
8735 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8736 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8737 WMITLV_GET_STRUCT_TLVLEN
8738 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8739
8740 /*
8741 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8742 * to the firmware to enable the phyerror
8743 * filtering offload.
8744 */
8745 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8746 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8747
Govind Singh67922e82016-04-01 16:48:57 +05308748 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308749 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308750 __func__, ret);
8751 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308752 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308753 }
Govind Singhb53420c2016-03-09 14:32:57 +05308754 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308755 __func__);
8756 }
8757
Govind Singhb53420c2016-03-09 14:32:57 +05308758 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308759}
8760
Naveen Rawata5817e72017-10-26 18:50:19 -07008761/**
8762 * send_wow_timer_pattern_cmd_tlv() - set timer pattern tlv, so that firmware
8763 * will wake up host after specified time is elapsed
8764 * @wmi_handle: wmi handle
8765 * @vdev_id: vdev id
8766 * @cookie: value to identify reason why host set up wake call.
8767 * @time: time in ms
8768 *
8769 * Return: QDF status
8770 */
8771static QDF_STATUS send_wow_timer_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8772 uint8_t vdev_id, uint32_t cookie, uint32_t time)
8773{
8774 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
8775 wmi_buf_t buf;
8776 uint8_t *buf_ptr;
8777 int32_t len;
8778 int ret;
8779
8780 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
8781 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_BITMAP_PATTERN_T) +
8782 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
8783 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
8784 WMI_TLV_HDR_SIZE + 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
Vivekc5823092018-03-22 23:27:21 +05308785 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t) +
8786 WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008787
8788 buf = wmi_buf_alloc(wmi_handle, len);
8789 if (!buf) {
8790 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8791 return QDF_STATUS_E_NOMEM;
8792 }
8793
8794 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8795 buf_ptr = (uint8_t *) cmd;
8796
8797 WMITLV_SET_HDR(&cmd->tlv_header,
8798 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
8799 WMITLV_GET_STRUCT_TLVLEN
8800 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
8801 cmd->vdev_id = vdev_id;
8802 cmd->pattern_id = cookie,
8803 cmd->pattern_type = WOW_TIMER_PATTERN;
8804 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
8805
8806 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
8807 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8808 buf_ptr += WMI_TLV_HDR_SIZE;
8809
8810 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
8811 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8812 buf_ptr += WMI_TLV_HDR_SIZE;
8813
8814 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
8815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8816 buf_ptr += WMI_TLV_HDR_SIZE;
8817
8818 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
8819 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
8820 buf_ptr += WMI_TLV_HDR_SIZE;
8821
8822 /* Fill TLV for pattern_info_timeout, and time value */
Vivekc5823092018-03-22 23:27:21 +05308823 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008824 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308825 *((uint32_t *) buf_ptr) = time;
8826 buf_ptr += sizeof(uint32_t);
Naveen Rawata5817e72017-10-26 18:50:19 -07008827
8828 /* Fill TLV for ra_ratelimit_interval. with dummy 0 value */
Vivekc5823092018-03-22 23:27:21 +05308829 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Naveen Rawata5817e72017-10-26 18:50:19 -07008830 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +05308831 *((uint32_t *) buf_ptr) = 0;
Naveen Rawata5817e72017-10-26 18:50:19 -07008832
8833 WMI_LOGD("%s: send wake timer pattern with time[%d] to fw vdev = %d",
8834 __func__, time, vdev_id);
8835
8836 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8837 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
8838 if (ret) {
8839 WMI_LOGE("%s: Failed to send wake timer pattern to fw",
8840 __func__);
8841 wmi_buf_free(buf);
8842 return QDF_STATUS_E_FAILURE;
8843 }
8844
8845 return QDF_STATUS_SUCCESS;
8846}
8847
Govind Singh20c5dac2016-03-07 15:33:31 +05308848#if !defined(REMOVE_PKT_LOG)
8849/**
8850 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8851 * @wmi_handle: wmi handle
8852 * @pktlog_event: pktlog event
8853 * @cmd_id: pktlog cmd id
8854 *
8855 * Return: CDF status
8856 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308857static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308858 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308859 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308860{
8861 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8862 WMI_CMD_ID CMD_ID;
8863 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8864 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8865 int len = 0;
8866 wmi_buf_t buf;
8867
8868 PKTLOG_EVENT = pktlog_event;
8869 CMD_ID = cmd_id;
8870
8871 switch (CMD_ID) {
8872 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8873 len = sizeof(*cmd);
8874 buf = wmi_buf_alloc(wmi_handle, len);
8875 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308876 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8877 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 }
8879 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8880 wmi_buf_data(buf);
8881 WMITLV_SET_HDR(&cmd->tlv_header,
8882 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8883 WMITLV_GET_STRUCT_TLVLEN
8884 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8885 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308886 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8887 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308888 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8889 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308890 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8891 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308892 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308893 goto wmi_send_failed;
8894 }
8895 break;
8896 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8897 len = sizeof(*disable_cmd);
8898 buf = wmi_buf_alloc(wmi_handle, len);
8899 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308900 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8901 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308902 }
8903 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8904 wmi_buf_data(buf);
8905 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8906 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8907 WMITLV_GET_STRUCT_TLVLEN
8908 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308909 disable_cmd->pdev_id =
8910 wmi_handle->ops->convert_pdev_id_host_to_target(
8911 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308912 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8913 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308914 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308915 goto wmi_send_failed;
8916 }
8917 break;
8918 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308919 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308920 break;
8921 }
8922
Govind Singhb53420c2016-03-09 14:32:57 +05308923 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308924
8925wmi_send_failed:
8926 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308927 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308928}
8929#endif /* REMOVE_PKT_LOG */
8930
8931/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308932 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8933 * @wmi_handle: wmi handle
8934 * @ptrn_id: pattern id
8935 * @vdev_id: vdev id
8936 *
8937 * Return: CDF status
8938 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308939static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8940 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308941{
8942 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8943 wmi_buf_t buf;
8944 int32_t len;
8945 int ret;
8946
8947 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8948
8949
8950 buf = wmi_buf_alloc(wmi_handle, len);
8951 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308952 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8953 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308954 }
8955
8956 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8957
8958 WMITLV_SET_HDR(&cmd->tlv_header,
8959 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8960 WMITLV_GET_STRUCT_TLVLEN(
8961 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8962 cmd->vdev_id = vdev_id;
8963 cmd->pattern_id = ptrn_id;
8964 cmd->pattern_type = WOW_BITMAP_PATTERN;
8965
Govind Singhb53420c2016-03-09 14:32:57 +05308966 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308967 cmd->pattern_id, vdev_id);
8968
8969 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8970 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8971 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308972 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308973 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308974 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308975 }
8976
Govind Singhb53420c2016-03-09 14:32:57 +05308977 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308978}
8979
8980/**
8981 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8982 * @wmi_handle: wmi handle
8983 *
8984 * Sends host wakeup indication to FW. On receiving this indication,
8985 * FW will come out of WOW.
8986 *
8987 * Return: CDF status
8988 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308989static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308990{
8991 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8992 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308993 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308994 int32_t len;
8995 int ret;
8996
8997 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8998
8999 buf = wmi_buf_alloc(wmi_handle, len);
9000 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309001 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9002 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309003 }
9004
9005 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
9006 wmi_buf_data(buf);
9007 WMITLV_SET_HDR(&cmd->tlv_header,
9008 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
9009 WMITLV_GET_STRUCT_TLVLEN
9010 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
9011
9012
9013 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9014 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
9015 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309016 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05309017 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309018 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309019 }
9020
Govind Singhb53420c2016-03-09 14:32:57 +05309021 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309022}
9023
9024/**
9025 * send_del_ts_cmd_tlv() - send DELTS request to fw
9026 * @wmi_handle: wmi handle
9027 * @msg: delts params
9028 *
9029 * Return: CDF status
9030 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309031static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309032 uint8_t ac)
9033{
9034 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
9035 wmi_buf_t buf;
9036 int32_t len = sizeof(*cmd);
9037
9038 buf = wmi_buf_alloc(wmi_handle, len);
9039 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309040 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9041 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309042 }
9043 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
9044 WMITLV_SET_HDR(&cmd->tlv_header,
9045 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
9046 WMITLV_GET_STRUCT_TLVLEN
9047 (wmi_vdev_wmm_delts_cmd_fixed_param));
9048 cmd->vdev_id = vdev_id;
9049 cmd->ac = ac;
9050
Govind Singhb53420c2016-03-09 14:32:57 +05309051 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309052 cmd->vdev_id, cmd->ac, __func__, __LINE__);
9053 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9054 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309055 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309056 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309057 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309058 }
9059
Govind Singhb53420c2016-03-09 14:32:57 +05309060 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309061}
9062
9063/**
9064 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
9065 * @wmi_handle: handle to wmi
9066 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
9067 *
Govind Singhb53420c2016-03-09 14:32:57 +05309068 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05309069 * ADD_TS requestes to firmware in loop for all the ACs with
9070 * active flow.
9071 *
9072 * Return: CDF status
9073 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309074static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309075 struct aggr_add_ts_param *aggr_qos_rsp_msg)
9076{
9077 int i = 0;
9078 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9079 wmi_buf_t buf;
9080 int32_t len = sizeof(*cmd);
9081
9082 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
9083 /* if flow in this AC is active */
9084 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
9085 /*
9086 * as per implementation of wma_add_ts_req() we
9087 * are not waiting any response from firmware so
9088 * apart from sending ADDTS to firmware just send
9089 * success to upper layers
9090 */
Govind Singhb53420c2016-03-09 14:32:57 +05309091 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309092
9093 buf = wmi_buf_alloc(wmi_handle, len);
9094 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309095 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9096 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309097 }
9098 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
9099 wmi_buf_data(buf);
9100 WMITLV_SET_HDR(&cmd->tlv_header,
9101 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9102 WMITLV_GET_STRUCT_TLVLEN
9103 (wmi_vdev_wmm_addts_cmd_fixed_param));
9104 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
9105 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05309106 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05309107 traffic.userPrio);
9108 cmd->medium_time_us =
9109 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
9110 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05309111 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309112 __func__, __LINE__, cmd->vdev_id, cmd->ac,
9113 cmd->medium_time_us, cmd->downgrade_type);
9114 if (wmi_unified_cmd_send
9115 (wmi_handle, buf, len,
9116 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309117 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309118 __func__);
9119 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05309120 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309121 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309122 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309123 }
9124 }
9125 }
9126
Govind Singhb53420c2016-03-09 14:32:57 +05309127 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309128}
9129
9130/**
9131 * send_add_ts_cmd_tlv() - send ADDTS request to fw
9132 * @wmi_handle: wmi handle
9133 * @msg: ADDTS params
9134 *
9135 * Return: CDF status
9136 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309137static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309138 struct add_ts_param *msg)
9139{
9140 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
9141 wmi_buf_t buf;
9142 int32_t len = sizeof(*cmd);
9143
Govind Singhb53420c2016-03-09 14:32:57 +05309144 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309145
9146 buf = wmi_buf_alloc(wmi_handle, len);
9147 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309148 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9149 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309150 }
9151 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
9152 WMITLV_SET_HDR(&cmd->tlv_header,
9153 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
9154 WMITLV_GET_STRUCT_TLVLEN
9155 (wmi_vdev_wmm_addts_cmd_fixed_param));
9156 cmd->vdev_id = msg->sme_session_id;
9157 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
9158 cmd->medium_time_us = msg->tspec.mediumTime * 32;
9159 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05309160 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309161 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
9162 cmd->downgrade_type, __func__, __LINE__);
9163 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9164 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309165 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
9166 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05309167 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309168 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309169 }
9170
Govind Singhb53420c2016-03-09 14:32:57 +05309171 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309172}
9173
9174/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309175 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
9176 * @wmi_handle: wmi handle
9177 * @pAddPeriodicTxPtrnParams: tx ptrn params
9178 *
9179 * Retrun: CDF status
9180 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309181static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309182 struct periodic_tx_pattern *
9183 pAddPeriodicTxPtrnParams,
9184 uint8_t vdev_id)
9185{
9186 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9187 wmi_buf_t wmi_buf;
9188 uint32_t len;
9189 uint8_t *buf_ptr;
9190 uint32_t ptrn_len, ptrn_len_aligned;
9191 int j;
9192
9193 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
9194 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
9195 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
9196 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
9197
9198 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9199 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309200 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9201 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309202 }
9203
9204 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9205
9206 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
9207 WMITLV_SET_HDR(&cmd->tlv_header,
9208 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9209 WMITLV_GET_STRUCT_TLVLEN
9210 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9211
9212 /* Pass the pattern id to delete for the corresponding vdev id */
9213 cmd->vdev_id = vdev_id;
9214 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
9215 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
9216 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
9217
9218 /* Pattern info */
9219 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9220 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
9221 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309222 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309223 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05309224 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05309225
Govind Singhb53420c2016-03-09 14:32:57 +05309226 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309227 __func__, cmd->pattern_id, cmd->vdev_id);
9228
9229 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9230 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309231 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309232 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309233 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309234 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309235 }
Govind Singhb53420c2016-03-09 14:32:57 +05309236 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309237}
9238
9239/**
9240 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
9241 * @wmi_handle: wmi handle
9242 * @vdev_id: vdev id
9243 * @pattern_id: pattern id
9244 *
9245 * Retrun: CDF status
9246 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309247static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309248 uint8_t vdev_id,
9249 uint8_t pattern_id)
9250{
9251 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
9252 wmi_buf_t wmi_buf;
9253 uint32_t len =
9254 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
9255
9256 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9257 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309258 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9259 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309260 }
9261
9262 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
9263 wmi_buf_data(wmi_buf);
9264 WMITLV_SET_HDR(&cmd->tlv_header,
9265 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
9266 WMITLV_GET_STRUCT_TLVLEN
9267 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
9268
9269 /* Pass the pattern id to delete for the corresponding vdev id */
9270 cmd->vdev_id = vdev_id;
9271 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05309272 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309273 __func__, cmd->pattern_id, cmd->vdev_id);
9274
9275 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9276 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309277 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309278 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309279 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309280 }
Govind Singhb53420c2016-03-09 14:32:57 +05309281 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309282}
9283
9284/**
9285 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
9286 * @wmi_handle: wmi handle
9287 * @preq: stats ext params
9288 *
9289 * Return: CDF status
9290 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309291static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309292 struct stats_ext_params *preq)
9293{
Govind Singh67922e82016-04-01 16:48:57 +05309294 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309295 wmi_req_stats_ext_cmd_fixed_param *cmd;
9296 wmi_buf_t buf;
9297 uint16_t len;
9298 uint8_t *buf_ptr;
9299
9300 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
9301
9302 buf = wmi_buf_alloc(wmi_handle, len);
9303 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309304 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05309305 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309306 }
9307
9308 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9309 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
9310
9311 WMITLV_SET_HDR(&cmd->tlv_header,
9312 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
9313 WMITLV_GET_STRUCT_TLVLEN
9314 (wmi_req_stats_ext_cmd_fixed_param));
9315 cmd->vdev_id = preq->vdev_id;
9316 cmd->data_len = preq->request_data_len;
9317
Govind Singhb53420c2016-03-09 14:32:57 +05309318 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05309319 __func__, preq->request_data_len, preq->vdev_id);
9320
9321 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
9322 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
9323
9324 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309325 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309326
9327 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9328 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309329 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309330 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05309331 ret);
9332 wmi_buf_free(buf);
9333 }
9334
9335 return ret;
9336}
9337
9338/**
9339 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
9340 * @wmi_handle: wmi handle
9341 * @params: ext wow params
9342 *
9343 * Return:0 for success or error code
9344 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309345static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309346 struct ext_wow_params *params)
9347{
9348 wmi_extwow_enable_cmd_fixed_param *cmd;
9349 wmi_buf_t buf;
9350 int32_t len;
9351 int ret;
9352
9353 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
9354 buf = wmi_buf_alloc(wmi_handle, len);
9355 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309356 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9357 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309358 }
9359
9360 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
9361
9362 WMITLV_SET_HDR(&cmd->tlv_header,
9363 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
9364 WMITLV_GET_STRUCT_TLVLEN
9365 (wmi_extwow_enable_cmd_fixed_param));
9366
9367 cmd->vdev_id = params->vdev_id;
9368 cmd->type = params->type;
9369 cmd->wakeup_pin_num = params->wakeup_pin_num;
9370
Govind Singhb53420c2016-03-09 14:32:57 +05309371 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05309372 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
9373
9374 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9375 WMI_EXTWOW_ENABLE_CMDID);
9376 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309377 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309378 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309379 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309380 }
9381
Govind Singhb53420c2016-03-09 14:32:57 +05309382 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309383
9384}
9385
9386/**
9387 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
9388 * @wmi_handle: wmi handle
9389 * @app_type1_params: app type1 params
9390 *
9391 * Return: CDF status
9392 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309393static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309394 struct app_type1_params *app_type1_params)
9395{
9396 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
9397 wmi_buf_t buf;
9398 int32_t len;
9399 int ret;
9400
9401 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
9402 buf = wmi_buf_alloc(wmi_handle, len);
9403 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309404 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9405 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309406 }
9407
9408 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
9409 wmi_buf_data(buf);
9410
9411 WMITLV_SET_HDR(&cmd->tlv_header,
9412 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
9413 WMITLV_GET_STRUCT_TLVLEN
9414 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
9415
9416 cmd->vdev_id = app_type1_params->vdev_id;
9417 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
9418 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05309419 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05309420 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05309421 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309422 cmd->passwd_len = app_type1_params->pass_length;
9423
Govind Singhb53420c2016-03-09 14:32:57 +05309424 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309425 "identification_id %.8s id_length %u "
9426 "password %.16s pass_length %u",
9427 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
9428 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
9429
9430 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9431 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
9432 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309433 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309434 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309435 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309436 }
9437
Govind Singhb53420c2016-03-09 14:32:57 +05309438 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309439}
9440
9441/**
9442 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
9443 * @wmi_handle: wmi handle
9444 * @appType2Params: app type2 params
9445 *
9446 * Return: CDF status
9447 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309448static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309449 struct app_type2_params *appType2Params)
9450{
9451 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
9452 wmi_buf_t buf;
9453 int32_t len;
9454 int ret;
9455
9456 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
9457 buf = wmi_buf_alloc(wmi_handle, len);
9458 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309459 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
9460 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309461 }
9462
9463 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
9464 wmi_buf_data(buf);
9465
9466 WMITLV_SET_HDR(&cmd->tlv_header,
9467 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
9468 WMITLV_GET_STRUCT_TLVLEN
9469 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
9470
9471 cmd->vdev_id = appType2Params->vdev_id;
9472
Govind Singhb53420c2016-03-09 14:32:57 +05309473 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05309474 cmd->rc4_key_len = appType2Params->rc4_key_len;
9475
9476 cmd->ip_id = appType2Params->ip_id;
9477 cmd->ip_device_ip = appType2Params->ip_device_ip;
9478 cmd->ip_server_ip = appType2Params->ip_server_ip;
9479
9480 cmd->tcp_src_port = appType2Params->tcp_src_port;
9481 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
9482 cmd->tcp_seq = appType2Params->tcp_seq;
9483 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
9484
9485 cmd->keepalive_init = appType2Params->keepalive_init;
9486 cmd->keepalive_min = appType2Params->keepalive_min;
9487 cmd->keepalive_max = appType2Params->keepalive_max;
9488 cmd->keepalive_inc = appType2Params->keepalive_inc;
9489
9490 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
9491 &cmd->gateway_mac);
9492 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
9493 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
9494
Govind Singhb53420c2016-03-09 14:32:57 +05309495 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05309496 "rc4_key %.16s rc4_key_len %u "
9497 "ip_id %x ip_device_ip %x ip_server_ip %x "
9498 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
9499 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
9500 "keepalive_max %u keepalive_inc %u "
9501 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
9502 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
9503 cmd->rc4_key, cmd->rc4_key_len,
9504 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
9505 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
9506 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
9507 cmd->keepalive_max, cmd->keepalive_inc,
9508 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
9509
9510 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9511 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
9512 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309513 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05309514 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309515 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309516 }
9517
Govind Singhb53420c2016-03-09 14:32:57 +05309518 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309519
9520}
9521
9522/**
9523 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
9524 * @wmi_handle: wmi handle
9525 * @timer_val: auto shutdown timer value
9526 *
9527 * Return: CDF status
9528 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309529static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309530 uint32_t timer_val)
9531{
Govind Singh67922e82016-04-01 16:48:57 +05309532 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309533 wmi_buf_t buf = NULL;
9534 uint8_t *buf_ptr;
9535 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
9536 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
9537
Govind Singhb53420c2016-03-09 14:32:57 +05309538 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 __func__, timer_val);
9540
9541 buf = wmi_buf_alloc(wmi_handle, len);
9542 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309543 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9544 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309545 }
9546
9547 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9548 wmi_auto_sh_cmd =
9549 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
9550 wmi_auto_sh_cmd->timer_value = timer_val;
9551
9552 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
9553 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
9554 WMITLV_GET_STRUCT_TLVLEN
9555 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
9556
9557 status = wmi_unified_cmd_send(wmi_handle, buf,
9558 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309559 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309560 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309561 __func__, status);
9562 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309563 }
9564
Govind Singh67922e82016-04-01 16:48:57 +05309565 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309566}
9567
9568/**
9569 * send_nan_req_cmd_tlv() - to send nan request to target
9570 * @wmi_handle: wmi handle
9571 * @nan_req: request data which will be non-null
9572 *
9573 * Return: CDF status
9574 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309575static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309576 struct nan_req_params *nan_req)
9577{
Govind Singh67922e82016-04-01 16:48:57 +05309578 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309579 wmi_nan_cmd_param *cmd;
9580 wmi_buf_t buf;
9581 uint16_t len = sizeof(*cmd);
9582 uint16_t nan_data_len, nan_data_len_aligned;
9583 uint8_t *buf_ptr;
9584
9585 /*
9586 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
9587 * +------------+----------+-----------------------+--------------+
9588 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
9589 * +------------+----------+-----------------------+--------------+
9590 */
9591 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05309592 WMI_LOGE("%s:nan req is not valid", __func__);
9593 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309594 }
9595 nan_data_len = nan_req->request_data_len;
9596 nan_data_len_aligned = roundup(nan_req->request_data_len,
9597 sizeof(uint32_t));
Naveen Rawatd30dad62018-05-08 09:40:10 -07009598 if (nan_data_len_aligned < nan_req->request_data_len) {
9599 WMI_LOGE("%s: integer overflow while rounding up data_len",
9600 __func__);
9601 return QDF_STATUS_E_FAILURE;
9602 }
9603
9604 if (nan_data_len_aligned > WMI_SVC_MSG_MAX_SIZE - WMI_TLV_HDR_SIZE) {
9605 WMI_LOGE("%s: wmi_max_msg_size overflow for given datalen",
9606 __func__);
9607 return QDF_STATUS_E_FAILURE;
9608 }
9609
Govind Singh20c5dac2016-03-07 15:33:31 +05309610 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
9611 buf = wmi_buf_alloc(wmi_handle, len);
9612 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309613 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
9614 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309615 }
9616 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9617 cmd = (wmi_nan_cmd_param *) buf_ptr;
9618 WMITLV_SET_HDR(&cmd->tlv_header,
9619 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
9620 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
9621 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05309622 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05309623 __func__, nan_req->request_data_len);
9624 buf_ptr += sizeof(wmi_nan_cmd_param);
9625 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
9626 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05309627 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309628
9629 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9630 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309631 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309632 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309633 __func__, ret);
9634 wmi_buf_free(buf);
9635 }
9636
9637 return ret;
9638}
9639
9640/**
9641 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
9642 * @wmi_handle: wmi handle
Jeff Johnsona87370f2017-10-04 19:19:20 -07009643 * @params: DHCP server offload info
Govind Singh20c5dac2016-03-07 15:33:31 +05309644 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309645 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309646 */
Jeff Johnsona87370f2017-10-04 19:19:20 -07009647static QDF_STATUS
9648send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
9649 struct dhcp_offload_info_params *params)
Govind Singh20c5dac2016-03-07 15:33:31 +05309650{
9651 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
9652 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05309653 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309654
9655 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
9656 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309657 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05309658 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05309659 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309660 }
9661
9662 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309663
9664 WMITLV_SET_HDR(&cmd->tlv_header,
9665 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
9666 WMITLV_GET_STRUCT_TLVLEN
9667 (wmi_set_dhcp_server_offload_cmd_fixed_param));
Jeff Johnsona87370f2017-10-04 19:19:20 -07009668 cmd->vdev_id = params->vdev_id;
9669 cmd->enable = params->dhcp_offload_enabled;
9670 cmd->num_client = params->dhcp_client_num;
9671 cmd->srv_ipv4 = params->dhcp_srv_addr;
Govind Singh20c5dac2016-03-07 15:33:31 +05309672 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05309673 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05309674 sizeof(*cmd),
9675 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309676 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309677 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05309678 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05309679 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309680 }
Govind Singhb53420c2016-03-09 14:32:57 +05309681 WMI_LOGD("Set dhcp server offload to vdevId %d",
Jeff Johnsona87370f2017-10-04 19:19:20 -07009682 params->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05309683
9684 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309685}
9686
9687/**
9688 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
9689 * @wmi_handle: wmi handle
9690 * @flashing: flashing request
9691 *
9692 * Return: CDF status
9693 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309694static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309695 struct flashing_req_params *flashing)
9696{
9697 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05309698 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309699 wmi_buf_t buf;
9700 uint8_t *buf_ptr;
9701 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
9702
9703 buf = wmi_buf_alloc(wmi_handle, len);
9704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309705 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05309706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309707 }
9708 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9709 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
9710 WMITLV_SET_HDR(&cmd->tlv_header,
9711 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
9712 WMITLV_GET_STRUCT_TLVLEN
9713 (wmi_set_led_flashing_cmd_fixed_param));
9714 cmd->pattern_id = flashing->pattern_id;
9715 cmd->led_x0 = flashing->led_x0;
9716 cmd->led_x1 = flashing->led_x1;
9717
9718 status = wmi_unified_cmd_send(wmi_handle, buf, len,
9719 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309720 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309721 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05309722 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309723 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309724 }
Govind Singh67922e82016-04-01 16:48:57 +05309725
9726 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309727}
9728
9729/**
9730 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
9731 * @wmi_handle: wmi handle
9732 * @ch_avoid_update_req: channel avoid update params
9733 *
9734 * Return: CDF status
9735 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309736static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05309737{
Govind Singh67922e82016-04-01 16:48:57 +05309738 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309739 wmi_buf_t buf = NULL;
9740 uint8_t *buf_ptr;
9741 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
9742 int len = sizeof(wmi_chan_avoid_update_cmd_param);
9743
9744
9745 buf = wmi_buf_alloc(wmi_handle, len);
9746 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309747 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
9748 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309749 }
9750
9751 buf_ptr = (uint8_t *) wmi_buf_data(buf);
9752 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
9753 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
9754 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
9755 WMITLV_GET_STRUCT_TLVLEN
9756 (wmi_chan_avoid_update_cmd_param));
9757
9758 status = wmi_unified_cmd_send(wmi_handle, buf,
9759 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309760 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309761 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05309762 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
9763 " returned Error %d", status);
9764 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05309765 }
9766
Govind Singh67922e82016-04-01 16:48:57 +05309767 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05309768}
9769
9770/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309771 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
9772 * @wmi_handle: wmi handle
9773 * @param: pointer to pdev regdomain params
9774 *
9775 * Return: 0 for success or error code
9776 */
9777static QDF_STATUS
9778send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
9779 struct pdev_set_regdomain_params *param)
9780{
9781 wmi_buf_t buf;
9782 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9783 int32_t len = sizeof(*cmd);
9784
9785
9786 buf = wmi_buf_alloc(wmi_handle, len);
9787 if (!buf) {
9788 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9789 return QDF_STATUS_E_NOMEM;
9790 }
9791 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9792 WMITLV_SET_HDR(&cmd->tlv_header,
9793 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9794 WMITLV_GET_STRUCT_TLVLEN
9795 (wmi_pdev_set_regdomain_cmd_fixed_param));
9796
9797 cmd->reg_domain = param->currentRDinuse;
9798 cmd->reg_domain_2G = param->currentRD2G;
9799 cmd->reg_domain_5G = param->currentRD5G;
9800 cmd->conformance_test_limit_2G = param->ctl_2G;
9801 cmd->conformance_test_limit_5G = param->ctl_5G;
9802 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309803 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9804 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309805
9806 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9807 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9808 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9809 __func__);
9810 wmi_buf_free(buf);
9811 return QDF_STATUS_E_FAILURE;
9812 }
9813
9814 return QDF_STATUS_SUCCESS;
9815}
9816
9817/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309818 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9819 * @wmi_handle: wmi handle
9820 * @reg_dmn: reg domain
9821 * @regdmn2G: 2G reg domain
9822 * @regdmn5G: 5G reg domain
9823 * @ctl2G: 2G test limit
9824 * @ctl5G: 5G test limit
9825 *
9826 * Return: none
9827 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309828static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309829 uint32_t reg_dmn, uint16_t regdmn2G,
Rajeev Kumar Sirasanagandla4c1fecd2017-06-06 13:27:56 +05309830 uint16_t regdmn5G, uint8_t ctl2G,
9831 uint8_t ctl5G)
Govind Singh20c5dac2016-03-07 15:33:31 +05309832{
9833 wmi_buf_t buf;
9834 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9835 int32_t len = sizeof(*cmd);
9836
9837
9838 buf = wmi_buf_alloc(wmi_handle, len);
9839 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309840 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9841 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309842 }
9843 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9844 WMITLV_SET_HDR(&cmd->tlv_header,
9845 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9846 WMITLV_GET_STRUCT_TLVLEN
9847 (wmi_pdev_set_regdomain_cmd_fixed_param));
9848 cmd->reg_domain = reg_dmn;
9849 cmd->reg_domain_2G = regdmn2G;
9850 cmd->reg_domain_5G = regdmn5G;
9851 cmd->conformance_test_limit_2G = ctl2G;
9852 cmd->conformance_test_limit_5G = ctl5G;
9853
9854 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9855 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309856 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309857 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309858 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309859 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309860 }
9861
Govind Singhb53420c2016-03-09 14:32:57 +05309862 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309863}
9864
9865
9866/**
9867 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9868 * @wmi_handle: wmi handle
9869 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9870 *
9871 * This function sets tdls off channel mode
9872 *
9873 * Return: 0 on success; Negative errno otherwise
9874 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309875static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309876 struct tdls_channel_switch_params *chan_switch_params)
9877{
9878 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9879 wmi_buf_t wmi_buf;
9880 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9881
9882 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9883 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309884 WMI_LOGE(FL("wmi_buf_alloc failed"));
9885 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309886 }
9887 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9888 wmi_buf_data(wmi_buf);
9889 WMITLV_SET_HDR(&cmd->tlv_header,
9890 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9891 WMITLV_GET_STRUCT_TLVLEN(
9892 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9893
9894 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9895 &cmd->peer_macaddr);
9896 cmd->vdev_id = chan_switch_params->vdev_id;
9897 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9898 cmd->is_peer_responder = chan_switch_params->is_responder;
9899 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9900 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9901 cmd->offchan_oper_class = chan_switch_params->oper_class;
9902
Govind Singhb53420c2016-03-09 14:32:57 +05309903 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309904 cmd->peer_macaddr.mac_addr31to0,
9905 cmd->peer_macaddr.mac_addr47to32);
9906
Govind Singhb53420c2016-03-09 14:32:57 +05309907 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309908 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9909 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9910 ),
9911 cmd->vdev_id,
9912 cmd->offchan_mode,
9913 cmd->offchan_num,
9914 cmd->offchan_bw_bitmap,
9915 cmd->is_peer_responder,
9916 cmd->offchan_oper_class);
9917
9918 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9919 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309920 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309921 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309922 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309923 }
9924
9925
Govind Singhb53420c2016-03-09 14:32:57 +05309926 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309927}
9928
9929/**
9930 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9931 * @wmi_handle: wmi handle
9932 * @pwmaTdlsparams: TDLS params
9933 *
Jeff Johnsoneb83ef02018-05-06 00:09:31 -07009934 * Return: 0 for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309935 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309936static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309937 void *tdls_param, uint8_t tdls_state)
9938{
9939 wmi_tdls_set_state_cmd_fixed_param *cmd;
9940 wmi_buf_t wmi_buf;
9941
9942 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9943 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9944
9945 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9946 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309947 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9948 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309949 }
9950 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9951 WMITLV_SET_HDR(&cmd->tlv_header,
9952 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9953 WMITLV_GET_STRUCT_TLVLEN
9954 (wmi_tdls_set_state_cmd_fixed_param));
9955 cmd->vdev_id = wmi_tdls->vdev_id;
9956 cmd->state = tdls_state;
9957 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9958 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9959 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9960 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9961 cmd->rssi_delta = wmi_tdls->rssi_delta;
9962 cmd->tdls_options = wmi_tdls->tdls_options;
9963 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9964 cmd->tdls_peer_traffic_response_timeout_ms =
9965 wmi_tdls->peer_traffic_response_timeout;
9966 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9967 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9968 cmd->tdls_puapsd_rx_frame_threshold =
9969 wmi_tdls->puapsd_rx_frame_threshold;
9970 cmd->teardown_notification_ms =
9971 wmi_tdls->teardown_notification_ms;
9972 cmd->tdls_peer_kickout_threshold =
9973 wmi_tdls->tdls_peer_kickout_threshold;
9974
Govind Singhb53420c2016-03-09 14:32:57 +05309975 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309976 "notification_interval_ms: %d, "
9977 "tx_discovery_threshold: %d, "
9978 "tx_teardown_threshold: %d, "
9979 "rssi_teardown_threshold: %d, "
9980 "rssi_delta: %d, "
9981 "tdls_options: 0x%x, "
9982 "tdls_peer_traffic_ind_window: %d, "
9983 "tdls_peer_traffic_response_timeout: %d, "
9984 "tdls_puapsd_mask: 0x%x, "
9985 "tdls_puapsd_inactivity_time: %d, "
9986 "tdls_puapsd_rx_frame_threshold: %d, "
9987 "teardown_notification_ms: %d, "
9988 "tdls_peer_kickout_threshold: %d",
9989 __func__, tdls_state, cmd->state,
9990 cmd->notification_interval_ms,
9991 cmd->tx_discovery_threshold,
9992 cmd->tx_teardown_threshold,
9993 cmd->rssi_teardown_threshold,
9994 cmd->rssi_delta,
9995 cmd->tdls_options,
9996 cmd->tdls_peer_traffic_ind_window,
9997 cmd->tdls_peer_traffic_response_timeout_ms,
9998 cmd->tdls_puapsd_mask,
9999 cmd->tdls_puapsd_inactivity_time_ms,
10000 cmd->tdls_puapsd_rx_frame_threshold,
10001 cmd->teardown_notification_ms,
10002 cmd->tdls_peer_kickout_threshold);
10003
10004 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10005 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010006 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010007 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010008 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010009 }
Govind Singhb53420c2016-03-09 14:32:57 +053010010 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +053010011
Govind Singhb53420c2016-03-09 14:32:57 +053010012 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010013}
10014
10015/**
10016 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
10017 * @wmi_handle: wmi handle
10018 * @peerStateParams: TDLS peer state params
10019 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010020 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +053010021 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010022static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010023 struct tdls_peer_state_params *peerStateParams,
10024 uint32_t *ch_mhz)
10025{
10026 wmi_tdls_peer_update_cmd_fixed_param *cmd;
10027 wmi_tdls_peer_capabilities *peer_cap;
10028 wmi_channel *chan_info;
10029 wmi_buf_t wmi_buf;
10030 uint8_t *buf_ptr;
10031 uint32_t i;
10032 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
10033 sizeof(wmi_tdls_peer_capabilities);
10034
10035
10036 len += WMI_TLV_HDR_SIZE +
10037 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
10038
10039 wmi_buf = wmi_buf_alloc(wmi_handle, len);
10040 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010041 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10042 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010043 }
10044
10045 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
10046 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
10047 WMITLV_SET_HDR(&cmd->tlv_header,
10048 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
10049 WMITLV_GET_STRUCT_TLVLEN
10050 (wmi_tdls_peer_update_cmd_fixed_param));
10051
10052 cmd->vdev_id = peerStateParams->vdevId;
10053 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
10054 &cmd->peer_macaddr);
10055
10056
10057 cmd->peer_state = peerStateParams->peerState;
10058
Govind Singhb53420c2016-03-09 14:32:57 +053010059 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +053010060 "peer_macaddr.mac_addr31to0: 0x%x, "
10061 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
10062 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
10063 cmd->peer_macaddr.mac_addr31to0,
10064 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
10065
10066 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
10067 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
10068 WMITLV_SET_HDR(&peer_cap->tlv_header,
10069 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
10070 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
10071
10072 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
10073 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
10074 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
10075 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
10076 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
10077 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
10078 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
10079 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
10080
10081 /* Ack and More Data Ack are sent as 0, so no need to set
10082 * but fill SP
10083 */
10084 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
10085 peerStateParams->peerCap.peerMaxSp);
10086
10087 peer_cap->buff_sta_support =
10088 peerStateParams->peerCap.peerBuffStaSupport;
10089 peer_cap->off_chan_support =
10090 peerStateParams->peerCap.peerOffChanSupport;
10091 peer_cap->peer_curr_operclass =
10092 peerStateParams->peerCap.peerCurrOperClass;
10093 /* self curr operclass is not being used and so pass op class for
10094 * preferred off chan in it.
10095 */
10096 peer_cap->self_curr_operclass =
10097 peerStateParams->peerCap.opClassForPrefOffChan;
10098 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
10099 peer_cap->peer_operclass_len =
10100 peerStateParams->peerCap.peerOperClassLen;
10101
Govind Singhb53420c2016-03-09 14:32:57 +053010102 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010103 __func__, peer_cap->peer_operclass_len);
10104 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
10105 peer_cap->peer_operclass[i] =
10106 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +053010107 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +053010108 __func__, i, peer_cap->peer_operclass[i]);
10109 }
10110
10111 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
10112 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
10113 peer_cap->pref_offchan_bw =
10114 peerStateParams->peerCap.prefOffChanBandwidth;
10115
Govind Singhb53420c2016-03-09 14:32:57 +053010116 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +053010117 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
10118 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
10119 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
10120 " %d, pref_offchan_bw: %d",
10121 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
10122 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
10123 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
10124 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
10125 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
10126
10127 /* next fill variable size array of peer chan info */
10128 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
10129 WMITLV_SET_HDR(buf_ptr,
10130 WMITLV_TAG_ARRAY_STRUC,
10131 sizeof(wmi_channel) *
10132 peerStateParams->peerCap.peerChanLen);
10133 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
10134
10135 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
10136 WMITLV_SET_HDR(&chan_info->tlv_header,
10137 WMITLV_TAG_STRUC_wmi_channel,
10138 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
10139 chan_info->mhz = ch_mhz[i];
10140 chan_info->band_center_freq1 = chan_info->mhz;
10141 chan_info->band_center_freq2 = 0;
10142
Govind Singhb53420c2016-03-09 14:32:57 +053010143 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +053010144
10145 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
10146 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +053010147 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +053010148 peerStateParams->peerCap.peerChan[i].chanId,
10149 peerStateParams->peerCap.peerChan[i].dfsSet);
10150 }
10151
10152 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
10153 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
10154 else
10155 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
10156
10157 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
10158 peerStateParams->peerCap.
10159 peerChan[i].pwr);
10160
10161 WMI_SET_CHANNEL_REG_POWER(chan_info,
10162 peerStateParams->peerCap.peerChan[i].
10163 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +053010164 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +053010165 peerStateParams->peerCap.peerChan[i].pwr);
10166
10167 chan_info++;
10168 }
10169
10170 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
10171 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010172 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +053010173 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053010174 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010175 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +053010176 }
10177
10178
Govind Singhb53420c2016-03-09 14:32:57 +053010179 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +053010180}
10181
10182/*
Govind Singh20c5dac2016-03-07 15:33:31 +053010183 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
10184 * @wmi_handle: Pointer to WMi handle
10185 * @ie_data: Pointer for ie data
10186 *
10187 * This function sends IE information to firmware
10188 *
Govind Singhb53420c2016-03-09 14:32:57 +053010189 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +053010190 *
10191 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010192static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +053010193 struct vdev_ie_info_param *ie_info)
10194{
10195 wmi_vdev_set_ie_cmd_fixed_param *cmd;
10196 wmi_buf_t buf;
10197 uint8_t *buf_ptr;
10198 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +053010199 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +053010200
10201
10202 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
10203 /* Allocate memory for the WMI command */
10204 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
10205
10206 buf = wmi_buf_alloc(wmi_handle, len);
10207 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010208 WMI_LOGE(FL("wmi_buf_alloc failed"));
10209 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +053010210 }
10211
10212 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010213 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010214
10215 /* Populate the WMI command */
10216 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
10217
10218 WMITLV_SET_HDR(&cmd->tlv_header,
10219 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
10220 WMITLV_GET_STRUCT_TLVLEN(
10221 wmi_vdev_set_ie_cmd_fixed_param));
10222 cmd->vdev_id = ie_info->vdev_id;
10223 cmd->ie_id = ie_info->ie_id;
10224 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -070010225 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +053010226
Govind Singhb53420c2016-03-09 14:32:57 +053010227 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +053010228 ie_info->length, ie_info->vdev_id);
10229
10230 buf_ptr += sizeof(*cmd);
10231 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
10232 buf_ptr += WMI_TLV_HDR_SIZE;
10233
Govind Singhb53420c2016-03-09 14:32:57 +053010234 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +053010235
10236 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10237 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053010238 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053010239 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +053010240 wmi_buf_free(buf);
10241 }
10242
10243 return ret;
10244}
10245
Sathish Kumar497bef42017-03-01 14:02:36 +053010246/**
10247 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
10248 *
10249 * @param wmi_handle : handle to WMI.
10250 * @param param : pointer to antenna param
10251 *
10252 * This function sends smart antenna enable command to FW
10253 *
10254 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10255 */
10256static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
10257 struct smart_ant_enable_params *param)
10258{
10259 /* Send WMI COMMAND to Enable */
10260 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
10261 wmi_pdev_smart_ant_gpio_handle *gpio_param;
10262 wmi_buf_t buf;
10263 uint8_t *buf_ptr;
10264 int len = 0;
10265 QDF_STATUS ret;
10266 int loop = 0;
10267
10268 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10269 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
10270 buf = wmi_buf_alloc(wmi_handle, len);
10271
10272 if (!buf) {
10273 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10274 return QDF_STATUS_E_NOMEM;
10275 }
10276
10277 buf_ptr = wmi_buf_data(buf);
10278 qdf_mem_zero(buf_ptr, len);
10279 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
10280
10281 WMITLV_SET_HDR(&cmd->tlv_header,
10282 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
10283 WMITLV_GET_STRUCT_TLVLEN(
10284 wmi_pdev_smart_ant_enable_cmd_fixed_param));
10285
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010286 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10287 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010288 cmd->enable = param->enable;
10289 cmd->mode = param->mode;
10290 cmd->rx_antenna = param->rx_antenna;
10291 cmd->tx_default_antenna = param->rx_antenna;
10292
10293 /* TLV indicating array of structures to follow */
10294 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
10295 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10296 WMI_HAL_MAX_SANTENNA *
10297 sizeof(wmi_pdev_smart_ant_gpio_handle));
10298
10299 buf_ptr += WMI_TLV_HDR_SIZE;
10300 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
10301
10302 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
10303 WMITLV_SET_HDR(&gpio_param->tlv_header,
10304 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
10305 WMITLV_GET_STRUCT_TLVLEN(
10306 wmi_pdev_smart_ant_gpio_handle));
10307 if (param->mode == SMART_ANT_MODE_SERIAL) {
10308 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
10309 gpio_param->gpio_pin = param->gpio_pin[loop];
10310 gpio_param->gpio_func = param->gpio_func[loop];
10311 } else {
10312 gpio_param->gpio_pin = 0;
10313 gpio_param->gpio_func = 0;
10314 }
10315 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
10316 gpio_param->gpio_pin = param->gpio_pin[loop];
10317 gpio_param->gpio_func = param->gpio_func[loop];
10318 }
10319 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010320 gpio_param->pdev_id =
10321 wmi_handle->ops->convert_pdev_id_host_to_target(
10322 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010323 gpio_param++;
10324 }
10325
10326 ret = wmi_unified_cmd_send(wmi_handle,
10327 buf,
10328 len,
10329 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
10330
10331 if (ret != 0) {
10332 WMI_LOGE(" %s :WMI Failed\n", __func__);
10333 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
10334 cmd->enable,
10335 cmd->mode,
10336 cmd->rx_antenna,
10337 param->gpio_pin[0], param->gpio_pin[1],
10338 param->gpio_pin[2], param->gpio_pin[3],
10339 param->gpio_func[0], param->gpio_func[1],
10340 param->gpio_func[2], param->gpio_func[3],
10341 ret);
10342 wmi_buf_free(buf);
10343 }
10344
10345 return ret;
10346}
10347
10348/**
10349 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
10350 *
10351 * @param wmi_handle : handle to WMI.
10352 * @param param : pointer to rx antenna param
10353 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10354 */
10355static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10356 struct smart_ant_rx_ant_params *param)
10357{
10358 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
10359 wmi_buf_t buf;
10360 uint8_t *buf_ptr;
10361 uint32_t len;
10362 QDF_STATUS ret;
10363
10364 len = sizeof(*cmd);
10365 buf = wmi_buf_alloc(wmi_handle, len);
10366 WMI_LOGD("%s:\n", __func__);
10367 if (!buf) {
10368 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10369 return QDF_STATUS_E_NOMEM;
10370 }
10371
10372 buf_ptr = wmi_buf_data(buf);
10373 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
10374 WMITLV_SET_HDR(&cmd->tlv_header,
10375 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
10376 WMITLV_GET_STRUCT_TLVLEN(
10377 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
10378 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010379 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10380 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010381
10382 ret = wmi_unified_cmd_send(wmi_handle,
10383 buf,
10384 len,
10385 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
10386
10387 if (ret != 0) {
10388 WMI_LOGE(" %s :WMI Failed\n", __func__);
10389 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
10390 __func__,
10391 cmd->rx_antenna,
10392 ret);
10393 wmi_buf_free(buf);
10394 }
10395
10396 return ret;
10397}
10398
10399/**
10400 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
10401 * @wmi_handle: wmi handle
10402 * @param: pointer to hold ctl table param
10403 *
10404 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10405 */
10406static QDF_STATUS
10407send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
10408 struct ctl_table_params *param)
10409{
10410 uint16_t len, ctl_tlv_len;
10411 uint8_t *buf_ptr;
10412 wmi_buf_t buf;
10413 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
10414 uint32_t *ctl_array;
10415
10416 if (!param->ctl_array)
10417 return QDF_STATUS_E_FAILURE;
10418
Sathish Kumar497bef42017-03-01 14:02:36 +053010419 ctl_tlv_len = WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053010420 roundup(param->ctl_cmd_len, sizeof(uint32_t));
Sathish Kumar497bef42017-03-01 14:02:36 +053010421 len = sizeof(*cmd) + ctl_tlv_len;
10422
10423 buf = wmi_buf_alloc(wmi_handle, len);
10424 if (!buf) {
10425 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10426 return QDF_STATUS_E_FAILURE;
10427 }
10428
10429 buf_ptr = wmi_buf_data(buf);
10430 qdf_mem_zero(buf_ptr, len);
10431
10432 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
10433
10434 WMITLV_SET_HDR(&cmd->tlv_header,
10435 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
10436 WMITLV_GET_STRUCT_TLVLEN(
10437 wmi_pdev_set_ctl_table_cmd_fixed_param));
10438 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010439 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10440 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010441
10442 buf_ptr += sizeof(*cmd);
10443 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10444 (cmd->ctl_len));
10445 buf_ptr += WMI_TLV_HDR_SIZE;
10446 ctl_array = (uint32_t *)buf_ptr;
10447
10448 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
10449 sizeof(param->ctl_band));
10450 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
10451 param->ctl_cmd_len -
10452 sizeof(param->ctl_band));
10453
10454 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10455 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
10456 WMI_LOGE("%s:Failed to send command\n", __func__);
10457 wmi_buf_free(buf);
10458 return QDF_STATUS_E_FAILURE;
10459 }
10460
10461 return QDF_STATUS_SUCCESS;
10462}
10463
10464/**
10465 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
10466 * @wmi_handle: wmi handle
10467 * @param: pointer to hold mimogain table param
10468 *
10469 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10470 */
10471static QDF_STATUS
10472send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
10473 struct mimogain_table_params *param)
10474{
10475 uint16_t len, table_tlv_len;
10476 wmi_buf_t buf;
10477 uint8_t *buf_ptr;
10478 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
10479 uint32_t *gain_table;
10480
10481 if (!param->array_gain)
10482 return QDF_STATUS_E_FAILURE;
10483
10484 /* len must be multiple of a single array gain table */
10485 if (param->tbl_len %
10486 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
10487 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
10488 WMI_LOGE("Array gain table len not correct\n");
10489 return QDF_STATUS_E_FAILURE;
10490 }
10491
10492 table_tlv_len = WMI_TLV_HDR_SIZE +
10493 roundup(param->tbl_len, sizeof(uint32_t));
10494 len = sizeof(*cmd) + table_tlv_len;
10495
10496 buf = wmi_buf_alloc(wmi_handle, len);
10497 if (!buf) {
10498 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10499 return QDF_STATUS_E_FAILURE;
10500 }
10501
10502 buf_ptr = wmi_buf_data(buf);
10503 qdf_mem_zero(buf_ptr, len);
10504
10505 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
10506
10507 WMITLV_SET_HDR(&cmd->tlv_header,
10508 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
10509 WMITLV_GET_STRUCT_TLVLEN(
10510 wmi_pdev_set_mimogain_table_cmd_fixed_param));
10511
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010512 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10513 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +053010514 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
10515 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
10516 param->multichain_gain_bypass);
10517
10518 buf_ptr += sizeof(*cmd);
10519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10520 (param->tbl_len));
10521 buf_ptr += WMI_TLV_HDR_SIZE;
10522 gain_table = (uint32_t *)buf_ptr;
10523
10524 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
10525 param->array_gain,
10526 param->tbl_len);
10527
10528 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10529 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
10530 return QDF_STATUS_E_FAILURE;
10531 }
10532
10533 return QDF_STATUS_SUCCESS;
10534}
10535
10536/**
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010537 * enum packet_power_tlv_flags: target defined
10538 * packet power rate flags for TLV
10539 * @WMI_TLV_FLAG_ONE_CHAIN: one chain
10540 * @WMI_TLV_FLAG_TWO_CHAIN: two chain
10541 * @WMI_TLV_FLAG_THREE_CHAIN: three chain
10542 * @WMI_TLV_FLAG_FOUR_CHAIN: four chain
10543 * @WMI_TLV_FLAG_FIVE_CHAIN: five chain
10544 * @WMI_TLV_FLAG_SIX_CHAIN: six chain
10545 * @WMI_TLV_FLAG_SEVEN_CHAIN: seven chain
10546 * @WMI_TLV_FLAG_EIGHT_CHAIN:eight chain
10547 * @WMI_TLV_FLAG_STBC: STBC is set
10548 * @WMI_TLV_FLAG_40MHZ: 40MHz chan width
10549 * @WMI_TLV_FLAG_80MHZ: 80MHz chan width
10550 * @WMI_TLV_FLAG_160MHZ: 160MHz chan width
10551 * @WMI_TLV_FLAG_TXBF: Tx Bf enabled
10552 * @WMI_TLV_FLAG_RTSENA: RTS enabled
10553 * @WMI_TLV_FLAG_CTSENA: CTS enabled
10554 * @WMI_TLV_FLAG_LDPC: LDPC is set
10555 * @WMI_TLV_FLAG_SGI: Short gaurd interval
10556 * @WMI_TLV_FLAG_SU: SU Data
10557 * @WMI_TLV_FLAG_DL_MU_MIMO_AC: DL AC MU data
10558 * @WMI_TLV_FLAG_DL_MU_MIMO_AX: DL AX MU data
10559 * @WMI_TLV_FLAG_DL_OFDMA: DL OFDMA data
10560 * @WMI_TLV_FLAG_UL_OFDMA: UL OFDMA data
10561 * @WMI_TLV_FLAG_UL_MU_MIMO: UL MU data
10562 *
10563 * @WMI_TLV_FLAG_BW_MASK: bandwidth mask
10564 * @WMI_TLV_FLAG_BW_SHIFT: bandwidth shift
10565 * @WMI_TLV_FLAG_SU_MU_OFDMA_MASK: su/mu/ofdma mask
10566 * @WMI_TLV_FLAG_SU_MU_OFDMA_shift: su/mu/ofdma shift
10567 */
10568enum packet_power_tlv_flags {
10569 WMI_TLV_FLAG_ONE_CHAIN = 0x00000001,
10570 WMI_TLV_FLAG_TWO_CHAIN = 0x00000003,
10571 WMI_TLV_FLAG_THREE_CHAIN = 0x00000007,
10572 WMI_TLV_FLAG_FOUR_CHAIN = 0x0000000F,
10573 WMI_TLV_FLAG_FIVE_CHAIN = 0x0000001F,
10574 WMI_TLV_FLAG_SIX_CHAIN = 0x0000003F,
10575 WMI_TLV_FLAG_SEVEN_CHAIN = 0x0000007F,
10576 WMI_TLV_FLAG_EIGHT_CHAIN = 0x0000008F,
10577 WMI_TLV_FLAG_STBC = 0x00000100,
10578 WMI_TLV_FLAG_40MHZ = 0x00000200,
10579 WMI_TLV_FLAG_80MHZ = 0x00000300,
10580 WMI_TLV_FLAG_160MHZ = 0x00000400,
10581 WMI_TLV_FLAG_TXBF = 0x00000800,
10582 WMI_TLV_FLAG_RTSENA = 0x00001000,
10583 WMI_TLV_FLAG_CTSENA = 0x00002000,
10584 WMI_TLV_FLAG_LDPC = 0x00004000,
10585 WMI_TLV_FLAG_SGI = 0x00008000,
10586 WMI_TLV_FLAG_SU = 0x00100000,
10587 WMI_TLV_FLAG_DL_MU_MIMO_AC = 0x00200000,
10588 WMI_TLV_FLAG_DL_MU_MIMO_AX = 0x00300000,
10589 WMI_TLV_FLAG_DL_OFDMA = 0x00400000,
10590 WMI_TLV_FLAG_UL_OFDMA = 0x00500000,
10591 WMI_TLV_FLAG_UL_MU_MIMO = 0x00600000,
10592
10593 WMI_TLV_FLAG_CHAIN_MASK = 0xff,
10594 WMI_TLV_FLAG_BW_MASK = 0x3,
10595 WMI_TLV_FLAG_BW_SHIFT = 9,
10596 WMI_TLV_FLAG_SU_MU_OFDMA_MASK = 0x7,
10597 WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT = 20,
10598};
10599
10600/**
10601 * convert_to_power_info_rate_flags() - convert packet_power_info_params
10602 * to FW understandable format
10603 * @param: pointer to hold packet power info param
10604 *
10605 * @return FW understandable 32 bit rate flags
10606 */
10607static uint32_t
10608convert_to_power_info_rate_flags(struct packet_power_info_params *param)
10609{
10610 uint32_t rateflags = 0;
10611
10612 if (param->chainmask)
10613 rateflags |=
10614 (param->chainmask & WMI_TLV_FLAG_CHAIN_MASK);
10615 if (param->chan_width)
10616 rateflags |=
10617 ((param->chan_width & WMI_TLV_FLAG_BW_MASK)
10618 << WMI_TLV_FLAG_BW_SHIFT);
10619 if (param->su_mu_ofdma)
10620 rateflags |=
10621 ((param->su_mu_ofdma & WMI_TLV_FLAG_SU_MU_OFDMA_MASK)
10622 << WMI_TLV_FLAG_SU_MU_OFDMA_SHIFT);
10623 if (param->rate_flags & WMI_HOST_FLAG_STBC)
10624 rateflags |= WMI_TLV_FLAG_STBC;
10625 if (param->rate_flags & WMI_HOST_FLAG_LDPC)
10626 rateflags |= WMI_TLV_FLAG_LDPC;
10627 if (param->rate_flags & WMI_HOST_FLAG_TXBF)
10628 rateflags |= WMI_TLV_FLAG_TXBF;
10629 if (param->rate_flags & WMI_HOST_FLAG_RTSENA)
10630 rateflags |= WMI_TLV_FLAG_RTSENA;
10631 if (param->rate_flags & WMI_HOST_FLAG_CTSENA)
10632 rateflags |= WMI_TLV_FLAG_CTSENA;
10633 if (param->rate_flags & WMI_HOST_FLAG_SGI)
10634 rateflags |= WMI_TLV_FLAG_SGI;
10635
10636 return rateflags;
10637}
10638
10639/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010640 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
10641 * info to fw
10642 * @wmi_handle: wmi handle
10643 * @param: pointer to hold packet power info param
10644 *
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010645 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
Sathish Kumar497bef42017-03-01 14:02:36 +053010646 */
10647static QDF_STATUS
10648send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
10649 struct packet_power_info_params *param)
10650{
10651 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
10652 wmi_buf_t wmibuf;
10653 uint8_t *buf_ptr;
10654 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
10655
10656 wmibuf = wmi_buf_alloc(wmi_handle, len);
10657 if (wmibuf == NULL)
10658 return QDF_STATUS_E_NOMEM;
10659
10660 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
10661
10662 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
10663 WMITLV_SET_HDR(&cmd->tlv_header,
10664 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
10665 WMITLV_GET_STRUCT_TLVLEN(
10666 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010667 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10668 param->pdev_id);
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010669 cmd->rate_flags = convert_to_power_info_rate_flags(param);
Sathish Kumar497bef42017-03-01 14:02:36 +053010670 cmd->nss = param->nss;
10671 cmd->preamble = param->preamble;
10672 cmd->hw_rate = param->hw_rate;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053010673
10674 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x,"
10675 "rate_flags: 0x%x, nss: %d, preamble: %d, hw_rate: %d\n",
10676 __func__, __LINE__, WMI_PDEV_GET_TPC_CMDID, *((u_int32_t *)cmd),
10677 cmd->rate_flags, cmd->nss, cmd->preamble, cmd->hw_rate);
10678
Sathish Kumar497bef42017-03-01 14:02:36 +053010679 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
10680 WMI_PDEV_GET_TPC_CMDID)) {
10681 WMI_LOGE(FL("Failed to get tpc command\n"));
10682 wmi_buf_free(wmibuf);
10683 return QDF_STATUS_E_FAILURE;
10684 }
10685
10686 return QDF_STATUS_SUCCESS;
10687}
10688
10689/**
10690 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
10691 * @wmi_handle: wmi handle
10692 * @param: pointer to hold config ratemask params
10693 *
10694 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10695 */
10696static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
10697 struct config_ratemask_params *param)
10698{
10699 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
10700 wmi_buf_t buf;
10701 int32_t len = sizeof(*cmd);
10702
10703 buf = wmi_buf_alloc(wmi_handle, len);
10704 if (!buf) {
10705 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10706 return QDF_STATUS_E_FAILURE;
10707 }
10708 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
10709 WMITLV_SET_HDR(&cmd->tlv_header,
10710 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
10711 WMITLV_GET_STRUCT_TLVLEN(
10712 wmi_vdev_config_ratemask_cmd_fixed_param));
10713 cmd->vdev_id = param->vdev_id;
10714 cmd->type = param->type;
10715 cmd->mask_lower32 = param->lower32;
10716 cmd->mask_higher32 = param->higher32;
10717 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
10718 param->vdev_id, param->type, param->lower32, param->higher32);
10719
10720 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10721 WMI_VDEV_RATEMASK_CMDID)) {
10722 WMI_LOGE("Seting vdev ratemask failed\n");
10723 wmi_buf_free(buf);
10724 return QDF_STATUS_E_FAILURE;
10725 }
10726
10727 return QDF_STATUS_SUCCESS;
10728}
10729
10730/**
Sathish Kumar6011c742017-11-08 14:49:58 +053010731 * copy_custom_aggr_bitmap() - copies host side bitmap using FW APIs
10732 * @param: param sent from the host side
10733 * @cmd: param to be sent to the fw side
10734 */
10735static inline void copy_custom_aggr_bitmap(
10736 struct set_custom_aggr_size_params *param,
10737 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd)
10738{
10739 WMI_VDEV_CUSTOM_AGGR_AC_SET(cmd->enable_bitmap,
10740 param->ac);
10741 WMI_VDEV_CUSTOM_AGGR_TYPE_SET(cmd->enable_bitmap,
10742 param->aggr_type);
10743 WMI_VDEV_CUSTOM_TX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10744 param->tx_aggr_size_disable);
10745 WMI_VDEV_CUSTOM_RX_AGGR_SZ_DIS_SET(cmd->enable_bitmap,
10746 param->rx_aggr_size_disable);
10747 WMI_VDEV_CUSTOM_TX_AC_EN_SET(cmd->enable_bitmap,
10748 param->tx_ac_enable);
10749}
10750
10751/**
10752 * send_vdev_set_custom_aggr_size_cmd_tlv() - custom aggr size param in fw
10753 * @wmi_handle: wmi handle
10754 * @param: pointer to hold custom aggr size params
10755 *
10756 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10757 */
10758static QDF_STATUS send_vdev_set_custom_aggr_size_cmd_tlv(
10759 wmi_unified_t wmi_handle,
10760 struct set_custom_aggr_size_params *param)
10761{
10762 wmi_vdev_set_custom_aggr_size_cmd_fixed_param *cmd;
10763 wmi_buf_t buf;
10764 int32_t len = sizeof(*cmd);
10765
10766 buf = wmi_buf_alloc(wmi_handle, len);
10767 if (!buf) {
10768 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10769 return QDF_STATUS_E_FAILURE;
10770 }
10771 cmd = (wmi_vdev_set_custom_aggr_size_cmd_fixed_param *)
10772 wmi_buf_data(buf);
10773 WMITLV_SET_HDR(&cmd->tlv_header,
10774 WMITLV_TAG_STRUC_wmi_vdev_set_custom_aggr_size_cmd_fixed_param,
10775 WMITLV_GET_STRUCT_TLVLEN(
10776 wmi_vdev_set_custom_aggr_size_cmd_fixed_param));
10777 cmd->vdev_id = param->vdev_id;
10778 cmd->tx_aggr_size = param->tx_aggr_size;
10779 cmd->rx_aggr_size = param->rx_aggr_size;
10780 copy_custom_aggr_bitmap(param, cmd);
10781
10782 WMI_LOGD("Set custom aggr: vdev id=0x%X, tx aggr size=0x%X "
10783 "rx_aggr_size=0x%X access category=0x%X, agg_type=0x%X "
10784 "tx_aggr_size_disable=0x%X, rx_aggr_size_disable=0x%X "
10785 "tx_ac_enable=0x%X\n",
10786 param->vdev_id, param->tx_aggr_size, param->rx_aggr_size,
10787 param->ac, param->aggr_type, param->tx_aggr_size_disable,
10788 param->rx_aggr_size_disable, param->tx_ac_enable);
10789
10790 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10791 WMI_VDEV_SET_CUSTOM_AGGR_SIZE_CMDID)) {
10792 WMI_LOGE("Seting custom aggregation size failed\n");
10793 wmi_buf_free(buf);
10794 return QDF_STATUS_E_FAILURE;
10795 }
10796
10797 return QDF_STATUS_SUCCESS;
10798}
10799
10800/**
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053010801 * send_vdev_set_qdepth_thresh_cmd_tlv() - WMI set qdepth threshold
10802 * @param wmi_handle : handle to WMI.
10803 * @param param : pointer to tx antenna param
10804 *
10805 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10806 */
10807
10808static QDF_STATUS send_vdev_set_qdepth_thresh_cmd_tlv(wmi_unified_t wmi_handle,
10809 struct set_qdepth_thresh_params *param)
10810{
10811 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *cmd;
10812 wmi_msduq_qdepth_thresh_update *cmd_update;
10813 wmi_buf_t buf;
10814 int32_t len = 0;
10815 int i;
10816 uint8_t *buf_ptr;
10817 QDF_STATUS ret;
10818
10819 if (param->num_of_msduq_updates > QDEPTH_THRESH_MAX_UPDATES) {
10820 WMI_LOGE("%s: Invalid Update Count!\n", __func__);
10821 return QDF_STATUS_E_INVAL;
10822 }
10823
10824 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10825 len += (sizeof(wmi_msduq_qdepth_thresh_update) *
10826 param->num_of_msduq_updates);
10827 buf = wmi_buf_alloc(wmi_handle, len);
10828
10829 if (!buf) {
10830 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10831 return QDF_STATUS_E_NOMEM;
10832 }
10833
10834 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10835 cmd = (wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param *)
10836 buf_ptr;
10837
10838 WMITLV_SET_HDR(&cmd->tlv_header,
10839 WMITLV_TAG_STRUC_wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param
10840 , WMITLV_GET_STRUCT_TLVLEN(
10841 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param));
10842
10843 cmd->pdev_id =
10844 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
10845 cmd->vdev_id = param->vdev_id;
10846 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->mac_addr, &cmd->peer_mac_address);
10847 cmd->num_of_msduq_updates = param->num_of_msduq_updates;
10848
10849 buf_ptr += sizeof(
10850 wmi_peer_tid_msduq_qdepth_thresh_update_cmd_fixed_param);
10851 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10852 param->num_of_msduq_updates *
10853 sizeof(wmi_msduq_qdepth_thresh_update));
10854 buf_ptr += WMI_TLV_HDR_SIZE;
10855 cmd_update = (wmi_msduq_qdepth_thresh_update *)buf_ptr;
10856
10857 for (i = 0; i < cmd->num_of_msduq_updates; i++) {
10858 WMITLV_SET_HDR(&cmd_update->tlv_header,
10859 WMITLV_TAG_STRUC_wmi_msduq_qdepth_thresh_update,
10860 WMITLV_GET_STRUCT_TLVLEN(
10861 wmi_msduq_qdepth_thresh_update));
10862 cmd_update->tid_num = param->update_params[i].tid_num;
10863 cmd_update->msduq_update_mask =
10864 param->update_params[i].msduq_update_mask;
10865 cmd_update->qdepth_thresh_value =
10866 param->update_params[i].qdepth_thresh_value;
10867 WMI_LOGD("Set QDepth Threshold: vdev=0x%X pdev=0x%X, tid=0x%X "
10868 "mac_addr_upper4=%X, mac_addr_lower2:%X,"
10869 " update mask=0x%X thresh val=0x%X\n",
10870 cmd->vdev_id, cmd->pdev_id, cmd_update->tid_num,
10871 cmd->peer_mac_address.mac_addr31to0,
10872 cmd->peer_mac_address.mac_addr47to32,
10873 cmd_update->msduq_update_mask,
10874 cmd_update->qdepth_thresh_value);
10875 cmd_update++;
10876 }
10877
10878 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10879 WMI_PEER_TID_MSDUQ_QDEPTH_THRESH_UPDATE_CMDID);
10880
10881 if (ret != 0) {
10882 WMI_LOGE(" %s :WMI Failed\n", __func__);
10883 wmi_buf_free(buf);
10884 }
10885
10886 return ret;
10887}
10888
10889/**
Sathish Kumar497bef42017-03-01 14:02:36 +053010890 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
10891 * @wmi_handle: wmi handle
10892 * @param: pointer to hold vap dscp tid map param
10893 *
10894 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10895 */
10896static QDF_STATUS
10897send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
10898 struct vap_dscp_tid_map_params *param)
10899{
10900 wmi_buf_t buf;
10901 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
10902 int32_t len = sizeof(*cmd);
10903
10904 buf = wmi_buf_alloc(wmi_handle, len);
10905 if (!buf) {
10906 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10907 return QDF_STATUS_E_FAILURE;
10908 }
10909
10910 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
10911 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
Vivekc5823092018-03-22 23:27:21 +053010912 sizeof(uint32_t) * WMI_DSCP_MAP_MAX);
Sathish Kumar497bef42017-03-01 14:02:36 +053010913
10914 cmd->vdev_id = param->vdev_id;
10915 cmd->enable_override = 0;
10916
10917 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
10918 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10919 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
10920 WMI_LOGE("Failed to set dscp cmd\n");
10921 wmi_buf_free(buf);
10922 return QDF_STATUS_E_FAILURE;
10923 }
10924
10925 return QDF_STATUS_SUCCESS;
10926}
10927
10928/**
10929 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
10930 * @wmi_handle: wmi handle
10931 * @macaddr: vdev mac address
10932 * @param: pointer to hold neigbour rx param
10933 *
10934 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10935 */
10936static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
10937 uint8_t macaddr[IEEE80211_ADDR_LEN],
10938 struct set_neighbour_rx_params *param)
10939{
10940 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
10941 wmi_buf_t buf;
10942 int32_t len = sizeof(*cmd);
10943
10944 buf = wmi_buf_alloc(wmi_handle, len);
10945 if (!buf) {
10946 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10947 return QDF_STATUS_E_FAILURE;
10948 }
10949 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
10950 WMITLV_SET_HDR(&cmd->tlv_header,
10951 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10952 WMITLV_GET_STRUCT_TLVLEN(
10953 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10954 cmd->vdev_id = param->vdev_id;
10955 cmd->bssid_idx = param->idx;
10956 cmd->action = param->action;
10957 cmd->type = param->type;
10958 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10959 cmd->flag = 0;
10960
10961 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10962 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10963 WMI_LOGE("Failed to set neighbour rx param\n");
10964 wmi_buf_free(buf);
10965 return QDF_STATUS_E_FAILURE;
10966 }
10967
10968 return QDF_STATUS_SUCCESS;
10969}
10970
10971/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010972 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010973 * @param wmi_handle : handle to WMI.
10974 * @param macaddr : vdev mac address
10975 * @param param : pointer to tx antenna param
10976 *
10977 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10978 */
10979static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10980 uint8_t macaddr[IEEE80211_ADDR_LEN],
10981 struct smart_ant_tx_ant_params *param)
10982{
10983 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10984 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10985 wmi_buf_t buf;
10986 int32_t len = 0;
10987 int i;
10988 uint8_t *buf_ptr;
10989 QDF_STATUS ret;
10990
10991 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10992 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10993 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10994 buf = wmi_buf_alloc(wmi_handle, len);
10995
10996 if (!buf) {
10997 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10998 return QDF_STATUS_E_NOMEM;
10999 }
11000
11001 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11002 qdf_mem_zero(buf_ptr, len);
11003 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
11004
11005 WMITLV_SET_HDR(&cmd->tlv_header,
11006 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
11007 WMITLV_GET_STRUCT_TLVLEN(
11008 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
11009
11010 cmd->vdev_id = param->vdev_id;
11011 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11012
11013 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
11014 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11015 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
11016 buf_ptr += WMI_TLV_HDR_SIZE;
11017 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
11018
11019 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
11020 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
11021 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
11022 WMITLV_GET_STRUCT_TLVLEN(
11023 wmi_peer_smart_ant_set_tx_antenna_series));
11024 ant_tx_series->antenna_series = param->antenna_array[i];
11025 ant_tx_series++;
11026 }
11027
11028 ret = wmi_unified_cmd_send(wmi_handle,
11029 buf,
11030 len,
11031 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
11032
11033 if (ret != 0) {
11034 WMI_LOGE(" %s :WMI Failed\n", __func__);
11035 wmi_buf_free(buf);
11036 }
11037
11038 return ret;
11039}
11040
Sathish Kumar02c3b542017-02-22 17:24:45 +053011041/**
11042 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
11043 * @wmi_handle: wmi handle
11044 * @param: pointer to hold ant switch tbl param
11045 *
11046 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11047 */
11048static QDF_STATUS
11049send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
11050 struct ant_switch_tbl_params *param)
11051{
11052 uint8_t len;
11053 wmi_buf_t buf;
11054 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
11055 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
11056 uint8_t *buf_ptr;
11057
11058 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11059 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
11060 buf = wmi_buf_alloc(wmi_handle, len);
11061
11062 if (!buf) {
11063 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11064 return QDF_STATUS_E_NOMEM;
11065 }
11066
11067 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11068 qdf_mem_zero(buf_ptr, len);
11069 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
11070
11071 WMITLV_SET_HDR(&cmd->tlv_header,
11072 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
11073 WMITLV_GET_STRUCT_TLVLEN(
11074 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
11075
11076 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
11077 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011078 cmd->mac_id =
11079 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011080
11081 /* TLV indicating array of structures to follow */
11082 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
11083 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11084 sizeof(wmi_pdev_set_ant_ctrl_chain));
11085 buf_ptr += WMI_TLV_HDR_SIZE;
11086 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
11087
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011088 ctrl_chain->pdev_id =
11089 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011090 ctrl_chain->antCtrlChain = param->antCtrlChain;
11091
11092 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11093 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
11094 wmi_buf_free(buf);
11095 return QDF_STATUS_E_FAILURE;
11096 }
11097
11098 return QDF_STATUS_SUCCESS;
11099}
11100
11101/**
11102 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
11103 * training information function
11104 * @param wmi_handle : handle to WMI.
11105 * @macaddr : vdev mac address
11106 * @param param : pointer to tx antenna param
11107 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11108 */
11109static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
11110 wmi_unified_t wmi_handle,
11111 uint8_t macaddr[IEEE80211_ADDR_LEN],
11112 struct smart_ant_training_info_params *param)
11113{
11114 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
11115 wmi_peer_smart_ant_set_train_antenna_param *train_param;
11116 wmi_buf_t buf;
11117 uint8_t *buf_ptr;
11118 int32_t len = 0;
11119 QDF_STATUS ret;
11120 int loop;
11121
11122 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11123 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
11124 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
11125 buf = wmi_buf_alloc(wmi_handle, len);
11126
11127 if (!buf) {
11128 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11129 return QDF_STATUS_E_NOMEM;
11130 }
11131
11132 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11133 qdf_mem_zero(buf_ptr, len);
11134 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
11135
11136 WMITLV_SET_HDR(&cmd->tlv_header,
11137 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
11138 WMITLV_GET_STRUCT_TLVLEN(
11139 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
11140
11141 cmd->vdev_id = param->vdev_id;
11142 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11143 cmd->num_pkts = param->numpkts;
11144
11145 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
11146 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11147 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
11148 WMI_SMART_ANT_MAX_RATE_SERIES);
11149
11150 buf_ptr += WMI_TLV_HDR_SIZE;
11151 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
11152
11153 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
11154 WMITLV_SET_HDR(&train_param->tlv_header,
11155 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
11156 WMITLV_GET_STRUCT_TLVLEN(
11157 wmi_peer_smart_ant_set_train_antenna_param));
11158 train_param->train_rate_series = param->rate_array[loop];
11159 train_param->train_antenna_series = param->antenna_array[loop];
11160 train_param->rc_flags = 0;
11161 WMI_LOGI(FL("Series number:%d\n"), loop);
11162 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
11163 train_param->train_rate_series,
11164 train_param->train_antenna_series);
11165 train_param++;
11166 }
11167
11168 ret = wmi_unified_cmd_send(wmi_handle,
11169 buf,
11170 len,
11171 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
11172
11173 if (ret != 0) {
11174 WMI_LOGE(" %s :WMI Failed\n", __func__);
11175 wmi_buf_free(buf);
11176 return QDF_STATUS_E_FAILURE;
11177 }
11178
11179 return ret;
11180}
11181
11182/**
11183 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
11184 * configuration function
11185 * @param wmi_handle : handle to WMI.
11186 * @macaddr : vdev mad address
11187 * @param param : pointer to tx antenna param
11188 *
11189 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11190 */
11191static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
11192 wmi_unified_t wmi_handle,
11193 uint8_t macaddr[IEEE80211_ADDR_LEN],
11194 struct smart_ant_node_config_params *param)
11195{
11196 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
11197 wmi_buf_t buf;
11198 uint8_t *buf_ptr;
11199 int32_t len = 0, args_tlv_len;
11200 int ret;
11201 int i = 0;
Vivekc5823092018-03-22 23:27:21 +053011202 uint32_t *node_config_args;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011203
Vivekc5823092018-03-22 23:27:21 +053011204 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(uint32_t);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011205 len = sizeof(*cmd) + args_tlv_len;
11206
Yuanyuan Liu977f53b2018-03-28 18:05:30 -070011207 if (param->args_count == 0) {
Sathish Kumar02c3b542017-02-22 17:24:45 +053011208 WMI_LOGE("%s: Can't send a command with %d arguments\n",
11209 __func__, param->args_count);
11210 return QDF_STATUS_E_FAILURE;
11211 }
11212
11213 buf = wmi_buf_alloc(wmi_handle, len);
11214 if (!buf) {
11215 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11216 return QDF_STATUS_E_NOMEM;
11217 }
11218
11219 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
11220 wmi_buf_data(buf);
11221 buf_ptr = (uint8_t *)cmd;
11222 WMITLV_SET_HDR(&cmd->tlv_header,
11223 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
11224 WMITLV_GET_STRUCT_TLVLEN(
11225 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
11226 cmd->vdev_id = param->vdev_id;
11227 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11228 cmd->cmd_id = param->cmd_id;
11229 cmd->args_count = param->args_count;
11230 buf_ptr += sizeof(
11231 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
11232 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053011233 (cmd->args_count * sizeof(uint32_t)));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011234 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053011235 node_config_args = (uint32_t *)buf_ptr;
Sathish Kumar02c3b542017-02-22 17:24:45 +053011236
11237 for (i = 0; i < param->args_count; i++) {
11238 node_config_args[i] = param->args_arr[i];
11239 WMI_LOGI("%d", param->args_arr[i]);
11240 }
11241
11242 ret = wmi_unified_cmd_send(wmi_handle,
11243 buf,
11244 len,
11245 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
11246
11247 if (ret != 0) {
11248 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
11249 __func__, param->cmd_id, macaddr[0],
11250 macaddr[1], macaddr[2], macaddr[3],
11251 macaddr[4], macaddr[5], ret);
11252 wmi_buf_free(buf);
11253 }
11254
11255 return ret;
11256}
11257
11258/**
11259 * send_set_atf_cmd_tlv() - send set atf command to fw
11260 * @wmi_handle: wmi handle
11261 * @param: pointer to set atf param
11262 *
11263 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11264 */
11265static QDF_STATUS
11266send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
11267 struct set_atf_params *param)
11268{
11269 wmi_atf_peer_info *peer_info;
11270 wmi_peer_atf_request_fixed_param *cmd;
11271 wmi_buf_t buf;
11272 uint8_t *buf_ptr;
11273 int i;
11274 int32_t len = 0;
11275 QDF_STATUS retval;
11276
11277 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11278 len += param->num_peers * sizeof(wmi_atf_peer_info);
11279 buf = wmi_buf_alloc(wmi_handle, len);
11280 if (!buf) {
11281 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11282 return QDF_STATUS_E_FAILURE;
11283 }
11284 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11285 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
11286 WMITLV_SET_HDR(&cmd->tlv_header,
11287 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
11288 WMITLV_GET_STRUCT_TLVLEN(
11289 wmi_peer_atf_request_fixed_param));
11290 cmd->num_peers = param->num_peers;
11291
11292 buf_ptr += sizeof(*cmd);
11293 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11294 sizeof(wmi_atf_peer_info) *
11295 cmd->num_peers);
11296 buf_ptr += WMI_TLV_HDR_SIZE;
11297 peer_info = (wmi_atf_peer_info *)buf_ptr;
11298
11299 for (i = 0; i < cmd->num_peers; i++) {
11300 WMITLV_SET_HDR(&peer_info->tlv_header,
11301 WMITLV_TAG_STRUC_wmi_atf_peer_info,
11302 WMITLV_GET_STRUCT_TLVLEN(
11303 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011304 qdf_mem_copy(&(peer_info->peer_macaddr),
11305 &(param->peer_info[i].peer_macaddr),
11306 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053011307 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011308 peer_info->vdev_id = param->peer_info[i].vdev_id;
11309 peer_info->pdev_id =
11310 wmi_handle->ops->convert_pdev_id_host_to_target(
11311 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053011312 /*
11313 * TLV definition for peer atf request fixed param combines
11314 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
11315 * stats and atf extension stats as two different
11316 * implementations.
11317 * Need to discuss with FW on this.
11318 *
11319 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
11320 * peer_info->atf_units_reserved =
11321 * param->peer_ext_info[i].atf_index_reserved;
11322 */
11323 peer_info++;
11324 }
11325
11326 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11327 WMI_PEER_ATF_REQUEST_CMDID);
11328
11329 if (retval != QDF_STATUS_SUCCESS) {
11330 WMI_LOGE("%s : WMI Failed\n", __func__);
11331 wmi_buf_free(buf);
11332 }
11333
11334 return retval;
11335}
11336
11337/**
11338 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
11339 * @wmi_handle: wmi handle
11340 * @param: pointer to hold fwtest param
11341 *
11342 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11343 */
11344static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
11345 struct set_fwtest_params *param)
11346{
11347 wmi_fwtest_set_param_cmd_fixed_param *cmd;
11348 wmi_buf_t buf;
11349 int32_t len = sizeof(*cmd);
11350
11351 buf = wmi_buf_alloc(wmi_handle, len);
11352
11353 if (!buf) {
11354 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11355 return QDF_STATUS_E_FAILURE;
11356 }
11357
11358 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
11359 WMITLV_SET_HDR(&cmd->tlv_header,
11360 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
11361 WMITLV_GET_STRUCT_TLVLEN(
11362 wmi_fwtest_set_param_cmd_fixed_param));
11363 cmd->param_id = param->arg;
11364 cmd->param_value = param->value;
11365
11366 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
11367 WMI_LOGE("Setting FW test param failed\n");
11368 wmi_buf_free(buf);
11369 return QDF_STATUS_E_FAILURE;
11370 }
11371
11372 return QDF_STATUS_SUCCESS;
11373}
11374
11375/**
11376 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
11377 * @wmi_handle: wmi handle
11378 * @param: pointer to qboost params
11379 * @macaddr: vdev mac address
11380 *
11381 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11382 */
11383static QDF_STATUS
11384send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
11385 uint8_t macaddr[IEEE80211_ADDR_LEN],
11386 struct set_qboost_params *param)
11387{
11388 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
11389 wmi_buf_t buf;
11390 int32_t len;
11391 QDF_STATUS ret;
11392
11393 len = sizeof(*cmd);
11394
11395 buf = wmi_buf_alloc(wmi_handle, len);
11396 if (!buf) {
11397 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11398 return QDF_STATUS_E_FAILURE;
11399 }
11400
11401 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
11402 WMITLV_SET_HDR(&cmd->tlv_header,
11403 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
11404 WMITLV_GET_STRUCT_TLVLEN(
11405 WMI_QBOOST_CFG_CMD_fixed_param));
11406 cmd->vdev_id = param->vdev_id;
11407 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
11408 cmd->qb_enable = param->value;
11409
11410 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11411 WMI_QBOOST_CFG_CMDID);
11412
11413 if (ret != 0) {
11414 WMI_LOGE("Setting qboost cmd failed\n");
11415 wmi_buf_free(buf);
11416 }
11417
11418 return ret;
11419}
11420
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011421/**
11422 * send_gpio_config_cmd_tlv() - send gpio config to fw
11423 * @wmi_handle: wmi handle
11424 * @param: pointer to hold gpio config param
11425 *
11426 * Return: 0 for success or error code
11427 */
11428static QDF_STATUS
11429send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
11430 struct gpio_config_params *param)
11431{
11432 wmi_gpio_config_cmd_fixed_param *cmd;
11433 wmi_buf_t buf;
11434 int32_t len;
11435 QDF_STATUS ret;
11436
11437 len = sizeof(*cmd);
11438
11439 /* Sanity Checks */
11440 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
11441 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
11442 return QDF_STATUS_E_FAILURE;
11443 }
11444
11445 buf = wmi_buf_alloc(wmi_handle, len);
11446 if (!buf) {
11447 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11448 return QDF_STATUS_E_FAILURE;
11449 }
11450
11451 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
11452 WMITLV_SET_HDR(&cmd->tlv_header,
11453 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
11454 WMITLV_GET_STRUCT_TLVLEN(
11455 wmi_gpio_config_cmd_fixed_param));
11456 cmd->gpio_num = param->gpio_num;
11457 cmd->input = param->input;
11458 cmd->pull_type = param->pull_type;
11459 cmd->intr_mode = param->intr_mode;
11460
11461 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11462 WMI_GPIO_CONFIG_CMDID);
11463
11464 if (ret != 0) {
11465 WMI_LOGE("Sending GPIO config cmd failed\n");
11466 wmi_buf_free(buf);
11467 }
11468
11469 return ret;
11470}
11471
11472/**
11473 * send_gpio_output_cmd_tlv() - send gpio output to fw
11474 * @wmi_handle: wmi handle
11475 * @param: pointer to hold gpio output param
11476 *
11477 * Return: 0 for success or error code
11478 */
11479static QDF_STATUS
11480send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
11481 struct gpio_output_params *param)
11482{
11483 wmi_gpio_output_cmd_fixed_param *cmd;
11484 wmi_buf_t buf;
11485 int32_t len;
11486 QDF_STATUS ret;
11487
11488 len = sizeof(*cmd);
11489
11490 buf = wmi_buf_alloc(wmi_handle, len);
11491 if (!buf) {
11492 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11493 return QDF_STATUS_E_FAILURE;
11494 }
11495
11496 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
11497 WMITLV_SET_HDR(&cmd->tlv_header,
11498 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
11499 WMITLV_GET_STRUCT_TLVLEN(
11500 wmi_gpio_output_cmd_fixed_param));
11501 cmd->gpio_num = param->gpio_num;
11502 cmd->set = param->set;
11503
11504 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11505 WMI_GPIO_OUTPUT_CMDID);
11506
11507 if (ret != 0) {
11508 WMI_LOGE("Sending GPIO output cmd failed\n");
11509 wmi_buf_free(buf);
11510 }
11511
11512 return ret;
11513
11514}
11515
11516/**
11517 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
11518 *
11519 * @param wmi_handle : handle to WMI.
11520 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11521 */
11522static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
11523{
11524 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
11525 wmi_buf_t buf;
11526 QDF_STATUS ret;
11527 int32_t len;
11528
11529 len = sizeof(*cmd);
11530
11531 buf = wmi_buf_alloc(wmi_handle, len);
11532 if (!buf) {
11533 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11534 return QDF_STATUS_E_FAILURE;
11535 }
11536
11537 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
11538 WMITLV_SET_HDR(&cmd->tlv_header,
11539 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
11540 WMITLV_GET_STRUCT_TLVLEN(
11541 wmi_pdev_dfs_disable_cmd_fixed_param));
11542 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011543 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11544 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011545
11546 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11547 WMI_PDEV_DFS_DISABLE_CMDID);
11548
11549 if (ret != 0) {
11550 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
11551 wmi_buf_free(buf);
11552 }
11553
11554 return ret;
11555}
11556
11557/**
11558 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
11559 *
11560 * @param wmi_handle : handle to WMI.
11561 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11562 */
11563static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
11564{
11565 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
11566 wmi_buf_t buf;
11567 QDF_STATUS ret;
11568 int32_t len;
11569
11570 len = sizeof(*cmd);
11571
11572 buf = wmi_buf_alloc(wmi_handle, len);
11573 if (!buf) {
11574 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11575 return QDF_STATUS_E_FAILURE;
11576 }
11577
11578 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
11579 WMITLV_SET_HDR(&cmd->tlv_header,
11580 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
11581 WMITLV_GET_STRUCT_TLVLEN(
11582 wmi_pdev_dfs_enable_cmd_fixed_param));
11583 /* Reserved for future use */
11584 cmd->reserved0 = 0;
11585
11586 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11587 WMI_PDEV_DFS_ENABLE_CMDID);
11588
11589 if (ret != 0) {
11590 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
11591 wmi_buf_free(buf);
11592 }
11593
11594 return ret;
11595}
11596
11597/**
Sathish Kumar0ff69e42017-11-02 10:44:39 +053011598 * send_periodic_chan_stats_config_cmd_tlv() - send periodic chan stats cmd
11599 * to fw
11600 * @wmi_handle: wmi handle
11601 * @param: pointer to hold periodic chan stats param
11602 *
11603 * Return: 0 for success or error code
11604 */
11605static QDF_STATUS
11606send_periodic_chan_stats_config_cmd_tlv(wmi_unified_t wmi_handle,
11607 struct periodic_chan_stats_params *param)
11608{
11609 wmi_set_periodic_channel_stats_config_fixed_param *cmd;
11610 wmi_buf_t buf;
11611 QDF_STATUS ret;
11612 int32_t len;
11613
11614 len = sizeof(*cmd);
11615
11616 buf = wmi_buf_alloc(wmi_handle, len);
11617 if (!buf) {
11618 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11619 return QDF_STATUS_E_FAILURE;
11620 }
11621
11622 cmd = (wmi_set_periodic_channel_stats_config_fixed_param *)
11623 wmi_buf_data(buf);
11624 WMITLV_SET_HDR(&cmd->tlv_header,
11625 WMITLV_TAG_STRUC_wmi_set_periodic_channel_stats_config_fixed_param,
11626 WMITLV_GET_STRUCT_TLVLEN(
11627 wmi_set_periodic_channel_stats_config_fixed_param));
11628 cmd->enable = param->enable;
11629 cmd->stats_period = param->stats_period;
11630 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11631 param->pdev_id);
11632
11633 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
11634 WMI_SET_PERIODIC_CHANNEL_STATS_CONFIG_CMDID);
11635
11636 if (ret != 0) {
11637 WMI_LOGE("Sending periodic chan stats config failed");
11638 wmi_buf_free(buf);
11639 }
11640
11641 return ret;
11642}
11643
11644/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011645 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
11646 * @wmi_handle: wmi handle
nobeljf74583b2018-01-25 16:35:36 -080011647 * @mac_id: radio context
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011648 *
11649 * Return: 0 for success or error code
11650 */
11651static QDF_STATUS
nobeljf74583b2018-01-25 16:35:36 -080011652send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle, uint8_t mac_id)
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011653{
11654 wmi_buf_t buf;
11655 QDF_STATUS ret;
nobeljf74583b2018-01-25 16:35:36 -080011656 wmi_pdev_get_nfcal_power_fixed_param *cmd;
11657 int32_t len = sizeof(*cmd);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011658
nobeljf74583b2018-01-25 16:35:36 -080011659 buf = wmi_buf_alloc(wmi_handle, len);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011660 if (buf == NULL)
11661 return QDF_STATUS_E_NOMEM;
11662
nobeljf74583b2018-01-25 16:35:36 -080011663 cmd = (wmi_pdev_get_nfcal_power_fixed_param *)wmi_buf_data(buf);
11664 WMITLV_SET_HDR(&cmd->tlv_header,
11665 WMITLV_TAG_STRUC_wmi_pdev_get_nfcal_power_fixed_param,
11666 WMITLV_GET_STRUCT_TLVLEN
11667 (wmi_pdev_get_nfcal_power_fixed_param));
11668 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
11669
11670 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053011671 WMI_PDEV_GET_NFCAL_POWER_CMDID);
11672 if (ret != 0) {
11673 WMI_LOGE("Sending get nfcal power cmd failed\n");
11674 wmi_buf_free(buf);
11675 }
11676
11677 return ret;
11678}
11679
11680/**
11681 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
11682 * @wmi_handle: wmi handle
11683 * @param: pointer to ht ie param
11684 *
11685 * Return: 0 for success or error code
11686 */
11687static QDF_STATUS
11688send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11689 struct ht_ie_params *param)
11690{
11691 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
11692 wmi_buf_t buf;
11693 QDF_STATUS ret;
11694 int32_t len;
11695 uint8_t *buf_ptr;
11696
11697 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11698 roundup(param->ie_len, sizeof(uint32_t));
11699
11700 buf = wmi_buf_alloc(wmi_handle, len);
11701 if (!buf) {
11702 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11703 return QDF_STATUS_E_FAILURE;
11704 }
11705
11706 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11707 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
11708 WMITLV_SET_HDR(&cmd->tlv_header,
11709 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
11710 WMITLV_GET_STRUCT_TLVLEN(
11711 wmi_pdev_set_ht_ie_cmd_fixed_param));
11712 cmd->reserved0 = 0;
11713 cmd->ie_len = param->ie_len;
11714 cmd->tx_streams = param->tx_streams;
11715 cmd->rx_streams = param->rx_streams;
11716
11717 buf_ptr += sizeof(*cmd);
11718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11719 buf_ptr += WMI_TLV_HDR_SIZE;
11720 if (param->ie_len)
11721 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11722 cmd->ie_len);
11723
11724 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11725 WMI_PDEV_SET_HT_CAP_IE_CMDID);
11726
11727 if (ret != 0) {
11728 WMI_LOGE("Sending set ht ie cmd failed\n");
11729 wmi_buf_free(buf);
11730 }
11731
11732 return ret;
11733}
11734
11735/**
11736 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
11737 * @wmi_handle: wmi handle
11738 * @param: pointer to vht ie param
11739 *
11740 * Return: 0 for success or error code
11741 */
11742static QDF_STATUS
11743send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
11744 struct vht_ie_params *param)
11745{
11746 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
11747 wmi_buf_t buf;
11748 QDF_STATUS ret;
11749 int32_t len;
11750 uint8_t *buf_ptr;
11751
11752 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11753 roundup(param->ie_len, sizeof(uint32_t));
11754
11755 buf = wmi_buf_alloc(wmi_handle, len);
11756 if (!buf) {
11757 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11758 return QDF_STATUS_E_FAILURE;
11759 }
11760
11761 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11762 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
11763 WMITLV_SET_HDR(&cmd->tlv_header,
11764 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
11765 WMITLV_GET_STRUCT_TLVLEN(
11766 wmi_pdev_set_vht_ie_cmd_fixed_param));
11767 cmd->reserved0 = 0;
11768 cmd->ie_len = param->ie_len;
11769 cmd->tx_streams = param->tx_streams;
11770 cmd->rx_streams = param->rx_streams;
11771
11772 buf_ptr += sizeof(*cmd);
11773 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
11774 buf_ptr += WMI_TLV_HDR_SIZE;
11775 if (param->ie_len)
11776 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
11777 cmd->ie_len);
11778
11779 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11780 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
11781
11782 if (ret != 0) {
11783 WMI_LOGE("Sending set vht ie cmd failed\n");
11784 wmi_buf_free(buf);
11785 }
11786
11787 return ret;
11788}
11789
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011790/**
11791 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
11792 * @wmi_handle: wmi handle
11793 * @param: pointer to quiet mode params
11794 *
11795 * Return: 0 for success or error code
11796 */
11797static QDF_STATUS
11798send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
11799 struct set_quiet_mode_params *param)
11800{
11801 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
11802 wmi_buf_t buf;
11803 QDF_STATUS ret;
11804 int32_t len;
11805
11806 len = sizeof(*quiet_cmd);
11807 buf = wmi_buf_alloc(wmi_handle, len);
11808 if (!buf) {
11809 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11810 return QDF_STATUS_E_FAILURE;
11811 }
11812
11813 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11814 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
11815 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
11816 WMITLV_GET_STRUCT_TLVLEN(
11817 wmi_pdev_set_quiet_cmd_fixed_param));
11818 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
11819 quiet_cmd->enabled = param->enabled;
11820 quiet_cmd->period = (param->period)*(param->intval);
11821 quiet_cmd->duration = param->duration;
11822 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011823 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11824 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011825
11826 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11827 WMI_PDEV_SET_QUIET_MODE_CMDID);
11828
11829 if (ret != 0) {
11830 WMI_LOGE("Sending set quiet cmd failed\n");
11831 wmi_buf_free(buf);
11832 }
11833
11834 return ret;
11835}
11836
11837/**
11838 * send_set_bwf_cmd_tlv() - send set bwf command to fw
11839 * @wmi_handle: wmi handle
11840 * @param: pointer to set bwf param
11841 *
11842 * Return: 0 for success or error code
11843 */
11844static QDF_STATUS
11845send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
11846 struct set_bwf_params *param)
11847{
11848 wmi_bwf_peer_info *peer_info;
11849 wmi_peer_bwf_request_fixed_param *cmd;
11850 wmi_buf_t buf;
11851 QDF_STATUS retval;
11852 int32_t len;
11853 uint8_t *buf_ptr;
11854 int i;
11855
11856 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
11857 len += param->num_peers * sizeof(wmi_bwf_peer_info);
11858 buf = wmi_buf_alloc(wmi_handle, len);
11859 if (!buf) {
11860 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
11861 return QDF_STATUS_E_FAILURE;
11862 }
11863 buf_ptr = (uint8_t *)wmi_buf_data(buf);
11864 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
11865 WMITLV_SET_HDR(&cmd->tlv_header,
11866 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
11867 WMITLV_GET_STRUCT_TLVLEN(
11868 wmi_peer_bwf_request_fixed_param));
11869 cmd->num_peers = param->num_peers;
11870
11871 buf_ptr += sizeof(*cmd);
11872 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11873 sizeof(wmi_bwf_peer_info) *
11874 cmd->num_peers);
11875 buf_ptr += WMI_TLV_HDR_SIZE;
11876 peer_info = (wmi_bwf_peer_info *)buf_ptr;
11877
11878 for (i = 0; i < cmd->num_peers; i++) {
11879 WMITLV_SET_HDR(&peer_info->tlv_header,
11880 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
11881 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
11882 peer_info->bwf_guaranteed_bandwidth =
11883 param->peer_info[i].throughput;
11884 peer_info->bwf_max_airtime =
11885 param->peer_info[i].max_airtime;
11886 peer_info->bwf_peer_priority =
11887 param->peer_info[i].priority;
11888 qdf_mem_copy(&peer_info->peer_macaddr,
11889 &param->peer_info[i].peer_macaddr,
11890 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011891 peer_info->vdev_id =
11892 param->peer_info[i].vdev_id;
11893 peer_info->pdev_id =
11894 wmi_handle->ops->convert_pdev_id_host_to_target(
11895 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011896 peer_info++;
11897 }
11898
11899 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11900 WMI_PEER_BWF_REQUEST_CMDID);
11901
11902 if (retval != QDF_STATUS_SUCCESS) {
11903 WMI_LOGE("%s : WMI Failed\n", __func__);
11904 wmi_buf_free(buf);
11905 }
11906
11907 return retval;
11908}
11909
11910/**
11911 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
11912 * @wmi_handle: wmi handle
11913 * @param: pointer to hold mcast update param
11914 *
11915 * Return: 0 for success or error code
11916 */
11917static QDF_STATUS
11918send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
11919 struct mcast_group_update_params *param)
11920{
11921 wmi_peer_mcast_group_cmd_fixed_param *cmd;
11922 wmi_buf_t buf;
11923 QDF_STATUS ret;
11924 int32_t len;
11925 int offset = 0;
11926 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
11927
11928 len = sizeof(*cmd);
11929 buf = wmi_buf_alloc(wmi_handle, len);
11930 if (!buf) {
11931 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11932 return QDF_STATUS_E_FAILURE;
11933 }
11934 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
11935 WMITLV_SET_HDR(&cmd->tlv_header,
11936 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
11937 WMITLV_GET_STRUCT_TLVLEN(
11938 wmi_peer_mcast_group_cmd_fixed_param));
11939 /* confirm the buffer is 4-byte aligned */
11940 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
11941 qdf_mem_zero(cmd, sizeof(*cmd));
11942
11943 cmd->vdev_id = param->vap_id;
11944 /* construct the message assuming our endianness matches the target */
11945 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
11946 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
11947 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
11948 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
11949 if (param->is_action_delete)
11950 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
11951
11952 if (param->is_mcast_addr_len)
11953 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
11954
11955 if (param->is_filter_mode_snoop)
11956 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
11957
11958 /* unicast address spec only applies for non-wildcard cases */
11959 if (!param->wildcard && param->ucast_mac_addr) {
11960 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
11961 &cmd->ucast_mac_addr);
11962 }
Amar Singhal5593c902017-10-03 13:00:29 -070011963
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011964 if (param->mcast_ip_addr) {
11965 QDF_ASSERT(param->mcast_ip_addr_bytes <=
11966 sizeof(cmd->mcast_ip_addr));
11967 offset = sizeof(cmd->mcast_ip_addr) -
11968 param->mcast_ip_addr_bytes;
11969 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
11970 param->mcast_ip_addr,
11971 param->mcast_ip_addr_bytes);
11972 }
11973 if (!param->mask)
11974 param->mask = &dummymask[0];
11975
11976 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
11977 param->mask,
11978 param->mcast_ip_addr_bytes);
11979
11980 if (param->srcs && param->nsrcs) {
11981 cmd->num_filter_addr = param->nsrcs;
11982 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
11983 sizeof(cmd->filter_addr));
11984
11985 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
11986 param->nsrcs * param->mcast_ip_addr_bytes);
11987 }
11988
11989 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11990 WMI_PEER_MCAST_GROUP_CMDID);
11991
11992 if (ret != QDF_STATUS_SUCCESS) {
11993 WMI_LOGE("%s : WMI Failed\n", __func__);
11994 wmi_buf_free(buf);
11995 }
11996
11997 return ret;
11998}
11999
12000/**
12001 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
12002 * command to fw
12003 * @wmi_handle: wmi handle
12004 * @param: pointer to hold spectral config parameter
12005 *
12006 * Return: 0 for success or error code
12007 */
12008static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
12009 struct vdev_spectral_configure_params *param)
12010{
12011 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
12012 wmi_buf_t buf;
12013 QDF_STATUS ret;
12014 int32_t len;
12015
12016 len = sizeof(*cmd);
12017 buf = wmi_buf_alloc(wmi_handle, len);
12018 if (!buf) {
12019 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12020 return QDF_STATUS_E_FAILURE;
12021 }
12022
12023 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
12024 WMITLV_SET_HDR(&cmd->tlv_header,
12025 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
12026 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012027 wmi_vdev_spectral_configure_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012028
12029 cmd->vdev_id = param->vdev_id;
12030 cmd->spectral_scan_count = param->count;
12031 cmd->spectral_scan_period = param->period;
12032 cmd->spectral_scan_priority = param->spectral_pri;
12033 cmd->spectral_scan_fft_size = param->fft_size;
12034 cmd->spectral_scan_gc_ena = param->gc_enable;
12035 cmd->spectral_scan_restart_ena = param->restart_enable;
12036 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
12037 cmd->spectral_scan_init_delay = param->init_delay;
12038 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
12039 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
12040 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
12041 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
12042 cmd->spectral_scan_rssi_thr = param->rssi_thr;
12043 cmd->spectral_scan_pwr_format = param->pwr_format;
12044 cmd->spectral_scan_rpt_mode = param->rpt_mode;
12045 cmd->spectral_scan_bin_scale = param->bin_scale;
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012046 cmd->spectral_scan_dBm_adj = param->dbm_adj;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012047 cmd->spectral_scan_chn_mask = param->chn_mask;
12048
12049 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12050 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
12051
12052 if (ret != 0) {
12053 WMI_LOGE("Sending set quiet cmd failed\n");
12054 wmi_buf_free(buf);
12055 }
12056
12057 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
12058 __func__);
12059
12060 WMI_LOGI("vdev_id = %u\n"
12061 "spectral_scan_count = %u\n"
12062 "spectral_scan_period = %u\n"
12063 "spectral_scan_priority = %u\n"
12064 "spectral_scan_fft_size = %u\n"
12065 "spectral_scan_gc_ena = %u\n"
12066 "spectral_scan_restart_ena = %u\n"
12067 "spectral_scan_noise_floor_ref = %u\n"
12068 "spectral_scan_init_delay = %u\n"
12069 "spectral_scan_nb_tone_thr = %u\n"
12070 "spectral_scan_str_bin_thr = %u\n"
12071 "spectral_scan_wb_rpt_mode = %u\n"
12072 "spectral_scan_rssi_rpt_mode = %u\n"
12073 "spectral_scan_rssi_thr = %u\n"
12074 "spectral_scan_pwr_format = %u\n"
12075 "spectral_scan_rpt_mode = %u\n"
12076 "spectral_scan_bin_scale = %u\n"
12077 "spectral_scan_dBm_adj = %u\n"
12078 "spectral_scan_chn_mask = %u\n",
12079 param->vdev_id,
12080 param->count,
12081 param->period,
12082 param->spectral_pri,
12083 param->fft_size,
12084 param->gc_enable,
12085 param->restart_enable,
12086 param->noise_floor_ref,
12087 param->init_delay,
12088 param->nb_tone_thr,
12089 param->str_bin_thr,
12090 param->wb_rpt_mode,
12091 param->rssi_rpt_mode,
12092 param->rssi_thr,
12093 param->pwr_format,
12094 param->rpt_mode,
12095 param->bin_scale,
Shiva Krishna Pittala90ccf6c2017-12-18 16:39:20 +053012096 param->dbm_adj,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012097 param->chn_mask);
12098 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12099
12100 return ret;
12101}
12102
12103/**
12104 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
12105 * command to fw
12106 * @wmi_handle: wmi handle
12107 * @param: pointer to hold spectral enable parameter
12108 *
12109 * Return: 0 for success or error code
12110 */
12111static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
12112 struct vdev_spectral_enable_params *param)
12113{
12114 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
12115 wmi_buf_t buf;
12116 QDF_STATUS ret;
12117 int32_t len;
12118
12119 len = sizeof(*cmd);
12120 buf = wmi_buf_alloc(wmi_handle, len);
12121 if (!buf) {
12122 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12123 return QDF_STATUS_E_FAILURE;
12124 }
12125
12126 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
12127 WMITLV_SET_HDR(&cmd->tlv_header,
12128 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
12129 WMITLV_GET_STRUCT_TLVLEN(
Edayilliam Jayadevdca20542017-07-21 12:24:04 +053012130 wmi_vdev_spectral_enable_cmd_fixed_param));
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012131
12132 cmd->vdev_id = param->vdev_id;
12133
12134 if (param->active_valid) {
12135 cmd->trigger_cmd = param->active ? 1 : 2;
12136 /* 1: Trigger, 2: Clear Trigger */
12137 } else {
12138 cmd->trigger_cmd = 0; /* 0: Ignore */
12139 }
12140
12141 if (param->enabled_valid) {
12142 cmd->enable_cmd = param->enabled ? 1 : 2;
12143 /* 1: Enable 2: Disable */
12144 } else {
12145 cmd->enable_cmd = 0; /* 0: Ignore */
12146 }
12147
12148 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12149 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
12150
12151 if (ret != 0) {
12152 WMI_LOGE("Sending scan enable CMD failed\n");
12153 wmi_buf_free(buf);
12154 }
12155
12156 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
12157
12158 WMI_LOGI("vdev_id = %u\n"
12159 "trigger_cmd = %u\n"
12160 "enable_cmd = %u\n",
12161 cmd->vdev_id,
12162 cmd->trigger_cmd,
12163 cmd->enable_cmd);
12164
12165 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
12166
12167 return ret;
12168}
12169
12170/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012171 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
12172 * @param wmi_handle : handle to WMI.
12173 * @param param : pointer to hold thermal mitigation param
12174 *
12175 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
12176 */
12177static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
12178 wmi_unified_t wmi_handle,
12179 struct thermal_mitigation_params *param)
12180{
12181 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
12182 wmi_therm_throt_level_config_info *lvl_conf = NULL;
12183 wmi_buf_t buf = NULL;
12184 uint8_t *buf_ptr = NULL;
12185 int error;
12186 int32_t len;
12187 int i;
12188
12189 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
12190 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
12191
12192 buf = wmi_buf_alloc(wmi_handle, len);
12193 if (!buf) {
12194 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12195 return QDF_STATUS_E_NOMEM;
12196 }
12197 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
12198
12199 /* init fixed params */
12200 WMITLV_SET_HDR(tt_conf,
12201 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
12202 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
12203
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012204 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12205 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053012206 tt_conf->enable = param->enable;
12207 tt_conf->dc = param->dc;
12208 tt_conf->dc_per_event = param->dc_per_event;
12209 tt_conf->therm_throt_levels = THERMAL_LEVELS;
12210
12211 buf_ptr = (uint8_t *) ++tt_conf;
12212 /* init TLV params */
12213 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12214 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
12215
12216 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
12217 for (i = 0; i < THERMAL_LEVELS; i++) {
12218 WMITLV_SET_HDR(&lvl_conf->tlv_header,
12219 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
12220 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
12221 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
12222 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
12223 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
12224 lvl_conf->prio = param->levelconf[i].priority;
12225 lvl_conf++;
12226 }
12227
12228 error = wmi_unified_cmd_send(wmi_handle, buf, len,
12229 WMI_THERM_THROT_SET_CONF_CMDID);
12230 if (QDF_IS_STATUS_ERROR(error)) {
12231 wmi_buf_free(buf);
12232 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
12233 }
12234
12235 return error;
12236}
12237
12238/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012239 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
12240 * @wmi_handle: wmi handle
12241 * @param: pointer to pdev_qvit_params
12242 *
12243 * Return: 0 for success or error code
12244 */
12245static QDF_STATUS
12246send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
12247 struct pdev_qvit_params *param)
12248{
12249 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012250 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012251 uint8_t *cmd;
12252 static uint8_t msgref = 1;
12253 uint8_t segnumber = 0, seginfo, numsegments;
12254 uint16_t chunk_len, total_bytes;
12255 uint8_t *bufpos;
12256 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
12257
12258 bufpos = param->utf_payload;
12259 total_bytes = param->len;
12260 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
12261 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
12262 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
12263
12264 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
12265 numsegments++;
12266
12267 while (param->len) {
12268 if (param->len > MAX_WMI_QVIT_LEN)
Jeff Johnsonda263992018-05-12 14:22:00 -070012269 chunk_len = MAX_WMI_QVIT_LEN; /* MAX message */
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012270 else
12271 chunk_len = param->len;
12272
12273 buf = wmi_buf_alloc(wmi_handle,
12274 (chunk_len + sizeof(seghdrinfo) +
12275 WMI_TLV_HDR_SIZE));
12276 if (!buf) {
12277 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
12278 return QDF_STATUS_E_NOMEM;
12279 }
12280
12281 cmd = (uint8_t *) wmi_buf_data(buf);
12282
12283 seghdrinfo.len = total_bytes;
12284 seghdrinfo.msgref = msgref;
12285 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
12286 seghdrinfo.segmentInfo = seginfo;
12287
12288 segnumber++;
12289
12290 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
12291 (chunk_len + sizeof(seghdrinfo)));
12292 cmd += WMI_TLV_HDR_SIZE;
12293 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
12294 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
12295
12296 ret = wmi_unified_cmd_send(wmi_handle, buf,
12297 (chunk_len + sizeof(seghdrinfo) +
12298 WMI_TLV_HDR_SIZE),
12299 WMI_PDEV_QVIT_CMDID);
12300
12301 if (ret != 0) {
12302 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
12303 wmi_buf_free(buf);
12304 break;
12305 }
12306
12307 param->len -= chunk_len;
12308 bufpos += chunk_len;
12309 }
12310 msgref++;
12311
12312 return ret;
12313}
12314
12315/**
12316 * send_wmm_update_cmd_tlv() - send wmm update command to fw
12317 * @wmi_handle: wmi handle
12318 * @param: pointer to wmm update param
12319 *
12320 * Return: 0 for success or error code
12321 */
12322static QDF_STATUS
12323send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
12324 struct wmm_update_params *param)
12325{
12326 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
12327 wmi_wmm_params *wmm_param;
12328 wmi_buf_t buf;
12329 QDF_STATUS ret;
12330 int32_t len;
12331 int ac = 0;
12332 struct wmi_host_wmeParams *wmep;
12333 uint8_t *buf_ptr;
12334
12335 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
12336 buf = wmi_buf_alloc(wmi_handle, len);
12337 if (!buf) {
12338 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12339 return QDF_STATUS_E_FAILURE;
12340 }
12341
12342 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12343 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
12344 WMITLV_SET_HDR(&cmd->tlv_header,
12345 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
12346 WMITLV_GET_STRUCT_TLVLEN
12347 (wmi_pdev_set_wmm_params_cmd_fixed_param));
12348
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012349 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053012350
12351 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
12352
12353 for (ac = 0; ac < WME_NUM_AC; ac++) {
12354 wmep = &param->wmep_array[ac];
12355 wmm_param = (wmi_wmm_params *)buf_ptr;
12356 WMITLV_SET_HDR(&wmm_param->tlv_header,
12357 WMITLV_TAG_STRUC_wmi_wmm_params,
12358 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
12359 wmm_param->aifs = wmep->wmep_aifsn;
12360 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
12361 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
12362 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
12363 wmm_param->acm = wmep->wmep_acm;
12364 wmm_param->no_ack = wmep->wmep_noackPolicy;
12365 buf_ptr += sizeof(wmi_wmm_params);
12366 }
12367 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12368 WMI_PDEV_SET_WMM_PARAMS_CMDID);
12369
12370 if (ret != 0) {
12371 WMI_LOGE("Sending WMM update CMD failed\n");
12372 wmi_buf_free(buf);
12373 }
12374
12375 return ret;
12376}
12377
Sathish Kumar80f4f382017-04-24 11:36:00 +053012378/**
12379 * send_coex_config_cmd_tlv() - send coex config command to fw
12380 * @wmi_handle: wmi handle
12381 * @param: pointer to coex config param
12382 *
12383 * Return: 0 for success or error code
12384 */
12385static QDF_STATUS
12386send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
12387 struct coex_config_params *param)
12388{
12389 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
12390 wmi_buf_t buf;
12391 QDF_STATUS ret;
12392 int32_t len;
12393
12394 len = sizeof(*cmd);
12395 buf = wmi_buf_alloc(wmi_handle, len);
12396 if (!buf) {
12397 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
12398 return QDF_STATUS_E_FAILURE;
12399 }
12400
12401 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
12402 WMITLV_SET_HDR(&cmd->tlv_header,
12403 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
12404 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053012405 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053012406
12407 cmd->vdev_id = param->vdev_id;
12408 cmd->config_type = param->config_type;
12409 cmd->config_arg1 = param->config_arg1;
12410 cmd->config_arg2 = param->config_arg2;
12411 cmd->config_arg3 = param->config_arg3;
12412 cmd->config_arg4 = param->config_arg4;
12413 cmd->config_arg5 = param->config_arg5;
12414 cmd->config_arg6 = param->config_arg6;
12415
12416 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12417 WMI_COEX_CONFIG_CMDID);
12418
12419 if (ret != 0) {
12420 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
12421 wmi_buf_free(buf);
12422 }
12423
12424 return ret;
12425}
12426
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012427
12428#ifdef WLAN_SUPPORT_TWT
12429static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12430 target_resource_config *tgt_res_cfg)
12431{
12432 resource_cfg->twt_ap_pdev_count = tgt_res_cfg->twt_ap_pdev_count;
12433 resource_cfg->twt_ap_sta_count = tgt_res_cfg->twt_ap_sta_count;
12434}
12435#else
12436static void wmi_copy_twt_resource_config(wmi_resource_config *resource_cfg,
12437 target_resource_config *tgt_res_cfg)
12438{
12439 resource_cfg->twt_ap_pdev_count = 0;
12440 resource_cfg->twt_ap_sta_count = 0;
12441}
12442#endif
12443
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012444static
Govind Singh9ddd5162016-03-07 16:30:32 +053012445void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053012446 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053012447{
Govind Singhe7f2f342016-05-23 12:12:52 +053012448 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053012449 resource_cfg->num_peers = tgt_res_cfg->num_peers;
12450 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
12451 resource_cfg->num_offload_reorder_buffs =
12452 tgt_res_cfg->num_offload_reorder_buffs;
12453 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
12454 resource_cfg->num_tids = tgt_res_cfg->num_tids;
12455 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
12456 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
12457 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
12458 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
12459 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
12460 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
12461 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
12462 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
12463 resource_cfg->scan_max_pending_req =
12464 tgt_res_cfg->scan_max_pending_req;
12465 resource_cfg->bmiss_offload_max_vdev =
12466 tgt_res_cfg->bmiss_offload_max_vdev;
12467 resource_cfg->roam_offload_max_vdev =
12468 tgt_res_cfg->roam_offload_max_vdev;
12469 resource_cfg->roam_offload_max_ap_profiles =
12470 tgt_res_cfg->roam_offload_max_ap_profiles;
12471 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
12472 resource_cfg->num_mcast_table_elems =
12473 tgt_res_cfg->num_mcast_table_elems;
12474 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
12475 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
12476 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
12477 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
12478 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
12479 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
12480 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
12481 resource_cfg->vow_config = tgt_res_cfg->vow_config;
12482 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
12483 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
12484 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
12485 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
12486 resource_cfg->num_tdls_conn_table_entries =
12487 tgt_res_cfg->num_tdls_conn_table_entries;
12488 resource_cfg->beacon_tx_offload_max_vdev =
12489 tgt_res_cfg->beacon_tx_offload_max_vdev;
12490 resource_cfg->num_multicast_filter_entries =
12491 tgt_res_cfg->num_multicast_filter_entries;
12492 resource_cfg->num_wow_filters =
12493 tgt_res_cfg->num_wow_filters;
12494 resource_cfg->num_keep_alive_pattern =
12495 tgt_res_cfg->num_keep_alive_pattern;
12496 resource_cfg->keep_alive_pattern_size =
12497 tgt_res_cfg->keep_alive_pattern_size;
12498 resource_cfg->max_tdls_concurrent_sleep_sta =
12499 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
12500 resource_cfg->max_tdls_concurrent_buffer_sta =
12501 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
12502 resource_cfg->wmi_send_separate =
12503 tgt_res_cfg->wmi_send_separate;
12504 resource_cfg->num_ocb_vdevs =
12505 tgt_res_cfg->num_ocb_vdevs;
12506 resource_cfg->num_ocb_channels =
12507 tgt_res_cfg->num_ocb_channels;
12508 resource_cfg->num_ocb_schedules =
12509 tgt_res_cfg->num_ocb_schedules;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053012510 resource_cfg->bpf_instruction_size = tgt_res_cfg->apf_instruction_size;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053012511 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
12512 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012513 resource_cfg->max_num_dbs_scan_duty_cycle =
12514 tgt_res_cfg->max_num_dbs_scan_duty_cycle;
Kris Muthusamy3c2c76a2017-11-30 01:40:46 -080012515 resource_cfg->sched_params = tgt_res_cfg->scheduler_params;
Dustin Brown983c53f2018-03-07 11:48:14 -080012516 resource_cfg->num_packet_filters = tgt_res_cfg->num_packet_filters;
12517 resource_cfg->num_max_sta_vdevs = tgt_res_cfg->num_max_sta_vdevs;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053012518
Mukul Sharmad7c9e332017-11-02 17:42:36 +053012519 if (tgt_res_cfg->atf_config)
12520 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1, 1);
12521 if (tgt_res_cfg->mgmt_comp_evt_bundle_support)
12522 WMI_RSRC_CFG_FLAG_MGMT_COMP_EVT_BUNDLE_SUPPORT_SET(
12523 resource_cfg->flag1, 1);
12524 if (tgt_res_cfg->tx_msdu_new_partition_id_support)
12525 WMI_RSRC_CFG_FLAG_TX_MSDU_ID_NEW_PARTITION_SUPPORT_SET(
12526 resource_cfg->flag1, 1);
Ruchi, Agrawal0a40ba12017-11-21 14:39:02 +053012527 if (tgt_res_cfg->cce_disable)
12528 WMI_RSRC_CFG_FLAG_TCL_CCE_DISABLE_SET(resource_cfg->flag1, 1);
Kiran Venkatappa3619e662018-04-04 14:31:43 +053012529
12530 wmi_copy_twt_resource_config(resource_cfg, tgt_res_cfg);
Govind Singh9ddd5162016-03-07 16:30:32 +053012531}
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012532
12533/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
12534 * @wmi_handle: pointer to wmi handle
12535 * @buf_ptr: pointer to current position in init command buffer
Jeff Johnsonac11e172018-05-06 15:40:42 -070012536 * @len: pointer to length. This will be updated with current length of cmd
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012537 * @param: point host parameters for init command
12538 *
12539 * Return: Updated pointer of buf_ptr.
12540 */
12541static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
12542 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
12543{
12544 uint16_t idx;
12545
12546 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
12547 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
12548 wmi_pdev_band_to_mac *band_to_mac;
12549
12550 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
12551 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
12552 sizeof(wmi_resource_config) +
12553 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
12554 sizeof(wlan_host_memory_chunk)));
12555
12556 WMITLV_SET_HDR(&hw_mode->tlv_header,
12557 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12558 (WMITLV_GET_STRUCT_TLVLEN
12559 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
12560
12561 hw_mode->hw_mode_index = param->hw_mode_id;
12562 hw_mode->num_band_to_mac = param->num_band_to_mac;
12563
12564 buf_ptr = (uint8_t *) (hw_mode + 1);
12565 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
12566 WMI_TLV_HDR_SIZE);
12567 for (idx = 0; idx < param->num_band_to_mac; idx++) {
12568 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
12569 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
12570 WMITLV_GET_STRUCT_TLVLEN
12571 (wmi_pdev_band_to_mac));
12572 band_to_mac[idx].pdev_id =
12573 wmi_handle->ops->convert_pdev_id_host_to_target(
12574 param->band_to_mac[idx].pdev_id);
12575 band_to_mac[idx].start_freq =
12576 param->band_to_mac[idx].start_freq;
12577 band_to_mac[idx].end_freq =
12578 param->band_to_mac[idx].end_freq;
12579 }
12580 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
12581 (param->num_band_to_mac *
12582 sizeof(wmi_pdev_band_to_mac)) +
12583 WMI_TLV_HDR_SIZE;
12584
12585 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12586 (param->num_band_to_mac *
12587 sizeof(wmi_pdev_band_to_mac)));
12588 }
12589
12590 return buf_ptr;
12591}
12592
12593static inline void copy_fw_abi_version_tlv(wmi_unified_t wmi_handle,
12594 wmi_init_cmd_fixed_param *cmd)
12595{
12596 int num_whitelist;
12597 wmi_abi_version my_vers;
12598
12599 num_whitelist = sizeof(version_whitelist) /
12600 sizeof(wmi_whitelist_version_info);
12601 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
12602 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
12603 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
12604 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
12605 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
12606 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
12607
12608 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
12609 &my_vers,
12610 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
12611 &cmd->host_abi_vers);
12612
12613 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
12614 __func__,
12615 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
12616 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
12617 cmd->host_abi_vers.abi_version_ns_0,
12618 cmd->host_abi_vers.abi_version_ns_1,
12619 cmd->host_abi_vers.abi_version_ns_2,
12620 cmd->host_abi_vers.abi_version_ns_3);
12621
12622 /* Save version sent from host -
12623 * Will be used to check ready event
12624 */
12625 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
12626 sizeof(wmi_abi_version));
12627}
12628
Sathish Kumarfd347372017-02-13 12:29:09 +053012629static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053012630{
12631 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
12632 wmi_service_ready_event_fixed_param *ev;
12633
12634
12635 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
12636
12637 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
12638 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053012639 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012640
12641 /*Save fw version from service ready message */
12642 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053012643 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012644 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012645
Govind Singhb53420c2016-03-09 14:32:57 +053012646 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012647}
12648
12649/**
12650 * wmi_unified_save_fw_version_cmd() - save fw version
12651 * @wmi_handle: pointer to wmi handle
12652 * @res_cfg: resource config
12653 * @num_mem_chunks: no of mem chunck
12654 * @mem_chunk: pointer to mem chunck structure
12655 *
12656 * This function sends IE information to firmware
12657 *
Govind Singhb53420c2016-03-09 14:32:57 +053012658 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053012659 *
12660 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012661static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053012662 void *evt_buf)
12663{
12664 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
12665 wmi_ready_event_fixed_param *ev = NULL;
12666
12667 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
12668 ev = param_buf->fixed_param;
Kiran Venkatappa22a02982017-10-11 22:56:45 +053012669 if (!wmi_versions_are_compatible((struct _wmi_abi_version *)
12670 &wmi_handle->final_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012671 &ev->fw_abi_vers)) {
12672 /*
12673 * Error: Our host version and the given firmware version
12674 * are incompatible.
12675 **/
Govind Singhb53420c2016-03-09 14:32:57 +053012676 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053012677 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
12678 __func__,
12679 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
12680 abi_version_0),
12681 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
12682 abi_version_0),
12683 wmi_handle->final_abi_vers.abi_version_ns_0,
12684 wmi_handle->final_abi_vers.abi_version_ns_1,
12685 wmi_handle->final_abi_vers.abi_version_ns_2,
12686 wmi_handle->final_abi_vers.abi_version_ns_3,
12687 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
12688 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
12689 ev->fw_abi_vers.abi_version_ns_0,
12690 ev->fw_abi_vers.abi_version_ns_1,
12691 ev->fw_abi_vers.abi_version_ns_2,
12692 ev->fw_abi_vers.abi_version_ns_3);
12693
Govind Singhb53420c2016-03-09 14:32:57 +053012694 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053012695 }
Govind Singhb53420c2016-03-09 14:32:57 +053012696 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012697 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053012698 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053012699 sizeof(wmi_abi_version));
Govind Singh9ddd5162016-03-07 16:30:32 +053012700
Govind Singhb53420c2016-03-09 14:32:57 +053012701 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053012702}
Govind Singha4836fd2016-03-07 16:45:38 +053012703
12704/**
12705 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
12706 * @wmi_handle: wmi handle
12707 * @custom_addr: base mac address
12708 *
Govind Singhe7f2f342016-05-23 12:12:52 +053012709 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053012710 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012711static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012712 uint8_t *custom_addr)
12713{
12714 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
12715 wmi_buf_t buf;
12716 int err;
12717
12718 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12719 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012720 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053012721 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012722 }
12723
12724 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012725 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053012726
12727 WMITLV_SET_HDR(&cmd->tlv_header,
12728 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
12729 WMITLV_GET_STRUCT_TLVLEN
12730 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
12731 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012732 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12733 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012734 err = wmi_unified_cmd_send(wmi_handle, buf,
12735 sizeof(*cmd),
12736 WMI_PDEV_SET_BASE_MACADDR_CMDID);
12737 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053012738 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053012739 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012740 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012741 }
12742
12743 return 0;
12744}
12745
12746/**
12747 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
12748 * @handle: wmi handle
12749 * @event: Event received from FW
12750 * @len: Length of the event
12751 *
12752 * Enables the low frequency events and disables the high frequency
12753 * events. Bit 17 indicates if the event if low/high frequency.
12754 * 1 - high frequency, 0 - low frequency
12755 *
12756 * Return: 0 on successfully enabling/disabling the events
12757 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012758static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012759 uint8_t *event,
12760 uint32_t len)
12761{
12762 uint32_t num_of_diag_events_logs;
12763 wmi_diag_event_log_config_fixed_param *cmd;
12764 wmi_buf_t buf;
12765 uint8_t *buf_ptr;
12766 uint32_t *cmd_args, *evt_args;
12767 uint32_t buf_len, i;
12768
12769 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
12770 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
12771
Govind Singhb53420c2016-03-09 14:32:57 +053012772 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053012773
12774 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
12775 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012776 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053012777 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012778 }
12779 wmi_event = param_buf->fixed_param;
12780 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
Amar Singhal5593c902017-10-03 13:00:29 -070012781
12782 if (num_of_diag_events_logs >
12783 param_buf->num_diag_events_logs_list) {
12784 WMI_LOGE("message number of events %d is more than tlv hdr content %d",
12785 num_of_diag_events_logs,
12786 param_buf->num_diag_events_logs_list);
12787 return QDF_STATUS_E_INVAL;
12788 }
12789
Govind Singha4836fd2016-03-07 16:45:38 +053012790 evt_args = param_buf->diag_events_logs_list;
12791 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053012792 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012793 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053012794 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012795 }
12796
Govind Singhb53420c2016-03-09 14:32:57 +053012797 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053012798 __func__, num_of_diag_events_logs);
12799
12800 /* Free any previous allocation */
12801 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053012802 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012803
Varun Reddy Yeturuc7997522017-08-20 13:41:02 -070012804 if (num_of_diag_events_logs >
12805 (WMI_SVC_MSG_MAX_SIZE / sizeof(uint32_t))) {
12806 WMI_LOGE("%s: excess num of logs:%d", __func__,
12807 num_of_diag_events_logs);
12808 QDF_ASSERT(0);
12809 return QDF_STATUS_E_INVAL;
12810 }
Govind Singha4836fd2016-03-07 16:45:38 +053012811 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053012812 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053012813 sizeof(uint32_t));
12814 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012815 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012816 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012817 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012818 }
12819 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
12820
12821 /* Prepare the send buffer */
12822 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12823 (num_of_diag_events_logs * sizeof(uint32_t));
12824
12825 buf = wmi_buf_alloc(wmi_handle, buf_len);
12826 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012827 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12828 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053012829 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053012830 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012831 }
12832
12833 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12834 buf_ptr = (uint8_t *) cmd;
12835
12836 WMITLV_SET_HDR(&cmd->tlv_header,
12837 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12838 WMITLV_GET_STRUCT_TLVLEN(
12839 wmi_diag_event_log_config_fixed_param));
12840
12841 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
12842
12843 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12844
12845 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12846 (num_of_diag_events_logs * sizeof(uint32_t)));
12847
12848 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12849
12850 /* Populate the events */
12851 for (i = 0; i < num_of_diag_events_logs; i++) {
12852 /* Low freq (0) - Enable (1) the event
12853 * High freq (1) - Disable (0) the event
12854 */
12855 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
12856 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
12857 /* Set the event ID */
12858 WMI_DIAG_ID_SET(cmd_args[i],
12859 WMI_DIAG_ID_GET(evt_args[i]));
12860 /* Set the type */
12861 WMI_DIAG_TYPE_SET(cmd_args[i],
12862 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053012863 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053012864 wmi_handle->events_logs_list[i] = evt_args[i];
12865 }
12866
12867 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
12868 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012869 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012870 __func__);
12871 wmi_buf_free(buf);
12872 /* Not clearing events_logs_list, though wmi cmd failed.
12873 * Host can still have this list
12874 */
Govind Singh67922e82016-04-01 16:48:57 +053012875 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012876 }
12877
12878 return 0;
12879}
12880
12881/**
12882 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
12883 * @wmi_handle: wmi handle
12884 * @start_log: Start logging related parameters
12885 *
12886 * Send the command to the FW based on which specific logging of diag
12887 * event/log id can be started/stopped
12888 *
12889 * Return: None
12890 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012891static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012892 struct wmi_wifi_start_log *start_log)
12893{
12894 wmi_diag_event_log_config_fixed_param *cmd;
12895 wmi_buf_t buf;
12896 uint8_t *buf_ptr;
12897 uint32_t len, count, log_level, i;
12898 uint32_t *cmd_args;
12899 uint32_t total_len;
12900 count = 0;
12901
12902 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053012903 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053012904 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012905 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012906 }
12907 /* total_len stores the number of events where BITS 17 and 18 are set.
12908 * i.e., events of high frequency (17) and for extended debugging (18)
12909 */
12910 total_len = 0;
12911 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12912 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
12913 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
12914 total_len++;
12915 }
12916
12917 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
12918 (total_len * sizeof(uint32_t));
12919
12920 buf = wmi_buf_alloc(wmi_handle, len);
12921 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012922 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012923 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012924 }
12925 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
12926 buf_ptr = (uint8_t *) cmd;
12927
12928 WMITLV_SET_HDR(&cmd->tlv_header,
12929 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
12930 WMITLV_GET_STRUCT_TLVLEN(
12931 wmi_diag_event_log_config_fixed_param));
12932
12933 cmd->num_of_diag_events_logs = total_len;
12934
12935 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
12936
12937 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12938 (total_len * sizeof(uint32_t)));
12939
12940 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
12941
Govind Singh224a7312016-06-21 14:33:26 +053012942 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053012943 log_level = 1;
12944 else
12945 log_level = 0;
12946
Govind Singhb53420c2016-03-09 14:32:57 +053012947 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053012948 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
12949 uint32_t val = wmi_handle->events_logs_list[i];
12950 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
12951 (WMI_DIAG_EXT_FEATURE_GET(val))) {
12952
12953 WMI_DIAG_ID_SET(cmd_args[count],
12954 WMI_DIAG_ID_GET(val));
12955 WMI_DIAG_TYPE_SET(cmd_args[count],
12956 WMI_DIAG_TYPE_GET(val));
12957 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
12958 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053012959 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053012960 count++;
12961 }
12962 }
12963
12964 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12965 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012966 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053012967 __func__);
12968 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053012969 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053012970 }
12971
Govind Singhb53420c2016-03-09 14:32:57 +053012972 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012973}
12974
12975/**
12976 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
12977 * @wmi_handle: WMI handle
12978 *
12979 * This function is used to send the flush command to the FW,
12980 * that will flush the fw logs that are residue in the FW
12981 *
12982 * Return: None
12983 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012984static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053012985{
12986 wmi_debug_mesg_flush_fixed_param *cmd;
12987 wmi_buf_t buf;
12988 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053012989 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012990
12991 buf = wmi_buf_alloc(wmi_handle, len);
12992 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012993 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053012994 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012995 }
12996
12997 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
12998 WMITLV_SET_HDR(&cmd->tlv_header,
12999 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
13000 WMITLV_GET_STRUCT_TLVLEN(
13001 wmi_debug_mesg_flush_fixed_param));
13002 cmd->reserved0 = 0;
13003
13004 ret = wmi_unified_cmd_send(wmi_handle,
13005 buf,
13006 len,
13007 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053013008 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013009 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053013010 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053013011 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013012 }
Govind Singhb53420c2016-03-09 14:32:57 +053013013 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053013014
Govind Singh67922e82016-04-01 16:48:57 +053013015 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053013016}
13017
13018/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013019 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013020 * @wmi_handle: wmi handle
13021 * @msg: PCL structure containing the PCL and the number of channels
13022 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013023 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053013024 * firmware. The DBS Manager is the consumer of this information in the WLAN
13025 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
13026 * to migrate to a new channel without host driver involvement. An example of
13027 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
13028 * manage the channel selection without firmware involvement.
13029 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013030 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
13031 * channel list. The weights corresponds to the channels sent in
13032 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
13033 * weightage compared to the non PCL channels.
13034 *
Govind Singha4836fd2016-03-07 16:45:38 +053013035 * Return: Success if the cmd is sent successfully to the firmware
13036 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013037static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013038 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013039{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013040 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013041 wmi_buf_t buf;
13042 uint8_t *buf_ptr;
13043 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013044 uint32_t chan_len;
13045
13046 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053013047
13048 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013049 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013050
13051 buf = wmi_buf_alloc(wmi_handle, len);
13052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013053 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13054 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013055 }
13056
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013057 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013058 buf_ptr = (uint8_t *) cmd;
13059 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013060 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
13061 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053013062
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013063 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13064 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013065 cmd->num_chan = chan_len;
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013066 WMI_LOGD("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013067
13068 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053013069 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013070 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053013071 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013072 for (i = 0; i < chan_len ; i++) {
13073 cmd_args[i] = msg->weighed_valid_list[i];
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080013074 WMI_LOGD("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013075 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013076 }
13077 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053013078 WMI_PDEV_SET_PCL_CMDID)) {
13079 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013080 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013081 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013082 }
Govind Singhb53420c2016-03-09 14:32:57 +053013083 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013084}
13085
13086/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013087 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013088 * @wmi_handle: wmi handle
13089 * @msg: Structure containing the following parameters
13090 *
13091 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
13092 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
13093 *
13094 * Provides notification to the WLAN firmware that host driver is requesting a
13095 * HardWare (HW) Mode change. This command is needed to support iHelium in the
13096 * configurations that include the Dual Band Simultaneous (DBS) feature.
13097 *
13098 * Return: Success if the cmd is sent successfully to the firmware
13099 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013100static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013101 uint32_t hw_mode_index)
13102{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013103 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013104 wmi_buf_t buf;
13105 uint32_t len;
13106
13107 len = sizeof(*cmd);
13108
13109 buf = wmi_buf_alloc(wmi_handle, len);
13110 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013111 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13112 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013113 }
13114
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013115 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013116 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013117 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13118 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
13119
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013120 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13121 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013122 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053013123 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053013124
13125 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053013126 WMI_PDEV_SET_HW_MODE_CMDID)) {
13127 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013128 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013129 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013130 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013131 }
13132
Govind Singhb53420c2016-03-09 14:32:57 +053013133 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013134}
13135
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013136#ifdef WLAN_POLICY_MGR_ENABLE
Govind Singha4836fd2016-03-07 16:45:38 +053013137/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013138 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053013139 * @wmi_handle: wmi handle
13140 * @msg: Dual MAC config parameters
13141 *
13142 * Configures WLAN firmware with the dual MAC features
13143 *
Govind Singhb53420c2016-03-09 14:32:57 +053013144 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053013145 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013146static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013147QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013148 struct policy_mgr_dual_mac_config *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053013149{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013150 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053013151 wmi_buf_t buf;
13152 uint32_t len;
13153
13154 len = sizeof(*cmd);
13155
13156 buf = wmi_buf_alloc(wmi_handle, len);
13157 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013158 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13159 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013160 }
13161
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013162 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013163 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013164 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053013165 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013166 wmi_pdev_set_mac_config_cmd_fixed_param));
13167
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013168 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13169 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053013170 cmd->concurrent_scan_config_bits = msg->scan_config;
13171 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053013172 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053013173 __func__, msg->scan_config, msg->fw_mode_config);
13174
13175 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053013176 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
13177 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053013178 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013179 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013180 }
Govind Singhb53420c2016-03-09 14:32:57 +053013181 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013182}
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080013183#endif
Govind Singha4836fd2016-03-07 16:45:38 +053013184
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013185#ifdef BIG_ENDIAN_HOST
13186/**
13187* fips_conv_data_be() - LE to BE conversion of FIPS ev data
13188* @param data_len - data length
13189* @param data - pointer to data
13190*
13191* Return: QDF_STATUS - success or error status
13192*/
13193static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13194 struct fips_params *param)
13195{
13196 unsigned char *key_unaligned, *data_unaligned;
13197 int c;
13198 u_int8_t *key_aligned = NULL;
13199 u_int8_t *data_aligned = NULL;
13200
13201 /* Assigning unaligned space to copy the key */
13202 key_unaligned = qdf_mem_malloc(
13203 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
13204 data_unaligned = qdf_mem_malloc(
13205 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
13206
Jeff Johnsonda263992018-05-12 14:22:00 -070013207 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013208 if (key_unaligned == NULL)
13209 return QDF_STATUS_SUCCESS;
13210 /* Checking if space is aligned */
13211 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
13212 /* align to 4 */
13213 key_aligned =
13214 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
13215 FIPS_ALIGN);
13216 } else {
13217 key_aligned = (u_int8_t *)key_unaligned;
13218 }
13219
13220 /* memset and copy content from key to key aligned */
13221 OS_MEMSET(key_aligned, 0, param->key_len);
13222 OS_MEMCPY(key_aligned, param->key, param->key_len);
13223
13224 /* print a hexdump for host debug */
13225 print_hex_dump(KERN_DEBUG,
13226 "\t Aligned and Copied Key:@@@@ ",
13227 DUMP_PREFIX_NONE,
13228 16, 1, key_aligned, param->key_len, true);
13229
Jeff Johnsonda263992018-05-12 14:22:00 -070013230 /* Checking if kmalloc is successful to allocate space */
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013231 if (data_unaligned == NULL)
13232 return QDF_STATUS_SUCCESS;
13233 /* Checking of space is aligned */
13234 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
13235 /* align to 4 */
13236 data_aligned =
13237 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
13238 FIPS_ALIGN);
13239 } else {
13240 data_aligned = (u_int8_t *)data_unaligned;
13241 }
13242
13243 /* memset and copy content from data to data aligned */
13244 OS_MEMSET(data_aligned, 0, param->data_len);
13245 OS_MEMCPY(data_aligned, param->data, param->data_len);
13246
13247 /* print a hexdump for host debug */
13248 print_hex_dump(KERN_DEBUG,
13249 "\t Properly Aligned and Copied Data:@@@@ ",
13250 DUMP_PREFIX_NONE,
13251 16, 1, data_aligned, param->data_len, true);
13252
13253 /* converting to little Endian both key_aligned and
13254 * data_aligned*/
13255 for (c = 0; c < param->key_len/4; c++) {
13256 *((u_int32_t *)key_aligned+c) =
13257 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
13258 }
13259 for (c = 0; c < param->data_len/4; c++) {
13260 *((u_int32_t *)data_aligned+c) =
13261 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
13262 }
13263
13264 /* update endian data to key and data vectors */
13265 OS_MEMCPY(param->key, key_aligned, param->key_len);
13266 OS_MEMCPY(param->data, data_aligned, param->data_len);
13267
13268 /* clean up allocated spaces */
13269 qdf_mem_free(key_unaligned);
13270 key_unaligned = NULL;
13271 key_aligned = NULL;
13272
13273 qdf_mem_free(data_unaligned);
13274 data_unaligned = NULL;
13275 data_aligned = NULL;
13276
13277 return QDF_STATUS_SUCCESS;
13278}
13279#else
13280/**
13281* fips_align_data_be() - DUMMY for LE platform
13282*
13283* Return: QDF_STATUS - success
13284*/
13285static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
13286 struct fips_params *param)
13287{
13288 return QDF_STATUS_SUCCESS;
13289}
13290#endif
13291
13292
13293/**
13294 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
13295 * @wmi_handle: wmi handle
13296 * @param: pointer to hold pdev fips param
13297 *
13298 * Return: 0 for success or error code
13299 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013300static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013301send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
13302 struct fips_params *param)
13303{
13304 wmi_pdev_fips_cmd_fixed_param *cmd;
13305 wmi_buf_t buf;
13306 uint8_t *buf_ptr;
13307 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
13308 QDF_STATUS retval = QDF_STATUS_SUCCESS;
13309
13310 /* Length TLV placeholder for array of bytes */
13311 len += WMI_TLV_HDR_SIZE;
13312 if (param->data_len)
13313 len += (param->data_len*sizeof(uint8_t));
13314
13315 /*
13316 * Data length must be multiples of 16 bytes - checked against 0xF -
13317 * and must be less than WMI_SVC_MSG_SIZE - static size of
13318 * wmi_pdev_fips_cmd structure
13319 */
13320
13321 /* do sanity on the input */
13322 if (!(((param->data_len & 0xF) == 0) &&
13323 ((param->data_len > 0) &&
13324 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
13325 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
13326 return QDF_STATUS_E_INVAL;
13327 }
13328
13329 buf = wmi_buf_alloc(wmi_handle, len);
13330 if (!buf) {
13331 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
13332 return QDF_STATUS_E_FAILURE;
13333 }
13334
13335 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13336 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
13337 WMITLV_SET_HDR(&cmd->tlv_header,
13338 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
13339 WMITLV_GET_STRUCT_TLVLEN
13340 (wmi_pdev_fips_cmd_fixed_param));
13341
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053013342 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
13343 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053013344 if (param->key != NULL && param->data != NULL) {
13345 cmd->key_len = param->key_len;
13346 cmd->data_len = param->data_len;
13347 cmd->fips_cmd = !!(param->op);
13348
13349 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
13350 return QDF_STATUS_E_FAILURE;
13351
13352 qdf_mem_copy(cmd->key, param->key, param->key_len);
13353
13354 if (param->mode == FIPS_ENGINE_AES_CTR ||
13355 param->mode == FIPS_ENGINE_AES_MIC) {
13356 cmd->mode = param->mode;
13357 } else {
13358 cmd->mode = FIPS_ENGINE_AES_CTR;
13359 }
13360 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
13361 cmd->key_len, cmd->data_len);
13362
13363 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
13364 cmd->key, cmd->key_len, true);
13365 buf_ptr += sizeof(*cmd);
13366
13367 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
13368
13369 buf_ptr += WMI_TLV_HDR_SIZE;
13370 if (param->data_len)
13371 qdf_mem_copy(buf_ptr,
13372 (uint8_t *) param->data, param->data_len);
13373
13374 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
13375 16, 1, buf_ptr, cmd->data_len, true);
13376
13377 buf_ptr += param->data_len;
13378
13379 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
13380 WMI_PDEV_FIPS_CMDID);
13381 qdf_print("%s return value %d\n", __func__, retval);
13382 } else {
13383 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
13384 wmi_buf_free(buf);
13385 retval = -QDF_STATUS_E_BADMSG;
13386 }
13387
13388 return retval;
13389}
13390
Wu Gao52c0b772018-05-17 16:14:00 +080013391#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013392/**
13393 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
13394 * @wmi_handle: wmi handle
13395 * @vdev_id: vdev id
13396 * @bitmap: Event bitmap
13397 * @enable: enable/disable
13398 *
13399 * Return: CDF status
13400 */
13401static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
13402 uint32_t vdev_id,
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013403 uint32_t *bitmap,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013404 bool enable)
13405{
13406 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
13407 uint16_t len;
13408 wmi_buf_t buf;
13409 int ret;
13410
13411 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
13412 buf = wmi_buf_alloc(wmi_handle, len);
13413 if (!buf) {
13414 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13415 return QDF_STATUS_E_NOMEM;
13416 }
13417 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
13418 WMITLV_SET_HDR(&cmd->tlv_header,
13419 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
13420 WMITLV_GET_STRUCT_TLVLEN
13421 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
13422 cmd->vdev_id = vdev_id;
13423 cmd->is_add = enable;
Ravi Kumar Bokkace4ac392017-03-23 17:20:31 +053013424 qdf_mem_copy(&(cmd->event_bitmaps[0]), bitmap, sizeof(uint32_t) *
13425 WMI_WOW_MAX_EVENT_BM_LEN);
13426
13427 WMI_LOGD("Wakeup pattern 0x%x%x%x%x %s in fw", cmd->event_bitmaps[0],
13428 cmd->event_bitmaps[1], cmd->event_bitmaps[2],
13429 cmd->event_bitmaps[3], enable ? "enabled" : "disabled");
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013430
13431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13432 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
13433 if (ret) {
13434 WMI_LOGE("Failed to config wow wakeup event");
13435 wmi_buf_free(buf);
13436 return QDF_STATUS_E_FAILURE;
13437 }
13438
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013439 return QDF_STATUS_SUCCESS;
13440}
13441
13442/**
13443 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
13444 * @wmi_handle: wmi handle
13445 * @vdev_id: vdev id
13446 * @ptrn_id: pattern id
13447 * @ptrn: pattern
13448 * @ptrn_len: pattern length
13449 * @ptrn_offset: pattern offset
13450 * @mask: mask
13451 * @mask_len: mask length
13452 * @user: true for user configured pattern and false for default pattern
13453 * @default_patterns: default patterns
13454 *
13455 * Return: CDF status
13456 */
13457static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
13458 uint8_t vdev_id, uint8_t ptrn_id,
13459 const uint8_t *ptrn, uint8_t ptrn_len,
13460 uint8_t ptrn_offset, const uint8_t *mask,
13461 uint8_t mask_len, bool user,
13462 uint8_t default_patterns)
13463{
13464 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13465 WOW_BITMAP_PATTERN_T *bitmap_pattern;
13466 wmi_buf_t buf;
13467 uint8_t *buf_ptr;
13468 int32_t len;
13469 int ret;
13470
13471 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13472 WMI_TLV_HDR_SIZE +
13473 1 * sizeof(WOW_BITMAP_PATTERN_T) +
13474 WMI_TLV_HDR_SIZE +
13475 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13476 WMI_TLV_HDR_SIZE +
13477 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13478 WMI_TLV_HDR_SIZE +
13479 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13480 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013481 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013482
13483 buf = wmi_buf_alloc(wmi_handle, len);
13484 if (!buf) {
13485 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13486 return QDF_STATUS_E_NOMEM;
13487 }
13488
13489 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13490 buf_ptr = (uint8_t *) cmd;
13491
13492 WMITLV_SET_HDR(&cmd->tlv_header,
13493 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13494 WMITLV_GET_STRUCT_TLVLEN
13495 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13496 cmd->vdev_id = vdev_id;
13497 cmd->pattern_id = ptrn_id;
13498
13499 cmd->pattern_type = WOW_BITMAP_PATTERN;
13500 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13501
13502 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13503 sizeof(WOW_BITMAP_PATTERN_T));
13504 buf_ptr += WMI_TLV_HDR_SIZE;
13505 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
13506
13507 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
13508 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
13509 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
13510
13511 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
13512 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
13513
13514 bitmap_pattern->pattern_offset = ptrn_offset;
13515 bitmap_pattern->pattern_len = ptrn_len;
13516
13517 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
13518 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
13519
13520 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
13521 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
13522
13523 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
13524 bitmap_pattern->pattern_id = ptrn_id;
13525
13526 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
13527 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
13528 bitmap_pattern->pattern_offset, user);
13529 WMI_LOGI("Pattern : ");
13530 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13531 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
13532
13533 WMI_LOGI("Mask : ");
13534 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
13535 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
13536
13537 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
13538
13539 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13540 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13541 buf_ptr += WMI_TLV_HDR_SIZE;
13542
13543 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13544 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13545 buf_ptr += WMI_TLV_HDR_SIZE;
13546
13547 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13548 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13549 buf_ptr += WMI_TLV_HDR_SIZE;
13550
13551 /* Fill TLV for pattern_info_timeout but no data. */
13552 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
13553 buf_ptr += WMI_TLV_HDR_SIZE;
13554
13555 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
Vivekc5823092018-03-22 23:27:21 +053013556 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013557 buf_ptr += WMI_TLV_HDR_SIZE;
Vivekc5823092018-03-22 23:27:21 +053013558 *(uint32_t *) buf_ptr = 0;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013559
13560 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13561 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
13562 if (ret) {
13563 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
13564 wmi_buf_free(buf);
13565 return QDF_STATUS_E_FAILURE;
13566 }
13567
13568 return QDF_STATUS_SUCCESS;
13569}
13570
Govind Singha4836fd2016-03-07 16:45:38 +053013571/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013572 * fill_arp_offload_params_tlv() - Fill ARP offload data
13573 * @wmi_handle: wmi handle
13574 * @offload_req: offload request
13575 * @buf_ptr: buffer pointer
13576 *
13577 * To fill ARP offload data to firmware
13578 * when target goes to wow mode.
13579 *
13580 * Return: None
13581 */
13582static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013583 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013584{
13585
13586 int i;
13587 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013588 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013589
13590 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13591 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
13592 *buf_ptr += WMI_TLV_HDR_SIZE;
13593 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
13594 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
13595 WMITLV_SET_HDR(&arp_tuple->tlv_header,
13596 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
13597 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
13598
13599 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013600 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013601 /* Copy the target ip addr and flags */
13602 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
13603 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013604 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013605 WMI_IPV4_ADDR_LEN);
13606 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013607 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013608 }
13609 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
13610 }
13611}
13612
13613#ifdef WLAN_NS_OFFLOAD
13614/**
13615 * fill_ns_offload_params_tlv() - Fill NS offload data
13616 * @wmi|_handle: wmi handle
13617 * @offload_req: offload request
13618 * @buf_ptr: buffer pointer
13619 *
13620 * To fill NS offload data to firmware
13621 * when target goes to wow mode.
13622 *
13623 * Return: None
13624 */
13625static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013626 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013627{
13628
13629 int i;
13630 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013631
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013632 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13633 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13634 *buf_ptr += WMI_TLV_HDR_SIZE;
13635 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
13636 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13637 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13638 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13639 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
13640
13641 /*
13642 * Fill data only for NS offload in the first ARP tuple for LA
13643 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013644 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013645 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13646 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013647 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013648 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013649 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013650 sizeof(WMI_IPV6_ADDR));
13651 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013652 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013653 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013654 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013655 ns_tuple->flags |=
13656 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13657 }
13658 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013659 i, &ns_req->self_ipv6_addr[i],
13660 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013661
13662 /* target MAC is optional, check if it is valid,
13663 * if this is not valid, the target will use the known
13664 * local MAC address rather than the tuple
13665 */
13666 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013667 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013668 &ns_tuple->target_mac);
13669 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13670 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13671 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13672 }
13673 }
13674 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13675 }
13676}
13677
13678
13679/**
13680 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
13681 * @wmi: wmi handle
13682 * @offload_req: offload request
13683 * @buf_ptr: buffer pointer
13684 *
13685 * To fill extended NS offload extended data to firmware
13686 * when target goes to wow mode.
13687 *
13688 * Return: None
13689 */
13690static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013691 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013692{
13693 int i;
13694 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
13695 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013696
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013697 count = ns_req->num_ns_offload_count;
13698 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013699 WMI_MAX_NS_OFFLOADS;
13700
13701 /* Populate extended NS offload tuples */
13702 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13703 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
13704 *buf_ptr += WMI_TLV_HDR_SIZE;
13705 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
13706 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
13707 WMITLV_SET_HDR(&ns_tuple->tlv_header,
13708 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
13709 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
13710
13711 /*
13712 * Fill data only for NS offload in the first ARP tuple for LA
13713 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013714 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013715 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
13716 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013717 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013718 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013719 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013720 sizeof(WMI_IPV6_ADDR));
13721 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013722 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013723 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013724 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013725 ns_tuple->flags |=
13726 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
13727 }
13728 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013729 i, &ns_req->self_ipv6_addr[i],
13730 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013731
13732 /* target MAC is optional, check if it is valid,
13733 * if this is not valid, the target will use the
13734 * known local MAC address rather than the tuple
13735 */
13736 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013737 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013738 &ns_tuple->target_mac);
13739 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
13740 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
13741 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
13742 }
13743 }
13744 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
13745 }
13746}
13747#else
13748static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013749 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013750{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013751}
13752
13753static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013754 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013755{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013756}
13757#endif
13758
13759/**
Govind Singha4836fd2016-03-07 16:45:38 +053013760 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
13761 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013762 * @arp_offload_req: arp offload request
13763 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053013764 * @arp_only: flag
13765 *
13766 * To configure ARP NS off load data to firmware
13767 * when target goes to wow mode.
13768 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013769 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053013770 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013771static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013772 struct pmo_arp_offload_params *arp_offload_req,
13773 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053013774 uint8_t vdev_id)
13775{
Govind Singha4836fd2016-03-07 16:45:38 +053013776 int32_t res;
13777 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Vivekc5823092018-03-22 23:27:21 +053013778 uint8_t *buf_ptr;
Govind Singha4836fd2016-03-07 16:45:38 +053013779 wmi_buf_t buf;
13780 int32_t len;
13781 uint32_t count = 0, num_ns_ext_tuples = 0;
13782
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013783 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053013784
Govind Singha4836fd2016-03-07 16:45:38 +053013785 /*
13786 * TLV place holder size for array of NS tuples
13787 * TLV place holder size for array of ARP tuples
13788 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013789 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
13790 WMI_TLV_HDR_SIZE +
13791 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
13792 WMI_TLV_HDR_SIZE +
13793 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013794
13795 /*
13796 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
13797 * extra length for extended NS offload tuples which follows ARP offload
13798 * tuples. Host needs to fill this structure in following format:
13799 * 2 NS ofload tuples
13800 * 2 ARP offload tuples
13801 * N numbers of extended NS offload tuples if HDD has given more than
13802 * 2 NS offload addresses
13803 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013804 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053013805 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013806 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
13807 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053013808 }
13809
13810 buf = wmi_buf_alloc(wmi_handle, len);
13811 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013812 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053013813 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013814 }
13815
Vivekc5823092018-03-22 23:27:21 +053013816 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013817 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
13818 WMITLV_SET_HDR(&cmd->tlv_header,
13819 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
13820 WMITLV_GET_STRUCT_TLVLEN
13821 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
13822 cmd->flags = 0;
13823 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013824 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053013825
Govind Singhb53420c2016-03-09 14:32:57 +053013826 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053013827
Govind Singha4836fd2016-03-07 16:45:38 +053013828 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053013829 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
13830 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
13831 if (num_ns_ext_tuples)
13832 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053013833
13834 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13835 WMI_SET_ARP_NS_OFFLOAD_CMDID);
13836 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053013837 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053013838 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013839 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013840 }
13841
Govind Singhb53420c2016-03-09 14:32:57 +053013842 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013843}
13844
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013845/**
13846 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
13847 * @wmi_handle: wmi handle
13848 * @vdev_id: vdev id
13849 * @action: true for enable else false
13850 *
13851 * To enable enhance multicast offload to firmware
13852 * when target goes to wow mode.
13853 *
13854 * Return: QDF Status
13855 */
13856
13857static
13858QDF_STATUS send_enable_enhance_multicast_offload_tlv(
13859 wmi_unified_t wmi_handle,
13860 uint8_t vdev_id, bool action)
13861{
13862 QDF_STATUS status;
13863 wmi_buf_t buf;
13864 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
13865
13866 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13867 if (!buf) {
13868 WMI_LOGE("Failed to allocate buffer to send set key cmd");
13869 return QDF_STATUS_E_NOMEM;
13870 }
13871
13872 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
13873 wmi_buf_data(buf);
13874
13875 WMITLV_SET_HDR(&cmd->tlv_header,
13876 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
13877 WMITLV_GET_STRUCT_TLVLEN(
13878 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
13879
13880 cmd->vdev_id = vdev_id;
13881 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
13882 ENHANCED_MCAST_FILTER_ENABLED);
13883 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
13884 __func__, action, vdev_id);
13885 status = wmi_unified_cmd_send(wmi_handle, buf,
13886 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
13887 if (status != QDF_STATUS_SUCCESS) {
13888 qdf_nbuf_free(buf);
13889 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
13890 __func__);
13891 }
13892
13893 return status;
13894}
13895
13896/**
13897 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
13898 * @wmi_handle: wmi handle
13899 * @param evt_buf: pointer to event buffer
13900 * @param hdr: Pointer to hold header
13901 * @param bufp: Pointer to hold pointer to rx param buffer
13902 *
13903 * Return: QDF_STATUS_SUCCESS for success or error code
13904 */
13905static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
13906 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
13907{
13908 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
13909 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
13910
13911 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
13912 if (!param_buf) {
13913 WMI_LOGE("gtk param_buf is NULL");
13914 return QDF_STATUS_E_INVAL;
13915 }
13916
13917 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
13918 WMI_LOGE("Invalid length for GTK status");
13919 return QDF_STATUS_E_INVAL;
13920 }
13921
13922 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
13923 param_buf->fixed_param;
13924 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
13925 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
13926 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
13927 qdf_mem_copy(&gtk_rsp_param->replay_counter,
13928 &fixed_param->replay_counter,
13929 GTK_REPLAY_COUNTER_BYTES);
13930
13931 return QDF_STATUS_SUCCESS;
13932
13933}
13934
13935#ifdef FEATURE_WLAN_RA_FILTERING
13936/**
13937 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
13938 * @wmi_handle: wmi handle
13939 * @vdev_id: vdev id
13940 *
13941 * Return: CDF status
13942 */
13943static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
13944 uint8_t vdev_id, uint8_t default_pattern,
13945 uint16_t rate_limit_interval)
13946{
13947
13948 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
13949 wmi_buf_t buf;
13950 uint8_t *buf_ptr;
13951 int32_t len;
13952 int ret;
13953
13954 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
13955 WMI_TLV_HDR_SIZE +
13956 0 * sizeof(WOW_BITMAP_PATTERN_T) +
13957 WMI_TLV_HDR_SIZE +
13958 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
13959 WMI_TLV_HDR_SIZE +
13960 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
13961 WMI_TLV_HDR_SIZE +
13962 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
13963 WMI_TLV_HDR_SIZE +
Vivekc5823092018-03-22 23:27:21 +053013964 0 * sizeof(uint32_t) + WMI_TLV_HDR_SIZE + 1 * sizeof(uint32_t);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013965
13966 buf = wmi_buf_alloc(wmi_handle, len);
13967 if (!buf) {
13968 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13969 return QDF_STATUS_E_NOMEM;
13970 }
13971
13972 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
13973 buf_ptr = (uint8_t *) cmd;
13974
13975 WMITLV_SET_HDR(&cmd->tlv_header,
13976 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
13977 WMITLV_GET_STRUCT_TLVLEN
13978 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
13979 cmd->vdev_id = vdev_id;
13980 cmd->pattern_id = default_pattern,
13981 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
13982 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
13983
13984 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
13985 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13986 buf_ptr += WMI_TLV_HDR_SIZE;
13987
13988 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
13989 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13990 buf_ptr += WMI_TLV_HDR_SIZE;
13991
13992 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
13993 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13994 buf_ptr += WMI_TLV_HDR_SIZE;
13995
13996 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
13997 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
13998 buf_ptr += WMI_TLV_HDR_SIZE;
13999
14000 /* Fill TLV for pattern_info_timeout but no data. */
14001 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
14002 buf_ptr += WMI_TLV_HDR_SIZE;
14003
14004 /* Fill TLV for ra_ratelimit_interval. */
Vivekc5823092018-03-22 23:27:21 +053014005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(uint32_t));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014006 buf_ptr += WMI_TLV_HDR_SIZE;
14007
Vivekc5823092018-03-22 23:27:21 +053014008 *((uint32_t *) buf_ptr) = rate_limit_interval;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014009
14010 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
14011 rate_limit_interval, vdev_id);
14012
14013 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14014 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
14015 if (ret) {
14016 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
14017 wmi_buf_free(buf);
14018 return QDF_STATUS_E_FAILURE;
14019 }
14020
14021 return QDF_STATUS_SUCCESS;
14022
14023}
14024#endif /* FEATURE_WLAN_RA_FILTERING */
14025
14026/**
14027 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
14028 * @wmi_handle: wmi handle
14029 * @vdev_id: vdev id
14030 * @multicastAddr: mcast address
14031 * @clearList: clear list flag
14032 *
14033 * Return: QDF_STATUS_SUCCESS for success or error code
14034 */
14035static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
14036 uint8_t vdev_id,
14037 struct qdf_mac_addr multicast_addr,
14038 bool clearList)
14039{
14040 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
14041 wmi_buf_t buf;
14042 int err;
14043
14044 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14045 if (!buf) {
14046 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14047 return QDF_STATUS_E_NOMEM;
14048 }
14049
14050 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
14051 qdf_mem_zero(cmd, sizeof(*cmd));
14052
14053 WMITLV_SET_HDR(&cmd->tlv_header,
14054 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
14055 WMITLV_GET_STRUCT_TLVLEN
14056 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
14057 cmd->action =
14058 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
14059 cmd->vdev_id = vdev_id;
14060 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
14061
14062 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
14063 cmd->action, vdev_id, clearList, multicast_addr.bytes);
14064
14065 err = wmi_unified_cmd_send(wmi_handle, buf,
14066 sizeof(*cmd),
14067 WMI_SET_MCASTBCAST_FILTER_CMDID);
14068 if (err) {
14069 WMI_LOGE("Failed to send set_param cmd");
14070 wmi_buf_free(buf);
14071 return QDF_STATUS_E_FAILURE;
14072 }
14073
14074 return QDF_STATUS_SUCCESS;
14075}
14076
14077/**
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014078 * send_multiple_add_clear_mcbc_filter_cmd_tlv() - send multiple mcast filter
14079 * command to fw
14080 * @wmi_handle: wmi handle
14081 * @vdev_id: vdev id
14082 * @mcast_filter_params: mcast filter params
14083 *
14084 * Return: QDF_STATUS_SUCCESS for success or error code
14085 */
14086static QDF_STATUS send_multiple_add_clear_mcbc_filter_cmd_tlv(
14087 wmi_unified_t wmi_handle,
14088 uint8_t vdev_id,
14089 struct pmo_mcast_filter_params *filter_param)
14090
14091{
14092 WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *cmd;
14093 uint8_t *buf_ptr;
14094 wmi_buf_t buf;
14095 int err;
14096 int i;
14097 uint8_t *mac_addr_src_ptr = NULL;
14098 wmi_mac_addr *mac_addr_dst_ptr;
14099 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
14100 sizeof(wmi_mac_addr) * filter_param->multicast_addr_cnt;
14101
14102 buf = wmi_buf_alloc(wmi_handle, len);
14103 if (!buf) {
14104 WMI_LOGE("Failed to allocate memory");
14105 return QDF_STATUS_E_NOMEM;
14106 }
14107
Vivekc5823092018-03-22 23:27:21 +053014108 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053014109 cmd = (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param *)
14110 wmi_buf_data(buf);
14111 qdf_mem_zero(cmd, sizeof(*cmd));
14112
14113 WMITLV_SET_HDR(&cmd->tlv_header,
14114 WMITLV_TAG_STRUC_wmi_set_multiple_mcast_filter_cmd_fixed_param,
14115 WMITLV_GET_STRUCT_TLVLEN
14116 (WMI_SET_MULTIPLE_MCAST_FILTER_CMD_fixed_param));
14117 cmd->operation =
14118 ((filter_param->action == 0) ? WMI_MULTIPLE_MCAST_FILTER_DELETE
14119 : WMI_MULTIPLE_MCAST_FILTER_ADD);
14120 cmd->vdev_id = vdev_id;
14121 cmd->num_mcastaddrs = filter_param->multicast_addr_cnt;
14122
14123 buf_ptr += sizeof(*cmd);
14124 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
14125 sizeof(wmi_mac_addr) *
14126 filter_param->multicast_addr_cnt);
14127
14128 if (filter_param->multicast_addr_cnt == 0)
14129 goto send_cmd;
14130
14131 mac_addr_src_ptr = (uint8_t *)&filter_param->multicast_addr;
14132 mac_addr_dst_ptr = (wmi_mac_addr *)
14133 (buf_ptr + WMI_TLV_HDR_SIZE);
14134
14135 for (i = 0; i < filter_param->multicast_addr_cnt; i++) {
14136 WMI_CHAR_ARRAY_TO_MAC_ADDR(mac_addr_src_ptr, mac_addr_dst_ptr);
14137 mac_addr_src_ptr += ATH_MAC_LEN;
14138 mac_addr_dst_ptr++;
14139 }
14140
14141send_cmd:
14142 err = wmi_unified_cmd_send(wmi_handle, buf,
14143 len,
14144 WMI_SET_MULTIPLE_MCAST_FILTER_CMDID);
14145 if (err) {
14146 WMI_LOGE("Failed to send set_param cmd");
14147 wmi_buf_free(buf);
14148 return QDF_STATUS_E_FAILURE;
14149 }
14150
14151 return QDF_STATUS_SUCCESS;
14152}
14153
14154
14155/**
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014156 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
14157 * @wmi_handle: wmi handle
14158 * @vdev_id: vdev id
14159 * @params: GTK offload parameters
14160 *
14161 * Return: CDF status
14162 */
14163static
14164QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
14165 struct pmo_gtk_req *params,
14166 bool enable_offload,
14167 uint32_t gtk_offload_opcode)
14168{
14169 int len;
14170 wmi_buf_t buf;
14171 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014172 wmi_gtk_offload_fils_tlv_param *ext_param;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014173 QDF_STATUS status = QDF_STATUS_SUCCESS;
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014174 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014175
14176 WMI_LOGD("%s Enter", __func__);
14177
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014178 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*ext_param);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014179
14180 /* alloc wmi buffer */
14181 buf = wmi_buf_alloc(wmi_handle, len);
14182 if (!buf) {
14183 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14184 status = QDF_STATUS_E_NOMEM;
14185 goto out;
14186 }
14187
14188 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014189 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014190 WMITLV_SET_HDR(&cmd->tlv_header,
14191 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14192 WMITLV_GET_STRUCT_TLVLEN
14193 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14194
14195 cmd->vdev_id = vdev_id;
14196
14197 /* Request target to enable GTK offload */
14198 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
14199 cmd->flags = gtk_offload_opcode;
14200
14201 /* Copy the keys and replay counter */
14202 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014203 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN_LEGACY);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014204 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
14205 GTK_REPLAY_COUNTER_BYTES);
14206 } else {
14207 cmd->flags = gtk_offload_opcode;
14208 }
14209
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014210 buf_ptr += sizeof(*cmd);
14211 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(*ext_param));
14212 buf_ptr += WMI_TLV_HDR_SIZE;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014213
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053014214 ext_param = (wmi_gtk_offload_fils_tlv_param *)buf_ptr;
14215 WMITLV_SET_HDR(&ext_param->tlv_header,
14216 WMITLV_TAG_STRUC_wmi_gtk_offload_extended_tlv_param,
14217 WMITLV_GET_STRUCT_TLVLEN(
14218 wmi_gtk_offload_fils_tlv_param));
14219 ext_param->vdev_id = vdev_id;
14220 ext_param->flags = cmd->flags;
14221 ext_param->kek_len = params->kek_len;
14222 qdf_mem_copy(ext_param->KEK, params->kek, params->kek_len);
14223 qdf_mem_copy(ext_param->KCK, params->kck, WMI_GTK_OFFLOAD_KCK_BYTES);
14224 qdf_mem_copy(ext_param->replay_counter, &params->replay_counter,
14225 GTK_REPLAY_COUNTER_BYTES);
14226
14227 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 +053014228 /* send the wmi command */
14229 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14230 WMI_GTK_OFFLOAD_CMDID)) {
14231 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
14232 wmi_buf_free(buf);
14233 status = QDF_STATUS_E_FAILURE;
14234 }
14235
14236out:
14237 WMI_LOGD("%s Exit", __func__);
14238 return status;
14239}
14240
14241/**
14242 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
14243 * @wmi_handle: wmi handle
14244 * @params: GTK offload params
14245 *
14246 * Return: CDF status
14247 */
14248static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
14249 wmi_unified_t wmi_handle,
14250 uint8_t vdev_id,
14251 uint64_t offload_req_opcode)
14252{
14253 int len;
14254 wmi_buf_t buf;
14255 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
14256 QDF_STATUS status = QDF_STATUS_SUCCESS;
14257
14258 len = sizeof(*cmd);
14259
14260 /* alloc wmi buffer */
14261 buf = wmi_buf_alloc(wmi_handle, len);
14262 if (!buf) {
14263 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
14264 status = QDF_STATUS_E_NOMEM;
14265 goto out;
14266 }
14267
14268 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
14269 WMITLV_SET_HDR(&cmd->tlv_header,
14270 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
14271 WMITLV_GET_STRUCT_TLVLEN
14272 (WMI_GTK_OFFLOAD_CMD_fixed_param));
14273
14274 /* Request for GTK offload status */
14275 cmd->flags = offload_req_opcode;
14276 cmd->vdev_id = vdev_id;
14277
14278 /* send the wmi command */
14279 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14280 WMI_GTK_OFFLOAD_CMDID)) {
14281 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
14282 wmi_buf_free(buf);
14283 status = QDF_STATUS_E_FAILURE;
14284 }
14285
14286out:
14287 return status;
14288}
14289
14290/**
14291 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
14292 * @wmi_handle: wmi handler
14293 * @action_params: pointer to action_params
14294 *
14295 * Return: 0 for success, otherwise appropriate error code
14296 */
14297static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
14298 struct pmo_action_wakeup_set_params *action_params)
14299{
14300 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
14301 wmi_buf_t buf;
14302 int i;
14303 int32_t err;
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014304 uint32_t len = 0, *cmd_args;
14305 uint8_t *buf_ptr;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014306
Vivekc5823092018-03-22 23:27:21 +053014307 len = (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t))
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014308 + WMI_TLV_HDR_SIZE + sizeof(*cmd);
14309 buf = wmi_buf_alloc(wmi_handle, len);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014310 if (!buf) {
14311 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
14312 return QDF_STATUS_E_NOMEM;
14313 }
14314 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014315 buf_ptr = (uint8_t *)cmd;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014316 WMITLV_SET_HDR(&cmd->tlv_header,
14317 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
14318 WMITLV_GET_STRUCT_TLVLEN(
14319 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
14320
14321 cmd->vdev_id = action_params->vdev_id;
14322 cmd->operation = action_params->operation;
14323
14324 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
14325 cmd->action_category_map[i] =
14326 action_params->action_category_map[i];
14327
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014328 buf_ptr += sizeof(WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param);
14329 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053014330 (PMO_SUPPORTED_ACTION_CATE * sizeof(uint32_t)));
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014331 buf_ptr += WMI_TLV_HDR_SIZE;
14332 cmd_args = (uint32_t *) buf_ptr;
14333 for (i = 0; i < PMO_SUPPORTED_ACTION_CATE; i++)
14334 cmd_args[i] = action_params->action_per_category[i];
14335
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014336 err = wmi_unified_cmd_send(wmi_handle, buf,
Sridhar Selvaraj2c51f4f2017-08-04 12:04:55 +053014337 len, WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014338 if (err) {
14339 WMI_LOGE("Failed to send ap_ps_egap cmd");
14340 wmi_buf_free(buf);
14341 return QDF_STATUS_E_FAILURE;
14342 }
14343
14344 return QDF_STATUS_SUCCESS;
14345}
14346
14347#ifdef FEATURE_WLAN_LPHB
14348
14349/**
14350 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
14351 * @wmi_handle: wmi handle
14352 * @lphb_conf_req: configuration info
14353 *
14354 * Return: CDF status
14355 */
14356static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
14357 wmi_hb_set_enable_cmd_fixed_param *params)
14358{
14359 QDF_STATUS status;
14360 wmi_buf_t buf = NULL;
14361 uint8_t *buf_ptr;
14362 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
14363 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
14364
14365
14366 buf = wmi_buf_alloc(wmi_handle, len);
14367 if (!buf) {
14368 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14369 return QDF_STATUS_E_NOMEM;
14370 }
14371
14372 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14373 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
14374 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
14375 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
14376 WMITLV_GET_STRUCT_TLVLEN
14377 (wmi_hb_set_enable_cmd_fixed_param));
14378
14379 /* fill in values */
14380 hb_enable_fp->vdev_id = params->session;
14381 hb_enable_fp->enable = params->enable;
14382 hb_enable_fp->item = params->item;
14383 hb_enable_fp->session = params->session;
14384
14385 status = wmi_unified_cmd_send(wmi_handle, buf,
14386 len, WMI_HB_SET_ENABLE_CMDID);
14387 if (QDF_IS_STATUS_ERROR(status)) {
14388 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
14389 status);
14390 wmi_buf_free(buf);
14391 }
14392
14393 return status;
14394}
14395
14396/**
14397 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
14398 * @wmi_handle: wmi handle
14399 * @lphb_conf_req: lphb config request
14400 *
14401 * Return: CDF status
14402 */
14403static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
14404 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
14405{
14406 QDF_STATUS status;
14407 wmi_buf_t buf = NULL;
14408 uint8_t *buf_ptr;
14409 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
14410 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
14411
14412 buf = wmi_buf_alloc(wmi_handle, len);
14413 if (!buf) {
14414 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14415 return QDF_STATUS_E_NOMEM;
14416 }
14417
14418 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14419 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
14420 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
14421 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
14422 WMITLV_GET_STRUCT_TLVLEN
14423 (wmi_hb_set_tcp_params_cmd_fixed_param));
14424
14425 /* fill in values */
14426 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14427 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14428 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14429 hb_tcp_params_fp->seq = lphb_conf_req->seq;
14430 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
14431 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
14432 hb_tcp_params_fp->interval = lphb_conf_req->interval;
14433 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
14434 hb_tcp_params_fp->session = lphb_conf_req->session;
14435 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
14436 &lphb_conf_req->gateway_mac,
14437 sizeof(hb_tcp_params_fp->gateway_mac));
14438
14439 status = wmi_unified_cmd_send(wmi_handle, buf,
14440 len, WMI_HB_SET_TCP_PARAMS_CMDID);
14441 if (QDF_IS_STATUS_ERROR(status)) {
14442 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
14443 status);
14444 wmi_buf_free(buf);
14445 }
14446
14447 return status;
14448}
14449
14450/**
14451 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
14452 * @wmi_handle: wmi handle
14453 * @lphb_conf_req: lphb config request
14454 *
14455 * Return: CDF status
14456 */
14457static
14458QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14459 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
14460{
14461 QDF_STATUS status;
14462 wmi_buf_t buf = NULL;
14463 uint8_t *buf_ptr;
14464 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
14465 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
14466
14467 buf = wmi_buf_alloc(wmi_handle, len);
14468 if (!buf) {
14469 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14470 return QDF_STATUS_E_NOMEM;
14471 }
14472
14473 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14474 hb_tcp_filter_fp =
14475 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
14476 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
14477 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
14478 WMITLV_GET_STRUCT_TLVLEN
14479 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
14480
14481 /* fill in values */
14482 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
14483 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
14484 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
14485 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
14486 memcpy((void *)&hb_tcp_filter_fp->filter,
14487 (void *)&g_hb_tcp_filter_fp->filter,
14488 WMI_WLAN_HB_MAX_FILTER_SIZE);
14489
14490 status = wmi_unified_cmd_send(wmi_handle, buf,
14491 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
14492 if (QDF_IS_STATUS_ERROR(status)) {
14493 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
14494 status);
14495 wmi_buf_free(buf);
14496 }
14497
14498 return status;
14499}
14500
14501/**
14502 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
14503 * @wmi_handle: wmi handle
14504 * @lphb_conf_req: lphb config request
14505 *
14506 * Return: CDF status
14507 */
14508static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
14509 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
14510{
14511 QDF_STATUS status;
14512 wmi_buf_t buf = NULL;
14513 uint8_t *buf_ptr;
14514 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
14515 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
14516
14517 buf = wmi_buf_alloc(wmi_handle, len);
14518 if (!buf) {
14519 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14520 return QDF_STATUS_E_NOMEM;
14521 }
14522
14523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14524 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
14525 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
14526 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
14527 WMITLV_GET_STRUCT_TLVLEN
14528 (wmi_hb_set_udp_params_cmd_fixed_param));
14529
14530 /* fill in values */
14531 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
14532 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
14533 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
14534 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
14535 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
14536 hb_udp_params_fp->interval = lphb_conf_req->interval;
14537 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
14538 hb_udp_params_fp->session = lphb_conf_req->session;
14539 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
14540 &lphb_conf_req->gateway_mac,
14541 sizeof(lphb_conf_req->gateway_mac));
14542
14543 status = wmi_unified_cmd_send(wmi_handle, buf,
14544 len, WMI_HB_SET_UDP_PARAMS_CMDID);
14545 if (QDF_IS_STATUS_ERROR(status)) {
14546 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
14547 status);
14548 wmi_buf_free(buf);
14549 }
14550
14551 return status;
14552}
14553
14554/**
14555 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
14556 * @wmi_handle: wmi handle
14557 * @lphb_conf_req: lphb config request
14558 *
14559 * Return: CDF status
14560 */
14561static
14562QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
14563 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
14564{
14565 QDF_STATUS status;
14566 wmi_buf_t buf = NULL;
14567 uint8_t *buf_ptr;
14568 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
14569 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
14570
14571 buf = wmi_buf_alloc(wmi_handle, len);
14572 if (!buf) {
14573 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14574 return QDF_STATUS_E_NOMEM;
14575 }
14576
14577 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14578 hb_udp_filter_fp =
14579 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
14580 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
14581 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
14582 WMITLV_GET_STRUCT_TLVLEN
14583 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
14584
14585 /* fill in values */
14586 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
14587 hb_udp_filter_fp->length = lphb_conf_req->length;
14588 hb_udp_filter_fp->offset = lphb_conf_req->offset;
14589 hb_udp_filter_fp->session = lphb_conf_req->session;
14590 memcpy((void *)&hb_udp_filter_fp->filter,
14591 (void *)&lphb_conf_req->filter,
14592 WMI_WLAN_HB_MAX_FILTER_SIZE);
14593
14594 status = wmi_unified_cmd_send(wmi_handle, buf,
14595 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
14596 if (QDF_IS_STATUS_ERROR(status)) {
14597 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
14598 status);
14599 wmi_buf_free(buf);
14600 }
14601
14602 return status;
14603}
14604#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053014605
Dustin Brownf31f88b2017-05-12 14:01:44 -070014606static QDF_STATUS send_conf_hw_filter_cmd_tlv(wmi_unified_t wmi,
14607 struct pmo_hw_filter_params *req)
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014608{
Dustin Brownf31f88b2017-05-12 14:01:44 -070014609 QDF_STATUS status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014610 wmi_hw_data_filter_cmd_fixed_param *cmd;
Dustin Brownf31f88b2017-05-12 14:01:44 -070014611 wmi_buf_t wmi_buf;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014612
Dustin Brownf31f88b2017-05-12 14:01:44 -070014613 if (!req) {
14614 WMI_LOGE("req is null");
14615 return QDF_STATUS_E_INVAL;
14616 }
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014617
Dustin Brownf31f88b2017-05-12 14:01:44 -070014618 wmi_buf = wmi_buf_alloc(wmi, sizeof(*cmd));
14619 if (!wmi_buf) {
14620 WMI_LOGE(FL("Out of memory"));
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014621 return QDF_STATUS_E_NOMEM;
14622 }
14623
Dustin Brownf31f88b2017-05-12 14:01:44 -070014624 cmd = (wmi_hw_data_filter_cmd_fixed_param *)wmi_buf_data(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014625 WMITLV_SET_HDR(&cmd->tlv_header,
Dustin Brownf31f88b2017-05-12 14:01:44 -070014626 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
14627 WMITLV_GET_STRUCT_TLVLEN(wmi_hw_data_filter_cmd_fixed_param));
14628 cmd->vdev_id = req->vdev_id;
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014629 cmd->enable = req->enable;
14630 /* Set all modes in case of disable */
14631 if (!cmd->enable)
14632 cmd->hw_filter_bitmap = ((uint32_t)~0U);
14633 else
14634 cmd->hw_filter_bitmap = req->mode_bitmap;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014635
Nachiket Kukade200fbf72018-02-27 18:21:53 +053014636 WMI_LOGD("Send %s hw filter mode: 0x%X for vdev id %d",
14637 req->enable ? "enable" : "disable", req->mode_bitmap,
14638 req->vdev_id);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014639
Dustin Brownf31f88b2017-05-12 14:01:44 -070014640 status = wmi_unified_cmd_send(wmi, wmi_buf, sizeof(*cmd),
14641 WMI_HW_DATA_FILTER_CMDID);
14642 if (QDF_IS_STATUS_ERROR(status)) {
14643 WMI_LOGE("Failed to configure hw filter");
14644 wmi_buf_free(wmi_buf);
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014645 }
14646
Dustin Brownf31f88b2017-05-12 14:01:44 -070014647 return status;
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014648}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053014649
14650/**
14651 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
14652 * @wmi_handle: wmi handle
14653 * @vdev_id: vdev id
14654 * @enable: Flag to enable/disable packet filter
14655 *
14656 * Return: QDF_STATUS_SUCCESS for success or error code
14657 */
14658static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
14659 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
14660{
14661 int32_t len;
14662 int ret = 0;
14663 wmi_buf_t buf;
14664 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
14665
14666 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
14667
14668 buf = wmi_buf_alloc(wmi_handle, len);
14669 if (!buf) {
14670 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
14671 return QDF_STATUS_E_NOMEM;
14672 }
14673
14674 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
14675 WMITLV_SET_HDR(&cmd->tlv_header,
14676 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
14677 WMITLV_GET_STRUCT_TLVLEN(
14678 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
14679
14680 cmd->vdev_id = vdev_id;
14681 if (enable)
14682 cmd->enable = PACKET_FILTER_SET_ENABLE;
14683 else
14684 cmd->enable = PACKET_FILTER_SET_DISABLE;
14685
14686 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
14687 __func__, cmd->enable, vdev_id);
14688
14689 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14690 WMI_PACKET_FILTER_ENABLE_CMDID);
14691 if (ret) {
14692 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
14693 wmi_buf_free(buf);
14694 }
14695
14696 return ret;
14697}
14698
14699/**
14700 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
14701 * @wmi_handle: wmi handle
14702 * @vdev_id: vdev id
14703 * @rcv_filter_param: Packet filter parameters
14704 * @filter_id: Filter id
14705 * @enable: Flag to add/delete packet filter configuration
14706 *
14707 * Return: QDF_STATUS_SUCCESS for success or error code
14708 */
14709static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
14710 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
14711 uint8_t filter_id, bool enable)
14712{
14713 int len, i;
14714 int err = 0;
14715 wmi_buf_t buf;
14716 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
14717
14718
14719 /* allocate the memory */
14720 len = sizeof(*cmd);
14721 buf = wmi_buf_alloc(wmi_handle, len);
14722 if (!buf) {
14723 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
14724 return QDF_STATUS_E_NOMEM;
14725 }
14726
14727 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
14728 WMITLV_SET_HDR(&cmd->tlv_header,
14729 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
14730 WMITLV_GET_STRUCT_TLVLEN
14731 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
14732
14733 cmd->vdev_id = vdev_id;
14734 cmd->filter_id = filter_id;
14735 if (enable)
14736 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
14737 else
14738 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
14739
14740 if (enable) {
14741 cmd->num_params = QDF_MIN(
14742 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
14743 rcv_filter_param->num_params);
14744 cmd->filter_type = rcv_filter_param->filter_type;
14745 cmd->coalesce_time = rcv_filter_param->coalesce_time;
14746
14747 for (i = 0; i < cmd->num_params; i++) {
14748 cmd->paramsData[i].proto_type =
14749 rcv_filter_param->params_data[i].protocol_layer;
14750 cmd->paramsData[i].cmp_type =
14751 rcv_filter_param->params_data[i].compare_flag;
14752 cmd->paramsData[i].data_length =
14753 rcv_filter_param->params_data[i].data_length;
14754 cmd->paramsData[i].data_offset =
14755 rcv_filter_param->params_data[i].data_offset;
14756 memcpy(&cmd->paramsData[i].compareData,
14757 rcv_filter_param->params_data[i].compare_data,
14758 sizeof(cmd->paramsData[i].compareData));
14759 memcpy(&cmd->paramsData[i].dataMask,
14760 rcv_filter_param->params_data[i].data_mask,
14761 sizeof(cmd->paramsData[i].dataMask));
14762 }
14763 }
14764
14765 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
14766 cmd->filter_action, cmd->filter_id, cmd->num_params);
14767 /* send the command along with data */
14768 err = wmi_unified_cmd_send(wmi_handle, buf, len,
14769 WMI_PACKET_FILTER_CONFIG_CMDID);
14770 if (err) {
14771 WMI_LOGE("Failed to send pkt_filter cmd");
14772 wmi_buf_free(buf);
14773 return QDF_STATUS_E_FAILURE;
14774 }
14775
14776 return QDF_STATUS_SUCCESS;
14777}
Wu Gao52c0b772018-05-17 16:14:00 +080014778#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053014779
Govind Singha4836fd2016-03-07 16:45:38 +053014780/**
14781 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
14782 * @wmi_handle: wmi handle
14783 * @request: SSID hotlist set request
14784 *
Govind Singhb53420c2016-03-09 14:32:57 +053014785 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053014786 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014787static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053014788send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
14789 struct ssid_hotlist_request_params *request)
14790{
14791 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
14792 wmi_buf_t wmi_buf;
14793 uint32_t len;
14794 uint32_t array_size;
14795 uint8_t *buf_ptr;
14796
14797 /* length of fixed portion */
14798 len = sizeof(*cmd);
14799
14800 /* length of variable portion */
14801 array_size =
14802 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
14803 len += WMI_TLV_HDR_SIZE + array_size;
14804
14805 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14806 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014807 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14808 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014809 }
14810
14811 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
14812 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
14813 buf_ptr;
14814 WMITLV_SET_HDR
14815 (&cmd->tlv_header,
14816 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
14817 WMITLV_GET_STRUCT_TLVLEN
14818 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
14819
14820 cmd->request_id = request->request_id;
14821 cmd->requestor_id = 0;
14822 cmd->vdev_id = request->session_id;
14823 cmd->table_id = 0;
14824 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
14825 cmd->total_entries = request->ssid_count;
14826 cmd->num_entries_in_page = request->ssid_count;
14827 cmd->first_entry_index = 0;
14828
14829 buf_ptr += sizeof(*cmd);
14830 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
14831
14832 if (request->ssid_count) {
14833 wmi_extscan_hotlist_ssid_entry *entry;
14834 int i;
14835
14836 buf_ptr += WMI_TLV_HDR_SIZE;
14837 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
14838 for (i = 0; i < request->ssid_count; i++) {
14839 WMITLV_SET_HDR
14840 (entry,
14841 WMITLV_TAG_ARRAY_STRUC,
14842 WMITLV_GET_STRUCT_TLVLEN
14843 (wmi_extscan_hotlist_ssid_entry));
14844 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053014845 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053014846 request->ssids[i].ssid.mac_ssid,
14847 request->ssids[i].ssid.length);
14848 entry->band = request->ssids[i].band;
14849 entry->min_rssi = request->ssids[i].rssi_low;
14850 entry->max_rssi = request->ssids[i].rssi_high;
14851 entry++;
14852 }
14853 cmd->mode = WMI_EXTSCAN_MODE_START;
14854 } else {
14855 cmd->mode = WMI_EXTSCAN_MODE_STOP;
14856 }
14857
14858 if (wmi_unified_cmd_send
14859 (wmi_handle, wmi_buf, len,
14860 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014861 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053014862 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014863 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014864 }
14865
Govind Singhb53420c2016-03-09 14:32:57 +053014866 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014867}
14868
14869/**
14870 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
14871 * @wmi_handle: wmi handle
14872 * @vdev_id: vdev id
14873 *
14874 * This function sends roam synch complete event to fw.
14875 *
14876 * Return: CDF STATUS
14877 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014878static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014879 uint8_t vdev_id)
14880{
14881 wmi_roam_synch_complete_fixed_param *cmd;
14882 wmi_buf_t wmi_buf;
14883 uint8_t *buf_ptr;
14884 uint16_t len;
14885 len = sizeof(wmi_roam_synch_complete_fixed_param);
14886
14887 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14888 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014889 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14890 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014891 }
14892 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
14893 buf_ptr = (uint8_t *) cmd;
14894 WMITLV_SET_HDR(&cmd->tlv_header,
14895 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
14896 WMITLV_GET_STRUCT_TLVLEN
14897 (wmi_roam_synch_complete_fixed_param));
14898 cmd->vdev_id = vdev_id;
14899 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14900 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014901 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053014902 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014903 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014904 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014905 }
14906
Govind Singhb53420c2016-03-09 14:32:57 +053014907 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014908}
14909
14910/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053014911 * send_fw_test_cmd_tlv() - send fw test command to fw.
14912 * @wmi_handle: wmi handle
14913 * @wmi_fwtest: fw test command
14914 *
14915 * This function sends fw test command to fw.
14916 *
14917 * Return: CDF STATUS
14918 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014919static
Anurag Chouhan459e0152016-07-22 20:19:54 +053014920QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
14921 struct set_fwtest_params *wmi_fwtest)
14922{
14923 wmi_fwtest_set_param_cmd_fixed_param *cmd;
14924 wmi_buf_t wmi_buf;
14925 uint16_t len;
14926
14927 len = sizeof(*cmd);
14928
14929 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14930 if (!wmi_buf) {
14931 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14932 return QDF_STATUS_E_NOMEM;
14933 }
14934
14935 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14936 WMITLV_SET_HDR(&cmd->tlv_header,
14937 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
14938 WMITLV_GET_STRUCT_TLVLEN(
14939 wmi_fwtest_set_param_cmd_fixed_param));
14940 cmd->param_id = wmi_fwtest->arg;
14941 cmd->param_value = wmi_fwtest->value;
14942
14943 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
14944 WMI_FWTEST_CMDID)) {
14945 WMI_LOGP("%s: failed to send fw test command", __func__);
14946 qdf_nbuf_free(wmi_buf);
14947 return QDF_STATUS_E_FAILURE;
14948 }
14949
14950 return QDF_STATUS_SUCCESS;
14951}
14952
14953/**
Govind Singha4836fd2016-03-07 16:45:38 +053014954 * send_unit_test_cmd_tlv() - send unit test command to fw.
14955 * @wmi_handle: wmi handle
14956 * @wmi_utest: unit test command
14957 *
14958 * This function send unit test command to fw.
14959 *
14960 * Return: CDF STATUS
14961 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014962static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014963 struct wmi_unit_test_cmd *wmi_utest)
14964{
14965 wmi_unit_test_cmd_fixed_param *cmd;
14966 wmi_buf_t wmi_buf;
14967 uint8_t *buf_ptr;
14968 int i;
14969 uint16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053014970 uint32_t *unit_test_cmd_args;
Govind Singha4836fd2016-03-07 16:45:38 +053014971
14972 args_tlv_len =
Vivekc5823092018-03-22 23:27:21 +053014973 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053014974 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
14975
14976 wmi_buf = wmi_buf_alloc(wmi_handle, len);
14977 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014978 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
14979 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014980 }
14981
14982 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
14983 buf_ptr = (uint8_t *) cmd;
14984 WMITLV_SET_HDR(&cmd->tlv_header,
14985 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
14986 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
14987 cmd->vdev_id = wmi_utest->vdev_id;
14988 cmd->module_id = wmi_utest->module_id;
14989 cmd->num_args = wmi_utest->num_args;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070014990 cmd->diag_token = wmi_utest->diag_token;
Govind Singha4836fd2016-03-07 16:45:38 +053014991 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
14992 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14993 (wmi_utest->num_args * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053014994 unit_test_cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070014995 WMI_LOGI("%s: VDEV ID: %d\n", __func__, cmd->vdev_id);
14996 WMI_LOGI("%s: MODULE ID: %d\n", __func__, cmd->module_id);
14997 WMI_LOGI("%s: TOKEN: %d\n", __func__, cmd->diag_token);
Govind Singhb53420c2016-03-09 14:32:57 +053014998 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Shaakir Mohamed66ebeca2018-01-19 15:49:23 -080014999 for (i = 0; (i < wmi_utest->num_args && i < WMI_UNIT_TEST_MAX_NUM_ARGS); i++) {
Govind Singha4836fd2016-03-07 16:45:38 +053015000 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015001 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015002 }
15003 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15004 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015005 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053015006 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015007 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015008 }
15009
Govind Singhb53420c2016-03-09 14:32:57 +053015010 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015011}
15012
15013/**
15014 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
15015 * @wmi_handle: wma handle
15016 * @roaminvoke: roam invoke command
15017 *
15018 * Send roam invoke command to fw for fastreassoc.
15019 *
15020 * Return: CDF STATUS
15021 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015022static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015023 struct wmi_roam_invoke_cmd *roaminvoke,
15024 uint32_t ch_hz)
15025{
15026 wmi_roam_invoke_cmd_fixed_param *cmd;
15027 wmi_buf_t wmi_buf;
15028 u_int8_t *buf_ptr;
15029 u_int16_t len, args_tlv_len;
Vivekc5823092018-03-22 23:27:21 +053015030 uint32_t *channel_list;
Govind Singha4836fd2016-03-07 16:45:38 +053015031 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080015032 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053015033
15034 /* Host sends only one channel and one bssid */
Vivekc5823092018-03-22 23:27:21 +053015035 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(uint32_t) +
Naveen Rawat77797922017-01-20 17:00:07 -080015036 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
15037 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053015038 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
15039 wmi_buf = wmi_buf_alloc(wmi_handle, len);
15040 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015041 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
15042 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015043 }
15044
15045 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
15046 buf_ptr = (u_int8_t *) cmd;
15047 WMITLV_SET_HDR(&cmd->tlv_header,
15048 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
15049 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
15050 cmd->vdev_id = roaminvoke->vdev_id;
Arif Hussain7698b6d2016-12-15 20:05:36 -080015051 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_REPORT_FAILURE);
Krunal Soni7544a402017-07-25 11:23:44 -070015052 if (roaminvoke->is_same_bssid)
15053 cmd->flags |= (1 << WMI_ROAM_INVOKE_FLAG_NO_NULL_FRAME_TO_AP);
15054 WMI_LOGD(FL("is_same_bssid flag: %d"), roaminvoke->is_same_bssid);
Naveen Rawat77797922017-01-20 17:00:07 -080015055
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015056 if (roaminvoke->frame_len) {
Naveen Rawat77797922017-01-20 17:00:07 -080015057 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015058 /* packing 1 beacon/probe_rsp frame with WMI cmd */
15059 cmd->num_buf = 1;
15060 } else {
Naveen Rawat77797922017-01-20 17:00:07 -080015061 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015062 cmd->num_buf = 0;
15063 }
Naveen Rawat77797922017-01-20 17:00:07 -080015064
Govind Singha4836fd2016-03-07 16:45:38 +053015065 cmd->roam_ap_sel_mode = 0;
15066 cmd->roam_delay = 0;
15067 cmd->num_chan = 1;
15068 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080015069
Govind Singha4836fd2016-03-07 16:45:38 +053015070 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
15071 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15072 (sizeof(u_int32_t)));
Vivekc5823092018-03-22 23:27:21 +053015073 channel_list = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singha4836fd2016-03-07 16:45:38 +053015074 *channel_list = ch_hz;
Vivekc5823092018-03-22 23:27:21 +053015075 buf_ptr += sizeof(uint32_t) + WMI_TLV_HDR_SIZE;
Govind Singha4836fd2016-03-07 16:45:38 +053015076 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15077 (sizeof(wmi_mac_addr)));
15078 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
15079 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080015080
15081 /* move to next tlv i.e. bcn_prb_buf_list */
15082 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
15083
15084 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
15085 sizeof(wmi_tlv_buf_len_param));
15086
15087 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
15088 buf_len_tlv->buf_len = roaminvoke->frame_len;
15089
15090 /* move to next tlv i.e. bcn_prb_frm */
15091 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
15092 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
15093 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
15094
15095 /* copy frame after the header */
15096 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
15097 roaminvoke->frame_buf,
15098 roaminvoke->frame_len);
15099
15100 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070015101 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat77797922017-01-20 17:00:07 -080015102 buf_ptr + WMI_TLV_HDR_SIZE,
15103 roaminvoke->frame_len);
Varun Reddy Yeturu2892dce2017-07-14 16:47:48 -070015104 WMI_LOGD(FL("flag:%d, MODE scn:%d, ap:%d, dly:%d, n_ch:%d, n_bssid:%d"),
15105 cmd->flags, cmd->roam_scan_mode,
15106 cmd->roam_ap_sel_mode, cmd->roam_delay,
15107 cmd->num_chan, cmd->num_bssid);
15108 WMI_LOGD(FL("BSSID: %pM, channel: %d"), roaminvoke->bssid, ch_hz);
Naveen Rawat77797922017-01-20 17:00:07 -080015109
Govind Singha4836fd2016-03-07 16:45:38 +053015110 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
15111 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015112 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053015113 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053015114 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053015115 }
15116
Govind Singhb53420c2016-03-09 14:32:57 +053015117 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015118}
15119
15120/**
15121 * send_roam_scan_offload_cmd_tlv() - set roam offload command
15122 * @wmi_handle: wmi handle
15123 * @command: command
15124 * @vdev_id: vdev id
15125 *
15126 * This function set roam offload command to fw.
15127 *
15128 * Return: CDF status
15129 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015130static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015131 uint32_t command, uint32_t vdev_id)
15132{
Govind Singh67922e82016-04-01 16:48:57 +053015133 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015134 wmi_roam_scan_cmd_fixed_param *cmd_fp;
15135 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015136 int len;
15137 uint8_t *buf_ptr;
15138
15139 len = sizeof(wmi_roam_scan_cmd_fixed_param);
15140 buf = wmi_buf_alloc(wmi_handle, len);
15141 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015142 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15143 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015144 }
15145
15146 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15147
15148 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
15149 WMITLV_SET_HDR(&cmd_fp->tlv_header,
15150 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
15151 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
15152 cmd_fp->vdev_id = vdev_id;
15153 cmd_fp->command_arg = command;
15154
15155 status = wmi_unified_cmd_send(wmi_handle, buf,
15156 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053015157 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015158 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015159 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015160 goto error;
15161 }
15162
Govind Singhb53420c2016-03-09 14:32:57 +053015163 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
15164 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015165
15166error:
15167 wmi_buf_free(buf);
15168
Govind Singh67922e82016-04-01 16:48:57 +053015169 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015170}
15171
15172/**
15173 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
15174 * @wmi_handle: wmi handle
15175 * @ap_profile_p: ap profile
15176 * @vdev_id: vdev id
15177 *
15178 * Send WMI_ROAM_AP_PROFILE to firmware
15179 *
15180 * Return: CDF status
15181 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015182static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015183 struct ap_profile_params *ap_profile)
Govind Singha4836fd2016-03-07 16:45:38 +053015184{
Govind Singha4836fd2016-03-07 16:45:38 +053015185 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015186 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015187 int len;
15188 uint8_t *buf_ptr;
15189 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015190 wmi_roam_cnd_scoring_param *score_param;
15191 wmi_ap_profile *profile;
Govind Singha4836fd2016-03-07 16:45:38 +053015192
15193 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015194 len += sizeof(*score_param);
Govind Singha4836fd2016-03-07 16:45:38 +053015195 buf = wmi_buf_alloc(wmi_handle, len);
15196 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015197 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15198 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015199 }
15200
15201 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15202 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
15203 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
15204 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
15205 WMITLV_GET_STRUCT_TLVLEN
15206 (wmi_roam_ap_profile_fixed_param));
15207 /* fill in threshold values */
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015208 roam_ap_profile_fp->vdev_id = ap_profile->vdev_id;
Govind Singha4836fd2016-03-07 16:45:38 +053015209 roam_ap_profile_fp->id = 0;
15210 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
15211
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015212 profile = (wmi_ap_profile *)buf_ptr;
15213 WMITLV_SET_HDR(&profile->tlv_header,
Govind Singha4836fd2016-03-07 16:45:38 +053015214 WMITLV_TAG_STRUC_wmi_ap_profile,
15215 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
Himanshu Agarwaleaf7d732017-09-28 11:51:35 +053015216 profile->flags = ap_profile->profile.flags;
15217 profile->rssi_threshold = ap_profile->profile.rssi_threshold;
15218 profile->ssid.ssid_len = ap_profile->profile.ssid.length;
15219 qdf_mem_copy(profile->ssid.ssid, ap_profile->profile.ssid.mac_ssid,
15220 profile->ssid.ssid_len);
15221 profile->rsn_authmode = ap_profile->profile.rsn_authmode;
15222 profile->rsn_ucastcipherset = ap_profile->profile.rsn_ucastcipherset;
15223 profile->rsn_mcastcipherset = ap_profile->profile.rsn_mcastcipherset;
15224 profile->rsn_mcastmgmtcipherset =
15225 ap_profile->profile.rsn_mcastmgmtcipherset;
15226 profile->rssi_abs_thresh = ap_profile->profile.rssi_abs_thresh;
15227
15228 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",
15229 profile->flags, profile->rssi_threshold,
15230 profile->ssid.ssid_len, ap_profile->profile.ssid.mac_ssid,
15231 profile->rsn_authmode, profile->rsn_ucastcipherset,
15232 profile->rsn_mcastcipherset, profile->rsn_mcastmgmtcipherset,
15233 profile->rssi_abs_thresh);
15234
15235 buf_ptr += sizeof(wmi_ap_profile);
15236
15237 score_param = (wmi_roam_cnd_scoring_param *)buf_ptr;
15238 WMITLV_SET_HDR(&score_param->tlv_header,
15239 WMITLV_TAG_STRUC_wmi_roam_cnd_scoring_param,
15240 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_cnd_scoring_param));
15241 score_param->disable_bitmap = ap_profile->param.disable_bitmap;
15242 score_param->rssi_weightage_pcnt =
15243 ap_profile->param.rssi_weightage;
15244 score_param->ht_weightage_pcnt = ap_profile->param.ht_weightage;
15245 score_param->vht_weightage_pcnt = ap_profile->param.vht_weightage;
15246 score_param->he_weightage_pcnt = ap_profile->param.he_weightage;
15247 score_param->bw_weightage_pcnt = ap_profile->param.bw_weightage;
15248 score_param->band_weightage_pcnt = ap_profile->param.band_weightage;
15249 score_param->nss_weightage_pcnt = ap_profile->param.nss_weightage;
15250 score_param->esp_qbss_weightage_pcnt =
15251 ap_profile->param.esp_qbss_weightage;
15252 score_param->beamforming_weightage_pcnt =
15253 ap_profile->param.beamforming_weightage;
15254 score_param->pcl_weightage_pcnt = ap_profile->param.pcl_weightage;
15255 score_param->oce_wan_weightage_pcnt =
15256 ap_profile->param.oce_wan_weightage;
15257
15258 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",
15259 score_param->disable_bitmap, score_param->rssi_weightage_pcnt,
15260 score_param->ht_weightage_pcnt,
15261 score_param->vht_weightage_pcnt,
15262 score_param->he_weightage_pcnt, score_param->bw_weightage_pcnt,
15263 score_param->band_weightage_pcnt,
15264 score_param->nss_weightage_pcnt,
15265 score_param->esp_qbss_weightage_pcnt,
15266 score_param->beamforming_weightage_pcnt,
15267 score_param->pcl_weightage_pcnt,
15268 score_param->oce_wan_weightage_pcnt);
15269
15270 score_param->bw_scoring.score_pcnt = ap_profile->param.bw_index_score;
15271 score_param->band_scoring.score_pcnt =
15272 ap_profile->param.band_index_score;
15273 score_param->nss_scoring.score_pcnt =
15274 ap_profile->param.nss_index_score;
15275
15276 WMI_LOGD("Params index score bitmask: bw_index_score %x band_index_score %x nss_index_score %x",
15277 score_param->bw_scoring.score_pcnt,
15278 score_param->band_scoring.score_pcnt,
15279 score_param->nss_scoring.score_pcnt);
15280
15281 score_param->rssi_scoring.best_rssi_threshold =
15282 (-1) * ap_profile->param.rssi_scoring.best_rssi_threshold;
15283 score_param->rssi_scoring.good_rssi_threshold =
15284 (-1) * ap_profile->param.rssi_scoring.good_rssi_threshold;
15285 score_param->rssi_scoring.bad_rssi_threshold =
15286 (-1) * ap_profile->param.rssi_scoring.bad_rssi_threshold;
15287 score_param->rssi_scoring.good_rssi_pcnt =
15288 ap_profile->param.rssi_scoring.good_rssi_pcnt;
15289 score_param->rssi_scoring.bad_rssi_pcnt =
15290 ap_profile->param.rssi_scoring.bad_rssi_pcnt;
15291 score_param->rssi_scoring.good_bucket_size =
15292 ap_profile->param.rssi_scoring.good_bucket_size;
15293 score_param->rssi_scoring.bad_bucket_size =
15294 ap_profile->param.rssi_scoring.bad_bucket_size;
15295 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh =
15296 (-1) * ap_profile->param.rssi_scoring.rssi_pref_5g_rssi_thresh;
15297
15298 WMI_LOGD("Rssi scoring threshold: best RSSI %d good RSSI %d bad RSSI %d prefer 5g threshold %d",
15299 score_param->rssi_scoring.best_rssi_threshold,
15300 score_param->rssi_scoring.good_rssi_threshold,
15301 score_param->rssi_scoring.bad_rssi_threshold,
15302 score_param->rssi_scoring.rssi_pref_5g_rssi_thresh);
15303 WMI_LOGD("Good RSSI score for each slot %d bad RSSI score for each slot %d good bucket %d bad bucket %d",
15304 score_param->rssi_scoring.good_rssi_pcnt,
15305 score_param->rssi_scoring.bad_rssi_pcnt,
15306 score_param->rssi_scoring.good_bucket_size,
15307 score_param->rssi_scoring.bad_bucket_size);
15308
15309 score_param->esp_qbss_scoring.num_slot =
15310 ap_profile->param.esp_qbss_scoring.num_slot;
15311 score_param->esp_qbss_scoring.score_pcnt3_to_0 =
15312 ap_profile->param.esp_qbss_scoring.score_pcnt3_to_0;
15313 score_param->esp_qbss_scoring.score_pcnt7_to_4 =
15314 ap_profile->param.esp_qbss_scoring.score_pcnt7_to_4;
15315 score_param->esp_qbss_scoring.score_pcnt11_to_8 =
15316 ap_profile->param.esp_qbss_scoring.score_pcnt11_to_8;
15317 score_param->esp_qbss_scoring.score_pcnt15_to_12 =
15318 ap_profile->param.esp_qbss_scoring.score_pcnt15_to_12;
15319
15320 WMI_LOGD("ESP QBSS index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15321 score_param->esp_qbss_scoring.num_slot,
15322 score_param->esp_qbss_scoring.score_pcnt3_to_0,
15323 score_param->esp_qbss_scoring.score_pcnt7_to_4,
15324 score_param->esp_qbss_scoring.score_pcnt11_to_8,
15325 score_param->esp_qbss_scoring.score_pcnt15_to_12);
15326
15327 score_param->oce_wan_scoring.num_slot =
15328 ap_profile->param.oce_wan_scoring.num_slot;
15329 score_param->oce_wan_scoring.score_pcnt3_to_0 =
15330 ap_profile->param.oce_wan_scoring.score_pcnt3_to_0;
15331 score_param->oce_wan_scoring.score_pcnt7_to_4 =
15332 ap_profile->param.oce_wan_scoring.score_pcnt7_to_4;
15333 score_param->oce_wan_scoring.score_pcnt11_to_8 =
15334 ap_profile->param.oce_wan_scoring.score_pcnt11_to_8;
15335 score_param->oce_wan_scoring.score_pcnt15_to_12 =
15336 ap_profile->param.oce_wan_scoring.score_pcnt15_to_12;
15337
15338 WMI_LOGD("OCE WAN index weight: slots %d weight 0to3 %x weight 4to7 %x weight 8to11 %x weight 12to15 %x",
15339 score_param->oce_wan_scoring.num_slot,
15340 score_param->oce_wan_scoring.score_pcnt3_to_0,
15341 score_param->oce_wan_scoring.score_pcnt7_to_4,
15342 score_param->oce_wan_scoring.score_pcnt11_to_8,
15343 score_param->oce_wan_scoring.score_pcnt15_to_12);
15344
Govind Singha4836fd2016-03-07 16:45:38 +053015345 status = wmi_unified_cmd_send(wmi_handle, buf,
15346 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053015347 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015348 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015349 status);
Govind Singh67922e82016-04-01 16:48:57 +053015350 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053015351 }
15352
Govind Singhb53420c2016-03-09 14:32:57 +053015353 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053015354
Govind Singh67922e82016-04-01 16:48:57 +053015355 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015356}
15357
15358/**
15359 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
15360 * @wmi_handle: wmi handle
15361 * @scan_period: scan period
15362 * @scan_age: scan age
15363 * @vdev_id: vdev id
15364 *
15365 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
15366 *
15367 * Return: CDF status
15368 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015369static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015370 uint32_t scan_period,
15371 uint32_t scan_age,
15372 uint32_t vdev_id)
15373{
Govind Singh67922e82016-04-01 16:48:57 +053015374 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015375 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053015376 int len;
15377 uint8_t *buf_ptr;
15378 wmi_roam_scan_period_fixed_param *scan_period_fp;
15379
15380 /* Send scan period values */
15381 len = sizeof(wmi_roam_scan_period_fixed_param);
15382 buf = wmi_buf_alloc(wmi_handle, len);
15383 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015384 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15385 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015386 }
15387
15388 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15389 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
15390 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
15391 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
15392 WMITLV_GET_STRUCT_TLVLEN
15393 (wmi_roam_scan_period_fixed_param));
15394 /* fill in scan period values */
15395 scan_period_fp->vdev_id = vdev_id;
15396 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
15397 scan_period_fp->roam_scan_age = scan_age;
15398
15399 status = wmi_unified_cmd_send(wmi_handle, buf,
15400 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053015401 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015402 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015403 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015404 goto error;
15405 }
15406
Govind Singhb53420c2016-03-09 14:32:57 +053015407 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053015408 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053015409 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015410error:
15411 wmi_buf_free(buf);
15412
Govind Singh67922e82016-04-01 16:48:57 +053015413 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015414}
15415
15416/**
15417 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
15418 * @wmi_handle: wmi handle
15419 * @chan_count: channel count
15420 * @chan_list: channel list
15421 * @list_type: list type
15422 * @vdev_id: vdev id
15423 *
15424 * Set roam offload channel list.
15425 *
15426 * Return: CDF status
15427 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015428static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015429 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070015430 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053015431 uint8_t list_type, uint32_t vdev_id)
15432{
Govind Singha4836fd2016-03-07 16:45:38 +053015433 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015434 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015435 int len, list_tlv_len;
15436 int i;
15437 uint8_t *buf_ptr;
15438 wmi_roam_chan_list_fixed_param *chan_list_fp;
Vivekc5823092018-03-22 23:27:21 +053015439 uint32_t *roam_chan_list_array;
Govind Singha4836fd2016-03-07 16:45:38 +053015440
15441 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053015442 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053015443 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053015444 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053015445 }
15446 /* Channel list is a table of 2 TLV's */
Vivekc5823092018-03-22 23:27:21 +053015447 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(uint32_t);
Govind Singha4836fd2016-03-07 16:45:38 +053015448 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
15449 buf = wmi_buf_alloc(wmi_handle, len);
15450 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015451 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15452 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015453 }
15454
15455 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15456 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
15457 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
15458 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
15459 WMITLV_GET_STRUCT_TLVLEN
15460 (wmi_roam_chan_list_fixed_param));
15461 chan_list_fp->vdev_id = vdev_id;
15462 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053015463 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053015464 /* external app is controlling channel list */
15465 chan_list_fp->chan_list_type =
15466 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
15467 } else {
15468 /* umac supplied occupied channel list in LFR */
15469 chan_list_fp->chan_list_type =
15470 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
15471 }
15472
15473 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
15474 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15475 (chan_list_fp->num_chan * sizeof(uint32_t)));
Vivekc5823092018-03-22 23:27:21 +053015476 roam_chan_list_array = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015477 WMI_LOGD("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053015478 for (i = 0; ((i < chan_list_fp->num_chan) &&
15479 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
15480 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053015481 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053015482 }
15483
15484 status = wmi_unified_cmd_send(wmi_handle, buf,
15485 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053015486 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015487 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015488 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015489 goto error;
15490 }
15491
Srinivas Girigowda245fa9e2017-03-10 16:00:56 -080015492 WMI_LOGD("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053015493 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015494error:
15495 wmi_buf_free(buf);
15496
Govind Singh67922e82016-04-01 16:48:57 +053015497 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015498}
15499
15500/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015501 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
15502 * @wmi_handle: wmi handle
15503 * @req_buf: per roam config buffer
15504 *
15505 * Return: QDF status
15506 */
15507static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
15508 struct wmi_per_roam_config_req *req_buf)
15509{
15510 wmi_buf_t buf = NULL;
15511 QDF_STATUS status;
15512 int len;
15513 uint8_t *buf_ptr;
15514 wmi_roam_per_config_fixed_param *wmi_per_config;
15515
15516 len = sizeof(wmi_roam_per_config_fixed_param);
15517 buf = wmi_buf_alloc(wmi_handle, len);
15518 if (!buf) {
15519 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15520 return QDF_STATUS_E_NOMEM;
15521 }
15522
15523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15524 wmi_per_config =
15525 (wmi_roam_per_config_fixed_param *) buf_ptr;
15526 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
15527 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
15528 WMITLV_GET_STRUCT_TLVLEN
15529 (wmi_roam_per_config_fixed_param));
15530
15531 /* fill in per roam config values */
15532 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015533
15534 wmi_per_config->enable = req_buf->per_config.enable;
15535 wmi_per_config->high_rate_thresh =
15536 (req_buf->per_config.tx_high_rate_thresh << 16) |
15537 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
15538 wmi_per_config->low_rate_thresh =
15539 (req_buf->per_config.tx_low_rate_thresh << 16) |
15540 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
15541 wmi_per_config->pkt_err_rate_thresh_pct =
15542 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
15543 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
15544 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053015545 wmi_per_config->pkt_err_rate_mon_time =
15546 (req_buf->per_config.tx_per_mon_time << 16) |
15547 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Selvaraj, Sridharba7e3612017-05-17 16:05:15 +053015548 wmi_per_config->min_candidate_rssi =
15549 req_buf->per_config.min_candidate_rssi;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053015550
15551 /* Send per roam config parameters */
15552 status = wmi_unified_cmd_send(wmi_handle, buf,
15553 len, WMI_ROAM_PER_CONFIG_CMDID);
15554 if (QDF_IS_STATUS_ERROR(status)) {
15555 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
15556 status);
15557 wmi_buf_free(buf);
15558 return status;
15559 }
15560
15561 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
15562 req_buf->per_config.enable, req_buf->vdev_id);
15563 return QDF_STATUS_SUCCESS;
15564}
15565
15566/**
Govind Singha4836fd2016-03-07 16:45:38 +053015567 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
15568 * @wmi_handle: wmi handle
15569 * @rssi_change_thresh: RSSI Change threshold
15570 * @bcn_rssi_weight: beacon RSSI weight
15571 * @vdev_id: vdev id
15572 *
15573 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
15574 *
15575 * Return: CDF status
15576 */
Sathish Kumarfd347372017-02-13 12:29:09 +053015577static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053015578 uint32_t vdev_id,
15579 int32_t rssi_change_thresh,
15580 uint32_t bcn_rssi_weight,
15581 uint32_t hirssi_delay_btw_scans)
15582{
Govind Singha4836fd2016-03-07 16:45:38 +053015583 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053015584 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053015585 int len;
15586 uint8_t *buf_ptr;
15587 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
15588
15589 /* Send rssi change parameters */
15590 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
15591 buf = wmi_buf_alloc(wmi_handle, len);
15592 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053015593 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15594 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053015595 }
15596
15597 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15598 rssi_change_fp =
15599 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
15600 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
15601 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
15602 WMITLV_GET_STRUCT_TLVLEN
15603 (wmi_roam_scan_rssi_change_threshold_fixed_param));
15604 /* fill in rssi change threshold (hysteresis) values */
15605 rssi_change_fp->vdev_id = vdev_id;
15606 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
15607 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
15608 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
15609
15610 status = wmi_unified_cmd_send(wmi_handle, buf,
15611 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053015612 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053015613 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053015614 status);
Govind Singha4836fd2016-03-07 16:45:38 +053015615 goto error;
15616 }
15617
Govind Singhb53420c2016-03-09 14:32:57 +053015618 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053015619 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053015620 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
15621 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053015622error:
15623 wmi_buf_free(buf);
15624
Govind Singh67922e82016-04-01 16:48:57 +053015625 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053015626}
15627
Govind Singhbca3b1b2016-05-02 17:59:24 +053015628/**
15629 * send_power_dbg_cmd_tlv() - send power debug commands
15630 * @wmi_handle: wmi handle
15631 * @param: wmi power debug parameter
15632 *
15633 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
15634 *
15635 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15636 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015637static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
15638 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053015639{
15640 wmi_buf_t buf = NULL;
15641 QDF_STATUS status;
15642 int len, args_tlv_len;
15643 uint8_t *buf_ptr;
15644 uint8_t i;
15645 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
15646 uint32_t *cmd_args;
15647
15648 /* Prepare and send power debug cmd parameters */
15649 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
15650 len = sizeof(*cmd) + args_tlv_len;
15651 buf = wmi_buf_alloc(wmi_handle, len);
15652 if (!buf) {
15653 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15654 return QDF_STATUS_E_NOMEM;
15655 }
15656
15657 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15658 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
15659 WMITLV_SET_HDR(&cmd->tlv_header,
15660 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
15661 WMITLV_GET_STRUCT_TLVLEN
15662 (wmi_pdev_wal_power_debug_cmd_fixed_param));
15663
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015664 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15665 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053015666 cmd->module_id = param->module_id;
15667 cmd->num_args = param->num_args;
15668 buf_ptr += sizeof(*cmd);
15669 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
15670 (param->num_args * sizeof(uint32_t)));
15671 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
15672 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
Varun Reddy Yeturue6f8be32018-02-27 13:46:11 -080015673 for (i = 0; (i < param->num_args && i < WMI_MAX_POWER_DBG_ARGS); i++) {
Govind Singhbca3b1b2016-05-02 17:59:24 +053015674 cmd_args[i] = param->args[i];
15675 WMI_LOGI("%d,", param->args[i]);
15676 }
15677
15678 status = wmi_unified_cmd_send(wmi_handle, buf,
15679 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
15680 if (QDF_IS_STATUS_ERROR(status)) {
15681 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
15682 status);
15683 goto error;
15684 }
15685
15686 return QDF_STATUS_SUCCESS;
15687error:
15688 wmi_buf_free(buf);
15689
15690 return status;
15691}
15692
Govind Singhe7f2f342016-05-23 12:12:52 +053015693/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015694 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
15695 * @wmi_handle: wmi handle
15696 * @param: wmi multiple vdev restart req param
15697 *
15698 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
15699 *
15700 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15701 */
15702static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
15703 wmi_unified_t wmi_handle,
15704 struct multiple_vdev_restart_params *param)
15705{
15706 wmi_buf_t buf;
15707 QDF_STATUS qdf_status;
15708 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
15709 int i;
15710 uint8_t *buf_ptr;
15711 uint32_t *vdev_ids;
15712 wmi_channel *chan_info;
15713 struct channel_param *tchan_info;
15714 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
15715
15716 len += sizeof(wmi_channel);
15717 if (param->num_vdevs)
15718 len += sizeof(uint32_t) * param->num_vdevs;
15719
15720 buf = wmi_buf_alloc(wmi_handle, len);
15721 if (!buf) {
15722 WMI_LOGE("Failed to allocate memory\n");
15723 qdf_status = QDF_STATUS_E_NOMEM;
15724 goto end;
15725 }
15726
15727 buf_ptr = (uint8_t *)wmi_buf_data(buf);
15728 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
15729 buf_ptr;
15730
15731 WMITLV_SET_HDR(&cmd->tlv_header,
15732 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
15733 WMITLV_GET_STRUCT_TLVLEN
15734 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015735 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
15736 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015737 cmd->requestor_id = param->requestor_id;
15738 cmd->disable_hw_ack = param->disable_hw_ack;
15739 cmd->cac_duration_ms = param->cac_duration_ms;
15740 cmd->num_vdevs = param->num_vdevs;
15741
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015742 WMI_LOGI("%s:cmd->pdev_id: %d ,cmd->requestor_id: %d ,"
15743 "cmd->disable_hw_ack: %d , cmd->cac_duration_ms:%d ,"
15744 " cmd->num_vdevs: %d ",
15745 __func__, cmd->pdev_id, cmd->requestor_id,
15746 cmd->disable_hw_ack, cmd->cac_duration_ms, cmd->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015747 buf_ptr += sizeof(*cmd);
15748
15749 WMITLV_SET_HDR(buf_ptr,
15750 WMITLV_TAG_ARRAY_UINT32,
Vivekc5823092018-03-22 23:27:21 +053015751 sizeof(uint32_t) * param->num_vdevs);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015752 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
15753 for (i = 0; i < param->num_vdevs; i++) {
15754 vdev_ids[i] = param->vdev_ids[i];
15755 }
15756
Vivekc5823092018-03-22 23:27:21 +053015757 buf_ptr += (sizeof(uint32_t) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015758
15759 WMITLV_SET_HDR(buf_ptr,
15760 WMITLV_TAG_STRUC_wmi_channel,
15761 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053015762 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053015763 tchan_info = &(param->ch_param);
15764 chan_info->mhz = tchan_info->mhz;
15765 chan_info->band_center_freq1 = tchan_info->cfreq1;
15766 chan_info->band_center_freq2 = tchan_info->cfreq2;
15767 if (tchan_info->is_chan_passive)
15768 WMI_SET_CHANNEL_FLAG(chan_info,
15769 WMI_CHAN_FLAG_PASSIVE);
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015770 if (tchan_info->dfs_set)
15771 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_DFS);
15772
Sathish Kumar45e991b2017-02-27 10:35:40 +053015773 if (tchan_info->allow_vht)
15774 WMI_SET_CHANNEL_FLAG(chan_info,
15775 WMI_CHAN_FLAG_ALLOW_VHT);
15776 else if (tchan_info->allow_ht)
15777 WMI_SET_CHANNEL_FLAG(chan_info,
15778 WMI_CHAN_FLAG_ALLOW_HT);
15779 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
15780 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
15781 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
15782 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
15783 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
15784 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
Kai Chen4710d462017-12-15 14:06:06 -080015785 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info, tchan_info->maxregpower);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015786
Shaakir Mohamed9fbf00a2018-02-12 14:00:22 -080015787 WMI_LOGI("%s:tchan_info->is_chan_passive: %d ,"
15788 "tchan_info->dfs_set : %d ,tchan_info->allow_vht:%d ,"
15789 "tchan_info->allow_ht: %d ,tchan_info->antennamax: %d ,"
15790 "tchan_info->phy_mode: %d ,tchan_info->minpower: %d,"
15791 "tchan_info->maxpower: %d ,tchan_info->maxregpower: %d ,"
15792 "tchan_info->reg_class_id: %d ,"
15793 "tchan_info->maxregpower : %d ", __func__,
15794 tchan_info->is_chan_passive, tchan_info->dfs_set,
15795 tchan_info->allow_vht, tchan_info->allow_ht,
15796 tchan_info->antennamax, tchan_info->phy_mode,
15797 tchan_info->minpower, tchan_info->maxpower,
15798 tchan_info->maxregpower, tchan_info->reg_class_id,
15799 tchan_info->maxregpower);
15800
Sathish Kumar45e991b2017-02-27 10:35:40 +053015801 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
15802 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
15803
15804 if (QDF_IS_STATUS_ERROR(qdf_status)) {
15805 WMI_LOGE("%s: Failed to send\n", __func__);
15806 wmi_buf_free(buf);
15807 }
15808
15809end:
15810 return qdf_status;
15811}
15812
15813/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080015814 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
15815 * @wmi_handle: wmi handle
15816 * @pdev_id: pdev id
15817 *
15818 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
15819 *
15820 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15821 */
15822static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
15823 uint32_t pdev_id)
15824{
15825 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
15826 wmi_buf_t buf;
15827 uint16_t len;
15828 QDF_STATUS ret;
15829
15830 len = sizeof(*cmd);
15831 buf = wmi_buf_alloc(wmi_handle, len);
15832
15833 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15834
15835 if (!buf) {
15836 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15837 return QDF_STATUS_E_NOMEM;
15838 }
15839
15840 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
15841 wmi_buf_data(buf);
15842
15843 WMITLV_SET_HDR(&cmd->tlv_header,
15844 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
15845 WMITLV_GET_STRUCT_TLVLEN(
15846 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
15847
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015848 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015849 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15850 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
15851 if (QDF_IS_STATUS_ERROR(ret)) {
15852 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15853 __func__, ret, pdev_id);
15854 wmi_buf_free(buf);
15855 return QDF_STATUS_E_FAILURE;
15856 }
15857
15858 return QDF_STATUS_SUCCESS;
15859}
15860
15861/**
15862 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
15863 * @wmi_handle: wmi handle
15864 * @pdev_id: pdev id
15865 *
15866 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
15867 *
15868 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
15869 */
15870static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
15871 uint32_t pdev_id)
15872{
15873 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
15874 wmi_buf_t buf;
15875 uint16_t len;
15876 QDF_STATUS ret;
15877
15878 len = sizeof(*cmd);
15879 buf = wmi_buf_alloc(wmi_handle, len);
15880
15881 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
15882
15883 if (!buf) {
15884 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
15885 return QDF_STATUS_E_NOMEM;
15886 }
15887
15888 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
15889 wmi_buf_data(buf);
15890
15891 WMITLV_SET_HDR(&cmd->tlv_header,
15892 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
15893 WMITLV_GET_STRUCT_TLVLEN(
15894 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
15895
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015896 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080015897 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
15898 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
15899 if (QDF_IS_STATUS_ERROR(ret)) {
15900 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
15901 __func__, ret, pdev_id);
15902 wmi_buf_free(buf);
15903 return QDF_STATUS_E_FAILURE;
15904 }
15905
15906 return QDF_STATUS_SUCCESS;
15907}
15908
15909/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015910 * init_cmd_send_tlv() - send initialization cmd to fw
15911 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053015912 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053015913 *
15914 * Return: QDF_STATUS_SUCCESS for success or error code
15915 */
15916static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053015917 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015918{
15919 wmi_buf_t buf;
15920 wmi_init_cmd_fixed_param *cmd;
Govind Singhe7f2f342016-05-23 12:12:52 +053015921 uint8_t *buf_ptr;
15922 wmi_resource_config *resource_cfg;
15923 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053015924 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053015925 uint16_t idx;
15926 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053015927 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053015928
Kiran Venkatappa26117052016-12-23 19:58:54 +053015929 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
15930 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015931 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053015932
15933 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
15934 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
15935 WMI_TLV_HDR_SIZE +
15936 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
15937
15938 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053015939 if (!buf) {
15940 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15941 return QDF_STATUS_E_FAILURE;
15942 }
15943
15944 buf_ptr = (uint8_t *) wmi_buf_data(buf);
15945 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
15946 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
15947
15948 host_mem_chunks = (wlan_host_memory_chunk *)
15949 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
15950 + WMI_TLV_HDR_SIZE);
15951
15952 WMITLV_SET_HDR(&cmd->tlv_header,
15953 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
15954 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
15955
Kiran Venkatappa26117052016-12-23 19:58:54 +053015956 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053015957 WMITLV_SET_HDR(&resource_cfg->tlv_header,
15958 WMITLV_TAG_STRUC_wmi_resource_config,
15959 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
15960
Kiran Venkatappa26117052016-12-23 19:58:54 +053015961 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053015962 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
15963 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
15964 WMITLV_GET_STRUCT_TLVLEN
15965 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053015966 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
15967 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
15968 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Vivekf85a42b2017-06-21 11:38:28 +053015969 QDF_TRACE(QDF_MODULE_ID_ANY, QDF_TRACE_LEVEL_DEBUG,
15970 "chunk %d len %d requested ,ptr 0x%x ",
Govind Singhe7f2f342016-05-23 12:12:52 +053015971 idx, host_mem_chunks[idx].size,
15972 host_mem_chunks[idx].ptr);
15973 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053015974 cmd->num_host_mem_chunks = param->num_mem_chunks;
15975 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
15976
Govind Singhe7f2f342016-05-23 12:12:52 +053015977 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
15978 WMITLV_TAG_ARRAY_STRUC,
15979 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053015980 param->num_mem_chunks));
15981
15982 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015983 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053015984
Kiran Venkatappa22a02982017-10-11 22:56:45 +053015985 /* Fill fw_abi_vers */
15986 copy_fw_abi_version_tlv(wmi_handle, cmd);
Govind Singhe7f2f342016-05-23 12:12:52 +053015987
Abhishek Singh716c46c2016-05-04 16:24:07 +053015988 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
15989 if (QDF_IS_STATUS_ERROR(ret)) {
15990 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
15991 ret);
15992 wmi_buf_free(buf);
15993 }
Kiran Venkatappa22a02982017-10-11 22:56:45 +053015994
Abhishek Singh716c46c2016-05-04 16:24:07 +053015995 return ret;
15996
Govind Singhe7f2f342016-05-23 12:12:52 +053015997}
15998
15999/**
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080016000 * send_addba_send_cmd_tlv() - send addba send command to fw
16001 * @wmi_handle: wmi handle
16002 * @param: pointer to delba send params
16003 * @macaddr: peer mac address
16004 *
16005 * Send WMI_ADDBA_SEND_CMDID command to firmware
16006 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16007 */
16008static QDF_STATUS
16009send_addba_send_cmd_tlv(wmi_unified_t wmi_handle,
16010 uint8_t macaddr[IEEE80211_ADDR_LEN],
16011 struct addba_send_params *param)
16012{
16013 wmi_addba_send_cmd_fixed_param *cmd;
16014 wmi_buf_t buf;
16015 uint16_t len;
16016 QDF_STATUS ret;
16017
16018 len = sizeof(*cmd);
16019
16020 buf = wmi_buf_alloc(wmi_handle, len);
16021 if (!buf) {
16022 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16023 return QDF_STATUS_E_NOMEM;
16024 }
16025
16026 cmd = (wmi_addba_send_cmd_fixed_param *)wmi_buf_data(buf);
16027
16028 WMITLV_SET_HDR(&cmd->tlv_header,
16029 WMITLV_TAG_STRUC_wmi_addba_send_cmd_fixed_param,
16030 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_send_cmd_fixed_param));
16031
16032 cmd->vdev_id = param->vdev_id;
16033 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16034 cmd->tid = param->tidno;
16035 cmd->buffersize = param->buffersize;
16036
16037 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_ADDBA_SEND_CMDID);
16038 if (QDF_IS_STATUS_ERROR(ret)) {
16039 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16040 wmi_buf_free(buf);
16041 return QDF_STATUS_E_FAILURE;
16042 }
16043
16044 return QDF_STATUS_SUCCESS;
16045}
16046
16047/**
16048 * send_delba_send_cmd_tlv() - send delba send command to fw
16049 * @wmi_handle: wmi handle
16050 * @param: pointer to delba send params
16051 * @macaddr: peer mac address
16052 *
16053 * Send WMI_DELBA_SEND_CMDID command to firmware
16054 * Return: QDF_STATUS_SUCCESS on success. QDF_STATUS_E** on error
16055 */
16056static QDF_STATUS
16057send_delba_send_cmd_tlv(wmi_unified_t wmi_handle,
16058 uint8_t macaddr[IEEE80211_ADDR_LEN],
16059 struct delba_send_params *param)
16060{
16061 wmi_delba_send_cmd_fixed_param *cmd;
16062 wmi_buf_t buf;
16063 uint16_t len;
16064 QDF_STATUS ret;
16065
16066 len = sizeof(*cmd);
16067
16068 buf = wmi_buf_alloc(wmi_handle, len);
16069 if (!buf) {
16070 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
16071 return QDF_STATUS_E_NOMEM;
16072 }
16073
16074 cmd = (wmi_delba_send_cmd_fixed_param *)wmi_buf_data(buf);
16075
16076 WMITLV_SET_HDR(&cmd->tlv_header,
16077 WMITLV_TAG_STRUC_wmi_delba_send_cmd_fixed_param,
16078 WMITLV_GET_STRUCT_TLVLEN(wmi_delba_send_cmd_fixed_param));
16079
16080 cmd->vdev_id = param->vdev_id;
16081 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16082 cmd->tid = param->tidno;
16083 cmd->initiator = param->initiator;
16084 cmd->reasoncode = param->reasoncode;
16085
16086 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_DELBA_SEND_CMDID);
16087 if (QDF_IS_STATUS_ERROR(ret)) {
16088 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16089 wmi_buf_free(buf);
16090 return QDF_STATUS_E_FAILURE;
16091 }
16092
16093 return QDF_STATUS_SUCCESS;
16094}
16095
16096/**
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080016097 * send_addba_clearresponse_cmd_tlv() - send addba clear response command
16098 * to fw
16099 * @wmi_handle: wmi handle
16100 * @param: pointer to addba clearresp params
16101 * @macaddr: peer mac address
16102 * Return: 0 for success or error code
16103 */
16104static QDF_STATUS
16105send_addba_clearresponse_cmd_tlv(wmi_unified_t wmi_handle,
16106 uint8_t macaddr[IEEE80211_ADDR_LEN],
16107 struct addba_clearresponse_params *param)
16108{
16109 wmi_addba_clear_resp_cmd_fixed_param *cmd;
16110 wmi_buf_t buf;
16111 uint16_t len;
16112 QDF_STATUS ret;
16113
16114 len = sizeof(*cmd);
16115
16116 buf = wmi_buf_alloc(wmi_handle, len);
16117 if (!buf) {
16118 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
16119 return QDF_STATUS_E_FAILURE;
16120 }
16121 cmd = (wmi_addba_clear_resp_cmd_fixed_param *)wmi_buf_data(buf);
16122
16123 WMITLV_SET_HDR(&cmd->tlv_header,
16124 WMITLV_TAG_STRUC_wmi_addba_clear_resp_cmd_fixed_param,
16125 WMITLV_GET_STRUCT_TLVLEN(wmi_addba_clear_resp_cmd_fixed_param));
16126
16127 cmd->vdev_id = param->vdev_id;
16128 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
16129
16130 ret = wmi_unified_cmd_send(wmi_handle,
16131 buf, len, WMI_ADDBA_CLEAR_RESP_CMDID);
16132 if (QDF_IS_STATUS_ERROR(ret)) {
16133 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d", __func__, ret);
16134 wmi_buf_free(buf);
16135 return QDF_STATUS_E_FAILURE;
16136 }
16137
16138 return QDF_STATUS_SUCCESS;
16139}
16140
16141/**
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016142 * send_bcn_offload_control_cmd_tlv - send beacon ofload control cmd to fw
16143 * @wmi_handle: wmi handle
16144 * @bcn_ctrl_param: pointer to bcn_offload_control param
16145 *
16146 * Return: QDF_STATUS_SUCCESS for success or error code
16147 */
16148static
16149QDF_STATUS send_bcn_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
16150 struct bcn_offload_control *bcn_ctrl_param)
16151{
16152 wmi_buf_t buf;
16153 wmi_bcn_offload_ctrl_cmd_fixed_param *cmd;
16154 QDF_STATUS ret;
16155 uint32_t len;
16156
16157 len = sizeof(*cmd);
16158
16159 buf = wmi_buf_alloc(wmi_handle, len);
16160 if (!buf) {
16161 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
16162 return QDF_STATUS_E_FAILURE;
16163 }
16164
16165 cmd = (wmi_bcn_offload_ctrl_cmd_fixed_param *) wmi_buf_data(buf);
16166 WMITLV_SET_HDR(&cmd->tlv_header,
16167 WMITLV_TAG_STRUC_wmi_bcn_offload_ctrl_cmd_fixed_param,
16168 WMITLV_GET_STRUCT_TLVLEN
16169 (wmi_bcn_offload_ctrl_cmd_fixed_param));
16170 cmd->vdev_id = bcn_ctrl_param->vdev_id;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016171 switch (bcn_ctrl_param->bcn_ctrl_op) {
16172 case BCN_OFFLD_CTRL_TX_DISABLE:
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016173 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_DISABLE;
Vinay Adella4662d4e2018-04-27 14:49:53 +053016174 break;
16175 case BCN_OFFLD_CTRL_TX_ENABLE:
16176 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_TX_ENABLE;
16177 break;
16178 case BCN_OFFLD_CTRL_SWBA_DISABLE:
16179 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_DISABLE;
16180 break;
16181 case BCN_OFFLD_CTRL_SWBA_ENABLE:
16182 cmd->bcn_ctrl_op = WMI_BEACON_CTRL_SWBA_EVENT_ENABLE;
16183 break;
16184 default:
16185 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID unknown CTRL Operation %d",
16186 bcn_ctrl_param->bcn_ctrl_op);
16187 wmi_buf_free(buf);
16188 return QDF_STATUS_E_FAILURE;
16189 break;
16190 }
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053016191 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
16192 WMI_BCN_OFFLOAD_CTRL_CMDID);
16193
16194 if (QDF_IS_STATUS_ERROR(ret)) {
16195 WMI_LOGE("WMI_BCN_OFFLOAD_CTRL_CMDID send returned Error %d",
16196 ret);
16197 wmi_buf_free(buf);
16198 }
16199
16200 return ret;
16201}
16202
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016203#ifdef WLAN_FEATURE_NAN_CONVERGENCE
16204static QDF_STATUS nan_ndp_initiator_req_tlv(wmi_unified_t wmi_handle,
16205 struct nan_datapath_initiator_req *ndp_req)
16206{
16207 uint16_t len;
16208 wmi_buf_t buf;
16209 uint8_t *tlv_ptr;
16210 QDF_STATUS status;
16211 wmi_channel *ch_tlv;
16212 wmi_ndp_initiator_req_fixed_param *cmd;
16213 uint32_t passphrase_len, service_name_len;
16214 uint32_t ndp_cfg_len, ndp_app_info_len, pmk_len;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016215 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016216
16217 /*
16218 * WMI command expects 4 byte alligned len:
16219 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16220 */
16221 ndp_cfg_len = qdf_roundup(ndp_req->ndp_config.ndp_cfg_len, 4);
16222 ndp_app_info_len = qdf_roundup(ndp_req->ndp_info.ndp_app_info_len, 4);
16223 pmk_len = qdf_roundup(ndp_req->pmk.pmk_len, 4);
16224 passphrase_len = qdf_roundup(ndp_req->passphrase.passphrase_len, 4);
16225 service_name_len =
16226 qdf_roundup(ndp_req->service_name.service_name_len, 4);
16227 /* allocated memory for fixed params as well as variable size data */
16228 len = sizeof(*cmd) + sizeof(*ch_tlv) + (5 * WMI_TLV_HDR_SIZE)
16229 + ndp_cfg_len + ndp_app_info_len + pmk_len
16230 + passphrase_len + service_name_len;
16231
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016232 if (ndp_req->is_ipv6_addr_present)
16233 len += sizeof(*tcp_ip_param);
16234
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016235 buf = wmi_buf_alloc(wmi_handle, len);
16236 if (!buf) {
16237 WMI_LOGE("wmi_buf_alloc failed");
16238 return QDF_STATUS_E_NOMEM;
16239 }
16240
16241 cmd = (wmi_ndp_initiator_req_fixed_param *) wmi_buf_data(buf);
16242 WMITLV_SET_HDR(&cmd->tlv_header,
16243 WMITLV_TAG_STRUC_wmi_ndp_initiator_req_fixed_param,
16244 WMITLV_GET_STRUCT_TLVLEN(
16245 wmi_ndp_initiator_req_fixed_param));
16246 cmd->vdev_id = wlan_vdev_get_id(ndp_req->vdev);
16247 cmd->transaction_id = ndp_req->transaction_id;
16248 cmd->service_instance_id = ndp_req->service_instance_id;
16249 WMI_CHAR_ARRAY_TO_MAC_ADDR(ndp_req->peer_discovery_mac_addr.bytes,
16250 &cmd->peer_discovery_mac_addr);
16251
16252 cmd->ndp_cfg_len = ndp_req->ndp_config.ndp_cfg_len;
16253 cmd->ndp_app_info_len = ndp_req->ndp_info.ndp_app_info_len;
16254 cmd->ndp_channel_cfg = ndp_req->channel_cfg;
16255 cmd->nan_pmk_len = ndp_req->pmk.pmk_len;
16256 cmd->nan_csid = ndp_req->ncs_sk_type;
16257 cmd->nan_passphrase_len = ndp_req->passphrase.passphrase_len;
16258 cmd->nan_servicename_len = ndp_req->service_name.service_name_len;
16259
16260 ch_tlv = (wmi_channel *)&cmd[1];
16261 WMITLV_SET_HDR(ch_tlv, WMITLV_TAG_STRUC_wmi_channel,
16262 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
16263 ch_tlv->mhz = ndp_req->channel;
16264 tlv_ptr = (uint8_t *)&ch_tlv[1];
16265
16266 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16267 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16268 ndp_req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16269 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16270
16271 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16272 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16273 ndp_req->ndp_info.ndp_app_info, cmd->ndp_app_info_len);
16274 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16275
16276 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16277 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->pmk.pmk,
16278 cmd->nan_pmk_len);
16279 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16280
16281 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16282 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], ndp_req->passphrase.passphrase,
16283 cmd->nan_passphrase_len);
16284 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16285
16286 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16287 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16288 ndp_req->service_name.service_name,
16289 cmd->nan_servicename_len);
16290 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16291
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016292 if (ndp_req->is_ipv6_addr_present) {
16293 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16294 WMITLV_SET_HDR(tcp_ip_param,
16295 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16296 WMITLV_GET_STRUCT_TLVLEN(
16297 wmi_ndp_transport_ip_param));
16298 tcp_ip_param->ipv6_addr_present = true;
16299 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16300 ndp_req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16301 }
16302 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16303 ndp_req->is_ipv6_addr_present, ndp_req->ipv6_addr);
16304
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016305 WMI_LOGD("vdev_id = %d, transaction_id: %d, service_instance_id: %d, ch: %d, ch_cfg: %d, csid: %d",
16306 cmd->vdev_id, cmd->transaction_id, cmd->service_instance_id,
16307 ch_tlv->mhz, cmd->ndp_channel_cfg, cmd->nan_csid);
16308 WMI_LOGD("peer mac addr: mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
16309 cmd->peer_discovery_mac_addr.mac_addr31to0,
16310 cmd->peer_discovery_mac_addr.mac_addr47to32);
16311
16312 WMI_LOGD("ndp_config len: %d", cmd->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016313 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016314 ndp_req->ndp_config.ndp_cfg,
16315 ndp_req->ndp_config.ndp_cfg_len);
16316
16317 WMI_LOGD("ndp_app_info len: %d", cmd->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016318 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016319 ndp_req->ndp_info.ndp_app_info,
16320 ndp_req->ndp_info.ndp_app_info_len);
16321
16322 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016323 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016324 ndp_req->pmk.pmk, cmd->nan_pmk_len);
16325
16326 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016327 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016328 ndp_req->passphrase.passphrase,
16329 cmd->nan_passphrase_len);
16330
16331 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016332 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016333 ndp_req->service_name.service_name,
16334 cmd->nan_servicename_len);
16335
16336 WMI_LOGD("sending WMI_NDP_INITIATOR_REQ_CMDID(0x%X)",
16337 WMI_NDP_INITIATOR_REQ_CMDID);
16338
16339 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16340 WMI_NDP_INITIATOR_REQ_CMDID);
16341 if (QDF_IS_STATUS_ERROR(status)) {
16342 WMI_LOGE("WMI_NDP_INITIATOR_REQ_CMDID failed, ret: %d", status);
16343 wmi_buf_free(buf);
16344 }
16345
16346 return status;
16347}
16348
16349static QDF_STATUS nan_ndp_responder_req_tlv(wmi_unified_t wmi_handle,
16350 struct nan_datapath_responder_req *req)
16351{
16352 uint16_t len;
16353 wmi_buf_t buf;
16354 uint8_t *tlv_ptr;
16355 QDF_STATUS status;
16356 wmi_ndp_responder_req_fixed_param *cmd;
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016357 wmi_ndp_transport_ip_param *tcp_ip_param;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016358 uint32_t passphrase_len, service_name_len;
16359 uint32_t vdev_id = 0, ndp_cfg_len, ndp_app_info_len, pmk_len;
16360
16361 vdev_id = wlan_vdev_get_id(req->vdev);
16362 WMI_LOGD("vdev_id: %d, transaction_id: %d, ndp_rsp %d, ndp_instance_id: %d, ndp_app_info_len: %d",
16363 vdev_id, req->transaction_id,
16364 req->ndp_rsp,
16365 req->ndp_instance_id,
16366 req->ndp_info.ndp_app_info_len);
16367
16368 /*
16369 * WMI command expects 4 byte alligned len:
16370 * round up ndp_cfg_len and ndp_app_info_len to 4 bytes
16371 */
16372 ndp_cfg_len = qdf_roundup(req->ndp_config.ndp_cfg_len, 4);
16373 ndp_app_info_len = qdf_roundup(req->ndp_info.ndp_app_info_len, 4);
16374 pmk_len = qdf_roundup(req->pmk.pmk_len, 4);
16375 passphrase_len = qdf_roundup(req->passphrase.passphrase_len, 4);
16376 service_name_len =
16377 qdf_roundup(req->service_name.service_name_len, 4);
16378
16379 /* allocated memory for fixed params as well as variable size data */
16380 len = sizeof(*cmd) + 5*WMI_TLV_HDR_SIZE + ndp_cfg_len + ndp_app_info_len
16381 + pmk_len + passphrase_len + service_name_len;
16382
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016383 if (req->is_ipv6_addr_present || req->is_port_present ||
16384 req->is_protocol_present)
16385 len += sizeof(*tcp_ip_param);
16386
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016387 buf = wmi_buf_alloc(wmi_handle, len);
16388 if (!buf) {
16389 WMI_LOGE("wmi_buf_alloc failed");
16390 return QDF_STATUS_E_NOMEM;
16391 }
16392 cmd = (wmi_ndp_responder_req_fixed_param *) wmi_buf_data(buf);
16393 WMITLV_SET_HDR(&cmd->tlv_header,
16394 WMITLV_TAG_STRUC_wmi_ndp_responder_req_fixed_param,
16395 WMITLV_GET_STRUCT_TLVLEN(
16396 wmi_ndp_responder_req_fixed_param));
16397 cmd->vdev_id = vdev_id;
16398 cmd->transaction_id = req->transaction_id;
16399 cmd->ndp_instance_id = req->ndp_instance_id;
16400 cmd->rsp_code = req->ndp_rsp;
16401 cmd->ndp_cfg_len = req->ndp_config.ndp_cfg_len;
16402 cmd->ndp_app_info_len = req->ndp_info.ndp_app_info_len;
16403 cmd->nan_pmk_len = req->pmk.pmk_len;
16404 cmd->nan_csid = req->ncs_sk_type;
16405 cmd->nan_passphrase_len = req->passphrase.passphrase_len;
16406 cmd->nan_servicename_len = req->service_name.service_name_len;
16407
16408 tlv_ptr = (uint8_t *)&cmd[1];
16409 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_cfg_len);
16410 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16411 req->ndp_config.ndp_cfg, cmd->ndp_cfg_len);
16412
16413 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_cfg_len;
16414 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, ndp_app_info_len);
16415 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16416 req->ndp_info.ndp_app_info,
16417 req->ndp_info.ndp_app_info_len);
16418
16419 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + ndp_app_info_len;
16420 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, pmk_len);
16421 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE], req->pmk.pmk,
16422 cmd->nan_pmk_len);
16423
16424 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + pmk_len;
16425 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, passphrase_len);
16426 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16427 req->passphrase.passphrase,
16428 cmd->nan_passphrase_len);
16429 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + passphrase_len;
16430
16431 WMITLV_SET_HDR(tlv_ptr, WMITLV_TAG_ARRAY_BYTE, service_name_len);
16432 qdf_mem_copy(&tlv_ptr[WMI_TLV_HDR_SIZE],
16433 req->service_name.service_name,
16434 cmd->nan_servicename_len);
16435
16436 tlv_ptr = tlv_ptr + WMI_TLV_HDR_SIZE + service_name_len;
16437
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016438 if (req->is_ipv6_addr_present || req->is_port_present ||
16439 req->is_protocol_present) {
16440 tcp_ip_param = (wmi_ndp_transport_ip_param *)tlv_ptr;
16441 WMITLV_SET_HDR(tcp_ip_param,
16442 WMITLV_TAG_STRUC_wmi_ndp_transport_ip_param,
16443 WMITLV_GET_STRUCT_TLVLEN(
16444 wmi_ndp_transport_ip_param));
16445 tcp_ip_param->ipv6_addr_present = req->is_ipv6_addr_present;
16446 qdf_mem_copy(tcp_ip_param->ipv6_intf_addr,
16447 req->ipv6_addr, WMI_NDP_IPV6_INTF_ADDR_LEN);
16448
16449 tcp_ip_param->trans_port_present = req->is_port_present;
16450 tcp_ip_param->transport_port = req->port;
16451
16452 tcp_ip_param->trans_proto_present = req->is_protocol_present;
16453 tcp_ip_param->transport_protocol = req->protocol;
16454 }
16455 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16456 req->is_ipv6_addr_present, req->ipv6_addr);
16457 WMI_LOGD(FL("port: %d present: %d"), req->is_port_present, req->port);
16458 WMI_LOGD(FL("protocol: %d present: %d"),
16459 req->is_protocol_present, req->protocol);
16460
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016461 WMI_LOGD("vdev_id = %d, transaction_id: %d, csid: %d",
16462 cmd->vdev_id, cmd->transaction_id, cmd->nan_csid);
16463
16464 WMI_LOGD("ndp_config len: %d",
16465 req->ndp_config.ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016466 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016467 req->ndp_config.ndp_cfg,
16468 req->ndp_config.ndp_cfg_len);
16469
16470 WMI_LOGD("ndp_app_info len: %d",
16471 req->ndp_info.ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016472 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016473 req->ndp_info.ndp_app_info,
16474 req->ndp_info.ndp_app_info_len);
16475
16476 WMI_LOGD("pmk len: %d", cmd->nan_pmk_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016477 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016478 req->pmk.pmk, cmd->nan_pmk_len);
16479
16480 WMI_LOGD("pass phrase len: %d", cmd->nan_passphrase_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016481 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016482 req->passphrase.passphrase,
16483 cmd->nan_passphrase_len);
16484
16485 WMI_LOGD("service name len: %d", cmd->nan_servicename_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016486 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016487 req->service_name.service_name,
16488 cmd->nan_servicename_len);
16489
16490 WMI_LOGD("sending WMI_NDP_RESPONDER_REQ_CMDID(0x%X)",
16491 WMI_NDP_RESPONDER_REQ_CMDID);
16492 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16493 WMI_NDP_RESPONDER_REQ_CMDID);
16494 if (QDF_IS_STATUS_ERROR(status)) {
16495 WMI_LOGE("WMI_NDP_RESPONDER_REQ_CMDID failed, ret: %d", status);
16496 wmi_buf_free(buf);
16497 }
16498 return status;
16499}
16500
16501static QDF_STATUS nan_ndp_end_req_tlv(wmi_unified_t wmi_handle,
16502 struct nan_datapath_end_req *req)
16503{
16504 uint16_t len;
16505 wmi_buf_t buf;
16506 QDF_STATUS status;
16507 uint32_t ndp_end_req_len, i;
16508 wmi_ndp_end_req *ndp_end_req_lst;
16509 wmi_ndp_end_req_fixed_param *cmd;
16510
16511 /* len of tlv following fixed param */
16512 ndp_end_req_len = sizeof(wmi_ndp_end_req) * req->num_ndp_instances;
16513 /* above comes out to 4 byte alligned already, no need of padding */
16514 len = sizeof(*cmd) + ndp_end_req_len + WMI_TLV_HDR_SIZE;
16515 buf = wmi_buf_alloc(wmi_handle, len);
16516 if (!buf) {
16517 WMI_LOGE("Malloc failed");
16518 return QDF_STATUS_E_NOMEM;
16519 }
16520
16521 cmd = (wmi_ndp_end_req_fixed_param *) wmi_buf_data(buf);
16522 WMITLV_SET_HDR(&cmd->tlv_header,
16523 WMITLV_TAG_STRUC_wmi_ndp_end_req_fixed_param,
16524 WMITLV_GET_STRUCT_TLVLEN(wmi_ndp_end_req_fixed_param));
16525
16526 cmd->transaction_id = req->transaction_id;
16527
16528 /* set tlv pointer to end of fixed param */
16529 WMITLV_SET_HDR((uint8_t *)&cmd[1], WMITLV_TAG_ARRAY_STRUC,
16530 ndp_end_req_len);
16531
16532 ndp_end_req_lst = (wmi_ndp_end_req *)((uint8_t *)&cmd[1] +
16533 WMI_TLV_HDR_SIZE);
16534 for (i = 0; i < req->num_ndp_instances; i++) {
16535 WMITLV_SET_HDR(&ndp_end_req_lst[i],
16536 WMITLV_TAG_ARRAY_FIXED_STRUC,
16537 (sizeof(*ndp_end_req_lst) - WMI_TLV_HDR_SIZE));
16538
16539 ndp_end_req_lst[i].ndp_instance_id = req->ndp_ids[i];
16540 }
16541
16542 WMI_LOGD("Sending WMI_NDP_END_REQ_CMDID to FW");
16543 status = wmi_unified_cmd_send(wmi_handle, buf, len,
16544 WMI_NDP_END_REQ_CMDID);
16545 if (QDF_IS_STATUS_ERROR(status)) {
16546 WMI_LOGE("WMI_NDP_END_REQ_CMDID failed, ret: %d", status);
16547 wmi_buf_free(buf);
16548 }
16549
16550 return status;
16551}
16552
16553static QDF_STATUS extract_ndp_initiator_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016554 uint8_t *data, struct nan_datapath_initiator_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016555{
16556 WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *event;
16557 wmi_ndp_initiator_rsp_event_fixed_param *fixed_params;
16558
16559 event = (WMI_NDP_INITIATOR_RSP_EVENTID_param_tlvs *)data;
16560 fixed_params = event->fixed_param;
16561
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016562 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016563 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16564 fixed_params->vdev_id,
16565 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016566 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016567 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016568 return QDF_STATUS_E_INVAL;
16569 }
16570
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016571 rsp->transaction_id = fixed_params->transaction_id;
16572 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16573 rsp->status = fixed_params->rsp_status;
16574 rsp->reason = fixed_params->reason_code;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016575
16576 return QDF_STATUS_SUCCESS;
16577}
16578
16579static QDF_STATUS extract_ndp_ind_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016580 uint8_t *data, struct nan_datapath_indication_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016581{
16582 WMI_NDP_INDICATION_EVENTID_param_tlvs *event;
16583 wmi_ndp_indication_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016584 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016585
16586 event = (WMI_NDP_INDICATION_EVENTID_param_tlvs *)data;
16587 fixed_params =
16588 (wmi_ndp_indication_event_fixed_param *)event->fixed_param;
16589
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016590 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16591 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16592 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16593 return QDF_STATUS_E_INVAL;
16594 }
16595
16596 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16597 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16598 fixed_params->ndp_app_info_len,
16599 event->num_ndp_app_info);
16600 return QDF_STATUS_E_INVAL;
16601 }
16602
gaolezab037cf2018-05-23 14:40:32 +080016603 if (fixed_params->ndp_cfg_len >
16604 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16605 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16606 __func__, fixed_params->ndp_cfg_len);
16607 return QDF_STATUS_E_INVAL;
16608 }
16609
16610 total_array_len = fixed_params->ndp_cfg_len +
16611 sizeof(*fixed_params);
16612
16613 if (fixed_params->ndp_app_info_len >
16614 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16615 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16616 __func__, fixed_params->ndp_app_info_len);
16617 return QDF_STATUS_E_INVAL;
16618 }
16619 total_array_len += fixed_params->ndp_app_info_len;
16620
16621 if (fixed_params->nan_scid_len >
16622 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16623 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16624 __func__, fixed_params->nan_scid_len);
16625 return QDF_STATUS_E_INVAL;
16626 }
16627
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016628 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016629 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16630 fixed_params->vdev_id,
16631 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016632 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016633 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016634 return QDF_STATUS_E_INVAL;
16635 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016636 rsp->service_instance_id = fixed_params->service_instance_id;
16637 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16638 rsp->role = fixed_params->self_ndp_role;
16639 rsp->policy = fixed_params->accept_policy;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016640
16641 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016642 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016643 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_discovery_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016644 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016645
16646 WMI_LOGD("WMI_NDP_INDICATION_EVENTID(0x%X) received. vdev %d,\n"
16647 "service_instance %d, ndp_instance %d, role %d, policy %d,\n"
16648 "csid: %d, scid_len: %d, peer_addr: %pM, peer_disc_addr: %pM",
16649 WMI_NDP_INDICATION_EVENTID, fixed_params->vdev_id,
16650 fixed_params->service_instance_id,
16651 fixed_params->ndp_instance_id, fixed_params->self_ndp_role,
16652 fixed_params->accept_policy,
16653 fixed_params->nan_csid, fixed_params->nan_scid_len,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016654 rsp->peer_mac_addr.bytes,
16655 rsp->peer_discovery_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016656
16657 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016658 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016659 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16660
16661 WMI_LOGD("ndp_app_info - %d bytes",
16662 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016663 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016664 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16665
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016666 rsp->ndp_config.ndp_cfg_len = fixed_params->ndp_cfg_len;
16667 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16668 rsp->ncs_sk_type = fixed_params->nan_csid;
16669 rsp->scid.scid_len = fixed_params->nan_scid_len;
16670 qdf_mem_copy(rsp->ndp_config.ndp_cfg, event->ndp_cfg,
16671 rsp->ndp_config.ndp_cfg_len);
16672 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16673 rsp->ndp_info.ndp_app_info_len);
16674 qdf_mem_copy(rsp->scid.scid, event->ndp_scid, rsp->scid.scid_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016675
16676 if (event->ndp_transport_ip_param &&
16677 event->num_ndp_transport_ip_param) {
16678 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16679 rsp->is_ipv6_addr_present = true;
16680 qdf_mem_copy(rsp->ipv6_addr,
16681 event->ndp_transport_ip_param->ipv6_intf_addr,
16682 WMI_NDP_IPV6_INTF_ADDR_LEN);
16683 }
16684 }
16685 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16686 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16687
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016688 WMI_LOGD("scid hex dump:");
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016689 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016690 rsp->scid.scid, rsp->scid.scid_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016691
16692 return QDF_STATUS_SUCCESS;
16693}
16694
16695static QDF_STATUS extract_ndp_confirm_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016696 uint8_t *data, struct nan_datapath_confirm_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016697{
Naveen Rawat38b21462018-05-31 15:04:16 -070016698 uint8_t i;
16699 WMI_HOST_WLAN_PHY_MODE ch_mode;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016700 WMI_NDP_CONFIRM_EVENTID_param_tlvs *event;
16701 wmi_ndp_confirm_event_fixed_param *fixed_params;
gaolezab037cf2018-05-23 14:40:32 +080016702 size_t total_array_len;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016703
16704 event = (WMI_NDP_CONFIRM_EVENTID_param_tlvs *) data;
16705 fixed_params = (wmi_ndp_confirm_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016706 WMI_LOGD("WMI_NDP_CONFIRM_EVENTID(0x%X) received. vdev %d, ndp_instance %d, rsp_code %d, reason_code: %d, num_active_ndps_on_peer: %d",
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016707 WMI_NDP_CONFIRM_EVENTID, fixed_params->vdev_id,
16708 fixed_params->ndp_instance_id, fixed_params->rsp_code,
16709 fixed_params->reason_code,
16710 fixed_params->num_active_ndps_on_peer);
Naveen Rawat38b21462018-05-31 15:04:16 -070016711 WMI_LOGE("num_ch: %d", fixed_params->num_ndp_channels);
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016712
16713 if (fixed_params->ndp_cfg_len > event->num_ndp_cfg) {
16714 WMI_LOGE("FW message ndp cfg length %d larger than TLV hdr %d",
16715 fixed_params->ndp_cfg_len, event->num_ndp_cfg);
16716 return QDF_STATUS_E_INVAL;
16717 }
16718
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016719 WMI_LOGD("ndp_cfg - %d bytes", fixed_params->ndp_cfg_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016720 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016721 &event->ndp_cfg, fixed_params->ndp_cfg_len);
16722
Vignesh Viswanathan376834c2018-01-23 14:54:18 +053016723 if (fixed_params->ndp_app_info_len > event->num_ndp_app_info) {
16724 WMI_LOGE("FW message ndp app info length %d more than TLV hdr %d",
16725 fixed_params->ndp_app_info_len,
16726 event->num_ndp_app_info);
16727 return QDF_STATUS_E_INVAL;
16728 }
16729
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016730 WMI_LOGD("ndp_app_info - %d bytes",
16731 fixed_params->ndp_app_info_len);
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016732 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016733 &event->ndp_app_info, fixed_params->ndp_app_info_len);
16734
gaolezab037cf2018-05-23 14:40:32 +080016735 if (fixed_params->ndp_cfg_len >
16736 (WMI_SVC_MSG_MAX_SIZE - sizeof(*fixed_params))) {
16737 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16738 __func__, fixed_params->ndp_cfg_len);
16739 return QDF_STATUS_E_INVAL;
16740 }
16741
16742 total_array_len = fixed_params->ndp_cfg_len +
16743 sizeof(*fixed_params);
16744
16745 if (fixed_params->ndp_app_info_len >
16746 (WMI_SVC_MSG_MAX_SIZE - total_array_len)) {
16747 WMI_LOGE("%s: excess wmi buffer: ndp_cfg_len %d",
16748 __func__, fixed_params->ndp_app_info_len);
16749 return QDF_STATUS_E_INVAL;
16750 }
16751
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016752 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016753 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16754 fixed_params->vdev_id,
16755 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016756 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016757 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016758 return QDF_STATUS_E_INVAL;
16759 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016760 rsp->ndp_instance_id = fixed_params->ndp_instance_id;
16761 rsp->rsp_code = fixed_params->rsp_code;
16762 rsp->reason_code = fixed_params->reason_code;
16763 rsp->num_active_ndps_on_peer = fixed_params->num_active_ndps_on_peer;
Naveen Rawat38b21462018-05-31 15:04:16 -070016764 rsp->num_channels = fixed_params->num_ndp_channels;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016765 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016766 rsp->peer_ndi_mac_addr.bytes);
16767 rsp->ndp_info.ndp_app_info_len = fixed_params->ndp_app_info_len;
16768 qdf_mem_copy(rsp->ndp_info.ndp_app_info, event->ndp_app_info,
16769 rsp->ndp_info.ndp_app_info_len);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016770
Naveen Rawat38b21462018-05-31 15:04:16 -070016771 if (rsp->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16772 WMI_LOGE(FL("too many channels"));
16773 rsp->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16774 }
16775
16776 for (i = 0; i < rsp->num_channels; i++) {
16777 rsp->ch[i].channel = event->ndp_channel_list[i].mhz;
16778 rsp->ch[i].nss = event->nss_list[i];
16779 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndp_channel_list[i]);
16780 rsp->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16781 ch_mode);
16782 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16783 rsp->ch[i].channel,
16784 rsp->ch[i].ch_width,
16785 rsp->ch[i].nss);
16786 }
16787
Naveen Rawat8fdc6b52018-05-31 15:04:59 -070016788 if (event->ndp_transport_ip_param &&
16789 event->num_ndp_transport_ip_param) {
16790 if (event->ndp_transport_ip_param->ipv6_addr_present) {
16791 rsp->is_ipv6_addr_present = true;
16792 qdf_mem_copy(rsp->ipv6_addr,
16793 event->ndp_transport_ip_param->ipv6_intf_addr,
16794 WMI_NDP_IPV6_INTF_ADDR_LEN);
16795 }
16796
16797 if (event->ndp_transport_ip_param->trans_port_present) {
16798 rsp->is_port_present = true;
16799 rsp->port =
16800 event->ndp_transport_ip_param->transport_port;
16801 }
16802
16803 if (event->ndp_transport_ip_param->trans_proto_present) {
16804 rsp->is_protocol_present = true;
16805 rsp->protocol =
16806 event->ndp_transport_ip_param->transport_protocol;
16807 }
16808 }
16809 WMI_LOGD(FL("IPv6 addr present: %d, addr: %pI6"),
16810 rsp->is_ipv6_addr_present, rsp->ipv6_addr);
16811 WMI_LOGD(FL("port: %d present: %d"), rsp->port, rsp->is_port_present);
16812 WMI_LOGD(FL("protocol: %d present: %d"),
16813 rsp->protocol, rsp->is_protocol_present);
16814
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016815 return QDF_STATUS_SUCCESS;
16816}
16817
16818static QDF_STATUS extract_ndp_responder_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016819 uint8_t *data, struct nan_datapath_responder_rsp *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016820{
16821 WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *event;
16822 wmi_ndp_responder_rsp_event_fixed_param *fixed_params;
16823
16824 event = (WMI_NDP_RESPONDER_RSP_EVENTID_param_tlvs *)data;
16825 fixed_params = event->fixed_param;
16826
16827 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",
16828 WMI_NDP_RESPONDER_RSP_EVENTID, fixed_params->vdev_id,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016829 rsp->peer_mac_addr.bytes, rsp->transaction_id,
16830 rsp->status, rsp->reason, rsp->create_peer);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016831
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016832 rsp->vdev =
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016833 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16834 fixed_params->vdev_id,
16835 WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016836 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016837 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016838 return QDF_STATUS_E_INVAL;
16839 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016840 rsp->transaction_id = fixed_params->transaction_id;
16841 rsp->reason = fixed_params->reason_code;
16842 rsp->status = fixed_params->rsp_status;
16843 rsp->create_peer = fixed_params->create_peer;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016844 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_ndi_mac_addr,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016845 rsp->peer_mac_addr.bytes);
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016846
16847 return QDF_STATUS_SUCCESS;
16848}
16849
16850static QDF_STATUS extract_ndp_end_rsp_tlv(wmi_unified_t wmi_handle,
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016851 uint8_t *data, struct nan_datapath_end_rsp_event *rsp)
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016852{
16853 WMI_NDP_END_RSP_EVENTID_param_tlvs *event;
16854 wmi_ndp_end_rsp_event_fixed_param *fixed_params = NULL;
16855
16856 event = (WMI_NDP_END_RSP_EVENTID_param_tlvs *) data;
16857 fixed_params = (wmi_ndp_end_rsp_event_fixed_param *)event->fixed_param;
Jeff Johnson3f955232018-05-06 16:25:49 -070016858 WMI_LOGD("WMI_NDP_END_RSP_EVENTID(0x%X) received. transaction_id: %d, rsp_status: %d, reason_code: %d",
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016859 WMI_NDP_END_RSP_EVENTID, fixed_params->transaction_id,
16860 fixed_params->rsp_status, fixed_params->reason_code);
16861
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016862 rsp->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016863 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016864 if (!rsp->vdev) {
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016865 WMI_LOGE("vdev is null");
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016866 return QDF_STATUS_E_INVAL;
16867 }
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016868 rsp->transaction_id = fixed_params->transaction_id;
16869 rsp->reason = fixed_params->reason_code;
16870 rsp->status = fixed_params->rsp_status;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016871
16872 return QDF_STATUS_SUCCESS;
16873}
16874
16875static QDF_STATUS extract_ndp_end_ind_tlv(wmi_unified_t wmi_handle,
16876 uint8_t *data, struct nan_datapath_end_indication_event **rsp)
16877{
16878 uint32_t i, buf_size;
16879 wmi_ndp_end_indication *ind;
16880 struct qdf_mac_addr peer_addr;
16881 WMI_NDP_END_INDICATION_EVENTID_param_tlvs *event;
16882
16883 event = (WMI_NDP_END_INDICATION_EVENTID_param_tlvs *) data;
16884 ind = event->ndp_end_indication_list;
16885
16886 if (event->num_ndp_end_indication_list == 0) {
16887 WMI_LOGE("Error: Event ignored, 0 ndp instances");
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016888 return QDF_STATUS_E_INVAL;
16889 }
16890
16891 WMI_LOGD("number of ndp instances = %d",
16892 event->num_ndp_end_indication_list);
16893
16894 if (event->num_ndp_end_indication_list > ((UINT_MAX - sizeof(**rsp))/
16895 sizeof((*rsp)->ndp_map[0]))) {
16896 WMI_LOGE("num_ndp_end_ind_list %d too large",
16897 event->num_ndp_end_indication_list);
16898 return QDF_STATUS_E_INVAL;
16899 }
16900
16901 buf_size = sizeof(**rsp) + event->num_ndp_end_indication_list *
16902 sizeof((*rsp)->ndp_map[0]);
16903 *rsp = qdf_mem_malloc(buf_size);
16904 if (!(*rsp)) {
16905 WMI_LOGE("Failed to allocate memory");
16906 return QDF_STATUS_E_NOMEM;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016907 }
16908
16909 (*rsp)->vdev = wlan_objmgr_get_vdev_by_opmode_from_psoc(
16910 wmi_handle->soc->wmi_psoc, QDF_NDI_MODE, WLAN_NAN_ID);
16911 if (!(*rsp)->vdev) {
16912 WMI_LOGE("vdev is null");
16913 qdf_mem_free(*rsp);
Naveen Rawat3aa16c42018-02-02 15:13:05 -080016914 *rsp = NULL;
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016915 return QDF_STATUS_E_INVAL;
16916 }
16917
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080016918 (*rsp)->num_ndp_ids = event->num_ndp_end_indication_list;
16919 for (i = 0; i < (*rsp)->num_ndp_ids; i++) {
16920 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
16921 peer_addr.bytes);
16922 WMI_LOGD("ind[%d]: type %d, reason_code %d, instance_id %d num_active %d ",
16923 i, ind[i].type, ind[i].reason_code,
16924 ind[i].ndp_instance_id,
16925 ind[i].num_active_ndps_on_peer);
16926 /* Add each instance entry to the list */
16927 (*rsp)->ndp_map[i].ndp_instance_id = ind[i].ndp_instance_id;
16928 (*rsp)->ndp_map[i].vdev_id = ind[i].vdev_id;
16929 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ind[i].peer_ndi_mac_addr,
16930 (*rsp)->ndp_map[i].peer_ndi_mac_addr.bytes);
16931 (*rsp)->ndp_map[i].num_active_ndp_sessions =
16932 ind[i].num_active_ndps_on_peer;
16933 (*rsp)->ndp_map[i].type = ind[i].type;
16934 (*rsp)->ndp_map[i].reason_code = ind[i].reason_code;
16935 }
16936
16937 return QDF_STATUS_SUCCESS;
16938}
Naveen Rawatd42ce382018-01-09 17:54:41 -080016939
16940static QDF_STATUS extract_ndp_sch_update_tlv(wmi_unified_t wmi_handle,
16941 uint8_t *data, struct nan_datapath_sch_update_event *ind)
16942{
16943 uint8_t i;
16944 WMI_HOST_WLAN_PHY_MODE ch_mode;
16945 WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *event;
16946 wmi_ndl_schedule_update_fixed_param *fixed_params;
16947
16948 event = (WMI_NDL_SCHEDULE_UPDATE_EVENTID_param_tlvs *)data;
16949 fixed_params = event->fixed_param;
16950
16951 WMI_LOGD(FL("flags: %d, num_ch: %d, num_ndp_instances: %d"),
16952 fixed_params->flags, fixed_params->num_channels,
16953 fixed_params->num_ndp_instances);
16954
16955 ind->vdev =
16956 wlan_objmgr_get_vdev_by_id_from_psoc(wmi_handle->soc->wmi_psoc,
16957 fixed_params->vdev_id,
16958 WLAN_NAN_ID);
16959 if (!ind->vdev) {
16960 WMI_LOGE("vdev is null");
16961 return QDF_STATUS_E_INVAL;
16962 }
16963
16964 ind->flags = fixed_params->flags;
16965 ind->num_channels = fixed_params->num_channels;
16966 ind->num_ndp_instances = fixed_params->num_ndp_instances;
16967 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fixed_params->peer_macaddr,
16968 ind->peer_addr.bytes);
16969
16970 if (ind->num_ndp_instances > NDP_NUM_INSTANCE_ID) {
16971 WMI_LOGE(FL("uint32 overflow"));
16972 wlan_objmgr_vdev_release_ref(ind->vdev, WLAN_NAN_ID);
16973 return QDF_STATUS_E_INVAL;
16974 }
16975
16976 qdf_mem_copy(ind->ndp_instances, event->ndp_instance_list,
16977 sizeof(uint32_t) * ind->num_ndp_instances);
16978
16979 if (ind->num_channels > NAN_CH_INFO_MAX_CHANNELS) {
16980 WMI_LOGE(FL("too many channels"));
16981 ind->num_channels = NAN_CH_INFO_MAX_CHANNELS;
16982 }
16983 for (i = 0; i < ind->num_channels; i++) {
16984 ind->ch[i].channel = event->ndl_channel_list[i].mhz;
16985 ind->ch[i].nss = event->nss_list[i];
16986 ch_mode = WMI_GET_CHANNEL_MODE(&event->ndl_channel_list[i]);
16987 ind->ch[i].ch_width = wmi_get_ch_width_from_phy_mode(wmi_handle,
16988 ch_mode);
16989 WMI_LOGD(FL("ch: %d, ch_mode: %d, nss: %d"),
16990 ind->ch[i].channel,
16991 ind->ch[i].ch_width,
16992 ind->ch[i].nss);
16993 }
16994
16995 for (i = 0; i < fixed_params->num_ndp_instances; i++)
16996 WMI_LOGD(FL("instance_id[%d]: %d"),
16997 i, event->ndp_instance_list[i]);
16998
16999 return QDF_STATUS_SUCCESS;
17000}
17001
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080017002#endif
17003
Naveen Rawat963ee942018-04-13 16:38:36 -070017004#ifdef QCA_SUPPORT_CP_STATS
17005/**
17006 * extract_cca_stats_tlv - api to extract congestion stats from event buffer
17007 * @wmi_handle: wma handle
17008 * @evt_buf: event buffer
17009 * @out_buff: buffer to populated after stats extraction
17010 *
17011 * Return: status of operation
17012 */
17013static QDF_STATUS extract_cca_stats_tlv(wmi_unified_t wmi_handle,
17014 void *evt_buf, struct wmi_host_congestion_stats *out_buff)
17015{
17016 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
17017 wmi_congestion_stats *congestion_stats;
17018
17019 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
17020 congestion_stats = param_buf->congestion_stats;
17021 if (!congestion_stats) {
17022 WMI_LOGD("%s: no cca stats in event buffer", __func__);
17023 return QDF_STATUS_E_INVAL;
17024 }
17025
17026 out_buff->vdev_id = congestion_stats->vdev_id;
17027 out_buff->congestion = congestion_stats->congestion;
17028
17029 WMI_LOGD("%s: cca stats event processed", __func__);
17030 return QDF_STATUS_SUCCESS;
17031}
17032#endif /* QCA_SUPPORT_CP_STATS */
17033
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053017034/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017035 * save_service_bitmap_tlv() - save service bitmap
17036 * @wmi_handle: wmi handle
17037 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080017038 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053017039 *
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017040 * Return: QDF_STATUS
Govind Singhe7f2f342016-05-23 12:12:52 +053017041 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017042static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017043QDF_STATUS save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017044 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017045{
17046 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017047 struct wmi_soc *soc = wmi_handle->soc;
17048
Govind Singhe7f2f342016-05-23 12:12:52 +053017049 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17050
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017051 /* If it is already allocated, use that buffer. This can happen
17052 * during target stop/start scenarios where host allocation is skipped.
17053 */
17054 if (!soc->wmi_service_bitmap) {
17055 soc->wmi_service_bitmap =
17056 qdf_mem_malloc(WMI_SERVICE_BM_SIZE * sizeof(uint32_t));
17057 if (!soc->wmi_service_bitmap) {
17058 WMI_LOGE("Failed memory allocation for service bitmap");
17059 return QDF_STATUS_E_NOMEM;
17060 }
17061 }
17062
17063 qdf_mem_copy(soc->wmi_service_bitmap,
Govind Singhe7f2f342016-05-23 12:12:52 +053017064 param_buf->wmi_service_bitmap,
17065 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080017066
17067 if (bitmap_buf)
17068 qdf_mem_copy(bitmap_buf,
17069 param_buf->wmi_service_bitmap,
17070 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017071
17072 return QDF_STATUS_SUCCESS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017073}
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017074
17075/**
17076 * save_ext_service_bitmap_tlv() - save extendend service bitmap
17077 * @wmi_handle: wmi handle
17078 * @param evt_buf: pointer to event buffer
17079 * @param bitmap_buf: bitmap buffer, for converged legacy support
17080 *
17081 * Return: QDF_STATUS
17082 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070017083static
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017084QDF_STATUS save_ext_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
Rajeev Kumar77901472017-02-12 02:12:17 -080017085 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053017086{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017087 WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *param_buf;
17088 wmi_service_available_event_fixed_param *ev;
17089 struct wmi_soc *soc = wmi_handle->soc;
17090
17091 param_buf = (WMI_SERVICE_AVAILABLE_EVENTID_param_tlvs *) evt_buf;
17092
17093 ev = param_buf->fixed_param;
17094
17095 /* If it is already allocated, use that buffer. This can happen
17096 * during target stop/start scenarios where host allocation is skipped.
17097 */
17098 if (!soc->wmi_ext_service_bitmap) {
17099 soc->wmi_ext_service_bitmap = qdf_mem_malloc(
17100 WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t));
17101 if (!soc->wmi_ext_service_bitmap) {
17102 WMI_LOGE("Failed memory allocation for service bitmap");
17103 return QDF_STATUS_E_NOMEM;
17104 }
17105 }
17106
17107 qdf_mem_copy(soc->wmi_ext_service_bitmap,
17108 ev->wmi_service_segment_bitmap,
17109 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017110
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053017111 WMI_LOGD("wmi_ext_service_bitmap 0:0x%x, 1:0x%x, 2:0x%x, 3:0x%x\n",
17112 soc->wmi_ext_service_bitmap[0], soc->wmi_ext_service_bitmap[1],
17113 soc->wmi_ext_service_bitmap[2], soc->wmi_ext_service_bitmap[3]);
17114
Rajeev Kumar77901472017-02-12 02:12:17 -080017115 if (bitmap_buf)
17116 qdf_mem_copy(bitmap_buf,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017117 soc->wmi_ext_service_bitmap,
17118 (WMI_SERVICE_SEGMENT_BM_SIZE32 * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053017119
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017120 return QDF_STATUS_SUCCESS;
17121}
Govind Singhe7f2f342016-05-23 12:12:52 +053017122/**
17123 * is_service_enabled_tlv() - Check if service enabled
17124 * @param wmi_handle: wmi handle
17125 * @param service_id: service identifier
17126 *
17127 * Return: 1 enabled, 0 disabled
17128 */
Govind Singhe7f2f342016-05-23 12:12:52 +053017129static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
17130 uint32_t service_id)
17131{
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017132 struct wmi_soc *soc = wmi_handle->soc;
17133
17134 if (!soc->wmi_service_bitmap) {
17135 WMI_LOGE("WMI service bit map is not saved yet\n");
17136 return false;
17137 }
17138
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053017139 /* if wmi_service_enabled was received with extended bitmap,
17140 * use WMI_SERVICE_EXT_IS_ENABLED to check the services.
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017141 */
17142 if (soc->wmi_ext_service_bitmap)
17143 return WMI_SERVICE_EXT_IS_ENABLED(soc->wmi_service_bitmap,
17144 soc->wmi_ext_service_bitmap,
17145 service_id);
17146
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080017147 if (service_id >= WMI_MAX_SERVICE) {
17148 WMI_LOGE("Service id %d but WMI ext service bitmap is NULL",
17149 service_id);
17150 return false;
17151 }
17152
Kiran Venkatappa7d739142017-09-01 17:02:34 +053017153 return WMI_SERVICE_IS_ENABLED(soc->wmi_service_bitmap,
17154 service_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017155}
Govind Singhe7f2f342016-05-23 12:12:52 +053017156
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017157static inline void copy_ht_cap_info(uint32_t ev_target_cap,
17158 struct wlan_psoc_target_capability_info *cap)
17159{
17160 /* except LDPC all flags are common betwen legacy and here
17161 * also IBFEER is not defined for TLV
17162 */
17163 cap->ht_cap_info |= ev_target_cap & (
17164 WMI_HT_CAP_ENABLED
17165 | WMI_HT_CAP_HT20_SGI
17166 | WMI_HT_CAP_DYNAMIC_SMPS
17167 | WMI_HT_CAP_TX_STBC
17168 | WMI_HT_CAP_TX_STBC_MASK_SHIFT
17169 | WMI_HT_CAP_RX_STBC
17170 | WMI_HT_CAP_RX_STBC_MASK_SHIFT
17171 | WMI_HT_CAP_LDPC
17172 | WMI_HT_CAP_L_SIG_TXOP_PROT
17173 | WMI_HT_CAP_MPDU_DENSITY
17174 | WMI_HT_CAP_MPDU_DENSITY_MASK_SHIFT
17175 | WMI_HT_CAP_HT40_SGI);
17176 if (ev_target_cap & WMI_HT_CAP_LDPC)
17177 cap->ht_cap_info |= WMI_HOST_HT_CAP_RX_LDPC |
17178 WMI_HOST_HT_CAP_TX_LDPC;
17179}
Govind Singhe7f2f342016-05-23 12:12:52 +053017180/**
17181 * extract_service_ready_tlv() - extract service ready event
17182 * @wmi_handle: wmi handle
17183 * @param evt_buf: pointer to received event buffer
17184 * @param cap: pointer to hold target capability information extracted from even
17185 *
17186 * Return: QDF_STATUS_SUCCESS for success or error code
17187 */
17188static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017189 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017190{
17191 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17192 wmi_service_ready_event_fixed_param *ev;
17193
17194
17195 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17196
17197 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17198 if (!ev) {
17199 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17200 return QDF_STATUS_E_FAILURE;
17201 }
17202
17203 cap->phy_capability = ev->phy_capability;
17204 cap->max_frag_entry = ev->max_frag_entry;
17205 cap->num_rf_chains = ev->num_rf_chains;
Nandha Kishore Easwarana769b362017-06-15 10:29:29 +053017206 copy_ht_cap_info(ev->ht_cap_info, cap);
Govind Singhe7f2f342016-05-23 12:12:52 +053017207 cap->vht_cap_info = ev->vht_cap_info;
17208 cap->vht_supp_mcs = ev->vht_supp_mcs;
17209 cap->hw_min_tx_power = ev->hw_min_tx_power;
17210 cap->hw_max_tx_power = ev->hw_max_tx_power;
17211 cap->sys_cap_info = ev->sys_cap_info;
17212 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
17213 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
17214 cap->max_num_scan_channels = ev->max_num_scan_channels;
17215 cap->max_supported_macs = ev->max_supported_macs;
17216 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
17217 cap->txrx_chainmask = ev->txrx_chainmask;
17218 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
17219 cap->num_msdu_desc = ev->num_msdu_desc;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053017220 cap->fw_version = ev->fw_build_vers;
17221 /* fw_version_1 is not available in TLV. */
17222 cap->fw_version_1 = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053017223
17224 return QDF_STATUS_SUCCESS;
17225}
17226
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017227/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
17228 * to host internal WMI_HOST_REGDMN_MODE values.
17229 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
17230 * host currently. Add this in the future if required.
17231 * 11AX (Phase II) : 11ax related values are not currently
17232 * advertised separately by FW. As part of phase II regulatory bring-up,
17233 * finalize the advertisement mechanism.
17234 * @target_wireless_mode: target wireless mode received in message
17235 *
17236 * Return: returns the host internal wireless mode.
17237 */
17238static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
17239{
17240
17241 uint32_t wireless_modes = 0;
17242
17243 if (target_wireless_mode & REGDMN_MODE_11A)
17244 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
17245
17246 if (target_wireless_mode & REGDMN_MODE_TURBO)
17247 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
17248
17249 if (target_wireless_mode & REGDMN_MODE_11B)
17250 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
17251
17252 if (target_wireless_mode & REGDMN_MODE_PUREG)
17253 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
17254
17255 if (target_wireless_mode & REGDMN_MODE_11G)
17256 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
17257
17258 if (target_wireless_mode & REGDMN_MODE_108G)
17259 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
17260
17261 if (target_wireless_mode & REGDMN_MODE_108A)
17262 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
17263
17264 if (target_wireless_mode & REGDMN_MODE_XR)
17265 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
17266
17267 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
17268 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
17269
17270 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
17271 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
17272
17273 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
17274 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
17275
17276 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
17277 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
17278
17279 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
17280 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
17281
17282 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
17283 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
17284
17285 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
17286 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
17287
17288 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
17289 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
17290
17291 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
17292 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
17293
17294 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
17295 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
17296
17297 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
17298 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
17299
17300 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
17301 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
17302
17303 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
17304 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
17305
17306 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
17307 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
17308
17309 return wireless_modes;
17310}
17311
Govind Singhe7f2f342016-05-23 12:12:52 +053017312/**
17313 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
17314 * @wmi_handle: wmi handle
17315 * @param evt_buf: Pointer to event buffer
17316 * @param cap: pointer to hold HAL reg capabilities
17317 *
17318 * Return: QDF_STATUS_SUCCESS for success or error code
17319 */
17320static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080017321 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053017322{
17323 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17324
17325 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17326
17327 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
17328 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080017329 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053017330
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053017331 cap->wireless_modes = convert_wireless_modes_tlv(
17332 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053017333
Govind Singhe7f2f342016-05-23 12:12:52 +053017334 return QDF_STATUS_SUCCESS;
17335}
17336
17337/**
17338 * extract_host_mem_req_tlv() - Extract host memory request event
17339 * @wmi_handle: wmi handle
17340 * @param evt_buf: pointer to event buffer
17341 * @param num_entries: pointer to hold number of entries requested
17342 *
17343 * Return: Number of entries requested
17344 */
17345static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
17346 void *evt_buf, uint8_t *num_entries)
17347{
17348 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17349 wmi_service_ready_event_fixed_param *ev;
17350
17351 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17352
17353 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17354 if (!ev) {
17355 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17356 return NULL;
17357 }
17358
17359 *num_entries = ev->num_mem_reqs;
17360
17361 return (host_mem_req *)param_buf->mem_reqs;
17362}
17363
17364/**
17365 * save_fw_version_in_service_ready_tlv() - Save fw version in service
17366 * ready function
17367 * @wmi_handle: wmi handle
17368 * @param evt_buf: pointer to event buffer
17369 *
17370 * Return: QDF_STATUS_SUCCESS for success or error code
17371 */
17372static QDF_STATUS
17373save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
17374{
17375 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
17376 wmi_service_ready_event_fixed_param *ev;
17377
17378
17379 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
17380
17381 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
17382 if (!ev) {
17383 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
17384 return QDF_STATUS_E_FAILURE;
17385 }
17386
17387 /*Save fw version from service ready message */
17388 /*This will be used while sending INIT message */
17389 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
17390 sizeof(wmi_handle->fw_abi_version));
Kiran Venkatappa22a02982017-10-11 22:56:45 +053017391
Govind Singhe7f2f342016-05-23 12:12:52 +053017392 return QDF_STATUS_SUCCESS;
17393}
17394
17395/**
17396 * ready_extract_init_status_tlv() - Extract init status from ready event
17397 * @wmi_handle: wmi handle
17398 * @param evt_buf: Pointer to event buffer
17399 *
17400 * Return: ready status
17401 */
17402static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
17403 void *evt_buf)
17404{
17405 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17406 wmi_ready_event_fixed_param *ev = NULL;
17407
Govind Singhe7f2f342016-05-23 12:12:52 +053017408 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17409 ev = param_buf->fixed_param;
17410
17411 qdf_print("%s:%d\n", __func__, ev->status);
17412
17413 return ev->status;
17414}
17415
17416/**
17417 * ready_extract_mac_addr_tlv() - extract mac address from ready event
17418 * @wmi_handle: wmi handle
17419 * @param evt_buf: pointer to event buffer
17420 * @param macaddr: Pointer to hold MAC address
17421 *
17422 * Return: QDF_STATUS_SUCCESS for success or error code
17423 */
17424static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
17425 void *evt_buf, uint8_t *macaddr)
17426{
17427 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17428 wmi_ready_event_fixed_param *ev = NULL;
17429
17430
17431 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17432 ev = param_buf->fixed_param;
17433
17434 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
17435
17436 return QDF_STATUS_SUCCESS;
17437}
17438
17439/**
Manoj Ekbotedd273902017-07-09 23:28:56 -070017440 * ready_extract_mac_addr_list_tlv() - extract MAC address list from ready event
17441 * @wmi_handle: wmi handle
17442 * @param evt_buf: pointer to event buffer
17443 * @param macaddr: Pointer to hold number of MAC addresses
17444 *
17445 * Return: Pointer to addr list
17446 */
17447static wmi_host_mac_addr *ready_extract_mac_addr_list_tlv(wmi_unified_t wmi_hamdle,
17448 void *evt_buf, uint8_t *num_mac)
17449{
17450 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17451 wmi_ready_event_fixed_param *ev = NULL;
17452
17453 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17454 ev = param_buf->fixed_param;
17455
17456 *num_mac = ev->num_extra_mac_addr;
17457
17458 return (wmi_host_mac_addr *) param_buf->mac_addr_list;
17459}
17460
17461/**
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017462 * extract_ready_params_tlv() - Extract data from ready event apart from
17463 * status, macaddr and version.
17464 * @wmi_handle: Pointer to WMI handle.
17465 * @evt_buf: Pointer to Ready event buffer.
17466 * @ev_param: Pointer to host defined struct to copy the data from event.
17467 *
17468 * Return: QDF_STATUS_SUCCESS on success.
17469 */
17470static QDF_STATUS extract_ready_event_params_tlv(wmi_unified_t wmi_handle,
17471 void *evt_buf, struct wmi_host_ready_ev_param *ev_param)
17472{
17473 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
17474 wmi_ready_event_fixed_param *ev = NULL;
17475
17476 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
17477 ev = param_buf->fixed_param;
17478
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017479 ev_param->status = ev->status;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017480 ev_param->num_dscp_table = ev->num_dscp_table;
17481 ev_param->num_extra_mac_addr = ev->num_extra_mac_addr;
17482 ev_param->num_total_peer = ev->num_total_peers;
Kiran Venkatappab458a1c2017-11-28 12:23:24 +053017483 ev_param->num_extra_peer = ev->num_extra_peers;
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053017484 /* Agile_cap in ready event is not supported in TLV target */
17485 ev_param->agile_capability = false;
17486
17487 return QDF_STATUS_SUCCESS;
17488}
17489
17490/**
Govind Singhe7f2f342016-05-23 12:12:52 +053017491 * extract_dbglog_data_len_tlv() - extract debuglog data length
17492 * @wmi_handle: wmi handle
17493 * @param evt_buf: pointer to event buffer
17494 *
17495 * Return: length
17496 */
17497static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080017498 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053017499{
17500 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
17501
17502 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
17503
17504 *len = param_buf->num_bufp;
17505
17506 return param_buf->bufp;
17507}
17508
17509/**
17510 * extract_vdev_start_resp_tlv() - extract vdev start response
17511 * @wmi_handle: wmi handle
17512 * @param evt_buf: pointer to event buffer
17513 * @param vdev_rsp: Pointer to hold vdev response
17514 *
17515 * Return: QDF_STATUS_SUCCESS for success or error code
17516 */
17517static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
17518 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
17519{
17520 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
17521 wmi_vdev_start_response_event_fixed_param *ev;
17522
17523 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
17524 if (!param_buf) {
17525 qdf_print("Invalid start response event buffer\n");
17526 return QDF_STATUS_E_INVAL;
17527 }
17528
17529 ev = param_buf->fixed_param;
17530 if (!ev) {
17531 qdf_print("Invalid start response event buffer\n");
17532 return QDF_STATUS_E_INVAL;
17533 }
17534
17535 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
17536
17537 vdev_rsp->vdev_id = ev->vdev_id;
17538 vdev_rsp->requestor_id = ev->requestor_id;
Varun Reddy Yeturue3d76012017-07-13 12:20:53 -070017539 switch (ev->resp_type) {
17540 case WMI_VDEV_START_RESP_EVENT:
17541 vdev_rsp->resp_type = WMI_HOST_VDEV_START_RESP_EVENT;
17542 break;
17543 case WMI_VDEV_RESTART_RESP_EVENT:
17544 vdev_rsp->resp_type = WMI_HOST_VDEV_RESTART_RESP_EVENT;
17545 break;
17546 default:
17547 qdf_print("Invalid start response event buffer\n");
17548 break;
17549 };
Govind Singhe7f2f342016-05-23 12:12:52 +053017550 vdev_rsp->status = ev->status;
17551 vdev_rsp->chain_mask = ev->chain_mask;
17552 vdev_rsp->smps_mode = ev->smps_mode;
17553 vdev_rsp->mac_id = ev->mac_id;
17554 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
17555 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
17556
17557 return QDF_STATUS_SUCCESS;
17558}
17559
17560/**
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053017561 * extract_vdev_delete_resp_tlv() - extract vdev delete response
17562 * @wmi_handle: wmi handle
17563 * @param evt_buf: pointer to event buffer
17564 * @param delete_rsp: Pointer to hold vdev delete response
17565 *
17566 * Return: QDF_STATUS_SUCCESS for success or error code
17567 */
17568static QDF_STATUS extract_vdev_delete_resp_tlv(wmi_unified_t wmi_handle,
17569 void *evt_buf, struct wmi_host_vdev_delete_resp *delete_rsp)
17570{
17571 WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *param_buf;
17572 wmi_vdev_delete_resp_event_fixed_param *ev;
17573
17574 param_buf = (WMI_VDEV_DELETE_RESP_EVENTID_param_tlvs *) evt_buf;
17575 if (!param_buf) {
17576 WMI_LOGE("Invalid vdev delete response event buffer\n");
17577 return QDF_STATUS_E_INVAL;
17578 }
17579
17580 ev = param_buf->fixed_param;
17581 if (!ev) {
17582 WMI_LOGE("Invalid vdev delete response event\n");
17583 return QDF_STATUS_E_INVAL;
17584 }
17585
17586 qdf_mem_zero(delete_rsp, sizeof(*delete_rsp));
17587 delete_rsp->vdev_id = ev->vdev_id;
17588
17589 return QDF_STATUS_SUCCESS;
17590}
17591
17592
17593/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017594 * extract_tbttoffset_num_vdevs_tlv() - extract tbtt offset num vdev
Govind Singhe7f2f342016-05-23 12:12:52 +053017595 * @wmi_handle: wmi handle
17596 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017597 * @param num_vdevs: Pointer to hold num vdev
17598 *
17599 * Return: QDF_STATUS_SUCCESS for success or error code
17600 */
17601static QDF_STATUS extract_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17602 void *evt_buf, uint32_t *num_vdevs)
17603{
17604 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17605 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
17606 uint32_t vdev_map;
17607
17608 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *)evt_buf;
17609 if (!param_buf) {
17610 qdf_print("Invalid tbtt update ext event buffer\n");
17611 return QDF_STATUS_E_INVAL;
17612 }
17613 tbtt_offset_event = param_buf->fixed_param;
17614 vdev_map = tbtt_offset_event->vdev_map;
17615 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
17616
17617 return QDF_STATUS_SUCCESS;
17618}
17619
17620/**
17621 * extract_ext_tbttoffset_num_vdevs_tlv() - extract ext tbtt offset num vdev
17622 * @wmi_handle: wmi handle
17623 * @param evt_buf: pointer to event buffer
17624 * @param num_vdevs: Pointer to hold num vdev
17625 *
17626 * Return: QDF_STATUS_SUCCESS for success or error code
17627 */
17628static QDF_STATUS extract_ext_tbttoffset_num_vdevs_tlv(void *wmi_hdl,
17629 void *evt_buf, uint32_t *num_vdevs)
17630{
17631 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17632 wmi_tbtt_offset_ext_event_fixed_param *tbtt_offset_ext_event;
17633
17634 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17635 if (!param_buf) {
17636 qdf_print("Invalid tbtt update ext event buffer\n");
17637 return QDF_STATUS_E_INVAL;
17638 }
17639 tbtt_offset_ext_event = param_buf->fixed_param;
17640
17641 *num_vdevs = tbtt_offset_ext_event->num_vdevs;
17642
17643 return QDF_STATUS_SUCCESS;
17644}
17645
17646/**
17647 * extract_tbttoffset_update_params_tlv() - extract tbtt offset param
17648 * @wmi_handle: wmi handle
17649 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017650 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017651 * @param tbtt_param: Pointer to tbttoffset event param
Govind Singhe7f2f342016-05-23 12:12:52 +053017652 *
17653 * Return: QDF_STATUS_SUCCESS for success or error code
17654 */
17655static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017656 void *evt_buf, uint8_t idx,
17657 struct tbttoffset_params *tbtt_param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017658{
17659 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
17660 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017661 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053017662
17663 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
17664 if (!param_buf) {
17665 qdf_print("Invalid tbtt update event buffer\n");
17666 return QDF_STATUS_E_INVAL;
17667 }
Govind Singhe7f2f342016-05-23 12:12:52 +053017668
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017669 tbtt_offset_event = param_buf->fixed_param;
17670 vdev_map = tbtt_offset_event->vdev_map;
17671 tbtt_param->vdev_id = wmi_vdev_map_to_vdev_id(vdev_map, idx);
17672 if (tbtt_param->vdev_id == WLAN_INVALID_VDEV_ID)
17673 return QDF_STATUS_E_INVAL;
17674 tbtt_param->tbttoffset =
17675 param_buf->tbttoffset_list[tbtt_param->vdev_id];
17676
17677 return QDF_STATUS_SUCCESS;
17678}
17679
17680/**
17681 * extract_ext_tbttoffset_update_params_tlv() - extract ext tbtt offset param
17682 * @wmi_handle: wmi handle
17683 * @param evt_buf: pointer to event buffer
Jeff Johnsonda263992018-05-12 14:22:00 -070017684 * @param idx: Index referring to a vdev
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053017685 * @param tbtt_param: Pointer to tbttoffset event param
17686 *
17687 * Return: QDF_STATUS_SUCCESS for success or error code
17688 */
17689static QDF_STATUS extract_ext_tbttoffset_update_params_tlv(void *wmi_hdl,
17690 void *evt_buf, uint8_t idx,
17691 struct tbttoffset_params *tbtt_param)
17692{
17693 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *param_buf;
17694 wmi_tbtt_offset_info *tbtt_offset_info;
17695
17696 param_buf = (WMI_TBTTOFFSET_EXT_UPDATE_EVENTID_param_tlvs *)evt_buf;
17697 if (!param_buf) {
17698 qdf_print("Invalid tbtt update event buffer\n");
17699 return QDF_STATUS_E_INVAL;
17700 }
17701 tbtt_offset_info = &param_buf->tbtt_offset_info[idx];
17702
17703 tbtt_param->vdev_id = tbtt_offset_info->vdev_id;
17704 tbtt_param->tbttoffset = tbtt_offset_info->tbttoffset;
Govind Singhe7f2f342016-05-23 12:12:52 +053017705
17706 return QDF_STATUS_SUCCESS;
17707}
17708
17709/**
17710 * extract_mgmt_rx_params_tlv() - extract management rx params from event
17711 * @wmi_handle: wmi handle
17712 * @param evt_buf: pointer to event buffer
17713 * @param hdr: Pointer to hold header
17714 * @param bufp: Pointer to hold pointer to rx param buffer
17715 *
17716 * Return: QDF_STATUS_SUCCESS for success or error code
17717 */
17718static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053017719 void *evt_buf, struct mgmt_rx_event_params *hdr,
17720 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053017721{
17722 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
17723 wmi_mgmt_rx_hdr *ev_hdr = NULL;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017724 int i;
Govind Singhe7f2f342016-05-23 12:12:52 +053017725
17726 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
17727 if (!param_tlvs) {
17728 WMI_LOGE("Get NULL point message from FW");
17729 return QDF_STATUS_E_INVAL;
17730 }
17731
17732 ev_hdr = param_tlvs->hdr;
17733 if (!hdr) {
17734 WMI_LOGE("Rx event is NULL");
17735 return QDF_STATUS_E_INVAL;
17736 }
17737
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017738 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17739 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053017740
17741 hdr->channel = ev_hdr->channel;
17742 hdr->snr = ev_hdr->snr;
17743 hdr->rate = ev_hdr->rate;
17744 hdr->phy_mode = ev_hdr->phy_mode;
17745 hdr->buf_len = ev_hdr->buf_len;
17746 hdr->status = ev_hdr->status;
17747 hdr->flags = ev_hdr->flags;
17748 hdr->rssi = ev_hdr->rssi;
17749 hdr->tsf_delta = ev_hdr->tsf_delta;
gaurank kathpalia6a51f2b2018-01-29 18:09:06 +053017750 for (i = 0; i < ATH_MAX_ANTENNA; i++)
17751 hdr->rssi_ctl[i] = ev_hdr->rssi_ctl[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053017752
17753 *bufp = param_tlvs->bufp;
17754
17755 return QDF_STATUS_SUCCESS;
17756}
17757
17758/**
17759 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
17760 * @wmi_handle: wmi handle
17761 * @param evt_buf: pointer to event buffer
17762 * @param vdev_id: Pointer to hold vdev identifier
17763 *
17764 * Return: QDF_STATUS_SUCCESS for success or error code
17765 */
17766static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
17767 void *evt_buf, uint32_t *vdev_id)
17768{
17769 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
17770 wmi_vdev_stopped_event_fixed_param *resp_event;
17771
17772 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
17773 if (!param_buf) {
17774 WMI_LOGE("Invalid event buffer");
17775 return QDF_STATUS_E_INVAL;
17776 }
17777 resp_event = param_buf->fixed_param;
17778 *vdev_id = resp_event->vdev_id;
17779
17780 return QDF_STATUS_SUCCESS;
17781}
17782
17783/**
17784 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
17785 * @wmi_handle: wmi handle
17786 * @param evt_buf: pointer to event buffer
17787 * @param param: Pointer to hold roam param
17788 *
17789 * Return: QDF_STATUS_SUCCESS for success or error code
17790 */
17791static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
17792 void *evt_buf, wmi_host_roam_event *param)
17793{
17794 WMI_ROAM_EVENTID_param_tlvs *param_buf;
17795 wmi_roam_event_fixed_param *evt;
17796
17797 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
17798 if (!param_buf) {
17799 WMI_LOGE("Invalid roam event buffer");
17800 return QDF_STATUS_E_INVAL;
17801 }
17802
17803 evt = param_buf->fixed_param;
17804 qdf_mem_zero(param, sizeof(*param));
17805
17806 param->vdev_id = evt->vdev_id;
17807 param->reason = evt->reason;
17808 param->rssi = evt->rssi;
17809
17810 return QDF_STATUS_SUCCESS;
17811}
17812
17813/**
17814 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
17815 * @wmi_handle: wmi handle
17816 * @param evt_buf: pointer to event buffer
17817 * @param param: Pointer to hold vdev scan param
17818 *
17819 * Return: QDF_STATUS_SUCCESS for success or error code
17820 */
17821static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017822 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053017823{
17824 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
17825 wmi_scan_event_fixed_param *evt = NULL;
17826
17827 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
17828 evt = param_buf->fixed_param;
17829
17830 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017831
Govind Singhe7f2f342016-05-23 12:12:52 +053017832 switch (evt->event) {
17833 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017834 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017835 break;
17836 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017837 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017838 break;
17839 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017840 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017841 break;
17842 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017843 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053017844 break;
17845 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017846 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017847 break;
17848 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017849 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017850 break;
17851 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017852 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017853 break;
17854 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017855 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017856 break;
Sreelakshmi Konamki76d62af2017-05-25 18:11:03 +053017857 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017858 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053017859 break;
17860 case WMI_SCAN_EVENT_MAX:
17861 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017862 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053017863 break;
17864 };
17865
17866 switch (evt->reason) {
17867 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017868 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017869 break;
17870 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017871 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017872 break;
17873 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017874 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017875 break;
17876 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017877 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053017878 break;
17879 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017880 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053017881 break;
17882 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017883 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017884 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017885 case WMI_SCAN_REASON_SUSPENDED:
17886 param->reason = SCAN_REASON_SUSPENDED;
17887 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053017888 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053017889 param->reason = SCAN_REASON_MAX;
17890 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053017891 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017892 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053017893 break;
17894 };
17895
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053017896 param->chan_freq = evt->channel_freq;
17897 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053017898 param->scan_id = evt->scan_id;
17899 param->vdev_id = evt->vdev_id;
Sathish Kumarb8633152017-08-11 15:00:04 +053017900 param->timestamp = evt->tsf_timestamp;
Govind Singhe7f2f342016-05-23 12:12:52 +053017901
17902 return QDF_STATUS_SUCCESS;
17903}
17904
Frank Liu3d5e9992017-03-15 17:51:43 +080017905#ifdef CONVERGED_TDLS_ENABLE
17906/**
17907 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
17908 * @wmi_handle: wmi handle
17909 * @param evt_buf: pointer to event buffer
17910 * @param param: Pointer to hold vdev tdls param
17911 *
17912 * Return: QDF_STATUS_SUCCESS for success or error code
17913 */
17914static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
17915 void *evt_buf, struct tdls_event_info *param)
17916{
17917 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
17918 wmi_tdls_peer_event_fixed_param *evt;
17919
17920 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
17921 if (!param_buf) {
17922 WMI_LOGE("%s: NULL param_buf", __func__);
17923 return QDF_STATUS_E_NULL_VALUE;
17924 }
17925
17926 evt = param_buf->fixed_param;
17927
17928 qdf_mem_zero(param, sizeof(*param));
17929
17930 param->vdev_id = evt->vdev_id;
17931 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
17932 param->peermac.bytes);
17933 switch (evt->peer_status) {
17934 case WMI_TDLS_SHOULD_DISCOVER:
17935 param->message_type = TDLS_SHOULD_DISCOVER;
17936 break;
17937 case WMI_TDLS_SHOULD_TEARDOWN:
17938 param->message_type = TDLS_SHOULD_TEARDOWN;
17939 break;
17940 case WMI_TDLS_PEER_DISCONNECTED:
17941 param->message_type = TDLS_PEER_DISCONNECTED;
17942 break;
17943 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
17944 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
17945 break;
17946 default:
17947 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
17948 __func__, evt->peer_status);
17949 return QDF_STATUS_E_INVAL;
17950 };
17951
17952 switch (evt->peer_reason) {
17953 case WMI_TDLS_TEARDOWN_REASON_TX:
17954 param->peer_reason = TDLS_TEARDOWN_TX;
17955 break;
17956 case WMI_TDLS_TEARDOWN_REASON_RSSI:
17957 param->peer_reason = TDLS_TEARDOWN_RSSI;
17958 break;
17959 case WMI_TDLS_TEARDOWN_REASON_SCAN:
17960 param->peer_reason = TDLS_TEARDOWN_SCAN;
17961 break;
17962 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
17963 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
17964 break;
17965 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
17966 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
17967 break;
17968 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
17969 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
17970 break;
17971 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
17972 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
17973 break;
17974 case WMI_TDLS_ENTER_BUF_STA:
17975 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
17976 break;
17977 case WMI_TDLS_EXIT_BUF_STA:
17978 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
17979 break;
17980 case WMI_TDLS_ENTER_BT_BUSY_MODE:
17981 param->peer_reason = TDLS_ENTER_BT_BUSY;
17982 break;
17983 case WMI_TDLS_EXIT_BT_BUSY_MODE:
17984 param->peer_reason = TDLS_EXIT_BT_BUSY;
17985 break;
17986 case WMI_TDLS_SCAN_STARTED_EVENT:
17987 param->peer_reason = TDLS_SCAN_STARTED;
17988 break;
17989 case WMI_TDLS_SCAN_COMPLETED_EVENT:
17990 param->peer_reason = TDLS_SCAN_COMPLETED;
17991 break;
17992
17993 default:
17994 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
17995 __func__, evt->peer_reason, evt->peer_status);
17996 return QDF_STATUS_E_INVAL;
17997 };
17998
17999 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
18000 __func__, param->peermac.bytes, param->message_type,
18001 param->peer_reason, param->vdev_id);
18002
18003 return QDF_STATUS_SUCCESS;
18004}
18005#endif
18006
Govind Singhe7f2f342016-05-23 12:12:52 +053018007/**
18008 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
18009 * @wmi_handle: wmi handle
18010 * @param evt_buf: pointer to event buffer
18011 * @param param: Pointer to hold MGMT TX completion params
18012 *
18013 * Return: QDF_STATUS_SUCCESS for success or error code
18014 */
18015static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
18016 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
18017{
18018 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18019 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
18020
18021 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
18022 evt_buf;
18023 if (!param_buf) {
18024 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
18025 return QDF_STATUS_E_INVAL;
18026 }
18027 cmpl_params = param_buf->fixed_param;
18028
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018029 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18030 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018031 param->desc_id = cmpl_params->desc_id;
18032 param->status = cmpl_params->status;
Soumya Bhat0ae28062018-03-09 13:04:57 +053018033 param->ppdu_id = cmpl_params->ppdu_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018034
18035 return QDF_STATUS_SUCCESS;
18036}
18037
18038/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018039 * extract_offchan_data_tx_compl_param_tlv() -
18040 * extract Offchan data tx completion event params
18041 * @wmi_handle: wmi handle
18042 * @param evt_buf: pointer to event buffer
18043 * @param param: Pointer to hold offchan data TX completion params
18044 *
18045 * Return: QDF_STATUS_SUCCESS for success or error code
18046 */
18047static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
18048 wmi_unified_t wmi_handle, void *evt_buf,
18049 struct wmi_host_offchan_data_tx_compl_event *param)
18050{
18051 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
18052 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
18053
18054 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
18055 evt_buf;
18056 if (!param_buf) {
18057 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
18058 return QDF_STATUS_E_INVAL;
18059 }
18060 cmpl_params = param_buf->fixed_param;
18061
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018062 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18063 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018064 param->desc_id = cmpl_params->desc_id;
18065 param->status = cmpl_params->status;
18066
18067 return QDF_STATUS_SUCCESS;
18068}
18069
18070/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053018071 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
18072 * status tlv
18073 * @wmi_handle: wmi handle
18074 * @param evt_buf: pointer to event buffer
18075 * @param param: Pointer to hold csa switch count status event param
18076 *
18077 * Return: QDF_STATUS_SUCCESS for success or error code
18078 */
18079static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
18080 wmi_unified_t wmi_handle,
18081 void *evt_buf,
18082 struct pdev_csa_switch_count_status *param)
18083{
18084 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
18085 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
18086
18087 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
18088 evt_buf;
18089 if (!param_buf) {
18090 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
18091 return QDF_STATUS_E_INVAL;
18092 }
18093
18094 csa_status = param_buf->fixed_param;
18095
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018096 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18097 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053018098 param->current_switch_count = csa_status->current_switch_count;
18099 param->num_vdevs = csa_status->num_vdevs;
18100 param->vdev_ids = param_buf->vdev_ids;
18101
18102 return QDF_STATUS_SUCCESS;
18103}
18104
18105/**
Shaakir Mohamed75208c32018-02-15 14:30:21 -080018106 * extract_pdev_tpc_config_ev_param_tlv() - extract pdev tpc configuration
18107 * param from event
18108 * @wmi_handle: wmi handle
18109 * @param evt_buf: pointer to event buffer
18110 * @param param: Pointer to hold tpc configuration
18111 *
18112 * Return: 0 for success or error code
18113 */
18114static QDF_STATUS extract_pdev_tpc_config_ev_param_tlv(wmi_unified_t wmi_handle,
18115 void *evt_buf,
18116 wmi_host_pdev_tpc_config_event *param)
18117{
18118 wmi_pdev_tpc_config_event_fixed_param *event =
18119 (wmi_pdev_tpc_config_event_fixed_param *)evt_buf;
18120
18121 if (!event) {
18122 WMI_LOGE("Invalid event buffer");
18123 return QDF_STATUS_E_INVAL;
18124 }
18125
18126 param->pdev_id = event->pdev_id;
18127 param->regDomain = event->regDomain;
18128 param->chanFreq = event->chanFreq;
18129 param->phyMode = event->phyMode;
18130 param->twiceAntennaReduction = event->twiceAntennaReduction;
18131 param->twiceMaxRDPower = event->twiceMaxRDPower;
18132 param->powerLimit = event->powerLimit;
18133 param->rateMax = event->rateMax;
18134 param->numTxChain = event->numTxChain;
18135 param->ctl = event->ctl;
18136 param->flags = event->flags;
18137
18138 qdf_mem_copy(param->maxRegAllowedPower, event->maxRegAllowedPower,
18139 sizeof(param->maxRegAllowedPower));
18140 qdf_mem_copy(param->maxRegAllowedPowerAGCDD,
18141 event->maxRegAllowedPowerAGCDD,
18142 sizeof(param->maxRegAllowedPowerAGCDD));
18143 qdf_mem_copy(param->maxRegAllowedPowerAGSTBC,
18144 event->maxRegAllowedPowerAGSTBC,
18145 sizeof(param->maxRegAllowedPowerAGSTBC));
18146 qdf_mem_copy(param->maxRegAllowedPowerAGTXBF,
18147 event->maxRegAllowedPowerAGTXBF,
18148 sizeof(param->maxRegAllowedPowerAGTXBF));
18149 WMI_LOGD("%s:extract success", __func__);
18150
18151 return QDF_STATUS_SUCCESS;
18152}
18153
18154/**
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018155 * extract_swba_num_vdevs_tlv() - extract swba num vdevs from event
Govind Singhe7f2f342016-05-23 12:12:52 +053018156 * @wmi_handle: wmi handle
18157 * @param evt_buf: pointer to event buffer
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018158 * @param num_vdevs: Pointer to hold num vdevs
Govind Singhe7f2f342016-05-23 12:12:52 +053018159 *
18160 * Return: QDF_STATUS_SUCCESS for success or error code
18161 */
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018162static QDF_STATUS extract_swba_num_vdevs_tlv(wmi_unified_t wmi_handle,
18163 void *evt_buf, uint32_t *num_vdevs)
Govind Singhe7f2f342016-05-23 12:12:52 +053018164{
18165 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18166 wmi_host_swba_event_fixed_param *swba_event;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018167 uint32_t vdev_map;
Govind Singhe7f2f342016-05-23 12:12:52 +053018168
18169 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18170 if (!param_buf) {
18171 WMI_LOGE("Invalid swba event buffer");
18172 return QDF_STATUS_E_INVAL;
18173 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018174
Govind Singhe7f2f342016-05-23 12:12:52 +053018175 swba_event = param_buf->fixed_param;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018176 *num_vdevs = swba_event->num_vdevs;
18177 if (!(*num_vdevs)) {
18178 vdev_map = swba_event->vdev_map;
18179 *num_vdevs = wmi_vdev_map_to_num_vdevs(vdev_map);
18180 }
Govind Singhe7f2f342016-05-23 12:12:52 +053018181
18182 return QDF_STATUS_SUCCESS;
18183}
18184
18185/**
18186 * extract_swba_tim_info_tlv() - extract swba tim info from event
18187 * @wmi_handle: wmi handle
18188 * @param evt_buf: pointer to event buffer
18189 * @param idx: Index to bcn info
18190 * @param tim_info: Pointer to hold tim info
18191 *
18192 * Return: QDF_STATUS_SUCCESS for success or error code
18193 */
18194static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
18195 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
18196{
18197 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18198 wmi_tim_info *tim_info_ev;
18199
18200 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18201 if (!param_buf) {
18202 WMI_LOGE("Invalid swba event buffer");
18203 return QDF_STATUS_E_INVAL;
18204 }
18205
18206 tim_info_ev = &param_buf->tim_info[idx];
18207
18208 tim_info->tim_len = tim_info_ev->tim_len;
18209 tim_info->tim_mcast = tim_info_ev->tim_mcast;
18210 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
18211 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
18212 tim_info->tim_changed = tim_info_ev->tim_changed;
18213 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018214 tim_info->vdev_id = tim_info_ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018215
18216 return QDF_STATUS_SUCCESS;
18217}
18218
18219/**
18220 * extract_swba_noa_info_tlv() - extract swba NoA information from event
18221 * @wmi_handle: wmi handle
18222 * @param evt_buf: pointer to event buffer
18223 * @param idx: Index to bcn info
18224 * @param p2p_desc: Pointer to hold p2p NoA info
18225 *
18226 * Return: QDF_STATUS_SUCCESS for success or error code
18227 */
18228static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
18229 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
18230{
18231 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
18232 wmi_p2p_noa_info *p2p_noa_info;
18233 uint8_t i = 0;
18234
18235 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
18236 if (!param_buf) {
18237 WMI_LOGE("Invalid swba event buffer");
18238 return QDF_STATUS_E_INVAL;
18239 }
18240
18241 p2p_noa_info = &param_buf->p2p_noa_info[idx];
18242
18243 p2p_desc->modified = false;
18244 p2p_desc->num_descriptors = 0;
18245 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
18246 p2p_desc->modified = true;
18247 p2p_desc->index =
18248 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
18249 p2p_desc->oppPS =
18250 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
18251 p2p_desc->ctwindow =
18252 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
18253 p2p_desc->num_descriptors =
18254 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
18255 (p2p_noa_info);
18256 for (i = 0; i < p2p_desc->num_descriptors; i++) {
18257 p2p_desc->noa_descriptors[i].type_count =
18258 (uint8_t) p2p_noa_info->noa_descriptors[i].
18259 type_count;
18260 p2p_desc->noa_descriptors[i].duration =
18261 p2p_noa_info->noa_descriptors[i].duration;
18262 p2p_desc->noa_descriptors[i].interval =
18263 p2p_noa_info->noa_descriptors[i].interval;
18264 p2p_desc->noa_descriptors[i].start_time =
18265 p2p_noa_info->noa_descriptors[i].start_time;
18266 }
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053018267 p2p_desc->vdev_id = p2p_noa_info->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018268 }
18269
18270 return QDF_STATUS_SUCCESS;
18271}
18272
Wu Gaocd3a8512017-03-13 20:17:34 +080018273#ifdef CONVERGED_P2P_ENABLE
18274/**
18275 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
18276 * @wmi_handle: wmi handle
18277 * @param evt_buf: pointer to event buffer
18278 * @param param: Pointer to hold p2p noa info
18279 *
18280 * Return: QDF_STATUS_SUCCESS for success or error code
18281 */
18282static QDF_STATUS extract_p2p_noa_ev_param_tlv(
18283 wmi_unified_t wmi_handle, void *evt_buf,
18284 struct p2p_noa_info *param)
18285{
18286 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
18287 wmi_p2p_noa_event_fixed_param *fixed_param;
18288 uint8_t i;
18289 wmi_p2p_noa_info *wmi_noa_info;
18290 uint8_t *buf_ptr;
18291 uint32_t descriptors;
18292
18293 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
18294 if (!param_tlvs) {
18295 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
18296 return QDF_STATUS_E_INVAL;
18297 }
18298
18299 if (!param) {
18300 WMI_LOGE("noa information param is null");
18301 return QDF_STATUS_E_INVAL;
18302 }
18303
18304 fixed_param = param_tlvs->fixed_param;
18305 buf_ptr = (uint8_t *) fixed_param;
18306 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
18307 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
18308
18309 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
18310 WMI_LOGE("%s: noa attr is not modified", __func__);
18311 return QDF_STATUS_E_INVAL;
18312 }
18313
18314 param->vdev_id = fixed_param->vdev_id;
18315 param->index =
18316 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
18317 param->opps_ps =
18318 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
18319 param->ct_window =
18320 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
18321 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
18322 param->num_desc = (uint8_t) descriptors;
18323
18324 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
18325 param->index, param->opps_ps, param->ct_window,
18326 param->num_desc);
18327 for (i = 0; i < param->num_desc; i++) {
18328 param->noa_desc[i].type_count =
18329 (uint8_t) wmi_noa_info->noa_descriptors[i].
18330 type_count;
18331 param->noa_desc[i].duration =
18332 wmi_noa_info->noa_descriptors[i].duration;
18333 param->noa_desc[i].interval =
18334 wmi_noa_info->noa_descriptors[i].interval;
18335 param->noa_desc[i].start_time =
18336 wmi_noa_info->noa_descriptors[i].start_time;
18337 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
18338 __func__, i, param->noa_desc[i].type_count,
18339 param->noa_desc[i].duration,
18340 param->noa_desc[i].interval,
18341 param->noa_desc[i].start_time);
18342 }
18343
18344 return QDF_STATUS_SUCCESS;
18345}
18346
18347/**
18348 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
18349 * information from event
18350 * @wmi_handle: wmi handle
18351 * @param evt_buf: pointer to event buffer
18352 * @param param: Pointer to hold p2p lo stop event information
18353 *
18354 * Return: QDF_STATUS_SUCCESS for success or error code
18355 */
18356static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
18357 wmi_unified_t wmi_handle, void *evt_buf,
18358 struct p2p_lo_event *param)
18359{
18360 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
18361 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
18362
18363 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
18364 evt_buf;
18365 if (!param_tlvs) {
18366 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
18367 return QDF_STATUS_E_INVAL;
18368 }
18369
18370 if (!param) {
18371 WMI_LOGE("lo stop event param is null");
18372 return QDF_STATUS_E_INVAL;
18373 }
18374
18375 lo_param = param_tlvs->fixed_param;
18376 param->vdev_id = lo_param->vdev_id;
18377 param->reason_code = lo_param->reason;
18378 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
18379 param->vdev_id, param->reason_code);
18380
18381 return QDF_STATUS_SUCCESS;
18382}
18383#endif /* End of CONVERGED_P2P_ENABLE */
18384
Govind Singhe7f2f342016-05-23 12:12:52 +053018385/**
18386 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
18387 * @wmi_handle: wmi handle
18388 * @param evt_buf: pointer to event buffer
18389 * @param ev: Pointer to hold peer param
18390 *
18391 * Return: QDF_STATUS_SUCCESS for success or error code
18392 */
18393static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
18394 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
18395{
18396 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
18397 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
18398
18399 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
18400 kickout_event = param_buf->fixed_param;
18401
18402 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
18403 ev->peer_macaddr);
18404
18405 ev->reason = kickout_event->reason;
18406 ev->rssi = kickout_event->rssi;
18407
18408 return QDF_STATUS_SUCCESS;
18409}
18410
18411/**
18412 * extract_all_stats_counts_tlv() - extract all stats count from event
18413 * @wmi_handle: wmi handle
18414 * @param evt_buf: pointer to event buffer
18415 * @param stats_param: Pointer to hold stats count
18416 *
18417 * Return: QDF_STATUS_SUCCESS for success or error code
18418 */
18419static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
18420 void *evt_buf, wmi_host_stats_event *stats_param)
18421{
Govind Singhe7f2f342016-05-23 12:12:52 +053018422 wmi_stats_event_fixed_param *ev;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018423 wmi_per_chain_rssi_stats *rssi_event;
18424 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018425
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018426 qdf_mem_zero(stats_param, sizeof(*stats_param));
Govind Singhe7f2f342016-05-23 12:12:52 +053018427 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053018428 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018429 rssi_event = param_buf->chain_stats;
Govind Singhe7f2f342016-05-23 12:12:52 +053018430 if (!ev) {
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018431 WMI_LOGE("%s: event fixed param NULL\n", __func__);
Govind Singhe7f2f342016-05-23 12:12:52 +053018432 return QDF_STATUS_E_FAILURE;
18433 }
18434
18435 switch (ev->stats_id) {
18436 case WMI_REQUEST_PEER_STAT:
18437 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
18438 break;
18439
18440 case WMI_REQUEST_AP_STAT:
18441 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
18442 break;
18443
18444 case WMI_REQUEST_PDEV_STAT:
18445 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
18446 break;
18447
18448 case WMI_REQUEST_VDEV_STAT:
18449 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
18450 break;
18451
18452 case WMI_REQUEST_BCNFLT_STAT:
18453 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
18454 break;
18455
18456 case WMI_REQUEST_VDEV_RATE_STAT:
18457 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
18458 break;
18459
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018460 case WMI_REQUEST_BCN_STAT:
18461 stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
18462 break;
18463
Govind Singhe7f2f342016-05-23 12:12:52 +053018464 default:
18465 stats_param->stats_id = 0;
18466 break;
18467
18468 }
18469
18470 stats_param->num_pdev_stats = ev->num_pdev_stats;
18471 stats_param->num_pdev_ext_stats = 0;
18472 stats_param->num_vdev_stats = ev->num_vdev_stats;
18473 stats_param->num_peer_stats = ev->num_peer_stats;
18474 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
18475 stats_param->num_chan_stats = ev->num_chan_stats;
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018476 stats_param->num_bcn_stats = ev->num_bcn_stats;
Gurumoorthi Gnanasambandhan305aeae2017-08-10 22:12:36 +053018477 stats_param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
18478 ev->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053018479
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018480 /* if chain_stats is not populated */
18481 if (!param_buf->chain_stats || !param_buf->num_chain_stats)
18482 return QDF_STATUS_SUCCESS;
18483
18484 if (WMITLV_TAG_STRUC_wmi_per_chain_rssi_stats !=
18485 WMITLV_GET_TLVTAG(rssi_event->tlv_header))
18486 return QDF_STATUS_SUCCESS;
18487
18488 if (WMITLV_GET_STRUCT_TLVLEN(wmi_per_chain_rssi_stats) !=
Naveen Rawata8e19e72018-06-01 17:12:31 -070018489 WMITLV_GET_TLVLEN(rssi_event->tlv_header))
Naveen Rawat57e47aa2018-04-06 10:57:20 -070018490 return QDF_STATUS_SUCCESS;
18491
18492 stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
18493
Govind Singhe7f2f342016-05-23 12:12:52 +053018494 return QDF_STATUS_SUCCESS;
18495}
18496
18497/**
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018498 * extract_pdev_tx_stats() - extract pdev tx stats from event
18499 */
18500static void extract_pdev_tx_stats(wmi_host_dbg_tx_stats *tx, struct wlan_dbg_tx_stats *tx_stats)
18501{
18502 /* Tx Stats */
18503 tx->comp_queued = tx_stats->comp_queued;
18504 tx->comp_delivered = tx_stats->comp_delivered;
18505 tx->msdu_enqued = tx_stats->msdu_enqued;
18506 tx->mpdu_enqued = tx_stats->mpdu_enqued;
18507 tx->wmm_drop = tx_stats->wmm_drop;
18508 tx->local_enqued = tx_stats->local_enqued;
18509 tx->local_freed = tx_stats->local_freed;
18510 tx->hw_queued = tx_stats->hw_queued;
18511 tx->hw_reaped = tx_stats->hw_reaped;
18512 tx->underrun = tx_stats->underrun;
18513 tx->tx_abort = tx_stats->tx_abort;
18514 tx->mpdus_requed = tx_stats->mpdus_requed;
18515 tx->data_rc = tx_stats->data_rc;
18516 tx->self_triggers = tx_stats->self_triggers;
18517 tx->sw_retry_failure = tx_stats->sw_retry_failure;
18518 tx->illgl_rate_phy_err = tx_stats->illgl_rate_phy_err;
18519 tx->pdev_cont_xretry = tx_stats->pdev_cont_xretry;
18520 tx->pdev_tx_timeout = tx_stats->pdev_tx_timeout;
18521 tx->pdev_resets = tx_stats->pdev_resets;
18522 tx->stateless_tid_alloc_failure = tx_stats->stateless_tid_alloc_failure;
18523 tx->phy_underrun = tx_stats->phy_underrun;
18524 tx->txop_ovf = tx_stats->txop_ovf;
18525
18526 return;
18527}
18528
18529
18530/**
18531 * extract_pdev_rx_stats() - extract pdev rx stats from event
18532 */
18533static void extract_pdev_rx_stats(wmi_host_dbg_rx_stats *rx, struct wlan_dbg_rx_stats *rx_stats)
18534{
18535 /* Rx Stats */
18536 rx->mid_ppdu_route_change = rx_stats->mid_ppdu_route_change;
18537 rx->status_rcvd = rx_stats->status_rcvd;
18538 rx->r0_frags = rx_stats->r0_frags;
18539 rx->r1_frags = rx_stats->r1_frags;
18540 rx->r2_frags = rx_stats->r2_frags;
18541 /* Only TLV */
18542 rx->r3_frags = 0;
18543 rx->htt_msdus = rx_stats->htt_msdus;
18544 rx->htt_mpdus = rx_stats->htt_mpdus;
18545 rx->loc_msdus = rx_stats->loc_msdus;
18546 rx->loc_mpdus = rx_stats->loc_mpdus;
18547 rx->oversize_amsdu = rx_stats->oversize_amsdu;
18548 rx->phy_errs = rx_stats->phy_errs;
18549 rx->phy_err_drop = rx_stats->phy_err_drop;
18550 rx->mpdu_errs = rx_stats->mpdu_errs;
18551
18552 return;
18553}
18554
18555/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018556 * extract_pdev_stats_tlv() - extract pdev stats from event
18557 * @wmi_handle: wmi handle
18558 * @param evt_buf: pointer to event buffer
18559 * @param index: Index into pdev stats
18560 * @param pdev_stats: Pointer to hold pdev stats
18561 *
18562 * Return: QDF_STATUS_SUCCESS for success or error code
18563 */
18564static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
18565 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
18566{
Gurumoorthi Gnanasambandhan871fd6e2017-05-24 17:41:46 +053018567 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18568 wmi_stats_event_fixed_param *ev_param;
18569 uint8_t *data;
18570
18571 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18572 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18573
18574 data = param_buf->data;
18575
18576 if (index < ev_param->num_pdev_stats) {
18577 wmi_pdev_stats *ev = (wmi_pdev_stats *) ((data) +
18578 (index * sizeof(wmi_pdev_stats)));
18579
18580 pdev_stats->chan_nf = ev->chan_nf;
18581 pdev_stats->tx_frame_count = ev->tx_frame_count;
18582 pdev_stats->rx_frame_count = ev->rx_frame_count;
18583 pdev_stats->rx_clear_count = ev->rx_clear_count;
18584 pdev_stats->cycle_count = ev->cycle_count;
18585 pdev_stats->phy_err_count = ev->phy_err_count;
18586 pdev_stats->chan_tx_pwr = ev->chan_tx_pwr;
18587
18588 extract_pdev_tx_stats(&(pdev_stats->pdev_stats.tx),
18589 &(ev->pdev_stats.tx));
18590 extract_pdev_rx_stats(&(pdev_stats->pdev_stats.rx),
18591 &(ev->pdev_stats.rx));
18592 }
18593
Govind Singhe7f2f342016-05-23 12:12:52 +053018594 return QDF_STATUS_SUCCESS;
18595}
18596
18597/**
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070018598 * extract_unit_test_tlv() - extract unit test data
18599 * @wmi_handle: wmi handle
18600 * @param evt_buf: pointer to event buffer
18601 * @param unit_test: pointer to hold unit test data
18602 * @param maxspace: Amount of space in evt_buf
18603 *
18604 * Return: QDF_STATUS_SUCCESS for success or error code
18605 */
18606static QDF_STATUS extract_unit_test_tlv(wmi_unified_t wmi_handle,
18607 void *evt_buf, wmi_unit_test_event *unit_test, uint32_t maxspace)
18608{
18609 WMI_UNIT_TEST_EVENTID_param_tlvs *param_buf;
18610 wmi_unit_test_event_fixed_param *ev_param;
18611 uint32_t num_bufp;
18612 uint32_t copy_size;
18613 uint8_t *bufp;
18614
18615 param_buf = (WMI_UNIT_TEST_EVENTID_param_tlvs *) evt_buf;
18616 ev_param = param_buf->fixed_param;
18617 bufp = param_buf->bufp;
18618 num_bufp = param_buf->num_bufp;
18619 unit_test->vdev_id = ev_param->vdev_id;
18620 unit_test->module_id = ev_param->module_id;
18621 unit_test->diag_token = ev_param->diag_token;
18622 unit_test->flag = ev_param->flag;
18623 unit_test->payload_len = ev_param->payload_len;
18624 WMI_LOGI("%s:vdev_id:%d mod_id:%d diag_token:%d flag:%d\n", __func__,
18625 ev_param->vdev_id,
18626 ev_param->module_id,
18627 ev_param->diag_token,
18628 ev_param->flag);
18629 WMI_LOGD("%s: Unit-test data given below %d", __func__, num_bufp);
18630 qdf_trace_hex_dump(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_DEBUG,
18631 bufp, num_bufp);
18632 copy_size = (num_bufp < maxspace) ? num_bufp : maxspace;
18633 qdf_mem_copy(unit_test->buffer, bufp, copy_size);
18634 unit_test->buffer_len = copy_size;
18635
18636 return QDF_STATUS_SUCCESS;
18637}
18638
18639/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018640 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
18641 * @wmi_handle: wmi handle
18642 * @param evt_buf: pointer to event buffer
18643 * @param index: Index into extended pdev stats
18644 * @param pdev_ext_stats: Pointer to hold extended pdev stats
18645 *
18646 * Return: QDF_STATUS_SUCCESS for success or error code
18647 */
18648static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
18649 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
18650{
18651 return QDF_STATUS_SUCCESS;
18652}
18653
18654/**
18655 * extract_vdev_stats_tlv() - extract vdev stats from event
18656 * @wmi_handle: wmi handle
18657 * @param evt_buf: pointer to event buffer
18658 * @param index: Index into vdev stats
18659 * @param vdev_stats: Pointer to hold vdev stats
18660 *
18661 * Return: QDF_STATUS_SUCCESS for success or error code
18662 */
18663static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
18664 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
18665{
18666 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18667 wmi_stats_event_fixed_param *ev_param;
18668 uint8_t *data;
18669
18670 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18671 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18672 data = (uint8_t *) param_buf->data;
18673
18674 if (index < ev_param->num_vdev_stats) {
18675 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
18676 ((ev_param->num_pdev_stats) *
18677 sizeof(wmi_pdev_stats)) +
18678 (index * sizeof(wmi_vdev_stats)));
18679
18680 vdev_stats->vdev_id = ev->vdev_id;
18681 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
18682 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
18683
18684 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
18685 sizeof(ev->tx_frm_cnt));
18686 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
18687 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
18688 ev->multiple_retry_cnt,
18689 sizeof(ev->multiple_retry_cnt));
18690 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
18691 sizeof(ev->fail_cnt));
18692 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
18693 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
18694 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
18695 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
18696 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
18697 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
18698 sizeof(ev->tx_rate_history));
18699 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
18700 sizeof(ev->bcn_rssi_history));
18701
18702 }
18703
18704 return QDF_STATUS_SUCCESS;
18705}
18706
18707/**
Naveen Rawatd2115722018-04-12 08:17:55 -070018708 * extract_per_chain_rssi_stats_tlv() - api to extract rssi stats from event
18709 * buffer
18710 * @wmi_handle: wmi handle
18711 * @evt_buf: pointer to event buffer
18712 * @index: Index into vdev stats
18713 * @rssi_stats: Pointer to hold rssi stats
18714 *
18715 * Return: QDF_STATUS_SUCCESS for success or error code
18716 */
18717static QDF_STATUS extract_per_chain_rssi_stats_tlv(wmi_unified_t wmi_handle,
18718 void *evt_buf, uint32_t index,
18719 struct wmi_host_per_chain_rssi_stats *rssi_stats)
18720{
18721 uint8_t *data;
18722 wmi_rssi_stats *fw_rssi_stats;
18723 wmi_per_chain_rssi_stats *rssi_event;
18724 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18725
18726 if (!evt_buf) {
18727 WMI_LOGE("evt_buf is null");
18728 return QDF_STATUS_E_NULL_VALUE;
18729 }
18730
18731 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18732 rssi_event = param_buf->chain_stats;
18733
18734 if (index >= rssi_event->num_per_chain_rssi_stats) {
18735 WMI_LOGE("invalid index");
18736 return QDF_STATUS_E_INVAL;
18737 }
18738
18739 data = ((uint8_t *)(&rssi_event[1])) + WMI_TLV_HDR_SIZE;
18740 fw_rssi_stats = &((wmi_rssi_stats *)data)[index];
18741
18742 rssi_stats->vdev_id = fw_rssi_stats->vdev_id;
18743 qdf_mem_copy(rssi_stats->rssi_avg_beacon,
18744 fw_rssi_stats->rssi_avg_beacon,
18745 sizeof(fw_rssi_stats->rssi_avg_beacon));
18746 qdf_mem_copy(rssi_stats->rssi_avg_data,
18747 fw_rssi_stats->rssi_avg_data,
18748 sizeof(fw_rssi_stats->rssi_avg_data));
18749 qdf_mem_copy(&rssi_stats->peer_macaddr,
18750 &fw_rssi_stats->peer_macaddr,
18751 sizeof(fw_rssi_stats->peer_macaddr));
18752
18753 return QDF_STATUS_SUCCESS;
18754}
18755
18756
18757
18758/**
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053018759 * extract_bcn_stats_tlv() - extract bcn stats from event
18760 * @wmi_handle: wmi handle
18761 * @param evt_buf: pointer to event buffer
18762 * @param index: Index into vdev stats
18763 * @param bcn_stats: Pointer to hold bcn stats
18764 *
18765 * Return: QDF_STATUS_SUCCESS for success or error code
18766 */
18767static QDF_STATUS extract_bcn_stats_tlv(wmi_unified_t wmi_handle,
18768 void *evt_buf, uint32_t index, wmi_host_bcn_stats *bcn_stats)
18769{
18770 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18771 wmi_stats_event_fixed_param *ev_param;
18772 uint8_t *data;
18773
18774 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18775 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18776 data = (uint8_t *) param_buf->data;
18777
18778 if (index < ev_param->num_bcn_stats) {
18779 wmi_bcn_stats *ev = (wmi_bcn_stats *) ((data) +
18780 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18781 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18782 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18783 ((ev_param->num_chan_stats) * sizeof(wmi_chan_stats)) +
18784 ((ev_param->num_mib_stats) * sizeof(wmi_mib_stats)) +
18785 (index * sizeof(wmi_bcn_stats)));
18786
18787 bcn_stats->vdev_id = ev->vdev_id;
18788 bcn_stats->tx_bcn_succ_cnt = ev->tx_bcn_succ_cnt;
18789 bcn_stats->tx_bcn_outage_cnt = ev->tx_bcn_outage_cnt;
18790 }
18791
18792 return QDF_STATUS_SUCCESS;
18793}
18794
18795/**
Govind Singhe7f2f342016-05-23 12:12:52 +053018796 * extract_peer_stats_tlv() - extract peer stats from event
18797 * @wmi_handle: wmi handle
18798 * @param evt_buf: pointer to event buffer
18799 * @param index: Index into peer stats
18800 * @param peer_stats: Pointer to hold peer stats
18801 *
18802 * Return: QDF_STATUS_SUCCESS for success or error code
18803 */
18804static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
18805 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
18806{
18807 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18808 wmi_stats_event_fixed_param *ev_param;
18809 uint8_t *data;
18810
18811 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18812 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18813 data = (uint8_t *) param_buf->data;
18814
18815 if (index < ev_param->num_peer_stats) {
18816 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
18817 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18818 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18819 (index * sizeof(wmi_peer_stats)));
18820
18821 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
18822
18823 OS_MEMCPY(&(peer_stats->peer_macaddr),
18824 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
18825
18826 peer_stats->peer_rssi = ev->peer_rssi;
18827 peer_stats->peer_tx_rate = ev->peer_tx_rate;
18828 peer_stats->peer_rx_rate = ev->peer_rx_rate;
18829 }
18830
18831 return QDF_STATUS_SUCCESS;
18832}
18833
18834/**
18835 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
18836 * @wmi_handle: wmi handle
18837 * @param evt_buf: pointer to event buffer
18838 * @param index: Index into bcn fault stats
18839 * @param bcnflt_stats: Pointer to hold bcn fault stats
18840 *
18841 * Return: QDF_STATUS_SUCCESS for success or error code
18842 */
18843static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
18844 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
18845{
18846 return QDF_STATUS_SUCCESS;
18847}
18848
18849/**
18850 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
18851 * @wmi_handle: wmi handle
18852 * @param evt_buf: pointer to event buffer
18853 * @param index: Index into extended peer stats
18854 * @param peer_extd_stats: Pointer to hold extended peer stats
18855 *
18856 * Return: QDF_STATUS_SUCCESS for success or error code
18857 */
18858static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
18859 void *evt_buf, uint32_t index,
18860 wmi_host_peer_extd_stats *peer_extd_stats)
18861{
18862 return QDF_STATUS_SUCCESS;
18863}
18864
18865/**
18866 * extract_chan_stats_tlv() - extract chan stats from event
18867 * @wmi_handle: wmi handle
18868 * @param evt_buf: pointer to event buffer
18869 * @param index: Index into chan stats
18870 * @param vdev_extd_stats: Pointer to hold chan stats
18871 *
18872 * Return: QDF_STATUS_SUCCESS for success or error code
18873 */
18874static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
18875 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
18876{
18877 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
18878 wmi_stats_event_fixed_param *ev_param;
18879 uint8_t *data;
18880
18881 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
18882 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
18883 data = (uint8_t *) param_buf->data;
18884
18885 if (index < ev_param->num_chan_stats) {
18886 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
18887 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
18888 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
18889 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
18890 (index * sizeof(wmi_chan_stats)));
18891
18892
Jeff Johnson79eaacb2018-05-06 17:53:18 -070018893 /* Non-TLV doesn't have num_chan_stats */
Govind Singhe7f2f342016-05-23 12:12:52 +053018894 chan_stats->chan_mhz = ev->chan_mhz;
18895 chan_stats->sampling_period_us = ev->sampling_period_us;
18896 chan_stats->rx_clear_count = ev->rx_clear_count;
18897 chan_stats->tx_duration_us = ev->tx_duration_us;
18898 chan_stats->rx_duration_us = ev->rx_duration_us;
18899 }
18900
18901 return QDF_STATUS_SUCCESS;
18902}
18903
18904/**
18905 * extract_profile_ctx_tlv() - extract profile context from event
18906 * @wmi_handle: wmi handle
18907 * @param evt_buf: pointer to event buffer
18908 * @idx: profile stats index to extract
18909 * @param profile_ctx: Pointer to hold profile context
18910 *
18911 * Return: QDF_STATUS_SUCCESS for success or error code
18912 */
18913static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
18914 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
18915{
18916 return QDF_STATUS_SUCCESS;
18917}
18918
18919/**
18920 * extract_profile_data_tlv() - extract profile data from event
18921 * @wmi_handle: wmi handle
18922 * @param evt_buf: pointer to event buffer
18923 * @param profile_data: Pointer to hold profile data
18924 *
18925 * Return: QDF_STATUS_SUCCESS for success or error code
18926 */
18927static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
18928 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
18929{
18930
18931 return QDF_STATUS_SUCCESS;
18932}
18933
18934/**
18935 * extract_chan_info_event_tlv() - extract chan information from event
18936 * @wmi_handle: wmi handle
18937 * @param evt_buf: pointer to event buffer
18938 * @param chan_info: Pointer to hold chan information
18939 *
18940 * Return: QDF_STATUS_SUCCESS for success or error code
18941 */
18942static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
18943 void *evt_buf, wmi_host_chan_info_event *chan_info)
18944{
18945 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
18946 wmi_chan_info_event_fixed_param *ev;
18947
18948 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
18949
18950 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
18951 if (!ev) {
18952 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
18953 return QDF_STATUS_E_FAILURE;
18954 }
18955
18956 chan_info->err_code = ev->err_code;
18957 chan_info->freq = ev->freq;
18958 chan_info->cmd_flags = ev->cmd_flags;
18959 chan_info->noise_floor = ev->noise_floor;
18960 chan_info->rx_clear_count = ev->rx_clear_count;
18961 chan_info->cycle_count = ev->cycle_count;
Edayilliam Jayadev5d161a92017-09-22 13:21:03 +053018962 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
18963 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053018964 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
18965 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
18966 ev->vdev_id, WLAN_SCAN_ID);
Kiran Venkatappada3eae62017-08-10 17:48:37 +053018967 chan_info->chan_tx_pwr_range = ev->chan_tx_pwr_range;
18968 chan_info->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
18969 chan_info->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
18970 chan_info->rx_11b_mode_data_duration = ev->rx_11b_mode_data_duration;
18971 chan_info->tx_frame_cnt = ev->tx_frame_cnt;
18972 chan_info->rx_frame_count = ev->rx_frame_count;
18973 chan_info->mac_clk_mhz = ev->mac_clk_mhz;
18974 chan_info->vdev_id = ev->vdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053018975
18976 return QDF_STATUS_SUCCESS;
18977}
18978
18979/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018980 * extract_pdev_utf_event_tlv() - extract UTF data info from event
18981 * @wmi_handle: WMI handle
18982 * @param evt_buf: Pointer to event buffer
18983 * @param param: Pointer to hold data
18984 *
18985 * Return : QDF_STATUS_SUCCESS for success or error code
18986 */
18987static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
18988 uint8_t *evt_buf,
18989 struct wmi_host_pdev_utf_event *event)
18990{
18991 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053018992 struct wmi_host_utf_seg_header_info *seg_hdr;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053018993
18994 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
18995 event->data = param_buf->data;
18996 event->datalen = param_buf->num_data;
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053018997 seg_hdr = (struct wmi_host_utf_seg_header_info *)param_buf->data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053018998 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018999 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
Kiran Venkatappa2bd431e2017-06-01 16:08:17 +053019000 seg_hdr->pdev_id);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053019001
19002 return QDF_STATUS_SUCCESS;
19003}
Govind Singhe7f2f342016-05-23 12:12:52 +053019004
Kiran Venkatappa06520822016-08-10 23:55:40 +053019005/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019006 * extract_chainmask_tables_tlv() - extract chain mask tables from event
19007 * @wmi_handle: wmi handle
19008 * @param evt_buf: pointer to event buffer
19009 * @param param: Pointer to hold evt buf
19010 *
19011 * Return: QDF_STATUS_SUCCESS for success or error code
19012 */
19013static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
19014 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
19015{
19016 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19017 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
19018 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19019 uint8_t i = 0, j = 0;
19020
19021 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19022 if (!param_buf)
19023 return QDF_STATUS_E_INVAL;
19024
19025 hw_caps = param_buf->soc_hw_mode_caps;
19026 if (!hw_caps)
19027 return QDF_STATUS_E_INVAL;
19028
19029 if (!hw_caps->num_chainmask_tables)
19030 return QDF_STATUS_E_INVAL;
19031
19032 chainmask_caps = param_buf->mac_phy_chainmask_caps;
19033
19034 if (chainmask_caps == NULL)
19035 return QDF_STATUS_E_INVAL;
19036
19037 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
19038
19039 qdf_print("Dumping chain mask combo data for table : %d\n", i);
19040 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
19041
19042 chainmask_table[i].cap_list[j].chainmask =
19043 chainmask_caps->chainmask;
19044
19045 chainmask_table[i].cap_list[j].supports_chan_width_20 =
19046 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
19047
19048 chainmask_table[i].cap_list[j].supports_chan_width_40 =
19049 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
19050
19051 chainmask_table[i].cap_list[j].supports_chan_width_80 =
19052 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
19053
19054 chainmask_table[i].cap_list[j].supports_chan_width_160 =
19055 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
19056
19057 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
19058 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
19059
19060 chainmask_table[i].cap_list[j].chain_mask_2G =
19061 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
19062
19063 chainmask_table[i].cap_list[j].chain_mask_5G =
19064 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
19065
19066 chainmask_table[i].cap_list[j].chain_mask_tx =
19067 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
19068
19069 chainmask_table[i].cap_list[j].chain_mask_rx =
19070 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
19071
19072 chainmask_table[i].cap_list[j].supports_aDFS =
19073 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
19074
19075 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
19076 chainmask_caps->supported_flags,
19077 chainmask_caps->chainmask
19078 );
19079 chainmask_caps++;
19080 }
19081 }
19082
19083 return QDF_STATUS_SUCCESS;
19084}
19085
19086/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053019087 * extract_service_ready_ext_tlv() - extract basic extended service ready params
19088 * from event
19089 * @wmi_handle: wmi handle
19090 * @param evt_buf: pointer to event buffer
19091 * @param param: Pointer to hold evt buf
19092 *
19093 * Return: QDF_STATUS_SUCCESS for success or error code
19094 */
19095static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019096 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019097{
19098 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19099 wmi_service_ready_ext_event_fixed_param *ev;
19100 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19101 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019102 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
19103 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019104
19105 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19106 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019107 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019108
19109 ev = param_buf->fixed_param;
19110 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019111 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019112
19113 /* Move this to host based bitmap */
19114 param->default_conc_scan_config_bits =
19115 ev->default_conc_scan_config_bits;
19116 param->default_fw_config_bits = ev->default_fw_config_bits;
19117 param->he_cap_info = ev->he_cap_info;
19118 param->mpdu_density = ev->mpdu_density;
19119 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
Kiran Venkatappa59d6e1f2017-10-12 15:04:22 +053019120 param->fw_build_vers_ext = ev->fw_build_vers_ext;
Sathish Kumarf396c722017-11-17 17:30:41 +053019121 param->num_dbr_ring_caps = param_buf->num_dma_ring_caps;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019122 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
19123
19124 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019125 if (hw_caps)
19126 param->num_hw_modes = hw_caps->num_hw_modes;
19127 else
19128 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019129
19130 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019131 if (reg_caps)
19132 param->num_phy = reg_caps->num_phy;
19133 else
19134 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019135
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019136 if (hw_caps) {
19137 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
19138 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
19139 } else
19140 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019141
19142 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
19143
19144 if (chain_mask_combo == NULL)
19145 return QDF_STATUS_SUCCESS;
19146
19147 qdf_print("Dumping chain mask combo data\n");
19148
Kapil Gupta0692a1a2017-05-15 15:57:36 +053019149 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019150
19151 qdf_print("table_id : %d Num valid chainmasks: %d\n",
19152 chain_mask_combo->chainmask_table_id,
19153 chain_mask_combo->num_valid_chainmask
19154 );
19155
19156 param->chainmask_table[i].table_id =
19157 chain_mask_combo->chainmask_table_id;
19158 param->chainmask_table[i].num_valid_chainmasks =
19159 chain_mask_combo->num_valid_chainmask;
19160 chain_mask_combo++;
19161 }
19162 qdf_print("chain mask combo end\n");
19163
Kiran Venkatappa06520822016-08-10 23:55:40 +053019164 return QDF_STATUS_SUCCESS;
19165}
19166
19167/**
19168 * extract_hw_mode_cap_service_ready_ext_tlv() -
19169 * extract HW mode cap from service ready event
19170 * @wmi_handle: wmi handle
19171 * @param evt_buf: pointer to event buffer
19172 * @param param: Pointer to hold evt buf
19173 * @param hw_mode_idx: hw mode idx should be less than num_mode
19174 *
19175 * Return: QDF_STATUS_SUCCESS for success or error code
19176 */
19177static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
19178 wmi_unified_t wmi_handle,
19179 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019180 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019181{
19182 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19183 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19184
19185 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19186 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019187 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019188
19189 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019190 if (!hw_caps)
19191 return QDF_STATUS_E_INVAL;
19192
Kiran Venkatappa06520822016-08-10 23:55:40 +053019193 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019194 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019195
19196 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
19197 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
19198
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019199 param->hw_mode_config_type =
19200 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
19201
Kiran Venkatappa06520822016-08-10 23:55:40 +053019202 return QDF_STATUS_SUCCESS;
19203}
19204
19205/**
19206 * extract_mac_phy_cap_service_ready_ext_tlv() -
19207 * extract MAC phy cap from service ready event
19208 * @wmi_handle: wmi handle
19209 * @param evt_buf: pointer to event buffer
19210 * @param param: Pointer to hold evt buf
19211 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019212 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053019213 *
19214 * Return: QDF_STATUS_SUCCESS for success or error code
19215 */
19216static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
19217 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019218 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019219 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019220{
19221 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019222 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019223 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
19224 uint32_t phy_map;
19225 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019226
19227 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19228 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019229 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019230
19231 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019232 if (!hw_caps)
19233 return QDF_STATUS_E_INVAL;
19234
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019235 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
19236 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
19237 break;
19238
19239 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
19240 while (phy_map) {
19241 phy_map >>= 1;
19242 phy_idx++;
19243 }
19244 }
19245
19246 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019247 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019248
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019249 phy_idx += phy_id;
19250 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019251 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019252
19253 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053019254
19255 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019256 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19257 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019258 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053019259 param->supports_11b =
19260 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
19261 param->supports_11g =
19262 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
19263 param->supports_11a =
19264 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
19265 param->supports_11n =
19266 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
19267 param->supports_11ac =
19268 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
19269 param->supports_11ax =
19270 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019271
19272 param->supported_bands = mac_phy_caps->supported_bands;
19273 param->ampdu_density = mac_phy_caps->ampdu_density;
19274 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
19275 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
19276 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
19277 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
19278 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
19279 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
19280 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
19281 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
19282 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
19283 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
19284 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
19285 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
19286 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
19287 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
19288 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
19289 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080019290 qdf_mem_copy(&param->he_cap_phy_info_2G,
19291 &mac_phy_caps->he_cap_phy_info_2G,
19292 sizeof(param->he_cap_phy_info_2G));
19293 qdf_mem_copy(&param->he_cap_phy_info_5G,
19294 &mac_phy_caps->he_cap_phy_info_5G,
19295 sizeof(param->he_cap_phy_info_5G));
19296 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
19297 sizeof(param->he_ppet2G));
19298 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
19299 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053019300 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019301
19302 return QDF_STATUS_SUCCESS;
19303}
19304
19305/**
19306 * extract_reg_cap_service_ready_ext_tlv() -
19307 * extract REG cap from service ready event
19308 * @wmi_handle: wmi handle
19309 * @param evt_buf: pointer to event buffer
19310 * @param param: Pointer to hold evt buf
19311 * @param phy_idx: phy idx should be less than num_mode
19312 *
19313 * Return: QDF_STATUS_SUCCESS for success or error code
19314 */
19315static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
19316 wmi_unified_t wmi_handle,
19317 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080019318 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053019319{
19320 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19321 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
19322 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
19323
19324 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
19325 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019326 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019327
19328 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019329 if (!reg_caps)
19330 return QDF_STATUS_E_INVAL;
19331
Kiran Venkatappa06520822016-08-10 23:55:40 +053019332 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019333 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053019334
19335 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
19336
19337 param->phy_id = ext_reg_cap->phy_id;
19338 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
19339 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
19340 param->regcap1 = ext_reg_cap->regcap1;
19341 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053019342 param->wireless_modes = convert_wireless_modes_tlv(
19343 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053019344 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
19345 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
19346 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
19347 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
19348
19349 return QDF_STATUS_SUCCESS;
19350}
19351
Sathish Kumarf396c722017-11-17 17:30:41 +053019352static QDF_STATUS extract_dbr_ring_cap_service_ready_ext_tlv(
19353 wmi_unified_t wmi_handle,
19354 uint8_t *event, uint8_t idx,
19355 struct wlan_psoc_host_dbr_ring_caps *param)
19356{
19357 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
19358 WMI_DMA_RING_CAPABILITIES *dbr_ring_caps;
19359
19360 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *)event;
19361 if (!param_buf)
19362 return QDF_STATUS_E_INVAL;
19363
19364 dbr_ring_caps = &param_buf->dma_ring_caps[idx];
19365
19366 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19367 dbr_ring_caps->pdev_id);
19368 param->mod_id = dbr_ring_caps->mod_id;
19369 param->ring_elems_min = dbr_ring_caps->ring_elems_min;
19370 param->min_buf_size = dbr_ring_caps->min_buf_size;
19371 param->min_buf_align = dbr_ring_caps->min_buf_align;
19372
19373 return QDF_STATUS_SUCCESS;
19374}
19375
19376static QDF_STATUS extract_dbr_buf_release_fixed_tlv(wmi_unified_t wmi_handle,
19377 uint8_t *event, struct direct_buf_rx_rsp *param)
19378{
19379 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19380 wmi_dma_buf_release_fixed_param *ev;
19381
19382 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19383 if (!param_buf)
19384 return QDF_STATUS_E_INVAL;
19385
19386 ev = param_buf->fixed_param;
19387 if (!ev)
19388 return QDF_STATUS_E_INVAL;
19389
19390 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19391 ev->pdev_id);
19392 param->mod_id = ev->mod_id;
19393 param->num_buf_release_entry = ev->num_buf_release_entry;
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019394 param->num_meta_data_entry = ev->num_meta_data_entry;
Sathish Kumarf396c722017-11-17 17:30:41 +053019395 WMI_LOGD("%s:pdev id %d mod id %d num buf release entry %d\n", __func__,
19396 param->pdev_id, param->mod_id, param->num_buf_release_entry);
19397
19398 return QDF_STATUS_SUCCESS;
19399}
19400
19401static QDF_STATUS extract_dbr_buf_release_entry_tlv(wmi_unified_t wmi_handle,
19402 uint8_t *event, uint8_t idx, struct direct_buf_rx_entry *param)
19403{
19404 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19405 wmi_dma_buf_release_entry *entry;
19406
19407 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19408 if (!param_buf)
19409 return QDF_STATUS_E_INVAL;
19410
19411 entry = &param_buf->entries[idx];
19412
19413 if (!entry) {
19414 WMI_LOGE("%s: Entry is NULL\n", __func__);
19415 return QDF_STATUS_E_FAILURE;
19416 }
19417
19418 WMI_LOGD("%s: paddr_lo[%d] = %x\n", __func__, idx, entry->paddr_lo);
19419
19420 param->paddr_lo = entry->paddr_lo;
19421 param->paddr_hi = entry->paddr_hi;
19422
19423 return QDF_STATUS_SUCCESS;
19424}
19425
Edayilliam Jayadev92651222018-04-06 16:37:17 +053019426static QDF_STATUS extract_dbr_buf_metadata_tlv(
19427 wmi_unified_t wmi_handle, uint8_t *event,
19428 uint8_t idx, struct direct_buf_rx_metadata *param)
19429{
19430 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *param_buf;
19431 wmi_dma_buf_release_spectral_meta_data *entry;
19432
19433 param_buf = (WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID_param_tlvs *)event;
19434 if (!param_buf)
19435 return QDF_STATUS_E_INVAL;
19436
19437 entry = &param_buf->meta_data[idx];
19438
19439 if (!entry) {
19440 WMI_LOGE("%s: Entry is NULL\n", __func__);
19441 return QDF_STATUS_E_FAILURE;
19442 }
19443
19444 qdf_mem_copy(param->noisefloor, entry->noise_floor,
19445 sizeof(entry->noise_floor));
19446 return QDF_STATUS_SUCCESS;
19447}
19448
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019449/**
19450 * extract_dcs_interference_type_tlv() - extract dcs interference type
19451 * from event
19452 * @wmi_handle: wmi handle
19453 * @param evt_buf: pointer to event buffer
19454 * @param param: Pointer to hold dcs interference param
19455 *
19456 * Return: 0 for success or error code
19457 */
19458static QDF_STATUS extract_dcs_interference_type_tlv(
19459 wmi_unified_t wmi_handle,
19460 void *evt_buf, struct wmi_host_dcs_interference_param *param)
19461{
19462 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19463
19464 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19465 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019466 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019467
19468 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019469 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19470 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019471
19472 return QDF_STATUS_SUCCESS;
19473}
19474
19475/*
19476 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
19477 * @wmi_handle: wmi handle
19478 * @param evt_buf: pointer to event buffer
19479 * @param cw_int: Pointer to hold cw interference
19480 *
19481 * Return: 0 for success or error code
19482 */
19483static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
19484 void *evt_buf,
19485 wmi_host_ath_dcs_cw_int *cw_int)
19486{
19487 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19488 wlan_dcs_cw_int *ev;
19489
19490 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19491 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019492 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019493
19494 ev = param_buf->cw_int;
19495
19496 cw_int->channel = ev->channel;
19497
19498 return QDF_STATUS_SUCCESS;
19499}
19500
19501/**
19502 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
19503 * @wmi_handle: wmi handle
19504 * @param evt_buf: pointer to event buffer
19505 * @param wlan_stat: Pointer to hold wlan stats
19506 *
19507 * Return: 0 for success or error code
19508 */
19509static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
19510 void *evt_buf,
19511 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
19512{
19513 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
19514 wlan_dcs_im_tgt_stats_t *ev;
19515
19516 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
19517 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053019518 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053019519
19520 ev = param_buf->wlan_stat;
19521 wlan_stat->reg_tsf32 = ev->reg_tsf32;
19522 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
19523 wlan_stat->tx_waste_time = ev->tx_waste_time;
19524 wlan_stat->rx_time = ev->rx_time;
19525 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
19526 wlan_stat->mib_stats.listen_time = ev->listen_time;
19527 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
19528 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
19529 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
19530 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
19531 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
19532 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
19533 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
19534 wlan_stat->chan_nf = ev->chan_nf;
19535 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
19536
19537 return QDF_STATUS_SUCCESS;
19538}
19539
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019540/**
19541 * extract_thermal_stats_tlv() - extract thermal stats from event
19542 * @wmi_handle: wmi handle
19543 * @param evt_buf: Pointer to event buffer
19544 * @param temp: Pointer to hold extracted temperature
19545 * @param level: Pointer to hold extracted level
19546 *
19547 * Return: 0 for success or error code
19548 */
19549static QDF_STATUS
19550extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
19551 void *evt_buf, uint32_t *temp,
19552 uint32_t *level, uint32_t *pdev_id)
19553{
19554 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19555 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
19556
19557 param_buf =
19558 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19559 if (!param_buf)
19560 return QDF_STATUS_E_INVAL;
19561
19562 tt_stats_event = param_buf->fixed_param;
19563
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019564 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19565 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053019566 *temp = tt_stats_event->temp;
19567 *level = tt_stats_event->level;
19568
19569 return QDF_STATUS_SUCCESS;
19570}
19571
19572/**
19573 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
19574 * @wmi_handle: wmi handle
19575 * @param evt_buf: pointer to event buffer
19576 * @param idx: Index to level stats
19577 * @param levelcount: Pointer to hold levelcount
19578 * @param dccount: Pointer to hold dccount
19579 *
19580 * Return: 0 for success or error code
19581 */
19582static QDF_STATUS
19583extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
19584 void *evt_buf, uint8_t idx, uint32_t *levelcount,
19585 uint32_t *dccount)
19586{
19587 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
19588 wmi_therm_throt_level_stats_info *tt_level_info;
19589
19590 param_buf =
19591 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
19592 if (!param_buf)
19593 return QDF_STATUS_E_INVAL;
19594
19595 tt_level_info = param_buf->therm_throt_level_stats_info;
19596
19597 if (idx < THERMAL_LEVELS) {
19598 *levelcount = tt_level_info[idx].level_count;
19599 *dccount = tt_level_info[idx].dc_count;
19600 return QDF_STATUS_SUCCESS;
19601 }
19602
19603 return QDF_STATUS_E_FAILURE;
19604}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019605#ifdef BIG_ENDIAN_HOST
19606/**
19607 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
19608 * @param data_len - data length
19609 * @param data - pointer to data
19610 *
19611 * Return: QDF_STATUS - success or error status
19612 */
19613static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19614{
19615 uint8_t *data_aligned = NULL;
19616 int c;
19617 unsigned char *data_unaligned;
19618
19619 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
19620 FIPS_ALIGN));
19621 /* Assigning unaligned space to copy the data */
Jeff Johnsonda263992018-05-12 14:22:00 -070019622 /* Checking if kmalloc does successful allocation */
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019623 if (data_unaligned == NULL)
19624 return QDF_STATUS_E_FAILURE;
19625
19626 /* Checking if space is alligned */
19627 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
19628 /* align the data space */
19629 data_aligned =
19630 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
19631 } else {
19632 data_aligned = (u_int8_t *)data_unaligned;
19633 }
19634
19635 /* memset and copy content from data to data aligned */
19636 OS_MEMSET(data_aligned, 0, data_len);
19637 OS_MEMCPY(data_aligned, data, data_len);
19638 /* Endianness to LE */
19639 for (c = 0; c < data_len/4; c++) {
19640 *((u_int32_t *)data_aligned + c) =
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019641 qdf_le32_to_cpu(*((u_int32_t *)data_aligned + c));
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019642 }
19643
19644 /* Copy content to event->data */
19645 OS_MEMCPY(data, data_aligned, data_len);
19646
19647 /* clean up allocated space */
19648 qdf_mem_free(data_unaligned);
19649 data_aligned = NULL;
19650 data_unaligned = NULL;
19651
19652 /*************************************************************/
19653
19654 return QDF_STATUS_SUCCESS;
19655}
19656#else
19657/**
19658 * fips_conv_data_be() - DUMMY for LE platform
19659 *
19660 * Return: QDF_STATUS - success
19661 */
19662static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
19663{
19664 return QDF_STATUS_SUCCESS;
19665}
19666#endif
19667
19668/**
19669 * extract_fips_event_data_tlv() - extract fips event data
19670 * @wmi_handle: wmi handle
19671 * @param evt_buf: pointer to event buffer
19672 * @param param: pointer FIPS event params
19673 *
19674 * Return: 0 for success or error code
19675 */
19676static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
19677 void *evt_buf, struct wmi_host_fips_event_param *param)
19678{
19679 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
19680 wmi_pdev_fips_event_fixed_param *event;
19681
19682 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
19683 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
19684
19685 if (fips_conv_data_be(event->data_len, param_buf->data) !=
19686 QDF_STATUS_SUCCESS)
19687 return QDF_STATUS_E_FAILURE;
19688
19689 param->data = (uint32_t *)param_buf->data;
19690 param->data_len = event->data_len;
19691 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019692 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19693 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053019694
19695 return QDF_STATUS_SUCCESS;
19696}
19697
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053019698/*
19699 * extract_peer_delete_response_event_tlv() - extract peer delete response event
19700 * @wmi_handle: wmi handle
19701 * @param evt_buf: pointer to event buffer
19702 * @param vdev_id: Pointer to hold vdev_id
19703 * @param mac_addr: Pointer to hold peer mac address
19704 *
19705 * Return: QDF_STATUS_SUCCESS for success or error code
19706 */
19707static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
19708 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
19709{
19710 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
19711 wmi_peer_delete_resp_event_fixed_param *ev;
19712
19713 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
19714
19715 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
19716 if (!ev) {
19717 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
19718 return QDF_STATUS_E_FAILURE;
19719 }
19720
19721 param->vdev_id = ev->vdev_id;
19722 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
19723 &param->mac_address.bytes[0]);
19724
19725 return QDF_STATUS_SUCCESS;
19726}
19727
Govind Singhecf03cd2016-05-12 12:45:51 +053019728static bool is_management_record_tlv(uint32_t cmd_id)
19729{
jiad36c94d22018-01-22 15:37:03 +080019730 if ((cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID) ||
19731 (cmd_id == WMI_MGMT_TX_SEND_CMDID) ||
19732 (cmd_id == WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
Govind Singhecf03cd2016-05-12 12:45:51 +053019733 return true;
jiad36c94d22018-01-22 15:37:03 +080019734 }
Govind Singhe7f2f342016-05-23 12:12:52 +053019735
Govind Singhecf03cd2016-05-12 12:45:51 +053019736 return false;
19737}
19738
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053019739static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19740{
19741 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
19742
19743 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
19744
19745 switch (set_cmd->param_id) {
19746 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
19747 case WMI_VDEV_PARAM_DTIM_POLICY:
19748 return HTC_TX_PACKET_TAG_AUTO_PM;
19749 default:
19750 break;
19751 }
19752
19753 return 0;
19754}
19755
19756static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
19757{
19758 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
19759
19760 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
19761
19762 switch (ps_cmd->param) {
19763 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
19764 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
19765 case WMI_STA_PS_ENABLE_QPOWER:
19766 return HTC_TX_PACKET_TAG_AUTO_PM;
19767 default:
19768 break;
19769 }
19770
19771 return 0;
19772}
19773
19774static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
19775 uint32_t cmd_id)
19776{
19777 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
19778 return 0;
19779
19780 switch (cmd_id) {
19781 case WMI_VDEV_SET_PARAM_CMDID:
19782 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
19783 case WMI_STA_POWERSAVE_PARAM_CMDID:
19784 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
19785 default:
19786 break;
19787 }
19788
19789 return 0;
19790}
19791
19792static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
19793{
19794 uint16_t tag = 0;
19795
19796 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
19797 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
19798 __func__);
19799 return tag;
19800 }
19801
19802 if (wmi_handle->tag_crash_inject)
19803 tag = HTC_TX_PACKET_TAG_AUTO_PM;
19804
19805 wmi_handle->tag_crash_inject = false;
19806 return tag;
19807}
19808
19809/**
19810 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
19811 * @wmi_handle: WMI handle
19812 * @buf: WMI buffer
19813 * @cmd_id: WMI command Id
19814 *
19815 * Return htc_tx_tag
19816 */
19817static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
19818 wmi_buf_t buf,
19819 uint32_t cmd_id)
19820{
19821 uint16_t htc_tx_tag = 0;
19822
19823 switch (cmd_id) {
19824 case WMI_WOW_ENABLE_CMDID:
19825 case WMI_PDEV_SUSPEND_CMDID:
19826 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
19827 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
19828 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
19829 case WMI_PDEV_RESUME_CMDID:
19830 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
19831 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
19832#ifdef FEATURE_WLAN_D0WOW
19833 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
19834#endif
19835 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
19836 break;
19837 case WMI_FORCE_FW_HANG_CMDID:
19838 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
19839 break;
19840 case WMI_VDEV_SET_PARAM_CMDID:
19841 case WMI_STA_POWERSAVE_PARAM_CMDID:
19842 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
19843 default:
19844 break;
19845 }
19846
19847 return htc_tx_tag;
19848}
19849
Sathish Kumard3ab1002017-02-07 17:10:59 +053019850/**
19851 * extract_channel_hopping_event_tlv() - extract channel hopping param
19852 * from event
19853 * @wmi_handle: wmi handle
19854 * @param evt_buf: pointer to event buffer
19855 * @param ch_hopping: Pointer to hold channel hopping param
19856 *
19857 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19858 */
19859static QDF_STATUS extract_channel_hopping_event_tlv(
19860 wmi_unified_t wmi_handle, void *evt_buf,
19861 wmi_host_pdev_channel_hopping_event *ch_hopping)
19862{
19863 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
19864 wmi_pdev_channel_hopping_event_fixed_param *event;
19865
19866 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
19867 event = (wmi_pdev_channel_hopping_event_fixed_param *)
19868 param_buf->fixed_param;
19869
19870 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
19871 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019872 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19873 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053019874
19875 return QDF_STATUS_SUCCESS;
19876}
19877
19878/**
19879 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
19880 * @wmi_handle: wmi handle
19881 * @param evt_buf: pointer to event buffer
19882 * @param param: Pointer to hold tpc param
19883 *
19884 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
19885 */
19886static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
19887 void *evt_buf,
19888 wmi_host_pdev_tpc_event *param)
19889{
19890 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
19891 wmi_pdev_tpc_event_fixed_param *event;
19892
19893 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
19894 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
19895
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053019896 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
19897 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053019898 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
19899
19900 return QDF_STATUS_SUCCESS;
19901}
19902
nobeljf74583b2018-01-25 16:35:36 -080019903/**
19904 * extract_nfcal_power_ev_param_tlv() - extract noise floor calibration
19905 * power param from event
19906 * @wmi_handle: wmi handle
19907 * @param evt_buf: pointer to event buffer
19908 * @param param: Pointer to hold nf cal power param
19909 *
19910 * Return: 0 for success or error code
19911 */
19912static QDF_STATUS
19913extract_nfcal_power_ev_param_tlv(wmi_unified_t wmi_handle,
19914 void *evt_buf,
19915 wmi_host_pdev_nfcal_power_all_channels_event *param)
19916{
19917 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *param_buf;
19918 wmi_pdev_nfcal_power_all_channels_event_fixed_param *event;
19919 wmi_pdev_nfcal_power_all_channels_nfdBr *ch_nfdbr;
19920 wmi_pdev_nfcal_power_all_channels_nfdBm *ch_nfdbm;
19921 wmi_pdev_nfcal_power_all_channels_freqNum *ch_freqnum;
19922 uint32_t i;
19923
19924 param_buf =
19925 (WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID_param_tlvs *)evt_buf;
19926 event = param_buf->fixed_param;
19927 ch_nfdbr = param_buf->nfdbr;
19928 ch_nfdbm = param_buf->nfdbm;
19929 ch_freqnum = param_buf->freqnum;
19930
19931 WMI_LOGD("pdev_id[%x], num_nfdbr[%d], num_nfdbm[%d] num_freqnum[%d]\n",
19932 event->pdev_id, param_buf->num_nfdbr,
19933 param_buf->num_nfdbm, param_buf->num_freqnum);
19934
19935 if (param_buf->num_nfdbr >
19936 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
19937 WMI_LOGE("invalid number of nfdBr");
19938 return QDF_STATUS_E_FAILURE;
19939 }
19940
19941 if (param_buf->num_nfdbm >
19942 WMI_HOST_RXG_CAL_CHAN_MAX * WMI_HOST_MAX_NUM_CHAINS) {
19943 WMI_LOGE("invalid number of nfdBm");
19944 return QDF_STATUS_E_FAILURE;
19945 }
19946
19947 if (param_buf->num_freqnum > WMI_HOST_RXG_CAL_CHAN_MAX) {
19948 WMI_LOGE("invalid number of freqNum");
19949 return QDF_STATUS_E_FAILURE;
19950 }
19951
19952 for (i = 0; i < param_buf->num_nfdbr; i++) {
19953 param->nfdbr[i] = (int8_t)ch_nfdbr->nfdBr;
19954 param->nfdbm[i] = (int8_t)ch_nfdbm->nfdBm;
19955 ch_nfdbr++;
19956 ch_nfdbm++;
19957 }
19958
19959 for (i = 0; i < param_buf->num_freqnum; i++) {
19960 param->freqnum[i] = ch_freqnum->freqNum;
19961 ch_freqnum++;
19962 }
19963
Keyur Parekh2c0bab62018-05-16 13:15:38 -070019964 param->pdev_id = wmi_handle->ops->
19965 convert_pdev_id_target_to_host(event->pdev_id);
nobeljf74583b2018-01-25 16:35:36 -080019966
19967 return QDF_STATUS_SUCCESS;
19968}
19969
Sathish Kumard3ab1002017-02-07 17:10:59 +053019970
19971#ifdef BIG_ENDIAN_HOST
19972/**
19973 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
19974 * @param data_len - data length
19975 * @param data - pointer to data
19976 *
19977 * Return: QDF_STATUS - success or error status
19978 */
19979static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
19980{
19981 uint8_t *datap = (uint8_t *)ev;
Padma Raghunathan1edbf232017-08-31 15:26:47 +053019982 int i;
Sathish Kumard3ab1002017-02-07 17:10:59 +053019983 /* Skip swapping the first word */
19984 datap += sizeof(uint32_t);
19985 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
19986 i++, datap += sizeof(uint32_t)) {
19987 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
19988 }
19989
19990 return QDF_STATUS_SUCCESS;
19991}
19992#else
19993/**
19994 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
19995 * @param data_len - data length
19996 * @param data - pointer to data
19997 *
19998 * Return: QDF_STATUS - success or error status
19999 */
20000static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
20001{
20002 return QDF_STATUS_SUCCESS;
20003}
20004#endif
20005
20006/**
20007 * extract_wds_addr_event_tlv() - extract wds address from event
20008 * @wmi_handle: wmi handle
20009 * @param evt_buf: pointer to event buffer
20010 * @param wds_ev: Pointer to hold wds address
20011 *
20012 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20013 */
20014static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
20015 void *evt_buf,
20016 uint16_t len, wds_addr_event_t *wds_ev)
20017{
20018 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
20019 wmi_wds_addr_event_fixed_param *ev;
20020 int i;
20021
20022 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
20023 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
20024
20025 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
20026 return QDF_STATUS_E_FAILURE;
20027
20028 qdf_mem_copy(wds_ev->event_type, ev->event_type,
20029 sizeof(wds_ev->event_type));
20030 for (i = 0; i < 4; i++) {
20031 wds_ev->peer_mac[i] =
20032 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
20033 wds_ev->dest_mac[i] =
20034 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
20035 }
20036 for (i = 0; i < 2; i++) {
20037 wds_ev->peer_mac[4+i] =
20038 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
20039 wds_ev->dest_mac[4+i] =
20040 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
20041 }
20042 return QDF_STATUS_SUCCESS;
20043}
20044
20045/**
20046 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
20047 * from event
20048 * @wmi_handle: wmi handle
20049 * @param evt_buf: pointer to event buffer
20050 * @param ev: Pointer to hold peer param and ps state
20051 *
20052 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20053 */
20054static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
20055 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
20056{
20057 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
20058 wmi_peer_sta_ps_statechange_event_fixed_param *event;
20059
20060 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
20061 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
20062 param_buf->fixed_param;
20063
20064 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
20065 ev->peer_ps_state = event->peer_ps_state;
20066
20067 return QDF_STATUS_SUCCESS;
20068}
20069
20070/**
20071 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
20072 * @wmi_handle: wmi handle
20073 * @param evt_buf: pointer to event buffer
20074 * @param inst_rssi_resp: Pointer to hold inst rssi response
20075 *
20076 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
20077 */
20078static QDF_STATUS extract_inst_rssi_stats_event_tlv(
20079 wmi_unified_t wmi_handle, void *evt_buf,
20080 wmi_host_inst_stats_resp *inst_rssi_resp)
20081{
20082 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
20083 wmi_inst_rssi_stats_resp_fixed_param *event;
20084
20085 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
20086 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
20087
20088 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
20089 &(event->peer_macaddr), sizeof(wmi_mac_addr));
20090 inst_rssi_resp->iRSSI = event->iRSSI;
20091
20092 return QDF_STATUS_SUCCESS;
20093}
20094
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020095static struct cur_reg_rule
20096*create_reg_rules_from_wmi(uint32_t num_reg_rules,
20097 wmi_regulatory_rule_struct *wmi_reg_rule)
20098{
20099 struct cur_reg_rule *reg_rule_ptr;
20100 uint32_t count;
20101
20102 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
20103
20104 if (NULL == reg_rule_ptr) {
20105 WMI_LOGE("memory allocation failure");
20106 return NULL;
20107 }
20108
20109 for (count = 0; count < num_reg_rules; count++) {
20110 reg_rule_ptr[count].start_freq =
20111 WMI_REG_RULE_START_FREQ_GET(
20112 wmi_reg_rule[count].freq_info);
20113 reg_rule_ptr[count].end_freq =
20114 WMI_REG_RULE_END_FREQ_GET(
20115 wmi_reg_rule[count].freq_info);
20116 reg_rule_ptr[count].max_bw =
20117 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020118 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020119 reg_rule_ptr[count].reg_power =
20120 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020121 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053020122 reg_rule_ptr[count].ant_gain =
20123 WMI_REG_RULE_ANTENNA_GAIN_GET(
20124 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020125 reg_rule_ptr[count].flags =
20126 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070020127 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020128 }
20129
20130 return reg_rule_ptr;
20131}
20132
20133static QDF_STATUS extract_reg_chan_list_update_event_tlv(
20134 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20135 struct cur_regulatory_info *reg_info, uint32_t len)
20136{
20137 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
20138 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
20139 wmi_regulatory_rule_struct *wmi_reg_rule;
20140 uint32_t num_2g_reg_rules, num_5g_reg_rules;
20141
20142 WMI_LOGD("processing regulatory channel list");
20143
20144 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
20145 if (!param_buf) {
20146 WMI_LOGE("invalid channel list event buf");
20147 return QDF_STATUS_E_FAILURE;
20148 }
20149
20150 chan_list_event_hdr = param_buf->fixed_param;
20151
20152 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
20153 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
20154 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
Amar Singhal7d204022017-06-23 12:17:00 +053020155 REG_ALPHA2_LEN);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020156 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
20157 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070020158 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070020159 reg_info->num_phy = chan_list_event_hdr->num_phy;
Amar Singhal7d204022017-06-23 12:17:00 +053020160 reg_info->phy_id = chan_list_event_hdr->phy_id;
Amar Singhala522f212017-05-12 16:39:23 -070020161 reg_info->ctry_code = chan_list_event_hdr->country_id;
20162 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
20163 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
20164 reg_info->status_code = REG_SET_CC_STATUS_PASS;
20165 else if (chan_list_event_hdr->status_code ==
20166 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
20167 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
20168 else if (chan_list_event_hdr->status_code ==
20169 WMI_REG_INIT_ALPHA2_NOT_FOUND)
20170 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
20171 else if (chan_list_event_hdr->status_code ==
20172 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
20173 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
20174 else if (chan_list_event_hdr->status_code ==
20175 WMI_REG_SET_CC_STATUS_NO_MEMORY)
20176 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
20177 else if (chan_list_event_hdr->status_code ==
20178 WMI_REG_SET_CC_STATUS_FAIL)
20179 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
20180
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020181 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
20182 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
20183 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
20184 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
20185
20186 num_2g_reg_rules = reg_info->num_2g_reg_rules;
20187 num_5g_reg_rules = reg_info->num_5g_reg_rules;
20188
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020189 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
20190 __func__, reg_info->alpha2, reg_info->dfs_region,
20191 reg_info->min_bw_2g, reg_info->max_bw_2g,
20192 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020193
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020194 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
20195 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070020196 wmi_reg_rule =
20197 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
20198 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
20199 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053020200 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
20201 wmi_reg_rule);
20202 wmi_reg_rule += num_2g_reg_rules;
20203
20204 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
20205 wmi_reg_rule);
20206
20207 WMI_LOGD("processed regulatory channel list");
20208
20209 return QDF_STATUS_SUCCESS;
20210}
20211
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070020212static QDF_STATUS extract_reg_11d_new_country_event_tlv(
20213 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20214 struct reg_11d_new_country *reg_11d_country, uint32_t len)
20215{
20216 wmi_11d_new_country_event_fixed_param *reg_11d_country_event;
20217 WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *param_buf;
20218
20219 param_buf = (WMI_11D_NEW_COUNTRY_EVENTID_param_tlvs *)evt_buf;
20220 if (!param_buf) {
20221 WMI_LOGE("invalid 11d country event buf");
20222 return QDF_STATUS_E_FAILURE;
20223 }
20224
20225 reg_11d_country_event = param_buf->fixed_param;
20226
20227 qdf_mem_copy(reg_11d_country->alpha2,
20228 &reg_11d_country_event->new_alpha2, REG_ALPHA2_LEN);
20229
20230 WMI_LOGD("processed 11d country event, new cc %s",
20231 reg_11d_country->alpha2);
20232
20233 return QDF_STATUS_SUCCESS;
20234}
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070020235
20236static QDF_STATUS extract_reg_ch_avoid_event_tlv(
20237 wmi_unified_t wmi_handle, uint8_t *evt_buf,
20238 struct ch_avoid_ind_type *ch_avoid_ind, uint32_t len)
20239{
20240 wmi_avoid_freq_ranges_event_fixed_param *afr_fixed_param;
20241 wmi_avoid_freq_range_desc *afr_desc;
20242 uint32_t num_freq_ranges, freq_range_idx;
20243 WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *param_buf =
20244 (WMI_WLAN_FREQ_AVOID_EVENTID_param_tlvs *) evt_buf;
20245
20246 if (!param_buf) {
20247 WMI_LOGE("Invalid channel avoid event buffer");
20248 return QDF_STATUS_E_INVAL;
20249 }
20250
20251 afr_fixed_param = param_buf->fixed_param;
20252 if (!afr_fixed_param) {
20253 WMI_LOGE("Invalid channel avoid event fixed param buffer");
20254 return QDF_STATUS_E_INVAL;
20255 }
20256
20257 if (!ch_avoid_ind) {
20258 WMI_LOGE("Invalid channel avoid indication buffer");
20259 return QDF_STATUS_E_INVAL;
20260 }
20261 num_freq_ranges = (afr_fixed_param->num_freq_ranges >
20262 CH_AVOID_MAX_RANGE) ? CH_AVOID_MAX_RANGE :
20263 afr_fixed_param->num_freq_ranges;
20264
20265 WMI_LOGD("Channel avoid event received with %d ranges",
20266 num_freq_ranges);
20267
20268 ch_avoid_ind->ch_avoid_range_cnt = num_freq_ranges;
20269 afr_desc = (wmi_avoid_freq_range_desc *)(param_buf->avd_freq_range);
20270 for (freq_range_idx = 0; freq_range_idx < num_freq_ranges;
20271 freq_range_idx++) {
20272 ch_avoid_ind->avoid_freq_range[freq_range_idx].start_freq =
20273 afr_desc->start_freq;
20274 ch_avoid_ind->avoid_freq_range[freq_range_idx].end_freq =
20275 afr_desc->end_freq;
20276 WMI_LOGD("range %d tlv id %u, start freq %u, end freq %u",
20277 freq_range_idx, afr_desc->tlv_header,
20278 afr_desc->start_freq, afr_desc->end_freq);
20279 afr_desc++;
20280 }
20281
20282 return QDF_STATUS_SUCCESS;
20283}
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020284#ifdef DFS_COMPONENT_ENABLE
20285/**
20286 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
20287 * @wmi_handle: wma handle
20288 * @evt_buf: event buffer
20289 * @vdev_id: vdev id
20290 * @len: length of buffer
20291 *
20292 * Return: 0 for success or error code
20293 */
20294static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
20295 uint8_t *evt_buf,
20296 uint32_t *vdev_id,
20297 uint32_t len)
20298{
20299 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
20300 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
20301
20302 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
20303 if (!param_tlvs) {
20304 WMI_LOGE("invalid cac complete event buf");
20305 return QDF_STATUS_E_FAILURE;
20306 }
20307
20308 cac_event = param_tlvs->fixed_param;
20309 *vdev_id = cac_event->vdev_id;
20310 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
20311
20312 return QDF_STATUS_SUCCESS;
20313}
20314
20315/**
20316 * extract_dfs_radar_detection_event_tlv() - extract radar found event
20317 * @wmi_handle: wma handle
20318 * @evt_buf: event buffer
20319 * @radar_found: radar found event info
20320 * @len: length of buffer
20321 *
20322 * Return: 0 for success or error code
20323 */
20324static QDF_STATUS extract_dfs_radar_detection_event_tlv(
20325 wmi_unified_t wmi_handle,
20326 uint8_t *evt_buf,
20327 struct radar_found_info *radar_found,
20328 uint32_t len)
20329{
20330 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
20331 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
20332
20333 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
20334 if (!param_tlv) {
20335 WMI_LOGE("invalid radar detection event buf");
20336 return QDF_STATUS_E_FAILURE;
20337 }
20338
20339 radar_event = param_tlv->fixed_param;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020340 radar_found->pdev_id = wmi_handle->ops->
20341 convert_pdev_id_target_to_host(radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020342 radar_found->detection_mode = radar_event->detection_mode;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020343 radar_found->chan_freq = radar_event->chan_freq;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020344 radar_found->chan_width = radar_event->chan_width;
20345 radar_found->detector_id = radar_event->detector_id;
20346 radar_found->segment_id = radar_event->segment_id;
20347 radar_found->timestamp = radar_event->timestamp;
20348 radar_found->is_chirp = radar_event->is_chirp;
Shaakir Mohamedb8357a52017-10-04 17:09:07 -070020349 radar_found->freq_offset = radar_event->freq_offset;
20350 radar_found->sidx = radar_event->sidx;
20351
Shaakir Mohamed3a72d0a2017-11-30 14:36:16 -080020352 WMI_LOGI("processed radar found event pdev %d,"
20353 "Radar Event Info:pdev_id %d,timestamp %d,chan_freq (dur) %d,"
20354 "chan_width (RSSI) %d,detector_id (false_radar) %d,"
20355 "freq_offset (radar_check) %d,segment_id %d,sidx %d,"
20356 "is_chirp %d,detection mode %d\n",
20357 radar_event->pdev_id, radar_event->pdev_id,
20358 radar_event->timestamp, radar_event->chan_freq,
20359 radar_event->chan_width, radar_event->detector_id,
20360 radar_event->freq_offset, radar_event->segment_id,
20361 radar_event->sidx, radar_event->is_chirp,
20362 radar_event->detection_mode);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020363
20364 return QDF_STATUS_SUCCESS;
20365}
bings1ea12532017-12-18 16:56:53 +080020366
20367#ifdef QCA_MCL_DFS_SUPPORT
20368/**
20369 * extract_wlan_radar_event_info_tlv() - extract radar pulse event
20370 * @wmi_handle: wma handle
20371 * @evt_buf: event buffer
20372 * @wlan_radar_event: Pointer to struct radar_event_info
20373 * @len: length of buffer
20374 *
20375 * Return: QDF_STATUS
20376 */
20377static QDF_STATUS extract_wlan_radar_event_info_tlv(
20378 wmi_unified_t wmi_handle,
20379 uint8_t *evt_buf,
20380 struct radar_event_info *wlan_radar_event,
20381 uint32_t len)
20382{
20383 WMI_DFS_RADAR_EVENTID_param_tlvs *param_tlv;
20384 wmi_dfs_radar_event_fixed_param *radar_event;
20385
20386 param_tlv = (WMI_DFS_RADAR_EVENTID_param_tlvs *)evt_buf;
20387 if (!param_tlv) {
20388 WMI_LOGE("invalid wlan radar event buf");
20389 return QDF_STATUS_E_FAILURE;
20390 }
20391
20392 radar_event = param_tlv->fixed_param;
20393 wlan_radar_event->pulse_is_chirp = radar_event->pulse_is_chirp;
20394 wlan_radar_event->pulse_center_freq = radar_event->pulse_center_freq;
20395 wlan_radar_event->pulse_duration = radar_event->pulse_duration;
20396 wlan_radar_event->rssi = radar_event->rssi;
20397 wlan_radar_event->pulse_detect_ts = radar_event->pulse_detect_ts;
20398 wlan_radar_event->upload_fullts_high = radar_event->upload_fullts_high;
20399 wlan_radar_event->upload_fullts_low = radar_event->upload_fullts_low;
20400 wlan_radar_event->peak_sidx = radar_event->peak_sidx;
bingsfd461642018-01-03 16:38:00 +080020401 wlan_radar_event->delta_peak = radar_event->pulse_delta_peak;
20402 wlan_radar_event->delta_diff = radar_event->pulse_delta_diff;
bings26d46df2018-02-11 16:40:08 +080020403 if (radar_event->pulse_flags &
20404 WMI_DFS_RADAR_PULSE_FLAG_MASK_PSIDX_DIFF_VALID) {
20405 wlan_radar_event->is_psidx_diff_valid = true;
20406 wlan_radar_event->psidx_diff = radar_event->psidx_diff;
20407 } else {
20408 wlan_radar_event->is_psidx_diff_valid = false;
20409 }
20410
bings1ea12532017-12-18 16:56:53 +080020411 wlan_radar_event->pdev_id = radar_event->pdev_id;
20412
20413 return QDF_STATUS_SUCCESS;
20414}
20415#else
20416static QDF_STATUS extract_wlan_radar_event_info_tlv(
20417 wmi_unified_t wmi_handle,
20418 uint8_t *evt_buf,
20419 struct radar_event_info *wlan_radar_event,
20420 uint32_t len)
20421{
20422 return QDF_STATUS_SUCCESS;
20423}
20424#endif
Arif Hussainbe58b4e2017-04-09 01:03:19 -070020425#endif
20426
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020427/**
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020428 * send_get_rcpi_cmd_tlv() - send request for rcpi value
20429 * @wmi_handle: wmi handle
20430 * @get_rcpi_param: rcpi params
20431 *
20432 * Return: QDF status
20433 */
20434static QDF_STATUS send_get_rcpi_cmd_tlv(wmi_unified_t wmi_handle,
20435 struct rcpi_req *get_rcpi_param)
20436{
20437 wmi_buf_t buf;
20438 wmi_request_rcpi_cmd_fixed_param *cmd;
20439 uint8_t len = sizeof(wmi_request_rcpi_cmd_fixed_param);
20440
20441 buf = wmi_buf_alloc(wmi_handle, len);
20442 if (!buf) {
20443 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
20444 return QDF_STATUS_E_NOMEM;
20445 }
20446
20447 cmd = (wmi_request_rcpi_cmd_fixed_param *) wmi_buf_data(buf);
20448 WMITLV_SET_HDR(&cmd->tlv_header,
20449 WMITLV_TAG_STRUC_wmi_request_rcpi_cmd_fixed_param,
20450 WMITLV_GET_STRUCT_TLVLEN
20451 (wmi_request_rcpi_cmd_fixed_param));
20452
20453 cmd->vdev_id = get_rcpi_param->vdev_id;
20454 WMI_CHAR_ARRAY_TO_MAC_ADDR(get_rcpi_param->mac_addr,
20455 &cmd->peer_macaddr);
Tushnim Bhattacharyya9c8a9542018-03-28 13:05:48 -070020456
20457 switch (get_rcpi_param->measurement_type) {
20458
20459 case RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20460 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20461 break;
20462
20463 case RCPI_MEASUREMENT_TYPE_AVG_DATA:
20464 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA;
20465 break;
20466
20467 case RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20468 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20469 break;
20470
20471 case RCPI_MEASUREMENT_TYPE_LAST_DATA:
20472 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA;
20473 break;
20474
20475 default:
20476 /*
20477 * invalid rcpi measurement type, fall back to
20478 * RCPI_MEASUREMENT_TYPE_AVG_MGMT
20479 */
20480 cmd->measurement_type = WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20481 break;
20482 }
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053020483 WMI_LOGD("RCPI REQ VDEV_ID:%d-->", cmd->vdev_id);
20484 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20485 WMI_REQUEST_RCPI_CMDID)) {
20486
20487 WMI_LOGE("%s: Failed to send WMI_REQUEST_RCPI_CMDID",
20488 __func__);
20489 wmi_buf_free(buf);
20490 return QDF_STATUS_E_FAILURE;
20491 }
20492
20493 return QDF_STATUS_SUCCESS;
20494}
20495
20496/**
20497 * extract_rcpi_response_event_tlv() - Extract RCPI event params
20498 * @wmi_handle: wmi handle
20499 * @evt_buf: pointer to event buffer
20500 * @res: pointer to hold rcpi response from firmware
20501 *
20502 * Return: QDF_STATUS_SUCCESS for successful event parse
20503 * else QDF_STATUS_E_INVAL or QDF_STATUS_E_FAILURE
20504 */
20505static QDF_STATUS
20506extract_rcpi_response_event_tlv(wmi_unified_t wmi_handle,
20507 void *evt_buf, struct rcpi_res *res)
20508{
20509 WMI_UPDATE_RCPI_EVENTID_param_tlvs *param_buf;
20510 wmi_update_rcpi_event_fixed_param *event;
20511
20512 param_buf = (WMI_UPDATE_RCPI_EVENTID_param_tlvs *)evt_buf;
20513 if (!param_buf) {
20514 WMI_LOGE(FL("Invalid rcpi event"));
20515 return QDF_STATUS_E_INVAL;
20516 }
20517
20518 event = param_buf->fixed_param;
20519 res->vdev_id = event->vdev_id;
20520 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, res->mac_addr);
20521
20522 switch (event->measurement_type) {
20523
20524 case WMI_RCPI_MEASUREMENT_TYPE_AVG_MGMT:
20525 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_MGMT;
20526 break;
20527
20528 case WMI_RCPI_MEASUREMENT_TYPE_AVG_DATA:
20529 res->measurement_type = RCPI_MEASUREMENT_TYPE_AVG_DATA;
20530 break;
20531
20532 case WMI_RCPI_MEASUREMENT_TYPE_LAST_MGMT:
20533 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_MGMT;
20534 break;
20535
20536 case WMI_RCPI_MEASUREMENT_TYPE_LAST_DATA:
20537 res->measurement_type = RCPI_MEASUREMENT_TYPE_LAST_DATA;
20538 break;
20539
20540 default:
20541 WMI_LOGE(FL("Invalid rcpi measurement type from firmware"));
20542 res->measurement_type = RCPI_MEASUREMENT_TYPE_INVALID;
20543 return QDF_STATUS_E_FAILURE;
20544 }
20545
20546 if (event->status)
20547 return QDF_STATUS_E_FAILURE;
20548 else
20549 return QDF_STATUS_SUCCESS;
20550}
20551
20552/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053020553 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
20554 * host to target defines. For legacy there is not conversion
20555 * required. Just return pdev_id as it is.
20556 * @param pdev_id: host pdev_id to be converted.
20557 * Return: target pdev_id after conversion.
20558 */
20559static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
20560 uint32_t pdev_id)
20561{
20562 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
20563 return WMI_PDEV_ID_SOC;
20564
20565 /*No conversion required*/
20566 return pdev_id;
20567}
20568
20569/**
20570 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
20571 * target to host defines. For legacy there is not conversion
20572 * required. Just return pdev_id as it is.
20573 * @param pdev_id: target pdev_id to be converted.
20574 * Return: host pdev_id after conversion.
20575 */
20576static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
20577 uint32_t pdev_id)
20578{
20579 /*No conversion required*/
20580 return pdev_id;
20581}
20582
20583/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070020584 * send_set_country_cmd_tlv() - WMI scan channel list function
20585 * @param wmi_handle : handle to WMI.
20586 * @param param : pointer to hold scan channel list parameter
20587 *
20588 * Return: 0 on success and -ve on failure.
20589 */
20590static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
20591 struct set_country *params)
20592{
20593 wmi_buf_t buf;
20594 QDF_STATUS qdf_status;
20595 wmi_set_current_country_cmd_fixed_param *cmd;
20596 uint16_t len = sizeof(*cmd);
20597
20598 buf = wmi_buf_alloc(wmi_handle, len);
20599 if (!buf) {
20600 WMI_LOGE("Failed to allocate memory");
20601 qdf_status = QDF_STATUS_E_NOMEM;
20602 goto end;
20603 }
20604
20605 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
20606 WMITLV_SET_HDR(&cmd->tlv_header,
20607 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
20608 WMITLV_GET_STRUCT_TLVLEN
20609 (wmi_set_current_country_cmd_fixed_param));
20610
20611 WMI_LOGD("setting cuurnet country to %s", params->country);
20612
20613 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
20614
20615 cmd->pdev_id = params->pdev_id;
20616
20617 qdf_status = wmi_unified_cmd_send(wmi_handle,
20618 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
20619
20620 if (QDF_IS_STATUS_ERROR(qdf_status)) {
20621 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
20622 wmi_buf_free(buf);
20623 }
20624
20625end:
20626 return qdf_status;
20627}
20628
Abhijit Pradhand38a2692017-06-29 12:32:20 +053020629#define WMI_REG_COUNTRY_ALPHA_SET(alpha, val0, val1, val2) do { \
20630 WMI_SET_BITS(alpha, 0, 8, val0); \
20631 WMI_SET_BITS(alpha, 8, 8, val1); \
20632 WMI_SET_BITS(alpha, 16, 8, val2); \
20633 } while (0)
20634
20635static QDF_STATUS send_user_country_code_cmd_tlv(wmi_unified_t wmi_handle,
20636 uint8_t pdev_id, struct cc_regdmn_s *rd)
20637{
20638 wmi_set_init_country_cmd_fixed_param *cmd;
20639 uint16_t len;
20640 wmi_buf_t buf;
20641 int ret;
20642
20643 len = sizeof(wmi_set_init_country_cmd_fixed_param);
20644 buf = wmi_buf_alloc(wmi_handle, len);
20645 if (!buf) {
20646 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
20647 return QDF_STATUS_E_NOMEM;
20648 }
20649 cmd = (wmi_set_init_country_cmd_fixed_param *) wmi_buf_data(buf);
20650 WMITLV_SET_HDR(&cmd->tlv_header,
20651 WMITLV_TAG_STRUC_wmi_set_init_country_cmd_fixed_param,
20652 WMITLV_GET_STRUCT_TLVLEN
20653 (wmi_set_init_country_cmd_fixed_param));
20654
20655 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
20656
20657 if (rd->flags == CC_IS_SET) {
20658 cmd->countrycode_type = WMI_COUNTRYCODE_COUNTRY_ID;
20659 cmd->country_code.country_id = rd->cc.country_code;
20660 } else if (rd->flags == ALPHA_IS_SET) {
20661 cmd->countrycode_type = WMI_COUNTRYCODE_ALPHA2;
20662 WMI_REG_COUNTRY_ALPHA_SET(cmd->country_code.alpha2,
20663 rd->cc.alpha[0],
20664 rd->cc.alpha[1],
20665 rd->cc.alpha[2]);
20666 } else if (rd->flags == REGDMN_IS_SET) {
20667 cmd->countrycode_type = WMI_COUNTRYCODE_DOMAIN_CODE;
20668 cmd->country_code.domain_code = rd->cc.regdmn_id;
20669 }
20670
20671 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
20672 WMI_SET_INIT_COUNTRY_CMDID);
20673 if (ret) {
20674 WMI_LOGE("Failed to config wow wakeup event");
20675 wmi_buf_free(buf);
20676 return QDF_STATUS_E_FAILURE;
20677 }
20678
20679 return QDF_STATUS_SUCCESS;
20680}
20681
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053020682/**
20683 * send_limit_off_chan_cmd_tlv() - send wmi cmd of limit off chan
20684 * configuration params
20685 * @wmi_handle: wmi handler
20686 * @limit_off_chan_param: pointer to wmi_off_chan_param
20687 *
20688 * Return: 0 for success and non zero for failure
20689 */
20690static
20691QDF_STATUS send_limit_off_chan_cmd_tlv(wmi_unified_t wmi_handle,
20692 struct wmi_limit_off_chan_param *limit_off_chan_param)
20693{
20694 wmi_vdev_limit_offchan_cmd_fixed_param *cmd;
20695 wmi_buf_t buf;
20696 uint32_t len = sizeof(*cmd);
20697 int err;
20698
20699 buf = wmi_buf_alloc(wmi_handle, len);
20700 if (!buf) {
20701 WMI_LOGP("%s: failed to allocate memory for limit off chan cmd",
20702 __func__);
20703 return QDF_STATUS_E_NOMEM;
20704 }
20705
20706 cmd = (wmi_vdev_limit_offchan_cmd_fixed_param *)wmi_buf_data(buf);
20707
20708 WMITLV_SET_HDR(&cmd->tlv_header,
20709 WMITLV_TAG_STRUC_wmi_vdev_limit_offchan_cmd_fixed_param,
20710 WMITLV_GET_STRUCT_TLVLEN(
20711 wmi_vdev_limit_offchan_cmd_fixed_param));
20712
20713 cmd->vdev_id = limit_off_chan_param->vdev_id;
20714
20715 cmd->flags &= 0;
20716 if (limit_off_chan_param->status)
20717 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_ENABLE;
20718 if (limit_off_chan_param->skip_dfs_chans)
20719 cmd->flags |= WMI_VDEV_LIMIT_OFFCHAN_SKIP_DFS;
20720
20721 cmd->max_offchan_time = limit_off_chan_param->max_offchan_time;
20722 cmd->rest_time = limit_off_chan_param->rest_time;
20723
20724 WMI_LOGE("%s: vdev_id=%d, flags =%x, max_offchan_time=%d, rest_time=%d",
20725 __func__, cmd->vdev_id, cmd->flags, cmd->max_offchan_time,
20726 cmd->rest_time);
20727
20728 err = wmi_unified_cmd_send(wmi_handle, buf,
20729 len, WMI_VDEV_LIMIT_OFFCHAN_CMDID);
20730 if (QDF_IS_STATUS_ERROR(err)) {
20731 WMI_LOGE("Failed to send limit off chan cmd err=%d", err);
20732 wmi_buf_free(buf);
20733 return QDF_STATUS_E_FAILURE;
20734 }
20735
20736 return QDF_STATUS_SUCCESS;
20737}
20738
Anurag Chouhan97f00422017-09-11 14:56:30 +053020739/**
20740 * send_set_arp_stats_req_cmd_tlv() - send wmi cmd to set arp stats request
20741 * @wmi_handle: wmi handler
20742 * @req_buf: set arp stats request buffer
20743 *
20744 * Return: 0 for success and non zero for failure
20745 */
20746static QDF_STATUS send_set_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20747 struct set_arp_stats *req_buf)
20748{
20749 wmi_buf_t buf = NULL;
20750 QDF_STATUS status;
20751 int len;
20752 uint8_t *buf_ptr;
20753 wmi_vdev_set_arp_stats_cmd_fixed_param *wmi_set_arp;
20754
20755 len = sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020756 if (req_buf->pkt_type_bitmap) {
20757 len += WMI_TLV_HDR_SIZE;
20758 len += sizeof(wmi_vdev_set_connectivity_check_stats);
20759 }
Anurag Chouhan97f00422017-09-11 14:56:30 +053020760 buf = wmi_buf_alloc(wmi_handle, len);
20761 if (!buf) {
20762 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20763 return QDF_STATUS_E_NOMEM;
20764 }
20765
20766 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20767 wmi_set_arp =
20768 (wmi_vdev_set_arp_stats_cmd_fixed_param *) buf_ptr;
20769 WMITLV_SET_HDR(&wmi_set_arp->tlv_header,
20770 WMITLV_TAG_STRUC_wmi_vdev_set_arp_stats_cmd_fixed_param,
20771 WMITLV_GET_STRUCT_TLVLEN
20772 (wmi_vdev_set_arp_stats_cmd_fixed_param));
20773
20774 /* fill in per roam config values */
20775 wmi_set_arp->vdev_id = req_buf->vdev_id;
20776
20777 wmi_set_arp->set_clr = req_buf->flag;
20778 wmi_set_arp->pkt_type = req_buf->pkt_type;
20779 wmi_set_arp->ipv4 = req_buf->ip_addr;
20780
Poddar, Siddarth45880bb2018-01-29 17:19:46 +053020781 WMI_LOGD("NUD Stats: vdev_id %u set_clr %u pkt_type:%u ipv4 %u",
20782 wmi_set_arp->vdev_id, wmi_set_arp->set_clr,
20783 wmi_set_arp->pkt_type, wmi_set_arp->ipv4);
20784
20785 /*
20786 * pkt_type_bitmap should be non-zero to ensure
20787 * presence of additional stats.
20788 */
20789 if (req_buf->pkt_type_bitmap) {
20790 wmi_vdev_set_connectivity_check_stats *wmi_set_connect_stats;
20791
20792 buf_ptr += sizeof(wmi_vdev_set_arp_stats_cmd_fixed_param);
20793 WMITLV_SET_HDR(buf_ptr,
20794 WMITLV_TAG_ARRAY_STRUC,
20795 sizeof(wmi_vdev_set_connectivity_check_stats));
20796 buf_ptr += WMI_TLV_HDR_SIZE;
20797 wmi_set_connect_stats =
20798 (wmi_vdev_set_connectivity_check_stats *)buf_ptr;
20799 WMITLV_SET_HDR(&wmi_set_connect_stats->tlv_header,
20800 WMITLV_TAG_STRUC_wmi_vdev_set_connectivity_check_stats,
20801 WMITLV_GET_STRUCT_TLVLEN(
20802 wmi_vdev_set_connectivity_check_stats));
20803 wmi_set_connect_stats->pkt_type_bitmap =
20804 req_buf->pkt_type_bitmap;
20805 wmi_set_connect_stats->tcp_src_port = req_buf->tcp_src_port;
20806 wmi_set_connect_stats->tcp_dst_port = req_buf->tcp_dst_port;
20807 wmi_set_connect_stats->icmp_ipv4 = req_buf->icmp_ipv4;
20808
20809 WMI_LOGD("Connectivity Stats: pkt_type_bitmap %u tcp_src_port:%u tcp_dst_port %u icmp_ipv4 %u",
20810 wmi_set_connect_stats->pkt_type_bitmap,
20811 wmi_set_connect_stats->tcp_src_port,
20812 wmi_set_connect_stats->tcp_dst_port,
20813 wmi_set_connect_stats->icmp_ipv4);
20814 }
20815
Anurag Chouhan97f00422017-09-11 14:56:30 +053020816 /* Send per roam config parameters */
20817 status = wmi_unified_cmd_send(wmi_handle, buf,
20818 len, WMI_VDEV_SET_ARP_STAT_CMDID);
20819 if (QDF_IS_STATUS_ERROR(status)) {
20820 WMI_LOGE("WMI_SET_ARP_STATS_CMDID failed, Error %d",
20821 status);
20822 goto error;
20823 }
20824
20825 WMI_LOGI(FL("set arp stats flag=%d, vdev=%d"),
20826 req_buf->flag, req_buf->vdev_id);
20827 return QDF_STATUS_SUCCESS;
20828error:
20829 wmi_buf_free(buf);
20830
20831 return status;
20832}
20833
20834/**
20835 * send_get_arp_stats_req_cmd_tlv() - send wmi cmd to get arp stats request
20836 * @wmi_handle: wmi handler
20837 * @req_buf: get arp stats request buffer
20838 *
20839 * Return: 0 for success and non zero for failure
20840 */
20841static QDF_STATUS send_get_arp_stats_req_cmd_tlv(wmi_unified_t wmi_handle,
20842 struct get_arp_stats *req_buf)
20843{
20844 wmi_buf_t buf = NULL;
20845 QDF_STATUS status;
20846 int len;
20847 uint8_t *buf_ptr;
20848 wmi_vdev_get_arp_stats_cmd_fixed_param *get_arp_stats;
20849
20850 len = sizeof(wmi_vdev_get_arp_stats_cmd_fixed_param);
20851 buf = wmi_buf_alloc(wmi_handle, len);
20852 if (!buf) {
20853 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
20854 return QDF_STATUS_E_NOMEM;
20855 }
20856
20857 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20858 get_arp_stats =
20859 (wmi_vdev_get_arp_stats_cmd_fixed_param *) buf_ptr;
20860 WMITLV_SET_HDR(&get_arp_stats->tlv_header,
20861 WMITLV_TAG_STRUC_wmi_vdev_get_arp_stats_cmd_fixed_param,
20862 WMITLV_GET_STRUCT_TLVLEN
20863 (wmi_vdev_get_arp_stats_cmd_fixed_param));
20864
20865 /* fill in arp stats req cmd values */
20866 get_arp_stats->vdev_id = req_buf->vdev_id;
20867
20868 WMI_LOGI(FL("vdev=%d"), req_buf->vdev_id);
20869 /* Send per roam config parameters */
20870 status = wmi_unified_cmd_send(wmi_handle, buf,
20871 len, WMI_VDEV_GET_ARP_STAT_CMDID);
20872 if (QDF_IS_STATUS_ERROR(status)) {
20873 WMI_LOGE("WMI_GET_ARP_STATS_CMDID failed, Error %d",
20874 status);
20875 goto error;
20876 }
20877
20878 return QDF_STATUS_SUCCESS;
20879error:
20880 wmi_buf_free(buf);
20881
20882 return status;
20883}
20884
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020885/**
20886 * send_set_del_pmkid_cache_cmd_tlv() - send wmi cmd of set del pmkid
20887 * @wmi_handle: wmi handler
20888 * @pmk_info: pointer to PMK cache entry
20889 * @vdev_id: vdev id
20890 *
20891 * Return: 0 for success and non zero for failure
20892 */
20893static QDF_STATUS send_set_del_pmkid_cache_cmd_tlv(wmi_unified_t wmi_handle,
20894 struct wmi_unified_pmk_cache *pmk_info)
20895{
20896 wmi_pdev_update_pmk_cache_cmd_fixed_param *cmd;
20897 wmi_buf_t buf;
20898 QDF_STATUS status;
20899 uint8_t *buf_ptr;
20900 wmi_pmk_cache *pmksa;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053020901 uint32_t len = sizeof(*cmd);
20902
20903 if (pmk_info->pmk_len)
20904 len += WMI_TLV_HDR_SIZE + sizeof(*pmksa);
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020905
20906 buf = wmi_buf_alloc(wmi_handle, len);
20907 if (!buf) {
20908 WMI_LOGP("%s: failed to allocate memory for set del pmkid cache",
20909 __func__);
20910 return QDF_STATUS_E_NOMEM;
20911 }
20912
20913 buf_ptr = (uint8_t *) wmi_buf_data(buf);
20914 cmd = (wmi_pdev_update_pmk_cache_cmd_fixed_param *) buf_ptr;
20915
20916 WMITLV_SET_HDR(&cmd->tlv_header,
20917 WMITLV_TAG_STRUC_wmi_pdev_update_pmk_cache_cmd_fixed_param,
20918 WMITLV_GET_STRUCT_TLVLEN(
20919 wmi_pdev_update_pmk_cache_cmd_fixed_param));
20920
20921 cmd->vdev_id = pmk_info->session_id;
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053020922
20923 /* If pmk_info->pmk_len is 0, this is a flush request */
20924 if (!pmk_info->pmk_len) {
20925 cmd->op_flag = WMI_PMK_CACHE_OP_FLAG_FLUSH_ALL;
20926 cmd->num_cache = 0;
20927 goto send_cmd;
20928 }
20929
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020930 cmd->num_cache = 1;
20931 buf_ptr += sizeof(*cmd);
20932
20933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
20934 sizeof(*pmksa));
20935 buf_ptr += WMI_TLV_HDR_SIZE;
20936
20937 pmksa = (wmi_pmk_cache *)buf_ptr;
20938 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_pmk_cache,
20939 WMITLV_GET_STRUCT_TLVLEN
20940 (wmi_pmk_cache));
20941 pmksa->pmk_len = pmk_info->pmk_len;
20942 qdf_mem_copy(pmksa->pmk, pmk_info->pmk, pmksa->pmk_len);
20943 pmksa->pmkid_len = pmk_info->pmkid_len;
20944 qdf_mem_copy(pmksa->pmkid, pmk_info->pmkid, pmksa->pmkid_len);
20945 qdf_mem_copy(&(pmksa->bssid), &(pmk_info->bssid), sizeof(wmi_mac_addr));
20946 pmksa->ssid.ssid_len = pmk_info->ssid.length;
20947 qdf_mem_copy(&(pmksa->ssid.ssid), &(pmk_info->ssid.mac_ssid),
20948 pmksa->ssid.ssid_len);
20949 pmksa->cache_id = pmk_info->cache_id;
20950 pmksa->cat_flag = pmk_info->cat_flag;
20951 pmksa->action_flag = pmk_info->action_flag;
20952
Vignesh Viswanathan6ee66d32017-10-11 20:40:58 +053020953send_cmd:
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053020954 status = wmi_unified_cmd_send(wmi_handle, buf, len,
20955 WMI_PDEV_UPDATE_PMK_CACHE_CMDID);
20956 if (status != QDF_STATUS_SUCCESS) {
20957 WMI_LOGE("%s: failed to send set del pmkid cache command %d",
20958 __func__, status);
20959 wmi_buf_free(buf);
20960 }
20961
20962 return status;
20963}
20964
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053020965/**
20966 * send_pdev_caldata_version_check_cmd_tlv() - send caldata check cmd to fw
20967 * @wmi_handle: wmi handle
20968 * @param: reserved param
20969 *
20970 * Return: 0 for success or error code
20971 */
20972static QDF_STATUS
20973send_pdev_caldata_version_check_cmd_tlv(wmi_unified_t wmi_handle,
20974 uint32_t param)
20975{
20976 wmi_pdev_check_cal_version_cmd_fixed_param *cmd;
20977 wmi_buf_t buf;
20978 int32_t len = sizeof(wmi_pdev_check_cal_version_cmd_fixed_param);
20979
20980 buf = wmi_buf_alloc(wmi_handle, len);
20981 if (!buf) {
20982 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
20983 return QDF_STATUS_E_FAILURE;
20984 }
20985 cmd = (wmi_pdev_check_cal_version_cmd_fixed_param *)wmi_buf_data(buf);
20986 WMITLV_SET_HDR(&cmd->tlv_header,
20987 WMITLV_TAG_STRUC_wmi_pdev_check_cal_version_cmd_fixed_param,
20988 WMITLV_GET_STRUCT_TLVLEN
20989 (wmi_pdev_check_cal_version_cmd_fixed_param));
20990 cmd->pdev_id = param; /* set to 0x0 as expected from FW */
20991 if (wmi_unified_cmd_send(wmi_handle, buf, len,
20992 WMI_PDEV_CHECK_CAL_VERSION_CMDID)) {
20993 wmi_buf_free(buf);
20994 return QDF_STATUS_E_FAILURE;
20995 }
20996
20997 return QDF_STATUS_SUCCESS;
20998}
20999
21000/**
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053021001 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
21002 * host to target defines.
21003 * @param pdev_id: host pdev_id to be converted.
21004 * Return: target pdev_id after conversion.
21005 */
21006static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
21007{
21008 switch (pdev_id) {
21009 case WMI_HOST_PDEV_ID_SOC:
21010 return WMI_PDEV_ID_SOC;
21011 case WMI_HOST_PDEV_ID_0:
21012 return WMI_PDEV_ID_1ST;
21013 case WMI_HOST_PDEV_ID_1:
21014 return WMI_PDEV_ID_2ND;
21015 case WMI_HOST_PDEV_ID_2:
21016 return WMI_PDEV_ID_3RD;
21017 }
21018
21019 QDF_ASSERT(0);
21020
21021 return WMI_PDEV_ID_SOC;
21022}
21023
21024/**
21025 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
21026 * target to host defines.
21027 * @param pdev_id: target pdev_id to be converted.
21028 * Return: host pdev_id after conversion.
21029 */
21030static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
21031{
21032 switch (pdev_id) {
21033 case WMI_PDEV_ID_SOC:
21034 return WMI_HOST_PDEV_ID_SOC;
21035 case WMI_PDEV_ID_1ST:
21036 return WMI_HOST_PDEV_ID_0;
21037 case WMI_PDEV_ID_2ND:
21038 return WMI_HOST_PDEV_ID_1;
21039 case WMI_PDEV_ID_3RD:
21040 return WMI_HOST_PDEV_ID_2;
21041 }
21042
21043 QDF_ASSERT(0);
21044
21045 return WMI_HOST_PDEV_ID_SOC;
21046}
21047
21048/**
21049 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
21050 *
21051 * Return None.
21052 */
21053static void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
21054{
21055 wmi_handle->ops->convert_pdev_id_host_to_target =
21056 convert_host_pdev_id_to_target_pdev_id;
21057 wmi_handle->ops->convert_pdev_id_target_to_host =
21058 convert_target_pdev_id_to_host_pdev_id;
21059}
21060
21061/**
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053021062 * extract_pdev_caldata_version_check_ev_param_tlv() - extract caldata from event
21063 * @wmi_handle: wmi handle
21064 * @param evt_buf: pointer to event buffer
21065 * @param param: Pointer to hold peer caldata version data
21066 *
21067 * Return: 0 for success or error code
21068 */
21069static QDF_STATUS extract_pdev_caldata_version_check_ev_param_tlv(
21070 wmi_unified_t wmi_handle,
21071 void *evt_buf,
21072 wmi_host_pdev_check_cal_version_event *param)
21073{
21074 WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *param_tlvs;
21075 wmi_pdev_check_cal_version_event_fixed_param *event;
21076
21077 param_tlvs = (WMI_PDEV_CHECK_CAL_VERSION_EVENTID_param_tlvs *) evt_buf;
21078 if (!param_tlvs) {
21079 WMI_LOGE("invalid cal version event buf");
21080 return QDF_STATUS_E_FAILURE;
21081 }
21082 event = param_tlvs->fixed_param;
21083 if (event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] != '\0')
21084 event->board_mcn_detail[WMI_BOARD_MCN_STRING_MAX_SIZE] = '\0';
21085 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(param->board_mcn_detail,
21086 event->board_mcn_detail, WMI_BOARD_MCN_STRING_BUF_SIZE);
21087
21088 param->software_cal_version = event->software_cal_version;
21089 param->board_cal_version = event->board_cal_version;
21090 param->cal_ok = event->cal_status;
21091
21092 return QDF_STATUS_SUCCESS;
21093}
21094
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021095/*
21096 * send_btm_config_cmd_tlv() - Send wmi cmd for BTM config
21097 * @wmi_handle: wmi handle
21098 * @params: pointer to wmi_btm_config
21099 *
21100 * Return: QDF_STATUS
21101 */
21102static QDF_STATUS send_btm_config_cmd_tlv(wmi_unified_t wmi_handle,
21103 struct wmi_btm_config *params)
21104{
21105
21106 wmi_btm_config_fixed_param *cmd;
21107 wmi_buf_t buf;
21108 uint32_t len;
21109
21110 len = sizeof(*cmd);
21111 buf = wmi_buf_alloc(wmi_handle, len);
21112 if (!buf) {
21113 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
21114 return QDF_STATUS_E_NOMEM;
21115 }
21116
21117 cmd = (wmi_btm_config_fixed_param *)wmi_buf_data(buf);
21118 WMITLV_SET_HDR(&cmd->tlv_header,
21119 WMITLV_TAG_STRUC_wmi_btm_config_fixed_param,
21120 WMITLV_GET_STRUCT_TLVLEN(wmi_btm_config_fixed_param));
21121 cmd->vdev_id = params->vdev_id;
21122 cmd->flags = params->btm_offload_config;
Jiachao Wu31bd2932018-01-08 16:45:09 +080021123 cmd->max_attempt_cnt = params->btm_max_attempt_cnt;
21124 cmd->solicited_timeout_ms = params->btm_solicited_timeout;
21125 cmd->stick_time_seconds = params->btm_sticky_time;
21126
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021127 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21128 WMI_ROAM_BTM_CONFIG_CMDID)) {
21129 WMI_LOGE("%s: failed to send WMI_ROAM_BTM_CONFIG_CMDID",
21130 __func__);
21131 wmi_buf_free(buf);
21132 return QDF_STATUS_E_FAILURE;
21133 }
Arif Hussainc5bfe072017-12-27 16:23:45 -080021134
21135 return QDF_STATUS_SUCCESS;
21136}
21137
21138/**
21139 * send_obss_detection_cfg_cmd_tlv() - send obss detection
21140 * configurations to firmware.
21141 * @wmi_handle: wmi handle
21142 * @obss_cfg_param: obss detection configurations
21143 *
21144 * Send WMI_SAP_OBSS_DETECTION_CFG_CMDID parameters to fw.
21145 *
21146 * Return: QDF_STATUS
21147 */
21148static QDF_STATUS send_obss_detection_cfg_cmd_tlv(wmi_unified_t wmi_handle,
21149 struct wmi_obss_detection_cfg_param *obss_cfg_param)
21150{
21151 wmi_buf_t buf;
21152 wmi_sap_obss_detection_cfg_cmd_fixed_param *cmd;
21153 uint8_t len = sizeof(wmi_sap_obss_detection_cfg_cmd_fixed_param);
21154
21155 buf = wmi_buf_alloc(wmi_handle, len);
21156 if (!buf) {
21157 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21158 return QDF_STATUS_E_NOMEM;
21159 }
21160
21161 cmd = (wmi_sap_obss_detection_cfg_cmd_fixed_param *)wmi_buf_data(buf);
21162 WMITLV_SET_HDR(&cmd->tlv_header,
21163 WMITLV_TAG_STRUC_wmi_sap_obss_detection_cfg_cmd_fixed_param,
21164 WMITLV_GET_STRUCT_TLVLEN
21165 (wmi_sap_obss_detection_cfg_cmd_fixed_param));
21166
21167 cmd->vdev_id = obss_cfg_param->vdev_id;
21168 cmd->detect_period_ms = obss_cfg_param->obss_detect_period_ms;
21169 cmd->b_ap_detect_mode = obss_cfg_param->obss_11b_ap_detect_mode;
21170 cmd->b_sta_detect_mode = obss_cfg_param->obss_11b_sta_detect_mode;
21171 cmd->g_ap_detect_mode = obss_cfg_param->obss_11g_ap_detect_mode;
21172 cmd->a_detect_mode = obss_cfg_param->obss_11a_detect_mode;
21173 cmd->ht_legacy_detect_mode = obss_cfg_param->obss_ht_legacy_detect_mode;
21174 cmd->ht_mixed_detect_mode = obss_cfg_param->obss_ht_mixed_detect_mode;
21175 cmd->ht_20mhz_detect_mode = obss_cfg_param->obss_ht_20mhz_detect_mode;
Arif Hussainc5bfe072017-12-27 16:23:45 -080021176
21177 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21178 WMI_SAP_OBSS_DETECTION_CFG_CMDID)) {
21179 WMI_LOGE("Failed to send WMI_SAP_OBSS_DETECTION_CFG_CMDID");
21180 wmi_buf_free(buf);
21181 return QDF_STATUS_E_FAILURE;
21182 }
21183
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053021184 return QDF_STATUS_SUCCESS;
21185}
21186
Arif Hussain33d98502018-01-12 13:15:04 -080021187/**
21188 * extract_obss_detection_info_tlv() - Extract obss detection info
21189 * received from firmware.
21190 * @evt_buf: pointer to event buffer
21191 * @obss_detection: Pointer to hold obss detection info
21192 *
21193 * Return: QDF_STATUS
21194 */
21195static QDF_STATUS extract_obss_detection_info_tlv(uint8_t *evt_buf,
21196 struct wmi_obss_detect_info
21197 *obss_detection)
21198{
21199 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *param_buf;
21200 wmi_sap_obss_detection_info_evt_fixed_param *fix_param;
21201
21202 if (!obss_detection) {
21203 WMI_LOGE("%s: Invalid obss_detection event buffer", __func__);
21204 return QDF_STATUS_E_INVAL;
21205 }
21206
21207 param_buf = (WMI_SAP_OBSS_DETECTION_REPORT_EVENTID_param_tlvs *)evt_buf;
21208 if (!param_buf) {
21209 WMI_LOGE("%s: Invalid evt_buf", __func__);
21210 return QDF_STATUS_E_INVAL;
21211 }
21212
21213 fix_param = param_buf->fixed_param;
21214 obss_detection->vdev_id = fix_param->vdev_id;
21215 obss_detection->matched_detection_masks =
21216 fix_param->matched_detection_masks;
21217 WMI_MAC_ADDR_TO_CHAR_ARRAY(&fix_param->matched_bssid_addr,
21218 &obss_detection->matched_bssid_addr[0]);
21219 switch (fix_param->reason) {
21220 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_NOT_SUPPORT:
21221 obss_detection->reason = OBSS_OFFLOAD_DETECTION_DISABLED;
21222 break;
21223 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_PRESENT_NOTIFY:
21224 obss_detection->reason = OBSS_OFFLOAD_DETECTION_PRESENT;
21225 break;
21226 case WMI_SAP_OBSS_DETECTION_EVENT_REASON_ABSENT_TIMEOUT:
21227 obss_detection->reason = OBSS_OFFLOAD_DETECTION_ABSENT;
21228 break;
21229 default:
21230 WMI_LOGE("%s: Invalid reason %d", __func__, fix_param->reason);
21231 return QDF_STATUS_E_INVAL;
21232 }
21233
21234 return QDF_STATUS_SUCCESS;
21235}
21236
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053021237/**
21238 * send_offload_11k_cmd_tlv() - send wmi cmd with 11k offload params
21239 * @wmi_handle: wmi handler
21240 * @params: pointer to 11k offload params
21241 *
21242 * Return: 0 for success and non zero for failure
21243 */
21244static QDF_STATUS send_offload_11k_cmd_tlv(wmi_unified_t wmi_handle,
21245 struct wmi_11k_offload_params *params)
21246{
21247 wmi_11k_offload_report_fixed_param *cmd;
21248 wmi_buf_t buf;
21249 QDF_STATUS status;
21250 uint8_t *buf_ptr;
21251 wmi_neighbor_report_11k_offload_tlv_param
21252 *neighbor_report_offload_params;
21253 wmi_neighbor_report_offload *neighbor_report_offload;
21254
21255 uint32_t len = sizeof(*cmd);
21256
21257 if (params->offload_11k_bitmask &
21258 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ)
21259 len += WMI_TLV_HDR_SIZE +
21260 sizeof(wmi_neighbor_report_11k_offload_tlv_param);
21261
21262 buf = wmi_buf_alloc(wmi_handle, len);
21263 if (!buf) {
21264 WMI_LOGP("%s: failed to allocate memory for 11k offload params",
21265 __func__);
21266 return QDF_STATUS_E_NOMEM;
21267 }
21268
21269 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21270 cmd = (wmi_11k_offload_report_fixed_param *) buf_ptr;
21271
21272 WMITLV_SET_HDR(&cmd->tlv_header,
21273 WMITLV_TAG_STRUC_wmi_offload_11k_report_fixed_param,
21274 WMITLV_GET_STRUCT_TLVLEN(
21275 wmi_11k_offload_report_fixed_param));
21276
21277 cmd->vdev_id = params->vdev_id;
21278 cmd->offload_11k = params->offload_11k_bitmask;
21279
21280 if (params->offload_11k_bitmask &
21281 WMI_11K_OFFLOAD_BITMAP_NEIGHBOR_REPORT_REQ) {
21282 buf_ptr += sizeof(wmi_11k_offload_report_fixed_param);
21283
21284 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
21285 sizeof(wmi_neighbor_report_11k_offload_tlv_param));
21286 buf_ptr += WMI_TLV_HDR_SIZE;
21287
21288 neighbor_report_offload_params =
21289 (wmi_neighbor_report_11k_offload_tlv_param *)buf_ptr;
21290 WMITLV_SET_HDR(&neighbor_report_offload_params->tlv_header,
21291 WMITLV_TAG_STRUC_wmi_neighbor_report_offload_tlv_param,
21292 WMITLV_GET_STRUCT_TLVLEN(
21293 wmi_neighbor_report_11k_offload_tlv_param));
21294
21295 neighbor_report_offload = &neighbor_report_offload_params->
21296 neighbor_rep_ofld_params;
21297
21298 neighbor_report_offload->time_offset =
21299 params->neighbor_report_params.time_offset;
21300 neighbor_report_offload->low_rssi_offset =
21301 params->neighbor_report_params.low_rssi_offset;
21302 neighbor_report_offload->bmiss_count_trigger =
21303 params->neighbor_report_params.bmiss_count_trigger;
21304 neighbor_report_offload->per_threshold_offset =
21305 params->neighbor_report_params.per_threshold_offset;
21306 neighbor_report_offload->neighbor_report_cache_timeout =
21307 params->neighbor_report_params.
21308 neighbor_report_cache_timeout;
21309 neighbor_report_offload->max_neighbor_report_req_cap =
21310 params->neighbor_report_params.
21311 max_neighbor_report_req_cap;
21312 neighbor_report_offload->ssid.ssid_len =
21313 params->neighbor_report_params.ssid.length;
21314 qdf_mem_copy(neighbor_report_offload->ssid.ssid,
21315 &params->neighbor_report_params.ssid.mac_ssid,
21316 neighbor_report_offload->ssid.ssid_len);
21317 }
21318
21319 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21320 WMI_11K_OFFLOAD_REPORT_CMDID);
21321 if (status != QDF_STATUS_SUCCESS) {
21322 WMI_LOGE("%s: failed to send 11k offload command %d",
21323 __func__, status);
21324 wmi_buf_free(buf);
21325 }
21326
21327 return status;
21328}
21329
21330/**
21331 * send_invoke_neighbor_report_cmd_tlv() - send invoke 11k neighbor report
21332 * command
21333 * @wmi_handle: wmi handler
21334 * @params: pointer to neighbor report invoke params
21335 *
21336 * Return: 0 for success and non zero for failure
21337 */
21338static QDF_STATUS send_invoke_neighbor_report_cmd_tlv(wmi_unified_t wmi_handle,
21339 struct wmi_invoke_neighbor_report_params *params)
21340{
21341 wmi_11k_offload_invoke_neighbor_report_fixed_param *cmd;
21342 wmi_buf_t buf;
21343 QDF_STATUS status;
21344 uint8_t *buf_ptr;
21345 uint32_t len = sizeof(*cmd);
21346
21347 buf = wmi_buf_alloc(wmi_handle, len);
21348 if (!buf) {
21349 WMI_LOGP("%s:failed to allocate memory for neighbor invoke cmd",
21350 __func__);
21351 return QDF_STATUS_E_NOMEM;
21352 }
21353
21354 buf_ptr = (uint8_t *) wmi_buf_data(buf);
21355 cmd = (wmi_11k_offload_invoke_neighbor_report_fixed_param *) buf_ptr;
21356
21357 WMITLV_SET_HDR(&cmd->tlv_header,
21358 WMITLV_TAG_STRUC_wmi_invoke_neighbor_report_fixed_param,
21359 WMITLV_GET_STRUCT_TLVLEN(
21360 wmi_11k_offload_invoke_neighbor_report_fixed_param));
21361
21362 cmd->vdev_id = params->vdev_id;
21363 cmd->flags = params->send_resp_to_host;
21364
21365 cmd->ssid.ssid_len = params->ssid.length;
21366 qdf_mem_copy(cmd->ssid.ssid,
21367 &params->ssid.mac_ssid,
21368 cmd->ssid.ssid_len);
21369
21370 status = wmi_unified_cmd_send(wmi_handle, buf, len,
21371 WMI_11K_INVOKE_NEIGHBOR_REPORT_CMDID);
21372 if (status != QDF_STATUS_SUCCESS) {
21373 WMI_LOGE("%s: failed to send invoke neighbor report command %d",
21374 __func__, status);
21375 wmi_buf_free(buf);
21376 }
21377
21378 return status;
21379}
21380
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021381#ifdef WLAN_SUPPORT_GREEN_AP
21382static QDF_STATUS extract_green_ap_egap_status_info_tlv(
21383 uint8_t *evt_buf,
21384 struct wlan_green_ap_egap_status_info *egap_status_info_params)
21385{
21386 WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *param_buf;
21387 wmi_ap_ps_egap_info_event_fixed_param *egap_info_event;
21388 wmi_ap_ps_egap_info_chainmask_list *chainmask_event;
21389
21390 param_buf = (WMI_AP_PS_EGAP_INFO_EVENTID_param_tlvs *)evt_buf;
21391 if (!param_buf) {
21392 WMI_LOGE("Invalid EGAP Info status event buffer");
21393 return QDF_STATUS_E_INVAL;
21394 }
21395
21396 egap_info_event = (wmi_ap_ps_egap_info_event_fixed_param *)
21397 param_buf->fixed_param;
21398 chainmask_event = (wmi_ap_ps_egap_info_chainmask_list *)
21399 param_buf->chainmask_list;
21400
21401 egap_status_info_params->status = egap_info_event->status;
21402 egap_status_info_params->mac_id = chainmask_event->mac_id;
21403 egap_status_info_params->tx_chainmask = chainmask_event->tx_chainmask;
21404 egap_status_info_params->rx_chainmask = chainmask_event->rx_chainmask;
21405
21406 return QDF_STATUS_SUCCESS;
21407}
21408#endif
21409
Arif Hussainec5cd3c2018-01-22 01:19:36 -080021410/*
21411 * send_bss_color_change_enable_cmd_tlv() - Send command to enable or disable of
21412 * updating bss color change within firmware when AP announces bss color change.
21413 * @wmi_handle: wmi handle
21414 * @vdev_id: vdev ID
21415 * @enable: enable bss color change within firmware
21416 *
21417 * Send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID parameters to fw.
21418 *
21419 * Return: QDF_STATUS
21420 */
21421static QDF_STATUS send_bss_color_change_enable_cmd_tlv(wmi_unified_t wmi_handle,
21422 uint32_t vdev_id,
21423 bool enable)
21424{
21425 wmi_buf_t buf;
21426 wmi_bss_color_change_enable_fixed_param *cmd;
21427 uint8_t len = sizeof(wmi_bss_color_change_enable_fixed_param);
21428
21429 buf = wmi_buf_alloc(wmi_handle, len);
21430 if (!buf) {
21431 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21432 return QDF_STATUS_E_NOMEM;
21433 }
21434
21435 cmd = (wmi_bss_color_change_enable_fixed_param *)wmi_buf_data(buf);
21436 WMITLV_SET_HDR(&cmd->tlv_header,
21437 WMITLV_TAG_STRUC_wmi_bss_color_change_enable_fixed_param,
21438 WMITLV_GET_STRUCT_TLVLEN
21439 (wmi_bss_color_change_enable_fixed_param));
21440 cmd->vdev_id = vdev_id;
21441 cmd->enable = enable;
21442 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21443 WMI_BSS_COLOR_CHANGE_ENABLE_CMDID)) {
21444 WMI_LOGE("Failed to send WMI_BSS_COLOR_CHANGE_ENABLE_CMDID");
21445 wmi_buf_free(buf);
21446 return QDF_STATUS_E_FAILURE;
21447 }
21448
21449 return QDF_STATUS_SUCCESS;
21450}
21451
21452/**
21453 * send_obss_color_collision_cfg_cmd_tlv() - send bss color detection
21454 * configurations to firmware.
21455 * @wmi_handle: wmi handle
21456 * @cfg_param: obss detection configurations
21457 *
21458 * Send WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID parameters to fw.
21459 *
21460 * Return: QDF_STATUS
21461 */
21462static QDF_STATUS send_obss_color_collision_cfg_cmd_tlv(
21463 wmi_unified_t wmi_handle,
21464 struct wmi_obss_color_collision_cfg_param *cfg_param)
21465{
21466 wmi_buf_t buf;
21467 wmi_obss_color_collision_det_config_fixed_param *cmd;
21468 uint8_t len = sizeof(wmi_obss_color_collision_det_config_fixed_param);
21469
21470 buf = wmi_buf_alloc(wmi_handle, len);
21471 if (!buf) {
21472 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
21473 return QDF_STATUS_E_NOMEM;
21474 }
21475
21476 cmd = (wmi_obss_color_collision_det_config_fixed_param *)wmi_buf_data(
21477 buf);
21478 WMITLV_SET_HDR(&cmd->tlv_header,
21479 WMITLV_TAG_STRUC_wmi_obss_color_collision_det_config_fixed_param,
21480 WMITLV_GET_STRUCT_TLVLEN
21481 (wmi_obss_color_collision_det_config_fixed_param));
21482 cmd->vdev_id = cfg_param->vdev_id;
21483 cmd->flags = cfg_param->flags;
21484 cmd->current_bss_color = cfg_param->current_bss_color;
21485 cmd->detection_period_ms = cfg_param->detection_period_ms;
21486 cmd->scan_period_ms = cfg_param->scan_period_ms;
21487 cmd->free_slot_expiry_time_ms = cfg_param->free_slot_expiry_time_ms;
21488
21489 switch (cfg_param->evt_type) {
21490 case OBSS_COLOR_COLLISION_DETECTION_DISABLE:
21491 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DISABLE;
21492 break;
21493 case OBSS_COLOR_COLLISION_DETECTION:
21494 cmd->evt_type = WMI_BSS_COLOR_COLLISION_DETECTION;
21495 break;
21496 case OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21497 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21498 break;
21499 case OBSS_COLOR_FREE_SLOT_AVAILABLE:
21500 cmd->evt_type = WMI_BSS_COLOR_FREE_SLOT_AVAILABLE;
21501 break;
21502 default:
21503 WMI_LOGE("%s: invalid event type: %d",
21504 __func__, cfg_param->evt_type);
21505 wmi_buf_free(buf);
21506 return QDF_STATUS_E_FAILURE;
21507 }
21508
21509 if (wmi_unified_cmd_send(wmi_handle, buf, len,
21510 WMI_OBSS_COLOR_COLLISION_DET_CONFIG_CMDID)) {
21511 WMI_LOGE("%s: Sending OBSS color det cmd failed, vdev_id: %d",
21512 __func__, cfg_param->vdev_id);
21513 wmi_buf_free(buf);
21514 return QDF_STATUS_E_FAILURE;
21515 }
21516
21517 return QDF_STATUS_SUCCESS;
21518}
21519
21520/**
21521 * extract_obss_color_collision_info_tlv() - Extract bss color collision info
21522 * received from firmware.
21523 * @evt_buf: pointer to event buffer
21524 * @info: Pointer to hold bss collision info
21525 *
21526 * Return: QDF_STATUS
21527 */
21528static QDF_STATUS extract_obss_color_collision_info_tlv(uint8_t *evt_buf,
21529 struct wmi_obss_color_collision_info *info)
21530{
21531 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *param_buf;
21532 wmi_obss_color_collision_evt_fixed_param *fix_param;
21533
21534 if (!info) {
21535 WMI_LOGE("%s: Invalid obss color buffer", __func__);
21536 return QDF_STATUS_E_INVAL;
21537 }
21538
21539 param_buf = (WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID_param_tlvs *)
21540 evt_buf;
21541 if (!param_buf) {
21542 WMI_LOGE("%s: Invalid evt_buf", __func__);
21543 return QDF_STATUS_E_INVAL;
21544 }
21545
21546 fix_param = param_buf->fixed_param;
21547 info->vdev_id = fix_param->vdev_id;
21548 info->obss_color_bitmap_bit0to31 = fix_param->bss_color_bitmap_bit0to31;
21549 info->obss_color_bitmap_bit32to63 =
21550 fix_param->bss_color_bitmap_bit32to63;
21551
21552 switch (fix_param->evt_type) {
21553 case WMI_BSS_COLOR_COLLISION_DISABLE:
21554 info->evt_type = OBSS_COLOR_COLLISION_DETECTION_DISABLE;
21555 break;
21556 case WMI_BSS_COLOR_COLLISION_DETECTION:
21557 info->evt_type = OBSS_COLOR_COLLISION_DETECTION;
21558 break;
21559 case WMI_BSS_COLOR_FREE_SLOT_TIMER_EXPIRY:
21560 info->evt_type = OBSS_COLOR_FREE_SLOT_TIMER_EXPIRY;
21561 break;
21562 case WMI_BSS_COLOR_FREE_SLOT_AVAILABLE:
21563 info->evt_type = OBSS_COLOR_FREE_SLOT_AVAILABLE;
21564 break;
21565 default:
21566 WMI_LOGE("%s: invalid event type: %d, vdev_id: %d",
21567 __func__, fix_param->evt_type, fix_param->vdev_id);
21568 return QDF_STATUS_E_FAILURE;
21569 }
21570
21571 return QDF_STATUS_SUCCESS;
21572}
21573
Arif Hussaine0eb7302018-03-01 14:40:59 -080021574/*
21575 * extract_comb_phyerr_tlv() - extract comb phy error from event
21576 * @wmi_handle: wmi handle
21577 * @evt_buf: pointer to event buffer
21578 * @datalen: data length of event buffer
21579 * @buf_offset: Pointer to hold value of current event buffer offset
21580 * post extraction
21581 * @phyerr: Pointer to hold phyerr
21582 *
21583 * Return: QDF_STATUS
21584 */
21585static QDF_STATUS extract_comb_phyerr_tlv(wmi_unified_t wmi_handle,
21586 void *evt_buf,
21587 uint16_t datalen,
21588 uint16_t *buf_offset,
21589 wmi_host_phyerr_t *phyerr)
21590{
21591 WMI_PHYERR_EVENTID_param_tlvs *param_tlvs;
21592 wmi_comb_phyerr_rx_hdr *pe_hdr;
21593
21594 param_tlvs = (WMI_PHYERR_EVENTID_param_tlvs *)evt_buf;
21595 if (!param_tlvs) {
21596 WMI_LOGD("%s: Received null data from FW", __func__);
21597 return QDF_STATUS_E_FAILURE;
21598 }
21599
21600 pe_hdr = param_tlvs->hdr;
21601 if (!pe_hdr) {
21602 WMI_LOGD("%s: Received Data PE Header is NULL", __func__);
21603 return QDF_STATUS_E_FAILURE;
21604 }
21605
21606 /* Ensure it's at least the size of the header */
21607 if (datalen < sizeof(*pe_hdr)) {
21608 WMI_LOGD("%s: Expected minimum size %zu, received %d",
21609 __func__, sizeof(*pe_hdr), datalen);
21610 return QDF_STATUS_E_FAILURE;
21611 }
21612
21613 phyerr->pdev_id = wmi_handle->ops->
21614 convert_pdev_id_target_to_host(pe_hdr->pdev_id);
21615 phyerr->tsf64 = pe_hdr->tsf_l32;
21616 phyerr->tsf64 |= (((uint64_t)pe_hdr->tsf_u32) << 32);
21617 phyerr->bufp = param_tlvs->bufp;
21618 phyerr->buf_len = pe_hdr->buf_len;
21619 phyerr->phy_err_mask0 = pe_hdr->rsPhyErrMask0;
21620 phyerr->phy_err_mask1 = pe_hdr->rsPhyErrMask1;
21621 *buf_offset = sizeof(*pe_hdr) + sizeof(uint32_t);
21622
21623 return QDF_STATUS_SUCCESS;
21624}
21625
21626/**
21627 * extract_single_phyerr_tlv() - extract single phy error from event
21628 * @wmi_handle: wmi handle
21629 * @evt_buf: pointer to event buffer
21630 * @datalen: data length of event buffer
21631 * @buf_offset: Pointer to hold value of current event buffer offset
21632 * post extraction
21633 * @phyerr: Pointer to hold phyerr
21634 *
21635 * Return: QDF_STATUS
21636 */
21637static QDF_STATUS extract_single_phyerr_tlv(wmi_unified_t wmi_handle,
21638 void *evt_buf,
21639 uint16_t datalen,
21640 uint16_t *buf_offset,
21641 wmi_host_phyerr_t *phyerr)
21642{
21643 wmi_single_phyerr_rx_event *ev;
21644 uint16_t n = *buf_offset;
21645 uint8_t *data = (uint8_t *)evt_buf;
21646
21647 if (n < datalen) {
21648 if ((datalen - n) < sizeof(ev->hdr)) {
21649 WMI_LOGD("%s: Not enough space. len=%d, n=%d, hdr=%zu",
21650 __func__, datalen, n, sizeof(ev->hdr));
21651 return QDF_STATUS_E_FAILURE;
21652 }
21653
21654 /*
21655 * Obtain a pointer to the beginning of the current event.
21656 * data[0] is the beginning of the WMI payload.
21657 */
21658 ev = (wmi_single_phyerr_rx_event *)&data[n];
21659
21660 /*
21661 * Sanity check the buffer length of the event against
21662 * what we currently have.
21663 *
21664 * Since buf_len is 32 bits, we check if it overflows
21665 * a large 32 bit value. It's not 0x7fffffff because
21666 * we increase n by (buf_len + sizeof(hdr)), which would
21667 * in itself cause n to overflow.
21668 *
21669 * If "int" is 64 bits then this becomes a moot point.
21670 */
21671 if (ev->hdr.buf_len > PHYERROR_MAX_BUFFER_LENGTH) {
21672 WMI_LOGD("%s: buf_len is garbage 0x%x",
21673 __func__, ev->hdr.buf_len);
21674 return QDF_STATUS_E_FAILURE;
21675 }
21676
21677 if ((n + ev->hdr.buf_len) > datalen) {
21678 WMI_LOGD("%s: len exceeds n=%d, buf_len=%d, datalen=%d",
21679 __func__, n, ev->hdr.buf_len, datalen);
21680 return QDF_STATUS_E_FAILURE;
21681 }
21682
21683 phyerr->phy_err_code = WMI_UNIFIED_PHYERRCODE_GET(&ev->hdr);
21684 phyerr->tsf_timestamp = ev->hdr.tsf_timestamp;
21685 phyerr->bufp = &ev->bufp[0];
21686 phyerr->buf_len = ev->hdr.buf_len;
21687 phyerr->rf_info.rssi_comb = WMI_UNIFIED_RSSI_COMB_GET(&ev->hdr);
21688
21689 /*
21690 * Advance the buffer pointer to the next PHY error.
21691 * buflen is the length of this payload, so we need to
21692 * advance past the current header _AND_ the payload.
21693 */
21694 n += sizeof(*ev) + ev->hdr.buf_len;
21695 }
21696 *buf_offset = n;
21697
21698 return QDF_STATUS_SUCCESS;
21699}
21700
Govind Singh5eb51532016-03-09 11:34:12 +053021701struct wmi_ops tlv_ops = {
21702 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
21703 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
21704 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053021705 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
21706 .send_hidden_ssid_vdev_restart_cmd =
21707 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021708 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
21709 .send_peer_param_cmd = send_peer_param_cmd_tlv,
21710 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021711 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021712 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021713 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070021714 .send_peer_rx_reorder_queue_setup_cmd =
21715 send_peer_rx_reorder_queue_setup_cmd_tlv,
21716 .send_peer_rx_reorder_queue_remove_cmd =
21717 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053021718 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
21719 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
21720 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021721 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
21722 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080021723 .send_pdev_get_tpc_config_cmd = send_pdev_get_tpc_config_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021724 .send_suspend_cmd = send_suspend_cmd_tlv,
21725 .send_resume_cmd = send_resume_cmd_tlv,
Will Huang422ac9a2017-11-17 13:19:16 +080021726#ifdef FEATURE_WLAN_D0WOW
21727 .send_d0wow_enable_cmd = send_d0wow_enable_cmd_tlv,
21728 .send_d0wow_disable_cmd = send_d0wow_disable_cmd_tlv,
21729#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021730 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
21731 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
21732 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
21733 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021734#ifdef FEATURE_FW_LOG_PARSING
Govind Singh5eb51532016-03-09 11:34:12 +053021735 .send_dbglog_cmd = send_dbglog_cmd_tlv,
Wen Gongca174012018-04-20 16:56:28 +080021736#endif
Govind Singh5eb51532016-03-09 11:34:12 +053021737 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
21738 .send_stats_request_cmd = send_stats_request_cmd_tlv,
21739 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
gaurank kathpaliacdfb4452018-02-21 18:58:29 +053021740 .send_time_stamp_sync_cmd = send_time_stamp_sync_cmd_tlv,
Keyur Parekhde522342017-08-18 14:01:05 -070021741 .send_packet_log_disable_cmd = send_packet_log_disable_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021742 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021743 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053021744 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
21745 .send_scan_start_cmd = send_scan_start_cmd_tlv,
21746 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
21747 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021748 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053021749 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021750 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
21751 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021752 .send_set_sta_uapsd_auto_trig_cmd =
21753 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053021754 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
21755 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
21756 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080021757#ifdef CONVERGED_P2P_ENABLE
21758 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
21759 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
21760#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053021761 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
21762 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021763#ifdef WLAN_FEATURE_DSRC
Govind Singh2edc80f2016-03-01 15:30:53 +053021764 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
21765 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
21766 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
21767 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
21768 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
21769 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
21770 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021771 .send_ocb_start_timing_advert_cmd =
21772 send_ocb_start_timing_advert_cmd_tlv,
Zhang Qian11c0de32018-01-05 16:50:53 +080021773 .extract_ocb_chan_config_resp = extract_ocb_channel_config_resp_tlv,
21774 .extract_ocb_tsf_timer = extract_ocb_tsf_timer_tlv,
21775 .extract_dcc_update_ndl_resp = extract_ocb_ndl_resp_tlv,
21776 .extract_dcc_stats = extract_ocb_dcc_stats_tlv,
21777#endif
Govind Singh17a9cfa2016-03-01 15:54:59 +053021778 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
21779 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
21780 .send_set_mcc_channel_time_latency_cmd =
21781 send_set_mcc_channel_time_latency_cmd_tlv,
21782 .send_set_mcc_channel_time_quota_cmd =
21783 send_set_mcc_channel_time_quota_cmd_tlv,
21784 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
21785 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053021786 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021787 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
21788 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
21789 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021790 .send_probe_rsp_tmpl_send_cmd =
21791 send_probe_rsp_tmpl_send_cmd_tlv,
21792 .send_p2p_go_set_beacon_ie_cmd =
21793 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053021794 .send_setup_install_key_cmd =
21795 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021796 .send_set_gateway_params_cmd =
21797 send_set_gateway_params_cmd_tlv,
21798 .send_set_rssi_monitoring_cmd =
21799 send_set_rssi_monitoring_cmd_tlv,
21800 .send_scan_probe_setoui_cmd =
21801 send_scan_probe_setoui_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021802 .send_roam_scan_offload_rssi_thresh_cmd =
21803 send_roam_scan_offload_rssi_thresh_cmd_tlv,
Varun Reddy Yeturu412601c2017-07-20 09:45:01 -070021804 .send_roam_mawc_params_cmd = send_roam_mawc_params_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053021805 .send_roam_scan_filter_cmd =
21806 send_roam_scan_filter_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021807#ifdef IPA_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +053021808 .send_ipa_offload_control_cmd =
21809 send_ipa_offload_control_cmd_tlv,
Sravan Kumar Kairam963cad92018-02-15 23:28:34 +053021810#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053021811 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
21812 .send_plm_start_cmd = send_plm_start_cmd_tlv,
21813 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
21814 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Varun Reddy Yeturueac038b2017-07-24 16:11:22 -070021815 .send_nlo_mawc_cmd = send_nlo_mawc_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053021816 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021817#ifdef WLAN_FEATURE_LINK_LAYER_STATS
Govind Singh4eacd2b2016-03-07 14:24:22 +053021818 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
21819 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
21820 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
Qiwei Cai1ccba222018-05-21 16:49:39 +080021821#endif /* WLAN_FEATURE_LINK_LAYER_STATS*/
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053021822 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021823 .send_snr_request_cmd = send_snr_request_cmd_tlv,
21824 .send_snr_cmd = send_snr_cmd_tlv,
21825 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021826#ifdef WLAN_POWER_MANAGEMENT_OFFLOAD
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021827 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
21828 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
21829 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
21830 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Poddar, Siddarth79ba8202017-09-28 17:14:01 +053021831 .send_multiple_add_clear_mcbc_filter_cmd =
21832 send_multiple_add_clear_mcbc_filter_cmd_tlv,
Dustin Brownf31f88b2017-05-12 14:01:44 -070021833 .send_conf_hw_filter_cmd = send_conf_hw_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021834 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
21835 .send_process_gtk_offload_getinfo_cmd =
21836 send_process_gtk_offload_getinfo_cmd_tlv,
21837 .send_enable_enhance_multicast_offload_cmd =
21838 send_enable_enhance_multicast_offload_tlv,
21839 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
21840#ifdef FEATURE_WLAN_RA_FILTERING
21841 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
21842#endif
21843 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021844 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
21845 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021846 .send_lphb_config_tcp_pkt_filter_cmd =
21847 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021848 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
21849 .send_lphb_config_udp_pkt_filter_cmd =
21850 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053021851 .send_enable_disable_packet_filter_cmd =
21852 send_enable_disable_packet_filter_cmd_tlv,
21853 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Wu Gao52c0b772018-05-17 16:14:00 +080021854#endif /* End of WLAN_POWER_MANAGEMENT_OFFLOAD */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053021855#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053021856 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
21857 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021858 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053021859 .send_roam_scan_offload_mode_cmd =
21860 send_roam_scan_offload_mode_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053021861#ifndef REMOVE_PKT_LOG
Govind Singh87542482016-06-08 19:40:11 +053021862 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
Nirav Shah66932f72018-05-17 16:58:12 +053021863#endif
Govind Singh87542482016-06-08 19:40:11 +053021864 .send_roam_scan_offload_ap_profile_cmd =
21865 send_roam_scan_offload_ap_profile_cmd_tlv,
21866#endif
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021867#ifdef WLAN_SUPPORT_GREEN_AP
21868 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
21869 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
Himanshu Agarwal157e4782018-01-24 22:24:17 +053021870 .extract_green_ap_egap_status_info =
21871 extract_green_ap_egap_status_info_tlv,
Himanshu Agarwal66d4a162018-01-10 14:21:53 +053021872#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053021873 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
21874 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021875 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
Paul Zhang92ab8d32017-12-08 16:08:00 +080021876 .send_wlm_latency_level_cmd = send_wlm_latency_level_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021877 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
Naveen Rawat42cd1e62017-05-13 15:56:57 -070021878#ifdef WLAN_FEATURE_CIF_CFR
21879 .send_oem_dma_cfg_cmd = send_oem_dma_cfg_cmd_tlv,
21880#endif
Sathish Kumarf396c722017-11-17 17:30:41 +053021881 .send_dbr_cfg_cmd = send_dbr_cfg_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021882 .send_dfs_phyerr_filter_offload_en_cmd =
21883 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021884 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
21885 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
21886 .send_del_ts_cmd = send_del_ts_cmd_tlv,
21887 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
21888 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021889 .send_process_add_periodic_tx_ptrn_cmd =
21890 send_process_add_periodic_tx_ptrn_cmd_tlv,
21891 .send_process_del_periodic_tx_ptrn_cmd =
21892 send_process_del_periodic_tx_ptrn_cmd_tlv,
21893 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
21894 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
21895 .send_set_app_type2_params_in_fw_cmd =
21896 send_set_app_type2_params_in_fw_cmd_tlv,
21897 .send_set_auto_shutdown_timer_cmd =
21898 send_set_auto_shutdown_timer_cmd_tlv,
21899 .send_nan_req_cmd = send_nan_req_cmd_tlv,
21900 .send_process_dhcpserver_offload_cmd =
21901 send_process_dhcpserver_offload_cmd_tlv,
21902 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
21903 .send_process_ch_avoid_update_cmd =
21904 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053021905 .send_pdev_set_regdomain_cmd =
21906 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021907 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
21908 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
21909 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
21910 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053021911 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053021912 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021913 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053021914 check_and_update_fw_version_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021915 .send_set_base_macaddr_indicate_cmd =
21916 send_set_base_macaddr_indicate_cmd_tlv,
21917 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
21918 .send_enable_specific_fw_logs_cmd =
21919 send_enable_specific_fw_logs_cmd_tlv,
21920 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053021921 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053021922 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080021923#ifdef WLAN_POLICY_MGR_ENABLE
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053021924 .send_pdev_set_dual_mac_config_cmd =
21925 send_pdev_set_dual_mac_config_cmd_tlv,
Srinivas Girigowda5029ae72018-02-15 14:30:05 -080021926#endif
Govind Singha4836fd2016-03-07 16:45:38 +053021927 .send_app_type1_params_in_fw_cmd =
21928 send_app_type1_params_in_fw_cmd_tlv,
21929 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
21930 .send_process_roam_synch_complete_cmd =
21931 send_process_roam_synch_complete_cmd_tlv,
21932 .send_unit_test_cmd = send_unit_test_cmd_tlv,
21933 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
21934 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053021935 .send_roam_scan_offload_scan_period_cmd =
21936 send_roam_scan_offload_scan_period_cmd_tlv,
21937 .send_roam_scan_offload_chan_list_cmd =
21938 send_roam_scan_offload_chan_list_cmd_tlv,
21939 .send_roam_scan_offload_rssi_change_cmd =
21940 send_roam_scan_offload_rssi_change_cmd_tlv,
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053021941#ifdef FEATURE_WLAN_APF
21942 .send_set_active_apf_mode_cmd = wmi_send_set_active_apf_mode_cmd_tlv,
21943 .send_apf_enable_cmd = wmi_send_apf_enable_cmd_tlv,
21944 .send_apf_write_work_memory_cmd =
21945 wmi_send_apf_write_work_memory_cmd_tlv,
21946 .send_apf_read_work_memory_cmd =
21947 wmi_send_apf_read_work_memory_cmd_tlv,
21948 .extract_apf_read_memory_resp_event =
21949 wmi_extract_apf_read_memory_resp_event_tlv,
21950#endif /* FEATURE_WLAN_APF */
Gupta, Kapil2e685982016-04-25 19:14:19 +053021951 .send_adapt_dwelltime_params_cmd =
21952 send_adapt_dwelltime_params_cmd_tlv,
Nitesh Shah52323d02017-05-22 15:49:00 +053021953 .send_dbs_scan_sel_params_cmd =
21954 send_dbs_scan_sel_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053021955 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053021956 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
21957 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
21958 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
21959 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
21960 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
21961 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
Sathish Kumar6011c742017-11-08 14:49:58 +053021962 .send_vdev_set_custom_aggr_size_cmd =
21963 send_vdev_set_custom_aggr_size_cmd_tlv,
Venkateswara Swamy Bandaru9983ac52017-12-22 17:16:19 +053021964 .send_vdev_set_qdepth_thresh_cmd =
21965 send_vdev_set_qdepth_thresh_cmd_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053021966 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
21967 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
21968 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053021969 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
21970 .send_smart_ant_set_training_info_cmd =
21971 send_smart_ant_set_training_info_cmd_tlv,
21972 .send_smart_ant_set_node_config_cmd =
21973 send_smart_ant_set_node_config_cmd_tlv,
21974 .send_set_atf_cmd = send_set_atf_cmd_tlv,
21975 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
21976 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053021977 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
21978 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
21979 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
21980 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
Sathish Kumar0ff69e42017-11-02 10:44:39 +053021981 .send_periodic_chan_stats_config_cmd =
21982 send_periodic_chan_stats_config_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053021983 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
21984 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
21985 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053021986 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
21987 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
21988 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
21989 .send_vdev_spectral_configure_cmd =
21990 send_vdev_spectral_configure_cmd_tlv,
21991 .send_vdev_spectral_enable_cmd =
21992 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053021993 .send_thermal_mitigation_param_cmd =
21994 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053021995 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
21996 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Vikram Kandukuri3bb482b2017-06-01 16:47:51 +053021997 .send_process_update_edca_param_cmd =
21998 send_process_update_edca_param_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053021999 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070022000 .send_set_country_cmd = send_set_country_cmd_tlv,
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022001 .send_bcn_offload_control_cmd = send_bcn_offload_control_cmd_tlv,
Gyanranjan Hazarika3f3b4712018-01-12 13:27:43 -080022002 .send_addba_send_cmd = send_addba_send_cmd_tlv,
22003 .send_delba_send_cmd = send_delba_send_cmd_tlv,
Gyanranjan Hazarikacd535f92018-01-17 19:29:45 -080022004 .send_addba_clearresponse_cmd = send_addba_clearresponse_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022005 .get_target_cap_from_service_ready = extract_service_ready_tlv,
22006 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
22007 .extract_host_mem_req = extract_host_mem_req_tlv,
22008 .save_service_bitmap = save_service_bitmap_tlv,
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022009 .save_ext_service_bitmap = save_ext_service_bitmap_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022010 .is_service_enabled = is_service_enabled_tlv,
22011 .save_fw_version = save_fw_version_in_service_ready_tlv,
22012 .ready_extract_init_status = ready_extract_init_status_tlv,
22013 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
Manoj Ekbotedd273902017-07-09 23:28:56 -070022014 .ready_extract_mac_addr_list = ready_extract_mac_addr_list_tlv,
Kiran Venkatappa094c24f2017-11-10 20:50:12 +053022015 .extract_ready_event_params = extract_ready_event_params_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022016 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
22017 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
Om Prakash Tripathif3ef42d2017-11-24 16:53:07 +053022018 .extract_vdev_delete_resp = extract_vdev_delete_resp_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022019 .extract_tbttoffset_update_params =
22020 extract_tbttoffset_update_params_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022021 .extract_ext_tbttoffset_update_params =
22022 extract_ext_tbttoffset_update_params_tlv,
22023 .extract_tbttoffset_num_vdevs =
22024 extract_tbttoffset_num_vdevs_tlv,
22025 .extract_ext_tbttoffset_num_vdevs =
22026 extract_ext_tbttoffset_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022027 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
22028 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
22029 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
22030 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080022031#ifdef CONVERGED_TDLS_ENABLE
22032 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
22033#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053022034 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022035 .extract_swba_num_vdevs = extract_swba_num_vdevs_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022036 .extract_swba_tim_info = extract_swba_tim_info_tlv,
22037 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080022038#ifdef CONVERGED_P2P_ENABLE
22039 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
22040 .extract_p2p_lo_stop_ev_param =
22041 extract_p2p_lo_stop_ev_param_tlv,
22042#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022043 .extract_offchan_data_tx_compl_param =
22044 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022045 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
22046 .extract_all_stats_count = extract_all_stats_counts_tlv,
22047 .extract_pdev_stats = extract_pdev_stats_tlv,
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022048 .extract_unit_test = extract_unit_test_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022049 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
22050 .extract_vdev_stats = extract_vdev_stats_tlv,
Naveen Rawatd2115722018-04-12 08:17:55 -070022051 .extract_per_chain_rssi_stats = extract_per_chain_rssi_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022052 .extract_peer_stats = extract_peer_stats_tlv,
Gurumoorthi Gnanasambandhanb5fb8362017-11-06 22:04:17 +053022053 .extract_bcn_stats = extract_bcn_stats_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053022054 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
22055 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
22056 .extract_chan_stats = extract_chan_stats_tlv,
22057 .extract_profile_ctx = extract_profile_ctx_tlv,
22058 .extract_profile_data = extract_profile_data_tlv,
22059 .extract_chan_info_event = extract_chan_info_event_tlv,
22060 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053022061 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022062#ifdef WLAN_FEATURE_DISA
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053022063 .send_encrypt_decrypt_send_cmd =
22064 send_encrypt_decrypt_send_cmd_tlv,
Nachiket Kukade03e7ab22017-12-20 17:28:29 +053022065 .extract_encrypt_decrypt_resp_event =
22066 extract_encrypt_decrypt_resp_event_tlv,
22067#endif
Manikandan Mohan31a13e22016-12-13 13:14:06 -080022068 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Jeff Johnson4783f902017-12-14 15:50:16 -080022069 .get_sar_limit_cmd = get_sar_limit_cmd_tlv,
22070 .extract_sar_limit_event = extract_sar_limit_event_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053022071 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022072 .send_multiple_vdev_restart_req_cmd =
22073 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053022074 .extract_service_ready_ext = extract_service_ready_ext_tlv,
22075 .extract_hw_mode_cap_service_ready_ext =
22076 extract_hw_mode_cap_service_ready_ext_tlv,
22077 .extract_mac_phy_cap_service_ready_ext =
22078 extract_mac_phy_cap_service_ready_ext_tlv,
22079 .extract_reg_cap_service_ready_ext =
22080 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumarf396c722017-11-17 17:30:41 +053022081 .extract_dbr_ring_cap_service_ready_ext =
22082 extract_dbr_ring_cap_service_ready_ext_tlv,
22083 .extract_dbr_buf_release_fixed = extract_dbr_buf_release_fixed_tlv,
22084 .extract_dbr_buf_release_entry = extract_dbr_buf_release_entry_tlv,
Edayilliam Jayadev92651222018-04-06 16:37:17 +053022085 .extract_dbr_buf_metadata = extract_dbr_buf_metadata_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053022086 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053022087 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053022088 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
22089 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
22090 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053022091 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022092 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022093 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022094 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053022095 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053022096 .extract_pdev_csa_switch_count_status =
22097 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022098 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
Shaakir Mohamed75208c32018-02-15 14:30:21 -080022099 .extract_pdev_tpc_config_ev_param =
22100 extract_pdev_tpc_config_ev_param_tlv,
nobeljf74583b2018-01-25 16:35:36 -080022101 .extract_nfcal_power_ev_param = extract_nfcal_power_ev_param_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053022102 .extract_wds_addr_event = extract_wds_addr_event_tlv,
22103 .extract_peer_sta_ps_statechange_ev =
22104 extract_peer_sta_ps_statechange_ev_tlv,
22105 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053022106 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080022107 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
22108 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022109 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053022110 extract_reg_chan_list_update_event_tlv,
22111 .extract_chainmask_tables =
22112 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022113 .extract_thermal_stats = extract_thermal_stats_tlv,
22114 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022115 .send_get_rcpi_cmd = send_get_rcpi_cmd_tlv,
22116 .extract_rcpi_response_event = extract_rcpi_response_event_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022117#ifdef DFS_COMPONENT_ENABLE
22118 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
22119 .extract_dfs_radar_detection_event =
22120 extract_dfs_radar_detection_event_tlv,
bings1ea12532017-12-18 16:56:53 +080022121 .extract_wlan_radar_event_info = extract_wlan_radar_event_info_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022122#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053022123 .convert_pdev_id_host_to_target =
22124 convert_host_pdev_id_to_target_pdev_id_legacy,
22125 .convert_pdev_id_target_to_host =
22126 convert_target_pdev_id_to_host_pdev_id_legacy,
Kiran Kumar Lokereb12cf5c2017-04-26 19:51:29 -070022127
22128 .send_start_11d_scan_cmd = send_start_11d_scan_cmd_tlv,
22129 .send_stop_11d_scan_cmd = send_stop_11d_scan_cmd_tlv,
22130 .extract_reg_11d_new_country_event =
22131 extract_reg_11d_new_country_event_tlv,
Abhijit Pradhand38a2692017-06-29 12:32:20 +053022132 .send_user_country_code_cmd = send_user_country_code_cmd_tlv,
Ganesh Kondabattini40252f52017-07-10 11:54:11 +053022133 .send_limit_off_chan_cmd =
22134 send_limit_off_chan_cmd_tlv,
Kiran Kumar Lokereec65bb42017-06-30 19:13:02 -070022135 .extract_reg_ch_avoid_event =
22136 extract_reg_ch_avoid_event_tlv,
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022137 .send_pdev_caldata_version_check_cmd =
22138 send_pdev_caldata_version_check_cmd_tlv,
22139 .extract_pdev_caldata_version_check_ev_param =
22140 extract_pdev_caldata_version_check_ev_param_tlv,
Anurag Chouhan97f00422017-09-11 14:56:30 +053022141 .send_set_arp_stats_req_cmd = send_set_arp_stats_req_cmd_tlv,
22142 .send_get_arp_stats_req_cmd = send_get_arp_stats_req_cmd_tlv,
Vignesh Viswanathan81bde492017-09-25 14:36:38 +053022143 .send_set_del_pmkid_cache_cmd = send_set_del_pmkid_cache_cmd_tlv,
22144#if defined(WLAN_FEATURE_FILS_SK)
22145 .send_roam_scan_hlp_cmd = send_roam_scan_send_hlp_cmd_tlv,
22146#endif
Naveen Rawata5817e72017-10-26 18:50:19 -070022147 .send_wow_timer_pattern_cmd = send_wow_timer_pattern_cmd_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022148#ifdef WLAN_FEATURE_NAN_CONVERGENCE
22149 .send_ndp_initiator_req_cmd = nan_ndp_initiator_req_tlv,
22150 .send_ndp_responder_req_cmd = nan_ndp_responder_req_tlv,
22151 .send_ndp_end_req_cmd = nan_ndp_end_req_tlv,
22152 .extract_ndp_initiator_rsp = extract_ndp_initiator_rsp_tlv,
22153 .extract_ndp_ind = extract_ndp_ind_tlv,
22154 .extract_ndp_confirm = extract_ndp_confirm_tlv,
22155 .extract_ndp_responder_rsp = extract_ndp_responder_rsp_tlv,
22156 .extract_ndp_end_rsp = extract_ndp_end_rsp_tlv,
22157 .extract_ndp_end_ind = extract_ndp_end_ind_tlv,
Naveen Rawatd42ce382018-01-09 17:54:41 -080022158 .extract_ndp_sch_update = extract_ndp_sch_update_tlv,
Naveen Rawat4f1e2ac2017-12-14 13:24:31 -080022159#endif
yeshwanth sriram guntuka07a15b82017-09-01 17:56:07 +053022160 .send_btm_config = send_btm_config_cmd_tlv,
Arif Hussainc5bfe072017-12-27 16:23:45 -080022161 .send_obss_detection_cfg_cmd = send_obss_detection_cfg_cmd_tlv,
Arif Hussain33d98502018-01-12 13:15:04 -080022162 .extract_obss_detection_info = extract_obss_detection_info_tlv,
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022163#ifdef WLAN_SUPPORT_FILS
22164 .send_vdev_fils_enable_cmd = send_vdev_fils_enable_cmd_tlv,
22165 .extract_swfda_vdev_id = extract_swfda_vdev_id_tlv,
22166 .send_fils_discovery_send_cmd = send_fils_discovery_send_cmd_tlv,
22167#endif /* WLAN_SUPPORT_FILS */
Vignesh Viswanathan7f057772018-01-18 19:06:40 +053022168 .send_offload_11k_cmd = send_offload_11k_cmd_tlv,
22169 .send_invoke_neighbor_report_cmd = send_invoke_neighbor_report_cmd_tlv,
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053022170 .wmi_pdev_id_conversion_enable = wmi_tlv_pdev_id_conversion_enable,
22171 .wmi_free_allocated_event = wmitlv_free_allocated_event_tlvs,
22172 .wmi_check_and_pad_event = wmitlv_check_and_pad_event_tlvs,
22173 .wmi_check_command_params = wmitlv_check_command_tlv_params,
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022174 .send_bss_color_change_enable_cmd =
22175 send_bss_color_change_enable_cmd_tlv,
22176 .send_obss_color_collision_cfg_cmd =
22177 send_obss_color_collision_cfg_cmd_tlv,
22178 .extract_obss_color_collision_info =
22179 extract_obss_color_collision_info_tlv,
Arif Hussaine0eb7302018-03-01 14:40:59 -080022180 .extract_comb_phyerr = extract_comb_phyerr_tlv,
22181 .extract_single_phyerr = extract_single_phyerr_tlv,
Naveen Rawat963ee942018-04-13 16:38:36 -070022182#ifdef QCA_SUPPORT_CP_STATS
22183 .extract_cca_stats = extract_cca_stats_tlv,
22184#endif
Govind Singh5eb51532016-03-09 11:34:12 +053022185};
22186
Govind Singhe7f2f342016-05-23 12:12:52 +053022187/**
22188 * populate_tlv_event_id() - populates wmi event ids
22189 *
22190 * @param event_ids: Pointer to hold event ids
22191 * Return: None
22192 */
22193static void populate_tlv_events_id(uint32_t *event_ids)
22194{
22195 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
22196 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
22197 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
22198 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22199 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
22200 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
22201 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
22202 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
22203 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
22204 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
22205 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
22206 event_ids[wmi_service_ready_ext_event_id] =
22207 WMI_SERVICE_READY_EXT_EVENTID;
22208 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
22209 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
22210 event_ids[wmi_vdev_install_key_complete_event_id] =
22211 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
22212 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
22213 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
22214
22215 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
22216 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
22217 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
22218 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
22219 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
22220 event_ids[wmi_peer_estimated_linkspeed_event_id] =
22221 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
22222 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053022223 event_ids[wmi_peer_delete_response_event_id] =
22224 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022225 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
22226 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
22227 event_ids[wmi_tbttoffset_update_event_id] =
22228 WMI_TBTTOFFSET_UPDATE_EVENTID;
Sathish Kumare5f0e0e2017-05-17 18:05:15 +053022229 event_ids[wmi_ext_tbttoffset_update_event_id] =
22230 WMI_TBTTOFFSET_EXT_UPDATE_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022231 event_ids[wmi_offload_bcn_tx_status_event_id] =
22232 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
22233 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
22234 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
22235 event_ids[wmi_mgmt_tx_completion_event_id] =
22236 WMI_MGMT_TX_COMPLETION_EVENTID;
nobeljf74583b2018-01-25 16:35:36 -080022237 event_ids[wmi_pdev_nfcal_power_all_channels_event_id] =
22238 WMI_PDEV_NFCAL_POWER_ALL_CHANNELS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022239 event_ids[wmi_tx_delba_complete_event_id] =
22240 WMI_TX_DELBA_COMPLETE_EVENTID;
22241 event_ids[wmi_tx_addba_complete_event_id] =
22242 WMI_TX_ADDBA_COMPLETE_EVENTID;
22243 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
22244
22245 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
22246
22247 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
22248 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
22249
22250 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
Padma, Santhosh Kumar9b21b052017-10-06 15:42:00 +053022251 event_ids[wmi_roam_synch_frame_event_id] = WMI_ROAM_SYNCH_FRAME_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022252
22253 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
22254
22255 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080022256 event_ids[wmi_p2p_lo_stop_event_id] =
22257 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022258 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
22259 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
Will Huangb661c4c2017-12-19 10:10:05 +080022260 event_ids[wmi_d0_wow_disable_ack_event_id] =
Govind Singhe7f2f342016-05-23 12:12:52 +053022261 WMI_D0_WOW_DISABLE_ACK_EVENTID;
22262 event_ids[wmi_wow_initial_wakeup_event_id] =
22263 WMI_WOW_INITIAL_WAKEUP_EVENTID;
22264
22265 event_ids[wmi_rtt_meas_report_event_id] =
22266 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
22267 event_ids[wmi_tsf_meas_report_event_id] =
22268 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
22269 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
22270 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
22271 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
22272 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
22273 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022274 event_ids[wmi_diag_event_id_log_supported_event_id] =
22275 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
22276 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
22277 event_ids[wmi_nlo_scan_complete_event_id] =
22278 WMI_NLO_SCAN_COMPLETE_EVENTID;
22279 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
22280 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
22281
22282 event_ids[wmi_gtk_offload_status_event_id] =
22283 WMI_GTK_OFFLOAD_STATUS_EVENTID;
22284 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
22285 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
22286 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
22287
22288 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
22289
22290 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
22291
22292 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
22293 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
22294 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
22295 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
22296 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
22297 event_ids[wmi_wlan_profile_data_event_id] =
22298 WMI_WLAN_PROFILE_DATA_EVENTID;
22299 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
22300 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
22301 event_ids[wmi_vdev_get_keepalive_event_id] =
22302 WMI_VDEV_GET_KEEPALIVE_EVENTID;
22303 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
22304
22305 event_ids[wmi_diag_container_event_id] =
22306 WMI_DIAG_DATA_CONTAINER_EVENTID;
22307
22308 event_ids[wmi_host_auto_shutdown_event_id] =
22309 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
22310
22311 event_ids[wmi_update_whal_mib_stats_event_id] =
22312 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
22313
22314 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
22315 event_ids[wmi_update_vdev_rate_stats_event_id] =
22316 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
22317
22318 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
Adil Saeed Musthafad2805962017-08-23 17:32:11 -070022319 event_ids[wmi_unit_test_event_id] = WMI_UNIT_TEST_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022320
22321 /** Set OCB Sched Response, deprecated */
22322 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
22323
22324 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
22325 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
22326 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
22327
22328 /* GPIO Event */
22329 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
22330 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
22331
22332 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
22333 event_ids[wmi_rfkill_state_change_event_id] =
22334 WMI_RFKILL_STATE_CHANGE_EVENTID;
22335
22336 /* TDLS Event */
22337 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
22338
22339 event_ids[wmi_batch_scan_enabled_event_id] =
22340 WMI_BATCH_SCAN_ENABLED_EVENTID;
22341 event_ids[wmi_batch_scan_result_event_id] =
22342 WMI_BATCH_SCAN_RESULT_EVENTID;
22343 /* OEM Event */
22344 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
22345 event_ids[wmi_oem_meas_report_event_id] =
22346 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
22347 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
22348
22349 /* NAN Event */
22350 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
22351
22352 /* LPI Event */
22353 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
22354 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
22355 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
22356
22357 /* ExtScan events */
22358 event_ids[wmi_extscan_start_stop_event_id] =
22359 WMI_EXTSCAN_START_STOP_EVENTID;
22360 event_ids[wmi_extscan_operation_event_id] =
22361 WMI_EXTSCAN_OPERATION_EVENTID;
22362 event_ids[wmi_extscan_table_usage_event_id] =
22363 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
22364 event_ids[wmi_extscan_cached_results_event_id] =
22365 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
22366 event_ids[wmi_extscan_wlan_change_results_event_id] =
22367 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
22368 event_ids[wmi_extscan_hotlist_match_event_id] =
22369 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
22370 event_ids[wmi_extscan_capabilities_event_id] =
22371 WMI_EXTSCAN_CAPABILITIES_EVENTID;
22372 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
22373 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
22374
22375 /* mDNS offload events */
22376 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
22377
22378 /* SAP Authentication offload events */
22379 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
22380 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
22381
22382 /** Out-of-context-of-bss (OCB) events */
22383 event_ids[wmi_ocb_set_config_resp_event_id] =
22384 WMI_OCB_SET_CONFIG_RESP_EVENTID;
22385 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
22386 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
22387 event_ids[wmi_dcc_get_stats_resp_event_id] =
22388 WMI_DCC_GET_STATS_RESP_EVENTID;
22389 event_ids[wmi_dcc_update_ndl_resp_event_id] =
22390 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
22391 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
22392 /* System-On-Chip events */
22393 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
22394 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
22395 event_ids[wmi_soc_hw_mode_transition_event_id] =
22396 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
22397 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
22398 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053022399 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053022400 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
22401 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053022402 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053022403 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
22404 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
22405 event_ids[wmi_peer_sta_ps_statechg_event_id] =
22406 WMI_PEER_STA_PS_STATECHG_EVENTID;
22407 event_ids[wmi_pdev_channel_hopping_event_id] =
22408 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053022409 event_ids[wmi_offchan_data_tx_completion_event] =
22410 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070022411 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
22412 event_ids[wmi_dfs_radar_detection_event_id] =
22413 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053022414 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Amar Singhal7db15c82017-05-19 16:39:34 -070022415 event_ids[wmi_11d_new_country_event_id] = WMI_11D_NEW_COUNTRY_EVENTID;
Om Prakash Tripathi53ed74b2017-09-06 15:22:04 +053022416 event_ids[wmi_pdev_tpc_event_id] = WMI_PDEV_TPC_EVENTID;
Anurag Chouhan97f00422017-09-11 14:56:30 +053022417 event_ids[wmi_get_arp_stats_req_id] = WMI_VDEV_GET_ARP_STAT_EVENTID;
Kiran Venkatappa7d739142017-09-01 17:02:34 +053022418 event_ids[wmi_service_available_event_id] =
22419 WMI_SERVICE_AVAILABLE_EVENTID;
Rajeev Kumar Sirasanagandlaab4275d2016-11-22 21:28:54 +053022420 event_ids[wmi_update_rcpi_event_id] = WMI_UPDATE_RCPI_EVENTID;
Balamurugan Mahalingamf2098292017-10-26 15:14:57 +053022421 event_ids[wmi_pdev_check_cal_version_event_id] = WMI_PDEV_CHECK_CAL_VERSION_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022422 /* NDP events */
22423 event_ids[wmi_ndp_initiator_rsp_event_id] =
22424 WMI_NDP_INITIATOR_RSP_EVENTID;
22425 event_ids[wmi_ndp_indication_event_id] = WMI_NDP_INDICATION_EVENTID;
22426 event_ids[wmi_ndp_confirm_event_id] = WMI_NDP_CONFIRM_EVENTID;
22427 event_ids[wmi_ndp_responder_rsp_event_id] =
22428 WMI_NDP_RESPONDER_RSP_EVENTID;
22429 event_ids[wmi_ndp_end_indication_event_id] =
22430 WMI_NDP_END_INDICATION_EVENTID;
22431 event_ids[wmi_ndp_end_rsp_event_id] = WMI_NDP_END_RSP_EVENTID;
Naveen Rawatd42ce382018-01-09 17:54:41 -080022432 event_ids[wmi_ndl_schedule_update_event_id] =
22433 WMI_NDL_SCHEDULE_UPDATE_EVENTID;
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022434
22435 event_ids[wmi_oem_response_event_id] = WMI_OEM_RESPONSE_EVENTID;
22436 event_ids[wmi_peer_stats_info_event_id] = WMI_PEER_STATS_INFO_EVENTID;
22437 event_ids[wmi_pdev_chip_power_stats_event_id] =
22438 WMI_PDEV_CHIP_POWER_STATS_EVENTID;
22439 event_ids[wmi_ap_ps_egap_info_event_id] = WMI_AP_PS_EGAP_INFO_EVENTID;
22440 event_ids[wmi_peer_assoc_conf_event_id] = WMI_PEER_ASSOC_CONF_EVENTID;
22441 event_ids[wmi_vdev_delete_resp_event_id] = WMI_VDEV_DELETE_RESP_EVENTID;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022442 event_ids[wmi_apf_capability_info_event_id] =
Mukul Sharma2c66f7e2017-11-03 19:26:54 +053022443 WMI_BPF_CAPABILIY_INFO_EVENTID;
22444 event_ids[wmi_vdev_encrypt_decrypt_data_rsp_event_id] =
22445 WMI_VDEV_ENCRYPT_DECRYPT_DATA_RESP_EVENTID;
22446 event_ids[wmi_report_rx_aggr_failure_event_id] =
22447 WMI_REPORT_RX_AGGR_FAILURE_EVENTID;
22448 event_ids[wmi_pdev_chip_pwr_save_failure_detect_event_id] =
22449 WMI_PDEV_CHIP_POWER_SAVE_FAILURE_DETECTED_EVENTID;
22450 event_ids[wmi_peer_antdiv_info_event_id] = WMI_PEER_ANTDIV_INFO_EVENTID;
22451 event_ids[wmi_pdev_set_hw_mode_rsp_event_id] =
22452 WMI_PDEV_SET_HW_MODE_RESP_EVENTID;
22453 event_ids[wmi_pdev_hw_mode_transition_event_id] =
22454 WMI_PDEV_HW_MODE_TRANSITION_EVENTID;
22455 event_ids[wmi_pdev_set_mac_config_resp_event_id] =
22456 WMI_PDEV_SET_MAC_CONFIG_RESP_EVENTID;
22457 event_ids[wmi_coex_bt_activity_event_id] =
22458 WMI_WLAN_COEX_BT_ACTIVITY_EVENTID;
22459 event_ids[wmi_mgmt_tx_bundle_completion_event_id] =
22460 WMI_MGMT_TX_BUNDLE_COMPLETION_EVENTID;
22461 event_ids[wmi_radio_tx_power_level_stats_event_id] =
22462 WMI_RADIO_TX_POWER_LEVEL_STATS_EVENTID;
22463 event_ids[wmi_report_stats_event_id] = WMI_REPORT_STATS_EVENTID;
Sathish Kumarf396c722017-11-17 17:30:41 +053022464 event_ids[wmi_dma_buf_release_event_id] =
22465 WMI_PDEV_DMA_RING_BUF_RELEASE_EVENTID;
Arif Hussainc5bfe072017-12-27 16:23:45 -080022466 event_ids[wmi_sap_obss_detection_report_event_id] =
22467 WMI_SAP_OBSS_DETECTION_REPORT_EVENTID;
Subrat Mishrad7c7a562017-09-27 14:41:20 +053022468 event_ids[wmi_host_swfda_event_id] = WMI_HOST_SWFDA_EVENTID;
Jeff Johnson4783f902017-12-14 15:50:16 -080022469 event_ids[wmi_sar_get_limits_event_id] = WMI_SAR_GET_LIMITS_EVENTID;
Arif Hussainec5cd3c2018-01-22 01:19:36 -080022470 event_ids[wmi_obss_color_collision_report_event_id] =
22471 WMI_OBSS_COLOR_COLLISION_DETECTION_EVENTID;
lifengfa983052018-04-03 19:01:45 +080022472 event_ids[wmi_pdev_div_rssi_antid_event_id] =
22473 WMI_PDEV_DIV_RSSI_ANTID_EVENTID;
Varun Reddy Yeturu2c8c9122018-04-17 11:04:27 -070022474 event_ids[wmi_twt_enable_complete_event_id] =
22475 WMI_TWT_ENABLE_COMPLETE_EVENTID;
Nachiket Kukadee06beaa2018-05-25 14:52:55 +053022476 event_ids[wmi_apf_get_vdev_work_memory_resp_event_id] =
22477 WMI_BPF_GET_VDEV_WORK_MEMORY_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022478}
22479
Soumya Bhat488092d2017-03-22 14:41:01 +053022480/**
22481 * populate_tlv_service() - populates wmi services
22482 *
22483 * @param wmi_service: Pointer to hold wmi_service
22484 * Return: None
22485 */
22486static void populate_tlv_service(uint32_t *wmi_service)
22487{
22488 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022489 wmi_service[wmi_service_ack_timeout] = WMI_SERVICE_ACK_TIMEOUT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022490 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
22491 wmi_service[wmi_service_roam_scan_offload] =
22492 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
22493 wmi_service[wmi_service_bcn_miss_offload] =
22494 WMI_SERVICE_BCN_MISS_OFFLOAD;
22495 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
22496 wmi_service[wmi_service_sta_advanced_pwrsave] =
22497 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
22498 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
22499 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
22500 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
22501 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
22502 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
22503 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
22504 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
22505 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
22506 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
22507 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
22508 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
22509 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
22510 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
22511 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
22512 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
22513 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
22514 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
22515 wmi_service[wmi_service_packet_power_save] =
22516 WMI_SERVICE_PACKET_POWER_SAVE;
22517 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
22518 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
22519 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
22520 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
22521 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
22522 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
22523 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
22524 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
22525 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
22526 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
22527 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
22528 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
22529 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
22530 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
22531 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
22532 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
22533 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
22534 wmi_service[wmi_service_mcc_bcn_interval_change] =
22535 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
22536 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
22537 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
22538 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
22539 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
22540 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
22541 wmi_service[wmi_service_lte_ant_share_support] =
22542 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
22543 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
22544 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
22545 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
22546 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
22547 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
22548 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
22549 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
22550 wmi_service[wmi_service_bcn_txrate_override] =
22551 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
22552 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
22553 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
22554 wmi_service[wmi_service_estimate_linkspeed] =
22555 WMI_SERVICE_ESTIMATE_LINKSPEED;
22556 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
22557 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
22558 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
22559 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
22560 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
22561 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
22562 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
22563 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
22564 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
22565 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
22566 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
22567 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
22568 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
22569 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
22570 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
22571 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
22572 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
22573 wmi_service[wmi_service_sap_auth_offload] =
22574 WMI_SERVICE_SAP_AUTH_OFFLOAD;
22575 wmi_service[wmi_service_dual_band_simultaneous_support] =
22576 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
22577 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
22578 wmi_service[wmi_service_ap_arpns_offload] =
22579 WMI_SERVICE_AP_ARPNS_OFFLOAD;
22580 wmi_service[wmi_service_per_band_chainmask_support] =
22581 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
22582 wmi_service[wmi_service_packet_filter_offload] =
22583 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
22584 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
22585 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
22586 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
22587 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
22588 wmi_service[wmi_service_multiple_vdev_restart] =
22589 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
22590
22591 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
22592 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
22593 wmi_service[wmi_service_smart_antenna_sw_support] =
22594 WMI_SERVICE_UNAVAILABLE;
22595 wmi_service[wmi_service_smart_antenna_hw_support] =
22596 WMI_SERVICE_UNAVAILABLE;
22597 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
Om Prakash Tripathi3bfb50c2017-11-07 14:37:22 +053022598 wmi_service[wmi_service_tt] = WMI_SERVICE_THERM_THROT;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022599 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053022600 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
22601 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
22602 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
22603 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
22604 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
22605 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
22606 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
22607 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053022608 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
22609 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
22610 wmi_service[wmi_service_periodic_chan_stat_support] =
Sathish Kumar0ff69e42017-11-02 10:44:39 +053022611 WMI_SERVICE_PERIODIC_CHAN_STAT_SUPPORT;
Soumya Bhat488092d2017-03-22 14:41:01 +053022612 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
22613 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
22614 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
22615 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
22616 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
22617 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022618 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
22619 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
22620 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
22621 wmi_service[wmi_service_unified_wow_capability] =
22622 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
22623 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Nachiket Kukadeae35a2c2018-05-22 12:17:15 +053022624 wmi_service[wmi_service_apf_offload] = WMI_SERVICE_BPF_OFFLOAD;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053022625 wmi_service[wmi_service_sync_delete_cmds] =
22626 WMI_SERVICE_SYNC_DELETE_CMDS;
22627 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
22628 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
22629 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
22630 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
22631 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
22632 wmi_service[wmi_service_deprecated_replace] =
22633 WMI_SERVICE_DEPRECATED_REPLACE;
22634 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
22635 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
22636 wmi_service[wmi_service_enhanced_mcast_filter] =
22637 WMI_SERVICE_ENHANCED_MCAST_FILTER;
22638 wmi_service[wmi_service_half_rate_quarter_rate_support] =
22639 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
22640 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
22641 wmi_service[wmi_service_p2p_listen_offload_support] =
22642 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
22643 wmi_service[wmi_service_mark_first_wakeup_packet] =
22644 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
22645 wmi_service[wmi_service_multiple_mcast_filter_set] =
22646 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
22647 wmi_service[wmi_service_host_managed_rx_reorder] =
22648 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
22649 wmi_service[wmi_service_flash_rdwr_support] =
22650 WMI_SERVICE_FLASH_RDWR_SUPPORT;
22651 wmi_service[wmi_service_wlan_stats_report] =
22652 WMI_SERVICE_WLAN_STATS_REPORT;
22653 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
22654 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
22655 wmi_service[wmi_service_dfs_phyerr_offload] =
22656 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
22657 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
22658 wmi_service[wmi_service_fw_mem_dump_support] =
22659 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
22660 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
22661 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
22662 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
22663 wmi_service[wmi_service_hw_data_filtering] =
22664 WMI_SERVICE_HW_DATA_FILTERING;
22665 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
22666 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Venkateswara Swamy Bandaru23e00ed2017-06-07 20:57:28 +053022667 wmi_service[wmi_service_chan_load_info] = WMI_SERVICE_CHAN_LOAD_INFO;
Soumya Bhat8db697d2017-08-29 18:49:13 +053022668 wmi_service[wmi_service_extended_nss_support] =
22669 WMI_SERVICE_EXTENDED_NSS_SUPPORT;
Om Prakash Tripathiae4413b2017-11-03 16:11:11 +053022670 wmi_service[wmi_service_widebw_scan] = WMI_SERVICE_SCAN_PHYMODE_SUPPORT;
Kiran Venkatappa7fe3afc2017-11-08 19:32:23 +053022671 wmi_service[wmi_service_bcn_offload_start_stop_support] =
22672 WMI_SERVICE_BCN_OFFLOAD_START_STOP_SUPPORT;
Kiran Venkatappa9c625d22017-11-17 17:08:02 +053022673 wmi_service[wmi_service_offchan_data_tid_support] =
22674 WMI_SERVICE_OFFCHAN_DATA_TID_SUPPORT;
Sathish Kumarf396c722017-11-17 17:30:41 +053022675 wmi_service[wmi_service_support_dma] =
22676 WMI_SERVICE_SUPPORT_DIRECT_DMA;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022677 wmi_service[wmi_service_8ss_tx_bfee] = WMI_SERVICE_8SS_TX_BFEE;
22678 wmi_service[wmi_service_fils_support] = WMI_SERVICE_FILS_SUPPORT;
22679 wmi_service[wmi_service_mawc_support] = WMI_SERVICE_MAWC_SUPPORT;
bings00d767c2018-05-31 15:33:02 +080022680 wmi_service[wmi_service_wow_wakeup_by_timer_pattern] =
22681 WMI_SERVICE_WOW_WAKEUP_BY_TIMER_PATTERN;
Arunk Khandavalli22a7d542018-02-08 11:52:23 +053022682 wmi_service[wmi_service_11k_neighbour_report_support] =
22683 WMI_SERVICE_11K_NEIGHBOUR_REPORT_SUPPORT;
Arif Hussaind9978f82018-02-09 16:42:05 -080022684 wmi_service[wmi_service_ap_obss_detection_offload] =
22685 WMI_SERVICE_AP_OBSS_DETECTION_OFFLOAD;
22686 wmi_service[wmi_service_bss_color_offload] =
22687 WMI_SERVICE_BSS_COLOR_OFFLOAD;
Padma, Santhosh Kumar5e751d42018-02-02 18:18:34 +053022688 wmi_service[wmi_service_gmac_offload_support] =
22689 WMI_SERVICE_GMAC_OFFLOAD_SUPPORT;
Zhu Jianmin3ed26de2018-04-19 17:55:30 +080022690 wmi_service[wmi_service_dual_beacon_on_single_mac_scc_support] =
22691 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_SCC_SUPPORT;
22692 wmi_service[wmi_service_dual_beacon_on_single_mac_mcc_support] =
22693 WMI_SERVICE_DUAL_BEACON_ON_SINGLE_MAC_MCC_SUPPORT;
Varun Reddy Yeturu94107f92018-05-30 15:31:13 -070022694 wmi_service[wmi_service_twt_requestor] = WMI_SERVICE_STA_TWT;
22695 wmi_service[wmi_service_twt_responder] = WMI_SERVICE_AP_TWT;
Nachiket Kukadeed200e52018-06-04 21:12:08 +053022696 wmi_service[wmi_service_listen_interval_offload_support] =
22697 WMI_SERVICE_LISTEN_INTERVAL_OFFLOAD_SUPPORT;
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022698
Soumya Bhat488092d2017-03-22 14:41:01 +053022699}
22700
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053022701#ifndef CONFIG_MCL
22702
Govind Singhe7f2f342016-05-23 12:12:52 +053022703/**
22704 * populate_pdev_param_tlv() - populates pdev params
22705 *
22706 * @param pdev_param: Pointer to hold pdev params
22707 * Return: None
22708 */
22709static void populate_pdev_param_tlv(uint32_t *pdev_param)
22710{
22711 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
22712 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
22713 pdev_param[wmi_pdev_param_txpower_limit2g] =
22714 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
22715 pdev_param[wmi_pdev_param_txpower_limit5g] =
22716 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
22717 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
22718 pdev_param[wmi_pdev_param_beacon_gen_mode] =
22719 WMI_PDEV_PARAM_BEACON_GEN_MODE;
22720 pdev_param[wmi_pdev_param_beacon_tx_mode] =
22721 WMI_PDEV_PARAM_BEACON_TX_MODE;
22722 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
22723 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
22724 pdev_param[wmi_pdev_param_protection_mode] =
22725 WMI_PDEV_PARAM_PROTECTION_MODE;
22726 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
22727 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
22728 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
22729 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
22730 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
22731 pdev_param[wmi_pdev_param_sta_kickout_th] =
22732 WMI_PDEV_PARAM_STA_KICKOUT_TH;
22733 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
22734 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
22735 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
22736 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
22737 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
22738 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
22739 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
22740 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
22741 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
22742 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
22743 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
22744 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
22745 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
22746 pdev_param[wmi_pdev_param_ltr_sleep_override] =
22747 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
22748 pdev_param[wmi_pdev_param_ltr_rx_override] =
22749 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
22750 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
22751 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
22752 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
22753 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
22754 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
22755 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
22756 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
22757 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
22758 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
22759 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
22760 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
22761 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
22762 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
22763 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
22764 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
22765 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
22766 pdev_param[wmi_pdev_param_peer_stats_update_period] =
22767 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
22768 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
22769 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
22770 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
22771 pdev_param[wmi_pdev_param_arp_ac_override] =
22772 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
22773 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
22774 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
22775 pdev_param[wmi_pdev_param_ani_poll_period] =
22776 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
22777 pdev_param[wmi_pdev_param_ani_listen_period] =
22778 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
22779 pdev_param[wmi_pdev_param_ani_ofdm_level] =
22780 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
22781 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
22782 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
22783 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
22784 pdev_param[wmi_pdev_param_idle_ps_config] =
22785 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
22786 pdev_param[wmi_pdev_param_power_gating_sleep] =
22787 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
22788 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
22789 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
22790 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
22791 pdev_param[wmi_pdev_param_hw_rfkill_config] =
22792 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
22793 pdev_param[wmi_pdev_param_low_power_rf_enable] =
22794 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
22795 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
22796 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
22797 pdev_param[wmi_pdev_param_power_collapse_enable] =
22798 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
22799 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
22800 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
22801 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
22802 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
22803 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
22804 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
22805 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
22806 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
22807 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
22808 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
22809 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
22810 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
22811 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
22812 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
22813 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
22814 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
22815 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
22816 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
22817 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
22818 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
22819 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
22820 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
22821 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
22822 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
22823 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
22824 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
22825 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
22826 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
22827 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
22828 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
22829 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
22830 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
22831 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
22832 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
22833 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
22834 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
22835 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
22836 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
22837 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
22838 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
22839 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
22840 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
22841 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
22842 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022843 pdev_param[wmi_pdev_param_rx_filter] = WMI_PDEV_PARAM_RX_FILTER;
22844 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] =
22845 WMI_PDEV_SET_MCAST_TO_UCAST_TID;
Sathish Kumard99852a2017-07-08 12:32:27 +053022846 pdev_param[wmi_pdev_param_mgmt_retry_limit] =
22847 WMI_PDEV_PARAM_MGMT_RETRY_LIMIT;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022848 pdev_param[wmi_pdev_param_aggr_burst] = WMI_PDEV_PARAM_AGGR_BURST;
Govind Singhe7f2f342016-05-23 12:12:52 +053022849 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022850 WMI_PDEV_PEER_STA_PS_STATECHG_ENABLE;
22851 pdev_param[wmi_pdev_param_proxy_sta_mode] =
22852 WMI_PDEV_PARAM_PROXY_STA_MODE;
22853 pdev_param[wmi_pdev_param_mu_group_policy] =
22854 WMI_PDEV_PARAM_MU_GROUP_POLICY;
22855 pdev_param[wmi_pdev_param_noise_detection] =
22856 WMI_PDEV_PARAM_NOISE_DETECTION;
22857 pdev_param[wmi_pdev_param_noise_threshold] =
22858 WMI_PDEV_PARAM_NOISE_THRESHOLD;
22859 pdev_param[wmi_pdev_param_dpd_enable] = WMI_PDEV_PARAM_DPD_ENABLE;
22860 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] =
22861 WMI_PDEV_PARAM_SET_MCAST_BCAST_ECHO;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022862 pdev_param[wmi_pdev_param_atf_strict_sch] =
22863 WMI_PDEV_PARAM_ATF_STRICT_SCH;
22864 pdev_param[wmi_pdev_param_atf_sched_duration] =
22865 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022866 pdev_param[wmi_pdev_param_ant_plzn] = WMI_PDEV_PARAM_ANT_PLZN;
22867 pdev_param[wmi_pdev_param_sensitivity_level] =
22868 WMI_PDEV_PARAM_SENSITIVITY_LEVEL;
22869 pdev_param[wmi_pdev_param_signed_txpower_2g] =
22870 WMI_PDEV_PARAM_SIGNED_TXPOWER_2G;
22871 pdev_param[wmi_pdev_param_signed_txpower_5g] =
22872 WMI_PDEV_PARAM_SIGNED_TXPOWER_5G;
Karunakar Dasineni39a5ff72017-08-10 12:12:28 -070022873 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] =
22874 WMI_PDEV_PARAM_ENABLE_PER_TID_AMSDU;
22875 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] =
22876 WMI_PDEV_PARAM_ENABLE_PER_TID_AMPDU;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022877 pdev_param[wmi_pdev_param_cca_threshold] =
22878 WMI_PDEV_PARAM_CCA_THRESHOLD;
22879 pdev_param[wmi_pdev_param_rts_fixed_rate] =
22880 WMI_PDEV_PARAM_RTS_FIXED_RATE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022881 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022882 pdev_param[wmi_pdev_param_pdev_reset] = WMI_PDEV_PARAM_PDEV_RESET;
22883 pdev_param[wmi_pdev_param_wapi_mbssid_offset] =
22884 WMI_PDEV_PARAM_WAPI_MBSSID_OFFSET;
22885 pdev_param[wmi_pdev_param_arp_srcaddr] =
22886 WMI_PDEV_PARAM_ARP_DBG_SRCADDR;
22887 pdev_param[wmi_pdev_param_arp_dstaddr] =
22888 WMI_PDEV_PARAM_ARP_DBG_DSTADDR;
22889 pdev_param[wmi_pdev_param_txpower_decr_db] =
22890 WMI_PDEV_PARAM_TXPOWER_DECR_DB;
Govind Singhe7f2f342016-05-23 12:12:52 +053022891 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
22892 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022893 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
22894 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053022895 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022896 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022897 pdev_param[wmi_pdev_param_cust_txpower_scale] =
22898 WMI_PDEV_PARAM_CUST_TXPOWER_SCALE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053022899 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
22900 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022901 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
22902 WMI_UNAVAILABLE_PARAM;
22903 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
22904 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022905 pdev_param[wmi_pdev_param_antenna_gain] = WMI_PDEV_PARAM_ANTENNA_GAIN;
22906 pdev_param[wmi_pdev_param_block_interbss] =
22907 WMI_PDEV_PARAM_BLOCK_INTERBSS;
Govind Singhe7f2f342016-05-23 12:12:52 +053022908 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022909 WMI_PDEV_PARAM_SET_DISABLE_RESET_CMDID;
22910 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] =
22911 WMI_PDEV_PARAM_SET_MSDU_TTL_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053022912 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
Sathish Kumarfd414b92017-08-24 13:32:49 +053022913 WMI_PDEV_PARAM_TXBF_SOUND_PERIOD_CMDID;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053022914 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
22915 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Sathish Kumarfd414b92017-08-24 13:32:49 +053022916 pdev_param[wmi_pdev_param_en_stats] = WMI_PDEV_PARAM_EN_STATS;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053022917 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
22918 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053022919 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
22920 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
22921 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
22922 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
22923 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
22924 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
22925 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
22926 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
22927 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
22928 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
22929 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
22930 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
22931 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
22932 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
22933 pdev_param[wmi_pdev_param_fast_channel_reset] =
22934 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
22935 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Sathish Kumareefe27e2017-10-04 09:58:00 +053022936 pdev_param[wmi_pdev_param_tx_ack_timeout] = WMI_PDEV_PARAM_ACK_TIMEOUT;
Shiva Krishna Pittala42a46612018-02-16 21:28:40 +053022937 pdev_param[wmi_pdev_param_cck_tx_enable] = WMI_PDEV_PARAM_CCK_TX_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053022938}
22939
22940/**
22941 * populate_vdev_param_tlv() - populates vdev params
22942 *
22943 * @param vdev_param: Pointer to hold vdev params
22944 * Return: None
22945 */
22946static void populate_vdev_param_tlv(uint32_t *vdev_param)
22947{
22948 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
22949 vdev_param[wmi_vdev_param_fragmentation_threshold] =
22950 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
22951 vdev_param[wmi_vdev_param_beacon_interval] =
22952 WMI_VDEV_PARAM_BEACON_INTERVAL;
22953 vdev_param[wmi_vdev_param_listen_interval] =
22954 WMI_VDEV_PARAM_LISTEN_INTERVAL;
22955 vdev_param[wmi_vdev_param_multicast_rate] =
22956 WMI_VDEV_PARAM_MULTICAST_RATE;
22957 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
22958 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
22959 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
22960 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
22961 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
22962 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
22963 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
22964 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
22965 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
22966 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
22967 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
22968 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
22969 vdev_param[wmi_vdev_param_bmiss_count_max] =
22970 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
22971 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
22972 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
22973 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
22974 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
22975 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
22976 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
22977 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
22978 vdev_param[wmi_vdev_param_disable_htprotection] =
22979 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
22980 vdev_param[wmi_vdev_param_sta_quickkickout] =
22981 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
22982 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
22983 vdev_param[wmi_vdev_param_protection_mode] =
22984 WMI_VDEV_PARAM_PROTECTION_MODE;
22985 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
22986 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
22987 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
22988 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
22989 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
22990 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
22991 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
22992 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
22993 vdev_param[wmi_vdev_param_bcast_data_rate] =
22994 WMI_VDEV_PARAM_BCAST_DATA_RATE;
22995 vdev_param[wmi_vdev_param_mcast_data_rate] =
22996 WMI_VDEV_PARAM_MCAST_DATA_RATE;
22997 vdev_param[wmi_vdev_param_mcast_indicate] =
22998 WMI_VDEV_PARAM_MCAST_INDICATE;
22999 vdev_param[wmi_vdev_param_dhcp_indicate] =
23000 WMI_VDEV_PARAM_DHCP_INDICATE;
23001 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
23002 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
23003 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
23004 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
23005 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
23006 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
23007 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
23008 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
23009 vdev_param[wmi_vdev_param_ap_enable_nawds] =
23010 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
23011 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
23012 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
23013 vdev_param[wmi_vdev_param_packet_powersave] =
23014 WMI_VDEV_PARAM_PACKET_POWERSAVE;
23015 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
23016 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
23017 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
23018 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
23019 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
23020 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
23021 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
23022 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
23023 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
23024 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
23025 vdev_param[wmi_vdev_param_early_rx_slop_step] =
23026 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
23027 vdev_param[wmi_vdev_param_early_rx_init_slop] =
23028 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
23029 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
23030 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
23031 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
23032 vdev_param[wmi_vdev_param_snr_num_for_cal] =
23033 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
23034 vdev_param[wmi_vdev_param_roam_fw_offload] =
23035 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
23036 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
23037 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
23038 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
23039 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
23040 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
23041 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
23042 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
23043 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
23044 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
23045 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
23046 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
23047 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
23048 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
23049 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
23050 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
23051 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
23052 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
23053 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
23054 vdev_param[wmi_vdev_param_inactivity_cnt] =
23055 WMI_VDEV_PARAM_INACTIVITY_CNT;
23056 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
23057 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
23058 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
23059 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
23060 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
23061 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
23062 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
23063 vdev_param[wmi_vdev_param_rx_leak_window] =
23064 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
23065 vdev_param[wmi_vdev_param_stats_avg_factor] =
23066 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
23067 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
23068 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
23069 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
23070 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
23071 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
23072 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053023073 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
23074 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053023075 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080023076 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
23077 vdev_param[wmi_vdev_param_he_range_ext_enable] =
23078 WMI_VDEV_PARAM_HE_RANGE_EXT;
23079 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
23080 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Gyanranjan Hazarikadc75d1c2017-10-13 12:36:24 -070023081 vdev_param[wmi_vdev_param_set_heop] = WMI_VDEV_PARAM_HEOPS_0_31;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053023082 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
23083 vdev_param[wmi_vdev_param_dtim_enable_cts] =
23084 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
23085 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
23086 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
23087 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
23088 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053023089 vdev_param[wmi_vdev_param_mcast2ucast_set] =
23090 WMI_VDEV_PARAM_MCAST2UCAST_SET;
23091 vdev_param[wmi_vdev_param_rc_num_retries] =
23092 WMI_VDEV_PARAM_RC_NUM_RETRIES;
23093 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
23094 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
23095 vdev_param[wmi_vdev_param_rts_fixed_rate] =
23096 WMI_VDEV_PARAM_RTS_FIXED_RATE;
23097 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
23098 vdev_param[wmi_vdev_param_vht80_ratemask] =
23099 WMI_VDEV_PARAM_VHT80_RATEMASK;
23100 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
23101 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
23102 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023103 vdev_param[wmi_vdev_param_set_he_ltf] =
23104 WMI_VDEV_PARAM_HE_LTF;
Anirban Sirkhellc6d72b92017-10-26 13:40:41 +053023105 vdev_param[wmi_vdev_param_disable_cabq] =
23106 WMI_VDEV_PARAM_DISABLE_CABQ;
Sathish Kumar6011c742017-11-08 14:49:58 +053023107 vdev_param[wmi_vdev_param_rate_dropdown_bmap] =
23108 WMI_VDEV_PARAM_RATE_DROPDOWN_BMAP;
Rhythm Patwa8cdcf672018-02-15 13:22:39 -080023109 vdev_param[wmi_vdev_param_set_ba_mode] =
23110 WMI_VDEV_PARAM_BA_MODE;
Neil Zhaod32a7bd2018-01-10 17:00:04 -080023111 vdev_param[wmi_vdev_param_capabilities] =
23112 WMI_VDEV_PARAM_CAPABILITIES;
Gyanranjan Hazarika32f00022018-03-13 17:09:08 -070023113 vdev_param[wmi_vdev_param_autorate_misc_cfg] =
23114 WMI_VDEV_PARAM_AUTORATE_MISC_CFG;
Govind Singhe7f2f342016-05-23 12:12:52 +053023115}
23116#endif
23117
Govind Singh5eb51532016-03-09 11:34:12 +053023118/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023119 * populate_target_defines_tlv() - Populate target defines and params
23120 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053023121 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023122 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053023123 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053023124#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023125static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053023126{
Govind Singhe7f2f342016-05-23 12:12:52 +053023127 populate_pdev_param_tlv(wmi_handle->pdev_param);
23128 populate_vdev_param_tlv(wmi_handle->vdev_param);
23129}
23130#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023131static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
23132{ }
23133#endif
23134
23135/**
Zhang Qian537fca62018-01-03 16:33:24 +080023136 * wmi_ocb_ut_attach() - Attach OCB test framework
23137 * @wmi_handle: wmi handle
23138 *
23139 * Return: None
23140 */
23141#ifdef WLAN_OCB_UT
23142void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle);
23143#else
23144static inline void wmi_ocb_ut_attach(struct wmi_unified *wmi_handle)
23145{
23146 return;
23147}
23148#endif
23149
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053023150/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023151 * wmi_tlv_attach() - Attach TLV APIs
23152 *
23153 * Return: None
23154 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023155void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053023156{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053023157 wmi_handle->ops = &tlv_ops;
Zhang Qian537fca62018-01-03 16:33:24 +080023158 wmi_ocb_ut_attach(wmi_handle);
Pratik Gandhicf3b8b92018-02-05 17:22:41 +053023159 wmi_handle->soc->svc_ids = &multi_svc_ids[0];
Govind Singhecf03cd2016-05-12 12:45:51 +053023160#ifdef WMI_INTERFACE_EVENT_LOGGING
Rakesh Pillai05110462017-12-27 14:08:59 +053023161 /* Skip saving WMI_CMD_HDR and TLV HDR */
23162 wmi_handle->log_info.buf_offset_command = 8;
23163 /* WMI_CMD_HDR is already stripped, skip saving TLV HDR */
Govind Singhecf03cd2016-05-12 12:45:51 +053023164 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053023165#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053023166 populate_tlv_events_id(wmi_handle->wmi_events);
Sourav Mohapatraa7b454d2017-12-03 11:44:44 +053023167 populate_tlv_service(wmi_handle->services);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053023168 populate_target_defines_tlv(wmi_handle);
Kiran Venkatappa136986d2018-02-05 10:56:43 +053023169 wmi_twt_attach_tlv(wmi_handle);
Wen Gongf60f11e2018-05-18 16:03:41 +080023170 wmi_extscan_attach_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053023171}
Manikandan Mohan3dc8c512018-03-01 16:23:30 -080023172qdf_export_symbol(wmi_tlv_attach);
Pratik Gandhi67da1bb2018-01-30 19:05:41 +053023173
23174/**
23175 * wmi_tlv_init() - Initialize WMI TLV module by registering TLV attach routine
23176 *
23177 * Return: None
23178 */
23179void wmi_tlv_init(void)
23180{
23181 wmi_unified_register_module(WMI_TLV_TARGET, &wmi_tlv_attach);
23182}