blob: af28a6858843431dd6df94d8c2f09cf46a591f85 [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Paul Zhangd19abd82017-01-04 16:45:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Wu Gaocd3a8512017-03-13 20:17:34 +080033#ifdef CONVERGED_P2P_ENABLE
34#include "wlan_p2p_public_struct.h"
35#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053036#include <wlan_utility.h>
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053037
38/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
39 * buffer.
40 * @cmd: pointer target vdev create command buffer
41 * @param: pointer host params for vdev create
42 *
43 * Return: None
44 */
45#ifdef CONFIG_MCL
46static inline void copy_vdev_create_pdev_id(
47 wmi_vdev_create_cmd_fixed_param * cmd,
48 struct vdev_create_params *param)
49{
50 cmd->pdev_id = WMI_PDEV_ID_SOC;
51}
52#else
53static inline void copy_vdev_create_pdev_id(
54 wmi_vdev_create_cmd_fixed_param * cmd,
55 struct vdev_create_params *param)
56{
57 cmd->pdev_id = param->pdev_id;
58}
59#endif
60
Govind Singh5eb51532016-03-09 11:34:12 +053061/**
62 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
63 * @wmi_handle: wmi handle
64 * @param: pointer to hold vdev create parameter
65 * @macaddr: vdev mac address
66 *
Govind Singhe7f2f342016-05-23 12:12:52 +053067 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053068 */
Sathish Kumarfd347372017-02-13 12:29:09 +053069static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053070 uint8_t macaddr[IEEE80211_ADDR_LEN],
71 struct vdev_create_params *param)
72{
73 wmi_vdev_create_cmd_fixed_param *cmd;
74 wmi_buf_t buf;
75 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053076 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070077 int num_bands = 2;
78 uint8_t *buf_ptr;
79 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053080
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070081 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053082 buf = wmi_buf_alloc(wmi_handle, len);
83 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053084 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053085 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053086 }
87 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
88 WMITLV_SET_HDR(&cmd->tlv_header,
89 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
90 WMITLV_GET_STRUCT_TLVLEN
91 (wmi_vdev_create_cmd_fixed_param));
92 cmd->vdev_id = param->if_id;
93 cmd->vdev_type = param->type;
94 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070095 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053096 copy_vdev_create_pdev_id(cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +053097 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +053098 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +053099 __func__, param->if_id,
100 macaddr[0], macaddr[1], macaddr[2],
101 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700102 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
103 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
104 (num_bands * sizeof(wmi_vdev_txrx_streams)));
105 buf_ptr += WMI_TLV_HDR_SIZE;
106
Govind Singh224a7312016-06-21 14:33:26 +0530107 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700108 param->type, param->subtype,
109 param->nss_2g, param->nss_5g);
110 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
111 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
112 txrx_streams->supported_tx_streams = param->nss_2g;
113 txrx_streams->supported_rx_streams = param->nss_2g;
114 WMITLV_SET_HDR(&txrx_streams->tlv_header,
115 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
116 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
117
118 txrx_streams++;
119 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
120 txrx_streams->supported_tx_streams = param->nss_5g;
121 txrx_streams->supported_rx_streams = param->nss_5g;
122 WMITLV_SET_HDR(&txrx_streams->tlv_header,
123 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
124 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530125 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530126 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530127 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530128 wmi_buf_free(buf);
129 }
130
131 return ret;
132}
133
134/**
135 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
136 * @wmi_handle: wmi handle
137 * @if_id: vdev id
138 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530139 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530140 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530141static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530142 uint8_t if_id)
143{
144 wmi_vdev_delete_cmd_fixed_param *cmd;
145 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530146 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530147
148 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
149 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530150 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530151 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530152 }
153
154 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
155 WMITLV_SET_HDR(&cmd->tlv_header,
156 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
157 WMITLV_GET_STRUCT_TLVLEN
158 (wmi_vdev_delete_cmd_fixed_param));
159 cmd->vdev_id = if_id;
160 ret = wmi_unified_cmd_send(wmi_handle, buf,
161 sizeof(wmi_vdev_delete_cmd_fixed_param),
162 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530163 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530164 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530165 wmi_buf_free(buf);
166 }
Govind Singhb53420c2016-03-09 14:32:57 +0530167 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530168
169 return ret;
170}
171
172/**
173 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
174 * @wmi: wmi handle
175 * @vdev_id: vdev id
176 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530177 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530178 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530179static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530180 uint8_t vdev_id)
181{
182 wmi_vdev_stop_cmd_fixed_param *cmd;
183 wmi_buf_t buf;
184 int32_t len = sizeof(*cmd);
185
186 buf = wmi_buf_alloc(wmi, len);
187 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530188 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530189 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530190 }
191 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
192 WMITLV_SET_HDR(&cmd->tlv_header,
193 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
194 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
195 cmd->vdev_id = vdev_id;
196 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530197 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530198 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530199 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530200 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530201 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530202
203 return 0;
204}
205
206/**
207 * send_vdev_down_cmd_tlv() - send vdev down command to fw
208 * @wmi: wmi handle
209 * @vdev_id: vdev id
210 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530211 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530212 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530213static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530214{
215 wmi_vdev_down_cmd_fixed_param *cmd;
216 wmi_buf_t buf;
217 int32_t len = sizeof(*cmd);
218
219 buf = wmi_buf_alloc(wmi, len);
220 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530221 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530222 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530223 }
224 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
225 WMITLV_SET_HDR(&cmd->tlv_header,
226 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
227 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
228 cmd->vdev_id = vdev_id;
229 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530230 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530231 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530232 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530233 }
Govind Singhb53420c2016-03-09 14:32:57 +0530234 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530235
236 return 0;
237}
238
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530239#ifdef CONFIG_MCL
240static inline void copy_channel_info(
241 wmi_vdev_start_request_cmd_fixed_param * cmd,
242 wmi_channel *chan,
243 struct vdev_start_params *req)
244{
245 chan->mhz = req->chan_freq;
246
247 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
248
249 chan->band_center_freq1 = req->band_center_freq1;
250 chan->band_center_freq2 = req->band_center_freq2;
251
252 if (req->is_half_rate)
253 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
254 else if (req->is_quarter_rate)
255 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
256
Naveen Rawat44f2f432016-12-01 12:58:57 -0800257 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530258 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
259 cmd->disable_hw_ack = req->dis_hw_ack;
260 }
261
262 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
263 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
264
265}
266#else
267static inline void copy_channel_info(
268 wmi_vdev_start_request_cmd_fixed_param * cmd,
269 wmi_channel *chan,
270 struct vdev_start_params *req)
271{
272 chan->mhz = req->channel.mhz;
273
274 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
275
276 chan->band_center_freq1 = req->channel.cfreq1;
277 chan->band_center_freq2 = req->channel.cfreq2;
278
279 if (req->channel.half_rate)
280 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
281 else if (req->channel.quarter_rate)
282 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
283
284 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530285 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530286 cmd->disable_hw_ack = req->disable_hw_ack;
287 }
288
Krishna Rao0b952ea2017-03-20 13:30:10 +0530289 if (req->channel.dfs_set_cfreq2)
290 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
291
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530292 /* FIXME: Find out min, max and regulatory power levels */
293 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
294 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
295
296}
297#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530298/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530299 * send_vdev_start_cmd_tlv() - send vdev start request to fw
300 * @wmi_handle: wmi handle
301 * @req: vdev start params
302 *
303 * Return: QDF status
304 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530305static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530306 struct vdev_start_params *req)
307{
308 wmi_vdev_start_request_cmd_fixed_param *cmd;
309 wmi_buf_t buf;
310 wmi_channel *chan;
311 int32_t len, ret;
312 uint8_t *buf_ptr;
313
314 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
315 buf = wmi_buf_alloc(wmi_handle, len);
316 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530317 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530318 return QDF_STATUS_E_NOMEM;
319 }
320 buf_ptr = (uint8_t *) wmi_buf_data(buf);
321 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
322 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
323 WMITLV_SET_HDR(&cmd->tlv_header,
324 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
325 WMITLV_GET_STRUCT_TLVLEN
326 (wmi_vdev_start_request_cmd_fixed_param));
327 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
328 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
329 cmd->vdev_id = req->vdev_id;
330
331 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530332 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530333
334 cmd->beacon_interval = req->beacon_intval;
335 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530336
337 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530338 cmd->beacon_interval = req->beacon_intval;
339 cmd->dtim_period = req->dtim_period;
340
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530341 /* Copy the SSID */
342 if (req->ssid.length) {
343 if (req->ssid.length < sizeof(cmd->ssid.ssid))
344 cmd->ssid.ssid_len = req->ssid.length;
345 else
346 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
347 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
348 cmd->ssid.ssid_len);
349 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530350
351 if (req->hidden_ssid)
352 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
353
354 if (req->pmf_enabled)
355 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530356 }
357
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530358 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530359 cmd->preferred_rx_streams = req->preferred_rx_streams;
360 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700361 cmd->cac_duration_ms = req->cac_duration_ms;
362 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700363 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530364
365 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
366 sizeof(wmi_channel));
367 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
368 cmd->num_noa_descriptors *
369 sizeof(wmi_p2p_noa_descriptor));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800370 WMI_LOGA("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530371 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
372 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700373 "Tx SS %d, Rx SS %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800374 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530375 req->is_dfs, req->beacon_intval, cmd->dtim_period,
376 chan->band_center_freq1, chan->band_center_freq2,
377 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700378 req->preferred_tx_streams, req->preferred_rx_streams,
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700379 req->cac_duration_ms, req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530380
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530381 if (req->is_restart)
382 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
383 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530384 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530385 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
386 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530387 if (ret) {
388 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530389 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530390 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530391 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530392
393 return QDF_STATUS_SUCCESS;
394}
395
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396/**
397 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
398 * @wmi_handle: wmi handle
399 * @restart_params: vdev restart params
400 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530401 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530402 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530403static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530404 struct hidden_ssid_vdev_restart_params *restart_params)
405{
406 wmi_vdev_start_request_cmd_fixed_param *cmd;
407 wmi_buf_t buf;
408 wmi_channel *chan;
409 int32_t len;
410 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530411 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530412
413 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
414 buf = wmi_buf_alloc(wmi_handle, len);
415 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530416 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530417 return QDF_STATUS_E_NOMEM;
418 }
419 buf_ptr = (uint8_t *) wmi_buf_data(buf);
420 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
421 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
422
423 WMITLV_SET_HDR(&cmd->tlv_header,
424 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
425 WMITLV_GET_STRUCT_TLVLEN
426 (wmi_vdev_start_request_cmd_fixed_param));
427
428 WMITLV_SET_HDR(&chan->tlv_header,
429 WMITLV_TAG_STRUC_wmi_channel,
430 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
431
432 cmd->vdev_id = restart_params->session_id;
433 cmd->ssid.ssid_len = restart_params->ssid_len;
434 qdf_mem_copy(cmd->ssid.ssid,
435 restart_params->ssid,
436 cmd->ssid.ssid_len);
437 cmd->flags = restart_params->flags;
438 cmd->requestor_id = restart_params->requestor_id;
439 cmd->disable_hw_ack = restart_params->disable_hw_ack;
440
441 chan->mhz = restart_params->mhz;
442 chan->band_center_freq1 =
443 restart_params->band_center_freq1;
444 chan->band_center_freq2 =
445 restart_params->band_center_freq2;
446 chan->info = restart_params->info;
447 chan->reg_info_1 = restart_params->reg_info_1;
448 chan->reg_info_2 = restart_params->reg_info_2;
449
450 cmd->num_noa_descriptors = 0;
451 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
452 sizeof(wmi_channel));
453 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
454 cmd->num_noa_descriptors *
455 sizeof(wmi_p2p_noa_descriptor));
456
457 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
458 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530459 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530460 wmi_buf_free(buf);
461 return QDF_STATUS_E_FAILURE;
462 }
463 return QDF_STATUS_SUCCESS;
464}
465
466
467/**
Govind Singh5eb51532016-03-09 11:34:12 +0530468 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
469 * @wmi: wmi handle
470 * @peer_addr: peer mac address
471 * @param: pointer to hold peer flush tid parameter
472 *
473 * Return: 0 for sucess or error code
474 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530475static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530476 uint8_t peer_addr[IEEE80211_ADDR_LEN],
477 struct peer_flush_params *param)
478{
479 wmi_peer_flush_tids_cmd_fixed_param *cmd;
480 wmi_buf_t buf;
481 int32_t len = sizeof(*cmd);
482
483 buf = wmi_buf_alloc(wmi, len);
484 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530485 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530486 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530487 }
488 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
489 WMITLV_SET_HDR(&cmd->tlv_header,
490 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
491 WMITLV_GET_STRUCT_TLVLEN
492 (wmi_peer_flush_tids_cmd_fixed_param));
493 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
494 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
495 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530496 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530497 peer_addr, param->vdev_id,
498 param->peer_tid_bitmap);
499 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530500 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530501 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530502 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530503 }
504
505 return 0;
506}
507
508/**
509 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
510 * @wmi: wmi handle
511 * @peer_addr: peer mac addr
512 * @vdev_id: vdev id
513 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530514 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530515 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530516static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530517 uint8_t peer_addr[IEEE80211_ADDR_LEN],
518 uint8_t vdev_id)
519{
520 wmi_peer_delete_cmd_fixed_param *cmd;
521 wmi_buf_t buf;
522 int32_t len = sizeof(*cmd);
523 buf = wmi_buf_alloc(wmi, len);
524 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530525 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530526 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530527 }
528 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
529 WMITLV_SET_HDR(&cmd->tlv_header,
530 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
531 WMITLV_GET_STRUCT_TLVLEN
532 (wmi_peer_delete_cmd_fixed_param));
533 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
534 cmd->vdev_id = vdev_id;
535
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800536 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530537 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530538 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530539 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530540 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530541 }
Govind Singh5eb51532016-03-09 11:34:12 +0530542
543 return 0;
544}
545
546/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530547 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
548 * to target id.
549 * @targ_paramid: Target parameter id to hold the result.
550 * @peer_param_id: host param id.
551 *
552 * Return: QDF_STATUS_SUCCESS for success
553 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
554 */
555#ifdef CONFIG_MCL
556static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
557 uint32_t *targ_paramid,
558 uint32_t peer_param_id)
559{
560 *targ_paramid = peer_param_id;
561 return QDF_STATUS_SUCCESS;
562}
563#else
564static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
565 uint32_t *targ_paramid,
566 uint32_t peer_param_id)
567{
568 switch (peer_param_id) {
569 case WMI_HOST_PEER_MIMO_PS_STATE:
570 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
571 break;
572 case WMI_HOST_PEER_AMPDU:
573 *targ_paramid = WMI_PEER_AMPDU;
574 break;
575 case WMI_HOST_PEER_AUTHORIZE:
576 *targ_paramid = WMI_PEER_AUTHORIZE;
577 break;
578 case WMI_HOST_PEER_CHWIDTH:
579 *targ_paramid = WMI_PEER_CHWIDTH;
580 break;
581 case WMI_HOST_PEER_NSS:
582 *targ_paramid = WMI_PEER_NSS;
583 break;
584 case WMI_HOST_PEER_USE_4ADDR:
585 *targ_paramid = WMI_PEER_USE_4ADDR;
586 break;
587 case WMI_HOST_PEER_MEMBERSHIP:
588 *targ_paramid = WMI_PEER_MEMBERSHIP;
589 break;
590 case WMI_HOST_PEER_USERPOS:
591 *targ_paramid = WMI_PEER_USERPOS;
592 break;
593 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
594 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
595 break;
596 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
597 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
598 break;
599 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
600 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
601 break;
602 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
603 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
604 break;
605 case WMI_HOST_PEER_PHYMODE:
606 *targ_paramid = WMI_PEER_PHYMODE;
607 break;
608 case WMI_HOST_PEER_USE_FIXED_PWR:
609 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
610 break;
611 case WMI_HOST_PEER_PARAM_FIXED_RATE:
612 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
613 break;
614 case WMI_HOST_PEER_SET_MU_WHITELIST:
615 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
616 break;
617 case WMI_HOST_PEER_SET_MAC_TX_RATE:
618 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
619 break;
620 case WMI_HOST_PEER_SET_MIN_TX_RATE:
621 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
622 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530623 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
624 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
625 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530626 default:
627 return QDF_STATUS_E_NOSUPPORT;
628 }
629
630 return QDF_STATUS_SUCCESS;
631}
632#endif
633/**
Govind Singh5eb51532016-03-09 11:34:12 +0530634 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530635 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530636 * @peer_addr: peer mac address
637 * @param : pointer to hold peer set parameter
638 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530639 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530640 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530641static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530642 uint8_t peer_addr[IEEE80211_ADDR_LEN],
643 struct peer_set_params *param)
644{
645 wmi_peer_set_param_cmd_fixed_param *cmd;
646 wmi_buf_t buf;
647 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530648 uint32_t param_id;
649
650 if (convert_host_peer_id_to_target_id_tlv(&param_id,
651 param->param_id) != QDF_STATUS_SUCCESS)
652 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530653
654 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
655 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530656 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530657 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530658 }
659 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
660 WMITLV_SET_HDR(&cmd->tlv_header,
661 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
662 WMITLV_GET_STRUCT_TLVLEN
663 (wmi_peer_set_param_cmd_fixed_param));
664 cmd->vdev_id = param->vdev_id;
665 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530666 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530667 cmd->param_value = param->param_value;
668 err = wmi_unified_cmd_send(wmi, buf,
669 sizeof(wmi_peer_set_param_cmd_fixed_param),
670 WMI_PEER_SET_PARAM_CMDID);
671 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530672 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530673 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530674 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530675 }
676
677 return 0;
678}
679
680/**
681 * send_vdev_up_cmd_tlv() - send vdev up command in fw
682 * @wmi: wmi handle
683 * @bssid: bssid
684 * @vdev_up_params: pointer to hold vdev up parameter
685 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530686 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530687 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530688static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530689 uint8_t bssid[IEEE80211_ADDR_LEN],
690 struct vdev_up_params *params)
691{
692 wmi_vdev_up_cmd_fixed_param *cmd;
693 wmi_buf_t buf;
694 int32_t len = sizeof(*cmd);
695
Govind Singhb53420c2016-03-09 14:32:57 +0530696 WMI_LOGD("%s: VDEV_UP", __func__);
697 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530698 params->vdev_id, params->assoc_id, bssid);
699 buf = wmi_buf_alloc(wmi, len);
700 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530701 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530702 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530703 }
704 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
705 WMITLV_SET_HDR(&cmd->tlv_header,
706 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
707 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
708 cmd->vdev_id = params->vdev_id;
709 cmd->vdev_assoc_id = params->assoc_id;
710 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
711 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530712 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530713 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530714 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530715 }
716
717 return 0;
718}
719
720/**
721 * send_peer_create_cmd_tlv() - send peer create command to fw
722 * @wmi: wmi handle
723 * @peer_addr: peer mac address
724 * @peer_type: peer type
725 * @vdev_id: vdev id
726 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530727 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530728 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530729static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530730 struct peer_create_params *param)
731{
732 wmi_peer_create_cmd_fixed_param *cmd;
733 wmi_buf_t buf;
734 int32_t len = sizeof(*cmd);
735
736 buf = wmi_buf_alloc(wmi, len);
737 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530738 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530739 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530740 }
741 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
742 WMITLV_SET_HDR(&cmd->tlv_header,
743 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
744 WMITLV_GET_STRUCT_TLVLEN
745 (wmi_peer_create_cmd_fixed_param));
746 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
747 cmd->peer_type = param->peer_type;
748 cmd->vdev_id = param->vdev_id;
749
750 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530751 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530752 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530753 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530754 }
Govind Singhb53420c2016-03-09 14:32:57 +0530755 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530756 param->vdev_id);
757
758 return 0;
759}
760
761/**
Leo Changeee40872016-09-28 13:43:36 -0700762 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
763 * command to fw
764 * @wmi: wmi handle
765 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
766 *
767 * Return: 0 for success or error code
768 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700769static
Leo Changeee40872016-09-28 13:43:36 -0700770QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
771 struct rx_reorder_queue_setup_params *param)
772{
773 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
774 wmi_buf_t buf;
775 int32_t len = sizeof(*cmd);
776
777 buf = wmi_buf_alloc(wmi, len);
778 if (!buf) {
779 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
780 return QDF_STATUS_E_NOMEM;
781 }
782 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
783 WMITLV_SET_HDR(&cmd->tlv_header,
784 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
785 WMITLV_GET_STRUCT_TLVLEN
786 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
787 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
788 cmd->vdev_id = param->vdev_id;
789 cmd->tid = param->tid;
790 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
791 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
792 cmd->queue_no = param->queue_no;
793
794 if (wmi_unified_cmd_send(wmi, buf, len,
795 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
796 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
797 __func__);
798 qdf_nbuf_free(buf);
799 return QDF_STATUS_E_FAILURE;
800 }
801 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
802 param->peer_macaddr, param->vdev_id, param->tid);
803
804 return QDF_STATUS_SUCCESS;
805}
806
807/**
808 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
809 * command to fw
810 * @wmi: wmi handle
811 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
812 *
813 * Return: 0 for success or error code
814 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700815static
Leo Changeee40872016-09-28 13:43:36 -0700816QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
817 struct rx_reorder_queue_remove_params *param)
818{
819 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
820 wmi_buf_t buf;
821 int32_t len = sizeof(*cmd);
822
823 buf = wmi_buf_alloc(wmi, len);
824 if (!buf) {
825 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
826 return QDF_STATUS_E_NOMEM;
827 }
828 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
829 wmi_buf_data(buf);
830 WMITLV_SET_HDR(&cmd->tlv_header,
831 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
832 WMITLV_GET_STRUCT_TLVLEN
833 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
834 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
835 cmd->vdev_id = param->vdev_id;
836 cmd->tid_mask = param->peer_tid_bitmap;
837
838 if (wmi_unified_cmd_send(wmi, buf, len,
839 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
840 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
841 __func__);
842 qdf_nbuf_free(buf);
843 return QDF_STATUS_E_FAILURE;
844 }
845 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
846 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
847
848 return QDF_STATUS_SUCCESS;
849}
850
851/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530852 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
853 * @wmi_handle: wmi handle
854 * @param: pointer holding peer details
855 *
856 * Return: 0 for success or error code
857 */
858static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
859 struct peer_add_wds_entry_params *param)
860{
861 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
862 wmi_buf_t buf;
863 int len = sizeof(*cmd);
864
865 buf = wmi_buf_alloc(wmi_handle, len);
866 if (!buf) {
867 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
868 return QDF_STATUS_E_FAILURE;
869 }
870 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
871 WMITLV_SET_HDR(&cmd->tlv_header,
872 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
873 WMITLV_GET_STRUCT_TLVLEN
874 (wmi_peer_add_wds_entry_cmd_fixed_param));
875 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
876 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
877 cmd->flags = param->flags;
878
879 return wmi_unified_cmd_send(wmi_handle, buf, len,
880 WMI_PEER_ADD_WDS_ENTRY_CMDID);
881}
882
883/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530884 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530885 * @wmi_handle: wmi handle
886 * @param: pointer holding peer details
887 *
888 * Return: 0 for success or error code
889 */
890static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
891 struct peer_del_wds_entry_params *param)
892{
893 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
894 wmi_buf_t buf;
895 int len = sizeof(*cmd);
896
897 buf = wmi_buf_alloc(wmi_handle, len);
898 if (!buf) {
899 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
900 return QDF_STATUS_E_NOMEM;
901 }
902 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
903 WMITLV_SET_HDR(&cmd->tlv_header,
904 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
905 WMITLV_GET_STRUCT_TLVLEN
906 (wmi_peer_remove_wds_entry_cmd_fixed_param));
907 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
908 return wmi_unified_cmd_send(wmi_handle, buf, len,
909 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
910}
911
912/**
913 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
914 * @wmi_handle: wmi handle
915 * @param: pointer holding peer details
916 *
917 * Return: 0 for success or error code
918 */
919static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
920 struct peer_update_wds_entry_params *param)
921{
922 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
923 wmi_buf_t buf;
924 int len = sizeof(*cmd);
925
926 buf = wmi_buf_alloc(wmi_handle, len);
927 if (!buf) {
928 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
929 return QDF_STATUS_E_NOMEM;
930 }
931
932 /* wmi_buf_alloc returns zeroed command buffer */
933 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
934 WMITLV_SET_HDR(&cmd->tlv_header,
935 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
936 WMITLV_GET_STRUCT_TLVLEN
937 (wmi_peer_update_wds_entry_cmd_fixed_param));
938 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
939 if (param->wds_macaddr)
940 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
941 &cmd->wds_macaddr);
942 if (param->peer_macaddr)
943 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
944 &cmd->peer_macaddr);
945 return wmi_unified_cmd_send(wmi_handle, buf, len,
946 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
947}
948
949
950
951/**
Govind Singh5eb51532016-03-09 11:34:12 +0530952 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
953 * @wmi_handle: wmi handle
954 * @value: value
955 * @mac_id: mac id to have radio context
956 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530957 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530958 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530959static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530960 uint32_t value, uint8_t mac_id)
961{
962 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
963 wmi_buf_t buf;
964 int32_t len = sizeof(*cmd);
965
Govind Singhb53420c2016-03-09 14:32:57 +0530966 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530967
968 buf = wmi_buf_alloc(wmi_handle, len);
969 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530970 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530971 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530972 }
973
974 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
975 WMITLV_SET_HDR(&cmd->tlv_header,
976 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
977 WMITLV_GET_STRUCT_TLVLEN
978 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa72da3b02017-03-28 22:45:27 +0530979 cmd->pdev_id = mac_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530980 cmd->enable = value;
981
982 if (wmi_unified_cmd_send(wmi_handle, buf, len,
983 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530984 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530985 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530986 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530987 }
988
989 return 0;
990}
991
992/**
993 * send_pdev_utf_cmd_tlv() - send utf command to fw
994 * @wmi_handle: wmi handle
995 * @param: pointer to pdev_utf_params
996 * @mac_id: mac id to have radio context
997 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530998 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530999 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301000static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301001send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1002 struct pdev_utf_params *param,
1003 uint8_t mac_id)
1004{
1005 wmi_buf_t buf;
1006 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001007 /* if param->len is 0 no data is sent, return error */
1008 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301009 static uint8_t msgref = 1;
1010 uint8_t segNumber = 0, segInfo, numSegments;
1011 uint16_t chunk_len, total_bytes;
1012 uint8_t *bufpos;
1013 struct seg_hdr_info segHdrInfo;
1014
1015 bufpos = param->utf_payload;
1016 total_bytes = param->len;
1017 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1018 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1019 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1020
1021 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1022 numSegments++;
1023
1024 while (param->len) {
1025 if (param->len > MAX_WMI_UTF_LEN)
1026 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1027 else
1028 chunk_len = param->len;
1029
1030 buf = wmi_buf_alloc(wmi_handle,
1031 (chunk_len + sizeof(segHdrInfo) +
1032 WMI_TLV_HDR_SIZE));
1033 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301034 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301035 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301036 }
1037
1038 cmd = (uint8_t *) wmi_buf_data(buf);
1039
1040 segHdrInfo.len = total_bytes;
1041 segHdrInfo.msgref = msgref;
1042 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1043 segHdrInfo.segmentInfo = segInfo;
1044 segHdrInfo.pad = 0;
1045
Govind Singhb53420c2016-03-09 14:32:57 +05301046 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301047 " segHdrInfo.segmentInfo = %d",
1048 __func__, segHdrInfo.len, segHdrInfo.msgref,
1049 segHdrInfo.segmentInfo);
1050
Govind Singhb53420c2016-03-09 14:32:57 +05301051 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301052 "chunk len %d", __func__, total_bytes, segNumber,
1053 numSegments, chunk_len);
1054
1055 segNumber++;
1056
1057 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1058 (chunk_len + sizeof(segHdrInfo)));
1059 cmd += WMI_TLV_HDR_SIZE;
1060 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1061 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1062
1063 ret = wmi_unified_cmd_send(wmi_handle, buf,
1064 (chunk_len + sizeof(segHdrInfo) +
1065 WMI_TLV_HDR_SIZE),
1066 WMI_PDEV_UTF_CMDID);
1067
Govind Singh67922e82016-04-01 16:48:57 +05301068 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301069 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301070 wmi_buf_free(buf);
1071 break;
1072 }
1073
1074 param->len -= chunk_len;
1075 bufpos += chunk_len;
1076 }
1077
1078 msgref++;
1079
1080 return ret;
1081}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301082#ifdef CONFIG_MCL
1083static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1084 uint32_t host_param)
1085{
1086 return host_param;
1087}
1088#else
1089static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1090 uint32_t host_param)
1091{
1092 if (host_param < wmi_pdev_param_max)
1093 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301094
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301095 return WMI_UNAVAILABLE_PARAM;
1096}
1097#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301098/**
1099 * send_pdev_param_cmd_tlv() - set pdev parameters
1100 * @wmi_handle: wmi handle
1101 * @param: pointer to pdev parameter
1102 * @mac_id: radio context
1103 *
1104 * Return: 0 on success, errno on failure
1105 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301106static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301107send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1108 struct pdev_params *param,
1109 uint8_t mac_id)
1110{
Govind Singh67922e82016-04-01 16:48:57 +05301111 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301112 wmi_pdev_set_param_cmd_fixed_param *cmd;
1113 wmi_buf_t buf;
1114 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301115 uint32_t pdev_param;
1116
1117 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1118 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1119 WMI_LOGW("%s: Unavailable param %d\n",
1120 __func__, param->param_id);
1121 return QDF_STATUS_E_INVAL;
1122 }
Govind Singh5eb51532016-03-09 11:34:12 +05301123
1124 buf = wmi_buf_alloc(wmi_handle, len);
1125 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301126 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301127 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301128 }
1129 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1130 WMITLV_SET_HDR(&cmd->tlv_header,
1131 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1132 WMITLV_GET_STRUCT_TLVLEN
1133 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa72da3b02017-03-28 22:45:27 +05301134 cmd->pdev_id = mac_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301135 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301136 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301137 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301138 param->param_value);
1139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1140 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301141 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301142 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301143 wmi_buf_free(buf);
1144 }
1145 return ret;
1146}
1147
1148/**
1149 * send_suspend_cmd_tlv() - WMI suspend function
1150 * @param wmi_handle : handle to WMI.
1151 * @param param : pointer to hold suspend parameter
1152 * @mac_id: radio context
1153 *
1154 * Return 0 on success and -ve on failure.
1155 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301156static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301157 struct suspend_params *param,
1158 uint8_t mac_id)
1159{
1160 wmi_pdev_suspend_cmd_fixed_param *cmd;
1161 wmi_buf_t wmibuf;
1162 uint32_t len = sizeof(*cmd);
1163 int32_t ret;
1164
1165 /*
1166 * send the comand to Target to ignore the
1167 * PCIE reset so as to ensure that Host and target
1168 * states are in sync
1169 */
1170 wmibuf = wmi_buf_alloc(wmi_handle, len);
1171 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301172 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301173
1174 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1175 WMITLV_SET_HDR(&cmd->tlv_header,
1176 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1177 WMITLV_GET_STRUCT_TLVLEN
1178 (wmi_pdev_suspend_cmd_fixed_param));
1179 if (param->disable_target_intr)
1180 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1181 else
1182 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1183 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1184 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301185 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301186 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301187 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301188 }
1189
1190 return ret;
1191}
1192
1193/**
1194 * send_resume_cmd_tlv() - WMI resume function
1195 * @param wmi_handle : handle to WMI.
1196 * @mac_id: radio context
1197 *
1198 * Return: 0 on success and -ve on failure.
1199 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301200static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301201 uint8_t mac_id)
1202{
1203 wmi_buf_t wmibuf;
1204 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301205 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301206
1207 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1208 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301209 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301210 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1211 WMITLV_SET_HDR(&cmd->tlv_header,
1212 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1213 WMITLV_GET_STRUCT_TLVLEN
1214 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001215 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301216 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1217 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301218 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301219 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301220 wmi_buf_free(wmibuf);
1221 }
1222
1223 return ret;
1224}
1225
1226/**
1227 * send_wow_enable_cmd_tlv() - WMI wow enable function
1228 * @param wmi_handle : handle to WMI.
1229 * @param param : pointer to hold wow enable parameter
1230 * @mac_id: radio context
1231 *
1232 * Return: 0 on success and -ve on failure.
1233 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301234static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301235 struct wow_cmd_params *param,
1236 uint8_t mac_id)
1237{
1238 wmi_wow_enable_cmd_fixed_param *cmd;
1239 wmi_buf_t buf;
1240 int32_t len;
1241 int32_t ret;
1242
1243 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1244
1245 buf = wmi_buf_alloc(wmi_handle, len);
1246 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301247 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1248 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301249 }
1250 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1251 WMITLV_SET_HDR(&cmd->tlv_header,
1252 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1253 WMITLV_GET_STRUCT_TLVLEN
1254 (wmi_wow_enable_cmd_fixed_param));
1255 cmd->enable = param->enable;
1256 if (param->can_suspend_link)
1257 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1258 else
1259 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001260 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301261
Govind Singhb53420c2016-03-09 14:32:57 +05301262 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301263 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1264 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1265
1266 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1267 WMI_WOW_ENABLE_CMDID);
1268 if (ret)
1269 wmi_buf_free(buf);
1270
1271 return ret;
1272}
1273
1274/**
1275 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301276 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301277 * @peer_addr: peer mac address
1278 * @param: pointer to ap_ps parameter structure
1279 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301280 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301281 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301282static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301283 uint8_t *peer_addr,
1284 struct ap_ps_params *param)
1285{
1286 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1287 wmi_buf_t buf;
1288 int32_t err;
1289
1290 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1291 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301292 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301293 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301294 }
1295 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1296 WMITLV_SET_HDR(&cmd->tlv_header,
1297 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1298 WMITLV_GET_STRUCT_TLVLEN
1299 (wmi_ap_ps_peer_cmd_fixed_param));
1300 cmd->vdev_id = param->vdev_id;
1301 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1302 cmd->param = param->param;
1303 cmd->value = param->value;
1304 err = wmi_unified_cmd_send(wmi_handle, buf,
1305 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1306 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301307 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301308 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301309 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301310 }
1311
1312 return 0;
1313}
1314
1315/**
1316 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301317 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301318 * @peer_addr: peer mac address
1319 * @param: pointer to sta_ps parameter structure
1320 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301321 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301323static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301324 struct sta_ps_params *param)
1325{
1326 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1327 wmi_buf_t buf;
1328 int32_t len = sizeof(*cmd);
1329
1330 buf = wmi_buf_alloc(wmi_handle, len);
1331 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301332 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301333 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301334 }
1335
1336 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1337 WMITLV_SET_HDR(&cmd->tlv_header,
1338 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1339 WMITLV_GET_STRUCT_TLVLEN
1340 (wmi_sta_powersave_param_cmd_fixed_param));
1341 cmd->vdev_id = param->vdev_id;
1342 cmd->param = param->param;
1343 cmd->value = param->value;
1344
1345 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1346 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301347 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301348 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301349 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301350 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301351 }
1352
1353 return 0;
1354}
1355
1356/**
1357 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301358 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301359 * @param: ponirt to crash inject paramter structure
1360 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301361 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301362 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301363static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301364 struct crash_inject *param)
1365{
1366 int32_t ret = 0;
1367 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1368 uint16_t len = sizeof(*cmd);
1369 wmi_buf_t buf;
1370
1371 buf = wmi_buf_alloc(wmi_handle, len);
1372 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301373 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301374 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301375 }
1376
1377 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1378 WMITLV_SET_HDR(&cmd->tlv_header,
1379 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1380 WMITLV_GET_STRUCT_TLVLEN
1381 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1382 cmd->type = param->type;
1383 cmd->delay_time_ms = param->delay_time_ms;
1384
1385 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1386 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301387 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301388 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301389 __func__, ret);
1390 wmi_buf_free(buf);
1391 }
1392
1393 return ret;
1394}
1395
1396/**
1397 * send_dbglog_cmd_tlv() - set debug log level
1398 * @param wmi_handle : handle to WMI.
1399 * @param param : pointer to hold dbglog level parameter
1400 *
1401 * Return: 0 on success and -ve on failure.
1402 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301403 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301404send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1405 struct dbglog_params *dbglog_param)
1406{
1407 wmi_buf_t buf;
1408 wmi_debug_log_config_cmd_fixed_param *configmsg;
1409 A_STATUS status = A_OK;
1410 int32_t i;
1411 int32_t len;
1412 int8_t *buf_ptr;
1413 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1414
1415 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1416
1417 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1418 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1419 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1420 buf = wmi_buf_alloc(wmi_handle, len);
1421 if (buf == NULL)
1422 return A_NO_MEMORY;
1423
1424 configmsg =
1425 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1426 buf_ptr = (int8_t *) configmsg;
1427 WMITLV_SET_HDR(&configmsg->tlv_header,
1428 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1429 WMITLV_GET_STRUCT_TLVLEN
1430 (wmi_debug_log_config_cmd_fixed_param));
1431 configmsg->dbg_log_param = dbglog_param->param;
1432 configmsg->value = dbglog_param->val;
1433 /* Filling in the data part of second tlv -- should
1434 * follow first tlv _ WMI_TLV_HDR_SIZE */
1435 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1436 sizeof
1437 (wmi_debug_log_config_cmd_fixed_param)
1438 + WMI_TLV_HDR_SIZE);
1439 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1440 WMITLV_TAG_ARRAY_UINT32,
1441 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1442 if (dbglog_param->module_id_bitmap) {
1443 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1444 module_id_bitmap_array[i] =
1445 dbglog_param->module_id_bitmap[i];
1446 }
1447 }
1448
1449 status = wmi_unified_cmd_send(wmi_handle, buf,
1450 len, WMI_DBGLOG_CFG_CMDID);
1451
1452 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301453 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301454
1455 return status;
1456}
1457
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301458#ifdef CONFIG_MCL
1459static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1460 uint32_t host_param)
1461{
1462 return host_param;
1463}
1464#else
1465static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1466 uint32_t host_param)
1467{
1468 if (host_param < wmi_vdev_param_max)
1469 return wmi_handle->vdev_param[host_param];
1470
1471 return WMI_UNAVAILABLE_PARAM;
1472}
1473#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301474/**
1475 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1476 * @param wmi_handle : handle to WMI.
1477 * @param macaddr : MAC address
1478 * @param param : pointer to hold vdev set parameter
1479 *
1480 * Return: 0 on success and -ve on failure.
1481 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301482static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301483 struct vdev_set_params *param)
1484{
Govind Singh67922e82016-04-01 16:48:57 +05301485 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301486 wmi_vdev_set_param_cmd_fixed_param *cmd;
1487 wmi_buf_t buf;
1488 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301489 uint32_t vdev_param;
1490
1491 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1492 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1493 WMI_LOGW("%s:Vdev param %d not available", __func__,
1494 param->param_id);
1495 return QDF_STATUS_E_INVAL;
1496
1497 }
Govind Singh5eb51532016-03-09 11:34:12 +05301498
1499 buf = wmi_buf_alloc(wmi_handle, len);
1500 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301501 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301502 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301503 }
1504 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1505 WMITLV_SET_HDR(&cmd->tlv_header,
1506 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1507 WMITLV_GET_STRUCT_TLVLEN
1508 (wmi_vdev_set_param_cmd_fixed_param));
1509 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301510 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301511 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301512 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301513 param->if_id, param->param_id, param->param_value);
1514 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1515 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301516 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301517 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301518 wmi_buf_free(buf);
1519 }
1520
1521 return ret;
1522}
1523
1524/**
1525 * send_stats_request_cmd_tlv() - WMI request stats function
1526 * @param wmi_handle : handle to WMI.
1527 * @param macaddr : MAC address
1528 * @param param : pointer to hold stats request parameter
1529 *
1530 * Return: 0 on success and -ve on failure.
1531 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301532static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301533 uint8_t macaddr[IEEE80211_ADDR_LEN],
1534 struct stats_request_params *param)
1535{
Govind Singhd3156eb2016-02-26 17:50:39 +05301536 int32_t ret;
1537 wmi_request_stats_cmd_fixed_param *cmd;
1538 wmi_buf_t buf;
1539 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1540
1541 buf = wmi_buf_alloc(wmi_handle, len);
1542 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301543 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1544 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301545 }
1546
1547 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1548 WMITLV_SET_HDR(&cmd->tlv_header,
1549 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1550 WMITLV_GET_STRUCT_TLVLEN
1551 (wmi_request_stats_cmd_fixed_param));
1552 cmd->stats_id = param->stats_id;
1553 cmd->vdev_id = param->vdev_id;
1554 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1555 WMI_REQUEST_STATS_CMDID);
1556 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301557 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301558 wmi_buf_free(buf);
1559 }
1560
1561 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301562}
1563
Govind Singh87542482016-06-08 19:40:11 +05301564#ifdef CONFIG_WIN
1565/**
1566 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1567 * @param wmi_handle : handle to WMI.
1568 * @param macaddr : MAC address
1569 * @param param : pointer to hold stats request parameter
1570 *
1571 * Return: 0 on success and -ve on failure.
1572 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301573static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301574 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1575{
1576 return 0;
1577}
1578#else
Govind Singh5eb51532016-03-09 11:34:12 +05301579/**
1580 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1581 * @param wmi_handle : handle to WMI.
1582 * @param macaddr : MAC address
1583 * @param param : pointer to hold stats request parameter
1584 *
1585 * Return: 0 on success and -ve on failure.
1586 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301587static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301588 uint8_t macaddr[IEEE80211_ADDR_LEN],
1589 struct packet_enable_params *param)
1590{
1591 return 0;
1592}
Govind Singh87542482016-06-08 19:40:11 +05301593#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301594
Govind Singh87542482016-06-08 19:40:11 +05301595#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301596/**
1597 * send_beacon_send_cmd_tlv() - WMI beacon send function
1598 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301599 * @param param : pointer to hold beacon send cmd parameter
1600 *
1601 * Return: 0 on success and -ve on failure.
1602 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301603static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301604 struct beacon_params *param)
1605{
Govind Singhd3156eb2016-02-26 17:50:39 +05301606 int32_t ret;
1607 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1608 wmi_bcn_prb_info *bcn_prb_info;
1609 wmi_buf_t wmi_buf;
1610 uint8_t *buf_ptr;
1611 uint32_t wmi_buf_len;
1612
1613 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1614 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1615 param->tmpl_len_aligned;
1616 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1617 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301618 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301619 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301620 }
1621 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1622 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1623 WMITLV_SET_HDR(&cmd->tlv_header,
1624 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1625 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1626 cmd->vdev_id = param->vdev_id;
1627 cmd->tim_ie_offset = param->tim_ie_offset;
1628 cmd->buf_len = param->tmpl_len;
1629 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1630
1631 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1632 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1633 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1634 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1635 bcn_prb_info->caps = 0;
1636 bcn_prb_info->erp = 0;
1637 buf_ptr += sizeof(wmi_bcn_prb_info);
1638
1639 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1640 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301641 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301642
1643 ret = wmi_unified_cmd_send(wmi_handle,
1644 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1645 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301646 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301647 wmi_buf_free(wmi_buf);
1648 }
Govind Singh5eb51532016-03-09 11:34:12 +05301649 return 0;
1650}
Govind Singh87542482016-06-08 19:40:11 +05301651#else
Sathish Kumarfd347372017-02-13 12:29:09 +05301652static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301653 struct beacon_params *param)
1654{
1655 return 0;
1656}
1657
1658/**
1659 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1660 * @param wmi_handle : handle to WMI.
1661 * @param param : pointer to hold beacon send cmd parameter
1662 *
1663 * Return: 0 on success and -ve on failure.
1664 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301665static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301666 struct beacon_tmpl_params *param)
1667{
1668 int32_t ret;
1669 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1670 wmi_bcn_prb_info *bcn_prb_info;
1671 wmi_buf_t wmi_buf;
1672 uint8_t *buf_ptr;
1673 uint32_t wmi_buf_len;
1674
Sathish Kumar45e991b2017-02-27 10:35:40 +05301675 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301676 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1677 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1678 param->tmpl_len_aligned;
1679 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1680 if (!wmi_buf) {
1681 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1682 return QDF_STATUS_E_NOMEM;
1683 }
1684 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1685 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1686 WMITLV_SET_HDR(&cmd->tlv_header,
1687 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1688 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1689 cmd->vdev_id = param->vdev_id;
1690 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301691 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1692 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301693 cmd->buf_len = param->tmpl_len;
1694 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1695
1696 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1697 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1698 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1699 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1700 bcn_prb_info->caps = 0;
1701 bcn_prb_info->erp = 0;
1702 buf_ptr += sizeof(wmi_bcn_prb_info);
1703
1704 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1705 buf_ptr += WMI_TLV_HDR_SIZE;
1706 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1707
1708 ret = wmi_unified_cmd_send(wmi_handle,
1709 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1710 if (ret) {
1711 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1712 wmi_buf_free(wmi_buf);
1713 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301714
Govind Singh87542482016-06-08 19:40:11 +05301715 return 0;
1716}
1717#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301718
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301719#ifdef CONFIG_MCL
1720static inline void copy_peer_flags_tlv(
1721 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1722 struct peer_assoc_params *param)
1723{
1724 cmd->peer_flags = param->peer_flags;
1725}
1726#else
1727static inline void copy_peer_flags_tlv(
1728 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1729 struct peer_assoc_params *param)
1730{
1731 /*
1732 * The target only needs a subset of the flags maintained in the host.
1733 * Just populate those flags and send it down
1734 */
1735 cmd->peer_flags = 0;
1736
1737 /*
1738 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1739 */
1740 if (param->is_wme_set) {
1741
1742 if (param->qos_flag)
1743 cmd->peer_flags |= WMI_PEER_QOS;
1744 if (param->apsd_flag)
1745 cmd->peer_flags |= WMI_PEER_APSD;
1746 if (param->ht_flag)
1747 cmd->peer_flags |= WMI_PEER_HT;
1748 if (param->bw_40)
1749 cmd->peer_flags |= WMI_PEER_40MHZ;
1750 if (param->bw_80)
1751 cmd->peer_flags |= WMI_PEER_80MHZ;
1752 if (param->bw_160)
1753 cmd->peer_flags |= WMI_PEER_160MHZ;
1754
1755 /* Typically if STBC is enabled for VHT it should be enabled
1756 * for HT as well
1757 **/
1758 if (param->stbc_flag)
1759 cmd->peer_flags |= WMI_PEER_STBC;
1760
1761 /* Typically if LDPC is enabled for VHT it should be enabled
1762 * for HT as well
1763 **/
1764 if (param->ldpc_flag)
1765 cmd->peer_flags |= WMI_PEER_LDPC;
1766
1767 if (param->static_mimops_flag)
1768 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1769 if (param->dynamic_mimops_flag)
1770 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1771 if (param->spatial_mux_flag)
1772 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1773 if (param->vht_flag)
1774 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001775 if (param->he_flag)
1776 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301777 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001778
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301779 /*
1780 * Suppress authorization for all AUTH modes that need 4-way handshake
1781 * (during re-association).
1782 * Authorization will be done for these modes on key installation.
1783 */
1784 if (param->auth_flag)
1785 cmd->peer_flags |= WMI_PEER_AUTH;
1786 if (param->need_ptk_4_way)
1787 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1788 else
1789 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1790 if (param->need_gtk_2_way)
1791 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1792 /* safe mode bypass the 4-way handshake */
1793 if (param->safe_mode_enabled)
1794 cmd->peer_flags &=
1795 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1796 /* Disable AMSDU for station transmit, if user configures it */
1797 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1798 * it
1799 * if (param->amsdu_disable) Add after FW support
1800 **/
1801
1802 /* Target asserts if node is marked HT and all MCS is set to 0.
1803 * Mark the node as non-HT if all the mcs rates are disabled through
1804 * iwpriv
1805 **/
1806 if (param->peer_ht_rates.num_rates == 0)
1807 cmd->peer_flags &= ~WMI_PEER_HT;
1808}
1809#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301810
1811#ifdef CONFIG_MCL
1812static inline void copy_peer_mac_addr_tlv(
1813 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1814 struct peer_assoc_params *param)
1815{
1816 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1817 sizeof(param->peer_macaddr));
1818}
1819#else
1820static inline void copy_peer_mac_addr_tlv(
1821 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1822 struct peer_assoc_params *param)
1823{
1824 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1825}
1826#endif
1827
Govind Singh5eb51532016-03-09 11:34:12 +05301828/**
1829 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1830 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301831 * @param param : pointer to peer assoc parameter
1832 *
1833 * Return: 0 on success and -ve on failure.
1834 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301835static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301836 struct peer_assoc_params *param)
1837{
Govind Singhd3156eb2016-02-26 17:50:39 +05301838 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1839 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001840 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301841 wmi_buf_t buf;
1842 int32_t len;
1843 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301844 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301845 uint32_t peer_legacy_rates_align;
1846 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001847 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301848
1849
1850 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1851 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301852
1853 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001854 (peer_legacy_rates_align * sizeof(uint8_t)) +
1855 WMI_TLV_HDR_SIZE +
1856 (peer_ht_rates_align * sizeof(uint8_t)) +
1857 sizeof(wmi_vht_rate_set) +
1858 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1859 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301860
1861 buf = wmi_buf_alloc(wmi_handle, len);
1862 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301863 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301864 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301865 }
1866
1867 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1868 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1869 WMITLV_SET_HDR(&cmd->tlv_header,
1870 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1871 WMITLV_GET_STRUCT_TLVLEN
1872 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301873
Govind Singhd3156eb2016-02-26 17:50:39 +05301874 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301875
Govind Singhd3156eb2016-02-26 17:50:39 +05301876 cmd->peer_new_assoc = param->peer_new_assoc;
1877 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301878
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301879 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301880 copy_peer_mac_addr_tlv(cmd, param);
1881
Govind Singhd3156eb2016-02-26 17:50:39 +05301882 cmd->peer_rate_caps = param->peer_rate_caps;
1883 cmd->peer_caps = param->peer_caps;
1884 cmd->peer_listen_intval = param->peer_listen_intval;
1885 cmd->peer_ht_caps = param->peer_ht_caps;
1886 cmd->peer_max_mpdu = param->peer_max_mpdu;
1887 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301888 cmd->peer_vht_caps = param->peer_vht_caps;
1889 cmd->peer_phymode = param->peer_phymode;
1890
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001891 /* Update 11ax capabilities */
1892 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1893 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001894 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1895 sizeof(param->peer_he_cap_phyinfo));
1896 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1897 sizeof(param->peer_ppet));
1898
Govind Singhd3156eb2016-02-26 17:50:39 +05301899 /* Update peer legacy rate information */
1900 buf_ptr += sizeof(*cmd);
1901 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301902 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301903 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301904 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301905 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301906 param->peer_legacy_rates.num_rates);
1907
1908 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001909 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301910 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301911 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301912 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301913 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301914 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301915 param->peer_ht_rates.num_rates);
1916
1917 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001918 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301919 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1920 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1921
1922 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301923
1924 /* Update bandwidth-NSS mapping */
1925 cmd->peer_bw_rxnss_override = 0;
1926 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
1927
Govind Singhd3156eb2016-02-26 17:50:39 +05301928 mcs = (wmi_vht_rate_set *) buf_ptr;
1929 if (param->vht_capable) {
1930 mcs->rx_max_rate = param->rx_max_rate;
1931 mcs->rx_mcs_set = param->rx_mcs_set;
1932 mcs->tx_max_rate = param->tx_max_rate;
1933 mcs->tx_mcs_set = param->tx_mcs_set;
1934 }
1935
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001936 /* HE Rates */
1937 cmd->peer_he_mcs = param->peer_he_mcs_count;
1938 buf_ptr += sizeof(wmi_vht_rate_set);
1939 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1940 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
1941 buf_ptr += WMI_TLV_HDR_SIZE;
1942
1943 /* Loop through the HE rate set */
1944 for (i = 0; i < param->peer_he_mcs_count; i++) {
1945 he_mcs = (wmi_he_rate_set *) buf_ptr;
1946 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
1947 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
1948
1949 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
1950 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
1951 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
1952 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
1953 buf_ptr += sizeof(wmi_he_rate_set);
1954 }
1955
1956
Govind Singhb53420c2016-03-09 14:32:57 +05301957 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301958 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1959 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001960 "cmd->peer_vht_caps %x "
1961 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05301962 "HE phy %x %x %x "
1963 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05301964 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1965 cmd->peer_rate_caps, cmd->peer_caps,
1966 cmd->peer_listen_intval, cmd->peer_ht_caps,
1967 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1968 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001969 cmd->peer_vht_caps, cmd->peer_he_cap_info,
1970 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05301971 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
1972 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05301973
1974 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1975 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301976 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301977 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301978 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301979 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301980 }
1981
1982 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301983}
1984
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301985/* copy_scan_notify_events() - Helper routine to copy scan notify events
1986 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05301987static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301988 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05301989 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301990{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301991
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05301992 /* Scan events subscription */
1993 if (param->scan_ev_started)
1994 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
1995 if (param->scan_ev_completed)
1996 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
1997 if (param->scan_ev_bss_chan)
1998 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
1999 if (param->scan_ev_foreign_chan)
2000 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2001 if (param->scan_ev_dequeued)
2002 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2003 if (param->scan_ev_preempted)
2004 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2005 if (param->scan_ev_start_failed)
2006 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2007 if (param->scan_ev_restarted)
2008 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2009 if (param->scan_ev_foreign_chn_exit)
2010 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2011 if (param->scan_ev_suspended)
2012 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2013 if (param->scan_ev_resumed)
2014 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302015
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302016 /** Set scan control flags */
2017 cmd->scan_ctrl_flags = 0;
2018 if (param->scan_f_passive)
2019 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2020 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302021 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302022 if (param->scan_f_promisc_mode)
2023 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2024 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302025 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302026 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302027 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302028 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302029 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302030 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302031 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302032 if (param->scan_f_ofdm_rates)
2033 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2034 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302035 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302036 if (param->scan_f_filter_prb_req)
2037 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2038 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302039 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302040 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302041 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302042 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302043 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302044 if (param->scan_f_force_active_dfs_chn)
2045 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2046 if (param->scan_f_add_tpc_ie_in_probe)
2047 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2048 if (param->scan_f_add_ds_ie_in_probe)
2049 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2050 if (param->scan_f_add_spoofed_mac_in_probe)
2051 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2052 if (param->scan_f_add_rand_seq_in_probe)
2053 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2054 if (param->scan_f_en_ie_whitelist_in_probe)
2055 cmd->scan_ctrl_flags |=
2056 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302057
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302058 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2059 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2060 param->adaptive_dwell_time_mode);
2061}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302062
2063/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302064static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302065 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302066{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302067 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302068}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302069
Anish Natarajdd855152017-03-20 12:49:08 +05302070/*
2071 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2072 * @param wmi_handle : Handle to WMI
2073 * @param vdev_id : vdev identifier
2074 *
2075 * Return : void *
2076 */
2077static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2078{
2079 struct wlan_objmgr_vdev *vdev = NULL;
2080 struct wlan_objmgr_pdev *pdev = NULL;
2081 uint8_t pdev_id = 0;
2082
2083 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2084 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2085 vdev_id, WLAN_SCAN_ID);
2086 if (vdev) {
2087 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2088 pdev = wlan_vdev_get_pdev(vdev);
2089 if (pdev)
2090 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2091 else {
2092 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2093 }
2094 } else {
2095 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2096 }
2097
2098 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2099}
2100
Govind Singh5eb51532016-03-09 11:34:12 +05302101/**
2102 * send_scan_start_cmd_tlv() - WMI scan start function
2103 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302104 * @param param : pointer to hold scan start cmd parameter
2105 *
2106 * Return: 0 on success and -ve on failure.
2107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302108static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302109 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302110{
Govind Singhd3156eb2016-02-26 17:50:39 +05302111 int32_t ret = 0;
2112 int32_t i;
2113 wmi_buf_t wmi_buf;
2114 wmi_start_scan_cmd_fixed_param *cmd;
2115 uint8_t *buf_ptr;
2116 uint32_t *tmp_ptr;
2117 wmi_ssid *ssid = NULL;
2118 wmi_mac_addr *bssid;
2119 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302120 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302121
2122 /* Length TLV placeholder for array of uint32_t */
2123 len += WMI_TLV_HDR_SIZE;
2124 /* calculate the length of buffer required */
2125 if (params->num_chan)
2126 len += params->num_chan * sizeof(uint32_t);
2127
2128 /* Length TLV placeholder for array of wmi_ssid structures */
2129 len += WMI_TLV_HDR_SIZE;
2130 if (params->num_ssids)
2131 len += params->num_ssids * sizeof(wmi_ssid);
2132
2133 /* Length TLV placeholder for array of wmi_mac_addr structures */
2134 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302135 if (params->num_bssid)
2136 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302137
2138 /* Length TLV placeholder for array of bytes */
2139 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302140 if (params->extraie.len)
2141 extraie_len_with_pad =
2142 roundup(params->extraie.len, sizeof(uint32_t));
2143 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302144
2145 /* Allocate the memory */
2146 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2147 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302148 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302149 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302150 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302151 }
2152 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2153 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2154 WMITLV_SET_HDR(&cmd->tlv_header,
2155 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2156 WMITLV_GET_STRUCT_TLVLEN
2157 (wmi_start_scan_cmd_fixed_param));
2158
2159 cmd->scan_id = params->scan_id;
2160 cmd->scan_req_id = params->scan_req_id;
2161 cmd->vdev_id = params->vdev_id;
2162 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302163
2164 copy_scan_event_cntrl_flags(cmd, params);
2165
Govind Singhd3156eb2016-02-26 17:50:39 +05302166 cmd->dwell_time_active = params->dwell_time_active;
2167 cmd->dwell_time_passive = params->dwell_time_passive;
2168 cmd->min_rest_time = params->min_rest_time;
2169 cmd->max_rest_time = params->max_rest_time;
2170 cmd->repeat_probe_time = params->repeat_probe_time;
2171 cmd->probe_spacing_time = params->probe_spacing_time;
2172 cmd->idle_time = params->idle_time;
2173 cmd->max_scan_time = params->max_scan_time;
2174 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302175 cmd->burst_duration = params->burst_duration;
2176 cmd->num_chan = params->num_chan;
2177 cmd->num_bssid = params->num_bssid;
2178 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302179 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302180 cmd->n_probes = params->n_probes;
2181 buf_ptr += sizeof(*cmd);
2182 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2183 for (i = 0; i < params->num_chan; ++i)
2184 tmp_ptr[i] = params->chan_list[i];
2185
2186 WMITLV_SET_HDR(buf_ptr,
2187 WMITLV_TAG_ARRAY_UINT32,
2188 (params->num_chan * sizeof(uint32_t)));
2189 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302190 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302191 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302192 goto error;
2193 }
2194
2195 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2196 (params->num_ssids * sizeof(wmi_ssid)));
2197
2198 if (params->num_ssids) {
2199 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2200 for (i = 0; i < params->num_ssids; ++i) {
2201 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302202 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302203 params->ssid[i].length);
2204 ssid++;
2205 }
2206 }
2207 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2208
2209 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2210 (params->num_bssid * sizeof(wmi_mac_addr)));
2211 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302212
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302213 if (params->num_bssid) {
2214 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302215 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2216 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302217 bssid++;
2218 }
2219 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302220
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302221 buf_ptr += WMI_TLV_HDR_SIZE +
2222 (params->num_bssid * sizeof(wmi_mac_addr));
2223
2224 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2225 if (params->extraie.len)
2226 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2227 params);
2228
2229 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302230
Anish Natarajdd855152017-03-20 12:49:08 +05302231 ret = wmi_unified_cmd_send(
2232 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302233 len, WMI_START_SCAN_CMDID);
2234 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302235 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302236 wmi_buf_free(wmi_buf);
2237 }
2238 return ret;
2239error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302240 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302241 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302242}
2243
2244/**
2245 * send_scan_stop_cmd_tlv() - WMI scan start function
2246 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302247 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302248 *
2249 * Return: 0 on success and -ve on failure.
2250 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302251static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302252 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302253{
Govind Singhd3156eb2016-02-26 17:50:39 +05302254 wmi_stop_scan_cmd_fixed_param *cmd;
2255 int ret;
2256 int len = sizeof(*cmd);
2257 wmi_buf_t wmi_buf;
2258
2259 /* Allocate the memory */
2260 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2261 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302262 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302263 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302264 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302265 goto error;
2266 }
2267
2268 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2269 WMITLV_SET_HDR(&cmd->tlv_header,
2270 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2271 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2272 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302273 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302274 cmd->scan_id = param->scan_id;
Anish Natarajdd855152017-03-20 12:49:08 +05302275 cmd->pdev_id = param->pdev_id + 1;
Govind Singhd3156eb2016-02-26 17:50:39 +05302276 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302277 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2278 /* Cancelling all scans */
2279 cmd->req_type = WMI_SCAN_STOP_ALL;
2280 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2281 /* Cancelling VAP scans */
2282 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2283 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2284 /* Cancelling specific scan */
2285 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302286 } else {
2287 WMI_LOGE("%s: Invalid Command : ", __func__);
2288 wmi_buf_free(wmi_buf);
2289 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302290 }
2291
Anish Natarajdd855152017-03-20 12:49:08 +05302292 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302293 len, WMI_STOP_SCAN_CMDID);
2294 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302295 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302296 wmi_buf_free(wmi_buf);
2297 }
2298
2299error:
2300 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302301}
2302
Govind Singh87542482016-06-08 19:40:11 +05302303#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302304/**
2305 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2306 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302307 * @param param : pointer to hold scan channel list parameter
2308 *
2309 * Return: 0 on success and -ve on failure.
2310 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302311static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302312 struct scan_chan_list_params *chan_list)
2313{
2314 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302315 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302316 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302317 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302318 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302319 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302320 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2321
2322 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2323 buf = wmi_buf_alloc(wmi_handle, len);
2324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302325 WMI_LOGE("Failed to allocate memory");
2326 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302327 goto end;
2328 }
2329
2330 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2331 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2332 WMITLV_SET_HDR(&cmd->tlv_header,
2333 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2334 WMITLV_GET_STRUCT_TLVLEN
2335 (wmi_scan_chan_list_cmd_fixed_param));
2336
Govind Singhb53420c2016-03-09 14:32:57 +05302337 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302338
2339 cmd->num_scan_chans = chan_list->num_scan_chans;
2340 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2341 WMITLV_TAG_ARRAY_STRUC,
2342 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302343 chan_info = (wmi_channel_param *)
2344 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302345 tchan_info = chan_list->chan_info;
2346
2347 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2348 WMITLV_SET_HDR(&chan_info->tlv_header,
2349 WMITLV_TAG_STRUC_wmi_channel,
2350 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2351 chan_info->mhz = tchan_info->mhz;
2352 chan_info->band_center_freq1 =
2353 tchan_info->band_center_freq1;
2354 chan_info->band_center_freq2 =
2355 tchan_info->band_center_freq2;
2356 chan_info->info = tchan_info->info;
2357 chan_info->reg_info_1 = tchan_info->reg_info_1;
2358 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302359 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302360
2361 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2362 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2363 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2364 tchan_info++;
2365 chan_info++;
2366 }
Anish Natarajdd855152017-03-20 12:49:08 +05302367 cmd->pdev_id = chan_list->pdev_id + 1;
Govind Singhd3156eb2016-02-26 17:50:39 +05302368
Anish Natarajdd855152017-03-20 12:49:08 +05302369 qdf_status = wmi_unified_cmd_send(wmi_handle,
2370 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302371
Govind Singh67922e82016-04-01 16:48:57 +05302372 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302373 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302374 wmi_buf_free(buf);
2375 }
Govind Singh67922e82016-04-01 16:48:57 +05302376
Govind Singhd3156eb2016-02-26 17:50:39 +05302377end:
Govind Singhb53420c2016-03-09 14:32:57 +05302378 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302379}
Govind Singh87542482016-06-08 19:40:11 +05302380#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302381static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302382 struct scan_chan_list_params *chan_list)
2383{
2384 wmi_buf_t buf;
2385 QDF_STATUS qdf_status;
2386 wmi_scan_chan_list_cmd_fixed_param *cmd;
2387 int i;
2388 uint8_t *buf_ptr;
2389 wmi_channel *chan_info;
2390 struct channel_param *tchan_info;
2391 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302392
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302393 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302394 buf = wmi_buf_alloc(wmi_handle, len);
2395 if (!buf) {
2396 WMI_LOGE("Failed to allocate memory");
2397 qdf_status = QDF_STATUS_E_NOMEM;
2398 goto end;
2399 }
2400
2401 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2402 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2403 WMITLV_SET_HDR(&cmd->tlv_header,
2404 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2405 WMITLV_GET_STRUCT_TLVLEN
2406 (wmi_scan_chan_list_cmd_fixed_param));
2407
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302408 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302409
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302410 cmd->pdev_id = chan_list->pdev_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302411 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302412 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2413 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302414 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302415 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2416 tchan_info = &(chan_list->ch_param[0]);
2417
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302418 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302419 WMITLV_SET_HDR(&chan_info->tlv_header,
2420 WMITLV_TAG_STRUC_wmi_channel,
2421 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2422 chan_info->mhz = tchan_info->mhz;
2423 chan_info->band_center_freq1 =
2424 tchan_info->cfreq1;
2425 chan_info->band_center_freq2 =
2426 tchan_info->cfreq2;
2427
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302428 if (tchan_info->is_chan_passive)
2429 WMI_SET_CHANNEL_FLAG(chan_info,
2430 WMI_CHAN_FLAG_PASSIVE);
2431
2432 if (tchan_info->allow_vht)
2433 WMI_SET_CHANNEL_FLAG(chan_info,
2434 WMI_CHAN_FLAG_ALLOW_VHT);
2435 else if (tchan_info->allow_ht)
2436 WMI_SET_CHANNEL_FLAG(chan_info,
2437 WMI_CHAN_FLAG_ALLOW_HT);
2438 WMI_SET_CHANNEL_MODE(chan_info,
2439 tchan_info->phy_mode);
2440
2441 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2442 * after FW support
2443 */
2444
2445 /* also fill in power information */
2446 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2447 tchan_info->minpower);
2448 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2449 tchan_info->maxpower);
2450 WMI_SET_CHANNEL_REG_POWER(chan_info,
2451 tchan_info->maxregpower);
2452 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2453 tchan_info->antennamax);
2454 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2455 tchan_info->reg_class_id);
2456
Govind Singh87542482016-06-08 19:40:11 +05302457 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2458
Govind Singh87542482016-06-08 19:40:11 +05302459 tchan_info++;
2460 chan_info++;
2461 }
Anish Natarajdd855152017-03-20 12:49:08 +05302462 cmd->pdev_id = chan_list->pdev_id + 1;
Govind Singh87542482016-06-08 19:40:11 +05302463
Anish Natarajdd855152017-03-20 12:49:08 +05302464 qdf_status = wmi_unified_cmd_send(
2465 wmi_handle,
2466 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302467
2468 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2469 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2470 wmi_buf_free(buf);
2471 }
2472
2473end:
2474 return qdf_status;
2475}
2476#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302477/**
2478 * send_mgmt_cmd_tlv() - WMI scan start function
2479 * @wmi_handle : handle to WMI.
2480 * @param : pointer to hold mgmt cmd parameter
2481 *
2482 * Return: 0 on success and -ve on failure.
2483 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302484static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302485 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302486{
Govind Singh427ee5a2016-02-26 18:09:36 +05302487 wmi_buf_t buf;
2488 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2489 int32_t cmd_len;
2490 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302491 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302492 uint8_t *bufp;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302493 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302494 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2495 mgmt_tx_dl_frm_len;
2496
2497 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2498 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2499
2500 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2501 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302502 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2503 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302504 }
2505
2506 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2507 bufp = (uint8_t *) cmd;
2508 WMITLV_SET_HDR(&cmd->tlv_header,
2509 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2510 WMITLV_GET_STRUCT_TLVLEN
2511 (wmi_mgmt_tx_send_cmd_fixed_param));
2512
2513 cmd->vdev_id = param->vdev_id;
2514
Govind Singh224a7312016-06-21 14:33:26 +05302515 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302516 cmd->chanfreq = param->chanfreq;
2517 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2518 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2519 sizeof(uint32_t)));
2520 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302521 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302522
2523 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2524 QDF_DMA_TO_DEVICE);
2525 if (status != QDF_STATUS_SUCCESS) {
2526 WMI_LOGE("%s: wmi buf map failed", __func__);
2527 goto err1;
2528 }
2529
Govind Singhb53420c2016-03-09 14:32:57 +05302530 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302531 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002532#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302533 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2534#endif
2535 cmd->frame_len = param->frm_len;
2536 cmd->buf_len = bufp_len;
2537
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002538 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002539 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002540
Govind Singh427ee5a2016-02-26 18:09:36 +05302541 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2542 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302543 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302544 goto err1;
2545 }
Govind Singhb53420c2016-03-09 14:32:57 +05302546 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302547
2548err1:
2549 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302550 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302551}
2552
2553/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302554 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2555 * @wmi_handle : handle to WMI.
2556 * @param : pointer to offchan data tx cmd parameter
2557 *
2558 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2559 */
2560static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2561 struct wmi_offchan_data_tx_params *param)
2562{
2563 wmi_buf_t buf;
2564 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2565 int32_t cmd_len;
2566 uint64_t dma_addr;
2567 void *qdf_ctx = param->qdf_ctx;
2568 uint8_t *bufp;
2569 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2570 param->frm_len : mgmt_tx_dl_frm_len;
2571
2572 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
2573 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2574
2575 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2576 if (!buf) {
2577 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2578 return QDF_STATUS_E_NOMEM;
2579 }
2580
2581 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2582 bufp = (uint8_t *) cmd;
2583 WMITLV_SET_HDR(&cmd->tlv_header,
2584 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2585 WMITLV_GET_STRUCT_TLVLEN
2586 (wmi_offchan_data_tx_send_cmd_fixed_param));
2587
2588 cmd->vdev_id = param->vdev_id;
2589
2590 cmd->desc_id = param->desc_id;
2591 cmd->chanfreq = param->chanfreq;
2592 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2593 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2594 sizeof(uint32_t)));
2595 bufp += WMI_TLV_HDR_SIZE;
2596 qdf_mem_copy(bufp, param->pdata, bufp_len);
2597 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2598 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2599 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2600#if defined(HTT_PADDR64)
2601 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2602#endif
2603 cmd->frame_len = param->frm_len;
2604 cmd->buf_len = bufp_len;
2605
2606 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2607 bufp, cmd->vdev_id, cmd->chanfreq);
2608
2609 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2610 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2611 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
2612 wmi_buf_free(buf);
2613 return QDF_STATUS_E_FAILURE;
2614 }
2615
2616 return QDF_STATUS_SUCCESS;
2617}
2618
2619/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302620 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2621 * @wmi_handle: wmi handle
2622 * @param_value: parameter value
2623 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302624 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302625 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302626static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302627 uint32_t param_value)
2628{
Govind Singh67922e82016-04-01 16:48:57 +05302629 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302630 wmi_modem_power_state_cmd_param *cmd;
2631 wmi_buf_t buf;
2632 uint16_t len = sizeof(*cmd);
2633
2634 buf = wmi_buf_alloc(wmi_handle, len);
2635 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302636 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302637 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302638 }
2639 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2640 WMITLV_SET_HDR(&cmd->tlv_header,
2641 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2642 WMITLV_GET_STRUCT_TLVLEN
2643 (wmi_modem_power_state_cmd_param));
2644 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302645 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302646 param_value);
2647 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2648 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302649 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302650 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302651 wmi_buf_free(buf);
2652 }
Govind Singh67922e82016-04-01 16:48:57 +05302653
Govind Singh427ee5a2016-02-26 18:09:36 +05302654 return ret;
2655}
2656
2657/**
2658 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2659 * @wmi_handle: wmi handle
2660 * @vdev_id: vdev id
2661 * @val: value
2662 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302663 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302664 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302665static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302666 uint32_t vdev_id, uint8_t val)
2667{
2668 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2669 wmi_buf_t buf;
2670 int32_t len = sizeof(*cmd);
2671
Govind Singhb53420c2016-03-09 14:32:57 +05302672 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302673
2674 buf = wmi_buf_alloc(wmi_handle, len);
2675 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302676 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302677 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302678 }
2679 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2680 WMITLV_SET_HDR(&cmd->tlv_header,
2681 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2682 WMITLV_GET_STRUCT_TLVLEN
2683 (wmi_sta_powersave_mode_cmd_fixed_param));
2684 cmd->vdev_id = vdev_id;
2685 if (val)
2686 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2687 else
2688 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2689
2690 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2691 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302692 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302693 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302694 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302695 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302696 }
Govind Singh5eb51532016-03-09 11:34:12 +05302697 return 0;
2698}
2699
Govind Singh427ee5a2016-02-26 18:09:36 +05302700/**
2701 * send_set_mimops_cmd_tlv() - set MIMO powersave
2702 * @wmi_handle: wmi handle
2703 * @vdev_id: vdev id
2704 * @value: value
2705 *
Govind Singhb53420c2016-03-09 14:32:57 +05302706 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302707 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302708static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302709 uint8_t vdev_id, int value)
2710{
Govind Singh67922e82016-04-01 16:48:57 +05302711 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302712 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2713 wmi_buf_t buf;
2714 uint16_t len = sizeof(*cmd);
2715
2716 buf = wmi_buf_alloc(wmi_handle, len);
2717 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302718 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302719 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302720 }
2721 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2722 WMITLV_SET_HDR(&cmd->tlv_header,
2723 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2724 WMITLV_GET_STRUCT_TLVLEN
2725 (wmi_sta_smps_force_mode_cmd_fixed_param));
2726
2727 cmd->vdev_id = vdev_id;
2728
Houston Hoffmanb5168052016-04-14 02:18:01 -07002729 /* WMI_SMPS_FORCED_MODE values do not directly map
2730 * to SM power save values defined in the specification.
2731 * Make sure to send the right mapping.
2732 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302733 switch (value) {
2734 case 0:
2735 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2736 break;
2737 case 1:
2738 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2739 break;
2740 case 2:
2741 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2742 break;
2743 case 3:
2744 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2745 break;
2746 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302747 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2748 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302749 }
2750
Govind Singhb53420c2016-03-09 14:32:57 +05302751 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302752
2753 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2754 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302755 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302756 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302757 wmi_buf_free(buf);
2758 }
2759
2760 return ret;
2761}
2762
2763/**
2764 * send_set_smps_params_cmd_tlv() - set smps params
2765 * @wmi_handle: wmi handle
2766 * @vdev_id: vdev id
2767 * @value: value
2768 *
Govind Singhb53420c2016-03-09 14:32:57 +05302769 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302770 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302771static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302772 int value)
2773{
Govind Singh67922e82016-04-01 16:48:57 +05302774 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302775 wmi_sta_smps_param_cmd_fixed_param *cmd;
2776 wmi_buf_t buf;
2777 uint16_t len = sizeof(*cmd);
2778
2779 buf = wmi_buf_alloc(wmi_handle, len);
2780 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302781 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302782 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302783 }
2784 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2785 WMITLV_SET_HDR(&cmd->tlv_header,
2786 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2787 WMITLV_GET_STRUCT_TLVLEN
2788 (wmi_sta_smps_param_cmd_fixed_param));
2789
2790 cmd->vdev_id = vdev_id;
2791 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2792 cmd->param =
2793 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2794
Govind Singhb53420c2016-03-09 14:32:57 +05302795 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302796 cmd->param);
2797
2798 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2799 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302800 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302801 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302802 wmi_buf_free(buf);
2803 }
2804
2805 return ret;
2806}
2807
2808/**
2809 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2810 * @wmi_handle: wmi handle
2811 * @noa: p2p power save parameters
2812 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302813 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302814 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302815static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302816 struct p2p_ps_params *noa)
2817{
2818 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2819 wmi_p2p_noa_descriptor *noa_discriptor;
2820 wmi_buf_t buf;
2821 uint8_t *buf_ptr;
2822 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302823 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302824 uint32_t duration;
2825
Govind Singhb53420c2016-03-09 14:32:57 +05302826 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302827 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2828 buf = wmi_buf_alloc(wmi_handle, len);
2829 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302830 WMI_LOGE("Failed to allocate memory");
2831 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302832 goto end;
2833 }
2834
2835 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2836 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2837 WMITLV_SET_HDR(&cmd->tlv_header,
2838 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2839 WMITLV_GET_STRUCT_TLVLEN
2840 (wmi_p2p_set_noa_cmd_fixed_param));
2841 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2842 cmd->vdev_id = noa->session_id;
2843 cmd->enable = (duration) ? true : false;
2844 cmd->num_noa = 1;
2845
2846 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2847 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2848 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2849 sizeof
2850 (wmi_p2p_set_noa_cmd_fixed_param)
2851 + WMI_TLV_HDR_SIZE);
2852 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2853 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2854 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2855 noa_discriptor->type_count = noa->count;
2856 noa_discriptor->duration = duration;
2857 noa_discriptor->interval = noa->interval;
2858 noa_discriptor->start_time = 0;
2859
Govind Singhb53420c2016-03-09 14:32:57 +05302860 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302861 cmd->vdev_id, noa->count, noa_discriptor->duration,
2862 noa->interval);
2863 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2864 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302865 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302866 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302867 wmi_buf_free(buf);
2868 }
2869
2870end:
Govind Singhb53420c2016-03-09 14:32:57 +05302871 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302872 return status;
2873}
2874
2875
2876/**
2877 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2878 * @wmi_handle: wmi handle
2879 * @noa: p2p opp power save parameters
2880 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302881 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302882 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302883static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302884 struct p2p_ps_params *oppps)
2885{
2886 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2887 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302888 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302889
Govind Singhb53420c2016-03-09 14:32:57 +05302890 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302891 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2892 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302893 WMI_LOGE("Failed to allocate memory");
2894 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302895 goto end;
2896 }
2897
2898 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2899 WMITLV_SET_HDR(&cmd->tlv_header,
2900 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2901 WMITLV_GET_STRUCT_TLVLEN
2902 (wmi_p2p_set_oppps_cmd_fixed_param));
2903 cmd->vdev_id = oppps->session_id;
2904 if (oppps->ctwindow)
2905 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2906
2907 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302908 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302909 cmd->vdev_id, oppps->ctwindow);
2910 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2911 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302912 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302913 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302914 wmi_buf_free(buf);
2915 }
2916
2917end:
Govind Singhb53420c2016-03-09 14:32:57 +05302918 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302919 return status;
2920}
2921
Wu Gaocd3a8512017-03-13 20:17:34 +08002922#ifdef CONVERGED_P2P_ENABLE
2923/**
2924 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
2925 * @wmi_handle: wmi handle
2926 * @param: p2p listen offload start parameters
2927 *
2928 * Return: QDF status
2929 */
2930static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
2931 struct p2p_lo_start *param)
2932{
2933 wmi_buf_t buf;
2934 wmi_p2p_lo_start_cmd_fixed_param *cmd;
2935 int32_t len = sizeof(*cmd);
2936 uint8_t *buf_ptr;
2937 QDF_STATUS status;
2938 int device_types_len_aligned;
2939 int probe_resp_len_aligned;
2940
2941 if (!param) {
2942 WMI_LOGE("lo start param is null");
2943 return QDF_STATUS_E_INVAL;
2944 }
2945
2946 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
2947
2948 device_types_len_aligned =
2949 qdf_roundup(param->dev_types_len,
2950 sizeof(A_UINT32));
2951 probe_resp_len_aligned =
2952 qdf_roundup(param->probe_resp_len,
2953 sizeof(A_UINT32));
2954
2955 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
2956 probe_resp_len_aligned;
2957
2958 buf = wmi_buf_alloc(wmi_handle, len);
2959 if (!buf) {
2960 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
2961 __func__);
2962 return QDF_STATUS_E_NOMEM;
2963 }
2964
2965 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
2966 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2967
2968 WMITLV_SET_HDR(&cmd->tlv_header,
2969 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
2970 WMITLV_GET_STRUCT_TLVLEN(
2971 wmi_p2p_lo_start_cmd_fixed_param));
2972
2973 cmd->vdev_id = param->vdev_id;
2974 cmd->ctl_flags = param->ctl_flags;
2975 cmd->channel = param->freq;
2976 cmd->period = param->period;
2977 cmd->interval = param->interval;
2978 cmd->count = param->count;
2979 cmd->device_types_len = param->dev_types_len;
2980 cmd->prob_resp_len = param->probe_resp_len;
2981
2982 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
2983 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2984 device_types_len_aligned);
2985 buf_ptr += WMI_TLV_HDR_SIZE;
2986 qdf_mem_copy(buf_ptr, param->device_types,
2987 param->dev_types_len);
2988
2989 buf_ptr += device_types_len_aligned;
2990 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2991 probe_resp_len_aligned);
2992 buf_ptr += WMI_TLV_HDR_SIZE;
2993 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
2994 param->probe_resp_len);
2995
2996 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
2997 cmd->channel, cmd->period, cmd->interval, cmd->count);
2998
2999 status = wmi_unified_cmd_send(wmi_handle,
3000 buf, len,
3001 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3002 if (status != QDF_STATUS_SUCCESS) {
3003 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3004 __func__, status);
3005 wmi_buf_free(buf);
3006 return status;
3007 }
3008
3009 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3010
3011 return QDF_STATUS_SUCCESS;
3012}
3013
3014/**
3015 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3016 * @wmi_handle: wmi handle
3017 * @param: p2p listen offload stop parameters
3018 *
3019 * Return: QDF status
3020 */
3021static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3022 uint8_t vdev_id)
3023{
3024 wmi_buf_t buf;
3025 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3026 int32_t len;
3027 QDF_STATUS status;
3028
3029 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3030
3031 len = sizeof(*cmd);
3032 buf = wmi_buf_alloc(wmi_handle, len);
3033 if (!buf) {
3034 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3035 __func__);
3036 return QDF_STATUS_E_NOMEM;
3037 }
3038 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3039
3040 WMITLV_SET_HDR(&cmd->tlv_header,
3041 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3042 WMITLV_GET_STRUCT_TLVLEN(
3043 wmi_p2p_lo_stop_cmd_fixed_param));
3044
3045 cmd->vdev_id = vdev_id;
3046
3047 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3048
3049 status = wmi_unified_cmd_send(wmi_handle,
3050 buf, len,
3051 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3052 if (status != QDF_STATUS_SUCCESS) {
3053 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3054 __func__, status);
3055 wmi_buf_free(buf);
3056 return status;
3057 }
3058
3059 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3060
3061 return QDF_STATUS_SUCCESS;
3062}
3063#endif /* End of CONVERGED_P2P_ENABLE */
3064
Govind Singh427ee5a2016-02-26 18:09:36 +05303065/**
3066 * send_get_temperature_cmd_tlv() - get pdev temperature req
3067 * @wmi_handle: wmi handle
3068 *
Govind Singhb53420c2016-03-09 14:32:57 +05303069 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303071static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303072{
3073 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3074 wmi_buf_t wmi_buf;
3075 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3076 uint8_t *buf_ptr;
3077
3078 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303079 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3080 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303081 }
3082
3083 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3084 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303085 WMI_LOGE(FL("wmi_buf_alloc failed"));
3086 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303087 }
3088
3089 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3090
3091 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3092 WMITLV_SET_HDR(&cmd->tlv_header,
3093 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3094 WMITLV_GET_STRUCT_TLVLEN
3095 (wmi_pdev_get_temperature_cmd_fixed_param));
3096
3097 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3098 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303099 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303100 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303101 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303102 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303103
Govind Singhb53420c2016-03-09 14:32:57 +05303104 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303105}
3106
3107/**
3108 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3109 * @wmi_handle: wmi handle
3110 * @vdevid: vdev id
3111 * @peer_addr: peer mac address
3112 * @auto_triggerparam: auto trigger parameters
3113 * @num_ac: number of access category
3114 *
3115 * This function sets the trigger
3116 * uapsd params such as service interval, delay interval
3117 * and suspend interval which will be used by the firmware
3118 * to send trigger frames periodically when there is no
3119 * traffic on the transmit side.
3120 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303121 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303122 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303123static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303124 struct sta_uapsd_trig_params *param)
3125{
3126 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303127 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303128 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3129 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3130 uint32_t i;
3131 wmi_buf_t buf;
3132 uint8_t *buf_ptr;
3133
3134 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3135 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303136 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303137 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303138 }
3139
3140 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3141 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3142 WMITLV_SET_HDR(&cmd->tlv_header,
3143 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3144 WMITLV_GET_STRUCT_TLVLEN
3145 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3146 cmd->vdev_id = param->vdevid;
3147 cmd->num_ac = param->num_ac;
3148 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3149
3150 /* TLV indicating array of structures to follow */
3151 buf_ptr += sizeof(*cmd);
3152 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3153
3154 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303155 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303156
3157 /*
3158 * Update tag and length for uapsd auto trigger params (this will take
3159 * care of updating tag and length if it is not pre-filled by caller).
3160 */
3161 for (i = 0; i < param->num_ac; i++) {
3162 WMITLV_SET_HDR((buf_ptr +
3163 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3164 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3165 WMITLV_GET_STRUCT_TLVLEN
3166 (wmi_sta_uapsd_auto_trig_param));
3167 }
3168
3169 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3170 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303171 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303172 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303173 wmi_buf_free(buf);
3174 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303175
Govind Singh427ee5a2016-02-26 18:09:36 +05303176 return ret;
3177}
3178
Govind Singh2edc80f2016-03-01 15:30:53 +05303179/**
3180 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3181 * @wmi_handle: pointer to the wmi handle
3182 * @utc: pointer to the UTC time struct
3183 *
3184 * Return: 0 on succes
3185 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303186static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303187 struct ocb_utc_param *utc)
3188{
Govind Singh67922e82016-04-01 16:48:57 +05303189 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303190 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3191 uint8_t *buf_ptr;
3192 uint32_t len, i;
3193 wmi_buf_t buf;
3194
3195 len = sizeof(*cmd);
3196 buf = wmi_buf_alloc(wmi_handle, len);
3197 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303198 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303199 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303200 }
3201
3202 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3203 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3204 WMITLV_SET_HDR(&cmd->tlv_header,
3205 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3206 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3207 cmd->vdev_id = utc->vdev_id;
3208
3209 for (i = 0; i < SIZE_UTC_TIME; i++)
3210 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3211
3212 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3213 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3214
3215 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3216 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303217 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303218 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303219 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303220 }
3221
Govind Singh67922e82016-04-01 16:48:57 +05303222 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303223}
3224
3225/**
3226 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3227 * frames on a channel
3228 * @wmi_handle: pointer to the wmi handle
3229 * @timing_advert: pointer to the timing advertisement struct
3230 *
3231 * Return: 0 on succes
3232 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303233static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303234 struct ocb_timing_advert_param *timing_advert)
3235{
Govind Singh67922e82016-04-01 16:48:57 +05303236 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303237 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3238 uint8_t *buf_ptr;
3239 uint32_t len, len_template;
3240 wmi_buf_t buf;
3241
3242 len = sizeof(*cmd) +
3243 WMI_TLV_HDR_SIZE;
3244
3245 len_template = timing_advert->template_length;
3246 /* Add padding to the template if needed */
3247 if (len_template % 4 != 0)
3248 len_template += 4 - (len_template % 4);
3249 len += len_template;
3250
3251 buf = wmi_buf_alloc(wmi_handle, len);
3252 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303253 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303254 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303255 }
3256
3257 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3258 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3259 WMITLV_SET_HDR(&cmd->tlv_header,
3260 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3261 WMITLV_GET_STRUCT_TLVLEN(
3262 wmi_ocb_start_timing_advert_cmd_fixed_param));
3263 cmd->vdev_id = timing_advert->vdev_id;
3264 cmd->repeat_rate = timing_advert->repeat_rate;
3265 cmd->channel_freq = timing_advert->chan_freq;
3266 cmd->timestamp_offset = timing_advert->timestamp_offset;
3267 cmd->time_value_offset = timing_advert->time_value_offset;
3268 cmd->timing_advert_template_length = timing_advert->template_length;
3269 buf_ptr += sizeof(*cmd);
3270
3271 /* Add the timing advert template */
3272 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3273 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303274 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303275 (uint8_t *)timing_advert->template_value,
3276 timing_advert->template_length);
3277
3278 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3279 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303280 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303281 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303282 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303283 }
3284
Govind Singh67922e82016-04-01 16:48:57 +05303285 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303286}
3287
3288/**
3289 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3290 * on a channel
3291 * @wmi_handle: pointer to the wmi handle
3292 * @timing_advert: pointer to the timing advertisement struct
3293 *
3294 * Return: 0 on succes
3295 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303296static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303297 struct ocb_timing_advert_param *timing_advert)
3298{
Govind Singh67922e82016-04-01 16:48:57 +05303299 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303300 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3301 uint8_t *buf_ptr;
3302 uint32_t len;
3303 wmi_buf_t buf;
3304
3305 len = sizeof(*cmd);
3306 buf = wmi_buf_alloc(wmi_handle, len);
3307 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303308 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303309 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303310 }
3311
3312 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3313 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3314 WMITLV_SET_HDR(&cmd->tlv_header,
3315 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3316 WMITLV_GET_STRUCT_TLVLEN(
3317 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3318 cmd->vdev_id = timing_advert->vdev_id;
3319 cmd->channel_freq = timing_advert->chan_freq;
3320
3321 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3322 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303323 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303324 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303325 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303326 }
3327
Govind Singh67922e82016-04-01 16:48:57 +05303328 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303329}
3330
3331/**
3332 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3333 * @wmi_handle: pointer to the wmi handle
3334 * @request: pointer to the request
3335 *
3336 * Return: 0 on succes
3337 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303338static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303339 uint8_t vdev_id)
3340{
Govind Singhb53420c2016-03-09 14:32:57 +05303341 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303342 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3343 uint8_t *buf_ptr;
3344 wmi_buf_t buf;
3345 int32_t len;
3346
3347 len = sizeof(*cmd);
3348 buf = wmi_buf_alloc(wmi_handle, len);
3349 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303350 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303351 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303352 }
3353 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3354
3355 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303356 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303357 WMITLV_SET_HDR(&cmd->tlv_header,
3358 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3359 WMITLV_GET_STRUCT_TLVLEN(
3360 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3361 cmd->vdev_id = vdev_id;
3362
3363 /* Send the WMI command */
3364 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3365 WMI_OCB_GET_TSF_TIMER_CMDID);
3366 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303367 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303368 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303369 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303370 }
3371
Govind Singh67922e82016-04-01 16:48:57 +05303372 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303373}
3374
3375/**
3376 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3377 * @wmi_handle: pointer to the wmi handle
3378 * @get_stats_param: pointer to the dcc stats
3379 *
3380 * Return: 0 on succes
3381 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303382static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303383 struct dcc_get_stats_param *get_stats_param)
3384{
Govind Singh67922e82016-04-01 16:48:57 +05303385 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303386 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3387 wmi_dcc_channel_stats_request *channel_stats_array;
3388 wmi_buf_t buf;
3389 uint8_t *buf_ptr;
3390 uint32_t len;
3391 uint32_t i;
3392
3393 /* Validate the input */
3394 if (get_stats_param->request_array_len !=
3395 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303396 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303397 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303398 }
3399
3400 /* Allocate memory for the WMI command */
3401 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3402 get_stats_param->request_array_len;
3403
3404 buf = wmi_buf_alloc(wmi_handle, len);
3405 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303406 WMI_LOGE(FL("wmi_buf_alloc failed"));
3407 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303408 }
3409
3410 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303411 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303412
3413 /* Populate the WMI command */
3414 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3415 buf_ptr += sizeof(*cmd);
3416
3417 WMITLV_SET_HDR(&cmd->tlv_header,
3418 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3419 WMITLV_GET_STRUCT_TLVLEN(
3420 wmi_dcc_get_stats_cmd_fixed_param));
3421 cmd->vdev_id = get_stats_param->vdev_id;
3422 cmd->num_channels = get_stats_param->channel_count;
3423
3424 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3425 get_stats_param->request_array_len);
3426 buf_ptr += WMI_TLV_HDR_SIZE;
3427
3428 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303429 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303430 get_stats_param->request_array_len);
3431 for (i = 0; i < cmd->num_channels; i++)
3432 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3433 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3434 WMITLV_GET_STRUCT_TLVLEN(
3435 wmi_dcc_channel_stats_request));
3436
3437 /* Send the WMI command */
3438 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3439 WMI_DCC_GET_STATS_CMDID);
3440
Govind Singh67922e82016-04-01 16:48:57 +05303441 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303442 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303443 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303444 }
3445
Govind Singh67922e82016-04-01 16:48:57 +05303446 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303447}
3448
3449/**
3450 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3451 * @wmi_handle: pointer to the wmi handle
3452 * @vdev_id: vdev id
3453 * @dcc_stats_bitmap: dcc status bitmap
3454 *
3455 * Return: 0 on succes
3456 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303457static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303458 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3459{
Govind Singh67922e82016-04-01 16:48:57 +05303460 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303461 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3462 wmi_buf_t buf;
3463 uint8_t *buf_ptr;
3464 uint32_t len;
3465
3466 /* Allocate memory for the WMI command */
3467 len = sizeof(*cmd);
3468
3469 buf = wmi_buf_alloc(wmi_handle, len);
3470 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303471 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303472 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303473 }
3474
3475 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303476 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303477
3478 /* Populate the WMI command */
3479 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3480
3481 WMITLV_SET_HDR(&cmd->tlv_header,
3482 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3483 WMITLV_GET_STRUCT_TLVLEN(
3484 wmi_dcc_clear_stats_cmd_fixed_param));
3485 cmd->vdev_id = vdev_id;
3486 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3487
3488 /* Send the WMI command */
3489 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3490 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303491 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303492 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303493 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303494 }
3495
Govind Singh67922e82016-04-01 16:48:57 +05303496 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303497}
3498
3499/**
3500 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3501 * @wmi_handle: pointer to the wmi handle
3502 * @update_ndl_param: pointer to the request parameters
3503 *
3504 * Return: 0 on success
3505 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303506static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303507 struct dcc_update_ndl_param *update_ndl_param)
3508{
Govind Singhb53420c2016-03-09 14:32:57 +05303509 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303510 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3511 wmi_dcc_ndl_chan *ndl_chan_array;
3512 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3513 uint32_t active_state_count;
3514 wmi_buf_t buf;
3515 uint8_t *buf_ptr;
3516 uint32_t len;
3517 uint32_t i;
3518
3519 /* validate the input */
3520 if (update_ndl_param->dcc_ndl_chan_list_len !=
3521 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303522 WMI_LOGE(FL("Invalid parameter"));
3523 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303524 }
3525 active_state_count = 0;
3526 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3527 for (i = 0; i < update_ndl_param->channel_count; i++)
3528 active_state_count +=
3529 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3530 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3531 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303532 WMI_LOGE(FL("Invalid parameter"));
3533 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303534 }
3535
3536 /* Allocate memory for the WMI command */
3537 len = sizeof(*cmd) +
3538 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3539 WMI_TLV_HDR_SIZE +
3540 update_ndl_param->dcc_ndl_active_state_list_len;
3541
3542 buf = wmi_buf_alloc(wmi_handle, len);
3543 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303544 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303545 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303546 }
3547
3548 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303549 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303550
3551 /* Populate the WMI command */
3552 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3553 buf_ptr += sizeof(*cmd);
3554
3555 WMITLV_SET_HDR(&cmd->tlv_header,
3556 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3557 WMITLV_GET_STRUCT_TLVLEN(
3558 wmi_dcc_update_ndl_cmd_fixed_param));
3559 cmd->vdev_id = update_ndl_param->vdev_id;
3560 cmd->num_channel = update_ndl_param->channel_count;
3561
3562 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3563 update_ndl_param->dcc_ndl_chan_list_len);
3564 buf_ptr += WMI_TLV_HDR_SIZE;
3565
3566 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303567 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303568 update_ndl_param->dcc_ndl_chan_list_len);
3569 for (i = 0; i < cmd->num_channel; i++)
3570 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3571 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3572 WMITLV_GET_STRUCT_TLVLEN(
3573 wmi_dcc_ndl_chan));
3574 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3575
3576 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3577 update_ndl_param->dcc_ndl_active_state_list_len);
3578 buf_ptr += WMI_TLV_HDR_SIZE;
3579
3580 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303581 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303582 update_ndl_param->dcc_ndl_active_state_list,
3583 update_ndl_param->dcc_ndl_active_state_list_len);
3584 for (i = 0; i < active_state_count; i++) {
3585 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3586 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3587 WMITLV_GET_STRUCT_TLVLEN(
3588 wmi_dcc_ndl_active_state_config));
3589 }
3590 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3591
3592 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303593 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303594 WMI_DCC_UPDATE_NDL_CMDID);
3595 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303596 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303597 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303598 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303599 }
3600
Govind Singh67922e82016-04-01 16:48:57 +05303601 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303602}
3603
3604/**
3605 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3606 * @wmi_handle: pointer to the wmi handle
3607 * @config: the OCB configuration
3608 *
3609 * Return: 0 on success
3610 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303611static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303612 struct ocb_config_param *config, uint32_t *ch_mhz)
3613{
Govind Singh67922e82016-04-01 16:48:57 +05303614 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303615 wmi_ocb_set_config_cmd_fixed_param *cmd;
3616 wmi_channel *chan;
3617 wmi_ocb_channel *ocb_chan;
3618 wmi_qos_parameter *qos_param;
3619 wmi_dcc_ndl_chan *ndl_chan;
3620 wmi_dcc_ndl_active_state_config *ndl_active_config;
3621 wmi_ocb_schedule_element *sched_elem;
3622 uint8_t *buf_ptr;
3623 wmi_buf_t buf;
3624 int32_t len;
3625 int32_t i, j, active_state_count;
3626
3627 /*
3628 * Validate the dcc_ndl_chan_list_len and count the number of active
3629 * states. Validate dcc_ndl_active_state_list_len.
3630 */
3631 active_state_count = 0;
3632 if (config->dcc_ndl_chan_list_len) {
3633 if (!config->dcc_ndl_chan_list ||
3634 config->dcc_ndl_chan_list_len !=
3635 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303636 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303637 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303638 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303639 }
3640
3641 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3642 i < config->channel_count; ++i, ++ndl_chan)
3643 active_state_count +=
3644 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3645
3646 if (active_state_count) {
3647 if (!config->dcc_ndl_active_state_list ||
3648 config->dcc_ndl_active_state_list_len !=
3649 active_state_count *
3650 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303651 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303652 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303653 }
3654 }
3655 }
3656
3657 len = sizeof(*cmd) +
3658 WMI_TLV_HDR_SIZE + config->channel_count *
3659 sizeof(wmi_channel) +
3660 WMI_TLV_HDR_SIZE + config->channel_count *
3661 sizeof(wmi_ocb_channel) +
3662 WMI_TLV_HDR_SIZE + config->channel_count *
3663 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3664 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3665 WMI_TLV_HDR_SIZE + active_state_count *
3666 sizeof(wmi_dcc_ndl_active_state_config) +
3667 WMI_TLV_HDR_SIZE + config->schedule_size *
3668 sizeof(wmi_ocb_schedule_element);
3669 buf = wmi_buf_alloc(wmi_handle, len);
3670 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303671 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303672 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303673 }
3674
3675 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3676 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3677 WMITLV_SET_HDR(&cmd->tlv_header,
3678 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3679 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3680 cmd->vdev_id = config->session_id;
3681 cmd->channel_count = config->channel_count;
3682 cmd->schedule_size = config->schedule_size;
3683 cmd->flags = config->flags;
3684 buf_ptr += sizeof(*cmd);
3685
3686 /* Add the wmi_channel info */
3687 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3688 config->channel_count*sizeof(wmi_channel));
3689 buf_ptr += WMI_TLV_HDR_SIZE;
3690 for (i = 0; i < config->channel_count; i++) {
3691 chan = (wmi_channel *)buf_ptr;
3692 WMITLV_SET_HDR(&chan->tlv_header,
3693 WMITLV_TAG_STRUC_wmi_channel,
3694 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3695 chan->mhz = config->channels[i].chan_freq;
3696 chan->band_center_freq1 = config->channels[i].chan_freq;
3697 chan->band_center_freq2 = 0;
3698 chan->info = 0;
3699
3700 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3701 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3702 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3703 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3704 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3705 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3706 config->channels[i].antenna_max);
3707
3708 if (config->channels[i].bandwidth < 10)
3709 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3710 else if (config->channels[i].bandwidth < 20)
3711 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3712 buf_ptr += sizeof(*chan);
3713 }
3714
3715 /* Add the wmi_ocb_channel info */
3716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3717 config->channel_count*sizeof(wmi_ocb_channel));
3718 buf_ptr += WMI_TLV_HDR_SIZE;
3719 for (i = 0; i < config->channel_count; i++) {
3720 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3721 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3722 WMITLV_TAG_STRUC_wmi_ocb_channel,
3723 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3724 ocb_chan->bandwidth = config->channels[i].bandwidth;
3725 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3726 config->channels[i].mac_address.bytes,
3727 &ocb_chan->mac_address);
3728 buf_ptr += sizeof(*ocb_chan);
3729 }
3730
3731 /* Add the wmi_qos_parameter info */
3732 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3733 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3734 buf_ptr += WMI_TLV_HDR_SIZE;
3735 /* WMI_MAX_NUM_AC parameters for each channel */
3736 for (i = 0; i < config->channel_count; i++) {
3737 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3738 qos_param = (wmi_qos_parameter *)buf_ptr;
3739 WMITLV_SET_HDR(&qos_param->tlv_header,
3740 WMITLV_TAG_STRUC_wmi_qos_parameter,
3741 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3742 qos_param->aifsn =
3743 config->channels[i].qos_params[j].aifsn;
3744 qos_param->cwmin =
3745 config->channels[i].qos_params[j].cwmin;
3746 qos_param->cwmax =
3747 config->channels[i].qos_params[j].cwmax;
3748 buf_ptr += sizeof(*qos_param);
3749 }
3750 }
3751
3752 /* Add the wmi_dcc_ndl_chan (per channel) */
3753 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3754 config->dcc_ndl_chan_list_len);
3755 buf_ptr += WMI_TLV_HDR_SIZE;
3756 if (config->dcc_ndl_chan_list_len) {
3757 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303758 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303759 config->dcc_ndl_chan_list_len);
3760 for (i = 0; i < config->channel_count; i++)
3761 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3762 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3763 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3764 buf_ptr += config->dcc_ndl_chan_list_len;
3765 }
3766
3767 /* Add the wmi_dcc_ndl_active_state_config */
3768 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3769 sizeof(wmi_dcc_ndl_active_state_config));
3770 buf_ptr += WMI_TLV_HDR_SIZE;
3771 if (active_state_count) {
3772 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303773 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303774 config->dcc_ndl_active_state_list,
3775 active_state_count * sizeof(*ndl_active_config));
3776 for (i = 0; i < active_state_count; ++i)
3777 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3778 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3779 WMITLV_GET_STRUCT_TLVLEN(
3780 wmi_dcc_ndl_active_state_config));
3781 buf_ptr += active_state_count *
3782 sizeof(*ndl_active_config);
3783 }
3784
3785 /* Add the wmi_ocb_schedule_element info */
3786 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3787 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3788 buf_ptr += WMI_TLV_HDR_SIZE;
3789 for (i = 0; i < config->schedule_size; i++) {
3790 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3791 WMITLV_SET_HDR(&sched_elem->tlv_header,
3792 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3793 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3794 sched_elem->channel_freq = config->schedule[i].chan_freq;
3795 sched_elem->total_duration = config->schedule[i].total_duration;
3796 sched_elem->guard_interval = config->schedule[i].guard_interval;
3797 buf_ptr += sizeof(*sched_elem);
3798 }
3799
3800
3801 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3802 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303803 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303804 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303805 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303806 }
3807
Govind Singh67922e82016-04-01 16:48:57 +05303808 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303809}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303810
3811/**
3812 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3813 * @wmi_handle: wmi handle
3814 * @mcc_adaptive_scheduler: enable/disable
3815 *
3816 * This function enable/disable mcc adaptive scheduler in fw.
3817 *
Govind Singhb53420c2016-03-09 14:32:57 +05303818 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303819 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303820static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003821 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3822 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303823{
Govind Singh67922e82016-04-01 16:48:57 +05303824 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303825 wmi_buf_t buf = 0;
3826 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3827 uint16_t len =
3828 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3829
3830 buf = wmi_buf_alloc(wmi_handle, len);
3831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303832 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3833 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303834 }
3835 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3836 wmi_buf_data(buf);
3837
3838 WMITLV_SET_HDR(&cmd->tlv_header,
3839 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3840 WMITLV_GET_STRUCT_TLVLEN
3841 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3842 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003843 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303844
3845 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3846 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303847 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303848 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303849 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303850 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303851 }
Govind Singh67922e82016-04-01 16:48:57 +05303852
3853 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303854}
3855
3856/**
3857 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3858 * @wmi: wmi handle
3859 * @mcc_channel: mcc channel
3860 * @mcc_channel_time_latency: MCC channel time latency.
3861 *
3862 * Currently used to set time latency for an MCC vdev/adapter using operating
3863 * channel of it and channel number. The info is provided run time using
3864 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3865 *
3866 * Return: CDF status
3867 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303868static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303869 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3870{
Govind Singh67922e82016-04-01 16:48:57 +05303871 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303872 wmi_buf_t buf = 0;
3873 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3874 uint16_t len = 0;
3875 uint8_t *buf_ptr = NULL;
3876 wmi_resmgr_chan_latency chan_latency;
3877 /* Note: we only support MCC time latency for a single channel */
3878 uint32_t num_channels = 1;
3879 uint32_t chan1_freq = mcc_channel_freq;
3880 uint32_t latency_chan1 = mcc_channel_time_latency;
3881
3882
3883 /* If 0ms latency is provided, then FW will set to a default.
3884 * Otherwise, latency must be at least 30ms.
3885 */
3886 if ((latency_chan1 > 0) &&
3887 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303888 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303889 "Minimum is 30ms (or 0 to use default value by "
3890 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303891 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303892 }
3893
3894 /* Set WMI CMD for channel time latency here */
3895 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3896 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3897 num_channels * sizeof(wmi_resmgr_chan_latency);
3898 buf = wmi_buf_alloc(wmi_handle, len);
3899 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303900 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3901 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303902 }
3903 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3904 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3905 wmi_buf_data(buf);
3906 WMITLV_SET_HDR(&cmdTL->tlv_header,
3907 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3908 WMITLV_GET_STRUCT_TLVLEN
3909 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3910 cmdTL->num_chans = num_channels;
3911 /* Update channel time latency information for home channel(s) */
3912 buf_ptr += sizeof(*cmdTL);
3913 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3914 num_channels * sizeof(wmi_resmgr_chan_latency));
3915 buf_ptr += WMI_TLV_HDR_SIZE;
3916 chan_latency.chan_mhz = chan1_freq;
3917 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303918 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303919 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3920 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303921 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303922 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303923 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303924 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303925 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303926 }
Govind Singh67922e82016-04-01 16:48:57 +05303927
3928 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303929}
3930
3931/**
3932 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3933 * @wmi: wmi handle
3934 * @adapter_1_chan_number: adapter 1 channel number
3935 * @adapter_1_quota: adapter 1 quota
3936 * @adapter_2_chan_number: adapter 2 channel number
3937 *
3938 * Return: CDF status
3939 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303940static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303941 uint32_t adapter_1_chan_freq,
3942 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3943{
Govind Singh67922e82016-04-01 16:48:57 +05303944 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303945 wmi_buf_t buf = 0;
3946 uint16_t len = 0;
3947 uint8_t *buf_ptr = NULL;
3948 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3949 wmi_resmgr_chan_time_quota chan_quota;
3950 uint32_t quota_chan1 = adapter_1_quota;
3951 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3952 uint32_t quota_chan2 = 100 - quota_chan1;
3953 /* Note: setting time quota for MCC requires info for 2 channels */
3954 uint32_t num_channels = 2;
3955 uint32_t chan1_freq = adapter_1_chan_freq;
3956 uint32_t chan2_freq = adapter_2_chan_freq;
3957
Govind Singhb53420c2016-03-09 14:32:57 +05303958 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303959 "freq2:%dMHz, Quota2:%dms", __func__,
3960 chan1_freq, quota_chan1, chan2_freq,
3961 quota_chan2);
3962
3963 /*
3964 * Perform sanity check on time quota values provided.
3965 */
3966 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3967 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303968 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303969 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303970 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303971 }
3972 /* Set WMI CMD for channel time quota here */
3973 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3974 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3975 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3976 buf = wmi_buf_alloc(wmi_handle, len);
3977 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303978 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3979 QDF_ASSERT(0);
3980 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303981 }
3982 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3983 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3984 wmi_buf_data(buf);
3985 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3986 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3987 WMITLV_GET_STRUCT_TLVLEN
3988 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3989 cmdTQ->num_chans = num_channels;
3990
3991 /* Update channel time quota information for home channel(s) */
3992 buf_ptr += sizeof(*cmdTQ);
3993 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3994 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3995 buf_ptr += WMI_TLV_HDR_SIZE;
3996 chan_quota.chan_mhz = chan1_freq;
3997 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303998 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303999 /* Construct channel and quota record for the 2nd MCC mode. */
4000 buf_ptr += sizeof(chan_quota);
4001 chan_quota.chan_mhz = chan2_freq;
4002 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304003 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304004
4005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4006 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304007 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304008 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304009 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304010 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304011 }
Govind Singh67922e82016-04-01 16:48:57 +05304012
4013 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304014}
4015
4016/**
4017 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4018 * @wmi_handle: Pointer to wmi handle
4019 * @thermal_info: Thermal command information
4020 *
4021 * This function sends the thermal management command
4022 * to the firmware
4023 *
Govind Singhb53420c2016-03-09 14:32:57 +05304024 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304025 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304026static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304027 struct thermal_cmd_params *thermal_info)
4028{
4029 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4030 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304031 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304032 uint32_t len = 0;
4033
4034 len = sizeof(*cmd);
4035
4036 buf = wmi_buf_alloc(wmi_handle, len);
4037 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304038 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4039 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304040 }
4041
4042 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4043
4044 WMITLV_SET_HDR(&cmd->tlv_header,
4045 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4046 WMITLV_GET_STRUCT_TLVLEN
4047 (wmi_thermal_mgmt_cmd_fixed_param));
4048
4049 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4050 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4051 cmd->enable = thermal_info->thermal_enable;
4052
Govind Singhb53420c2016-03-09 14:32:57 +05304053 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304054 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4055
4056 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4057 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304058 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304059 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304060 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304061 }
4062
Govind Singh67922e82016-04-01 16:48:57 +05304063 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304064}
4065
4066
4067/**
4068 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304069 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304070 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4071 *
4072 * This function sends down the LRO configuration parameters to
4073 * the firmware to enable LRO, sets the TCP flags and sets the
4074 * seed values for the toeplitz hash generation
4075 *
Govind Singhb53420c2016-03-09 14:32:57 +05304076 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304077 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304078static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304079 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4080{
4081 wmi_lro_info_cmd_fixed_param *cmd;
4082 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304083 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304084
4085
4086 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4087 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304088 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4089 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304090 }
4091
4092 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4093
4094 WMITLV_SET_HDR(&cmd->tlv_header,
4095 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4096 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4097
4098 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4099 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4100 wmi_lro_cmd->tcp_flag);
4101 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4102 wmi_lro_cmd->tcp_flag_mask);
4103 cmd->toeplitz_hash_ipv4_0_3 =
4104 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4105 cmd->toeplitz_hash_ipv4_4_7 =
4106 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4107 cmd->toeplitz_hash_ipv4_8_11 =
4108 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4109 cmd->toeplitz_hash_ipv4_12_15 =
4110 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4111 cmd->toeplitz_hash_ipv4_16 =
4112 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4113
4114 cmd->toeplitz_hash_ipv6_0_3 =
4115 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4116 cmd->toeplitz_hash_ipv6_4_7 =
4117 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4118 cmd->toeplitz_hash_ipv6_8_11 =
4119 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4120 cmd->toeplitz_hash_ipv6_12_15 =
4121 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4122 cmd->toeplitz_hash_ipv6_16_19 =
4123 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4124 cmd->toeplitz_hash_ipv6_20_23 =
4125 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4126 cmd->toeplitz_hash_ipv6_24_27 =
4127 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4128 cmd->toeplitz_hash_ipv6_28_31 =
4129 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4130 cmd->toeplitz_hash_ipv6_32_35 =
4131 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4132 cmd->toeplitz_hash_ipv6_36_39 =
4133 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4134 cmd->toeplitz_hash_ipv6_40 =
4135 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4136
Govind Singhb53420c2016-03-09 14:32:57 +05304137 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304138 cmd->lro_enable, cmd->tcp_flag_u32);
4139
4140 status = wmi_unified_cmd_send(wmi_handle, buf,
4141 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304142 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304143 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304144 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304145 }
4146
Govind Singh67922e82016-04-01 16:48:57 +05304147 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304148}
4149
Govind Singh4eacd2b2016-03-07 14:24:22 +05304150/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304151 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4152 * @wmi_handle: Pointer to wmi handle
4153 * @rate_report_params: Pointer to peer rate report parameters
4154 *
4155 *
4156 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4157 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304158static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304159 struct wmi_peer_rate_report_params *rate_report_params)
4160{
4161 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4162 wmi_buf_t buf = NULL;
4163 QDF_STATUS status = 0;
4164 uint32_t len = 0;
4165 uint32_t i, j;
4166
4167 len = sizeof(*cmd);
4168
4169 buf = wmi_buf_alloc(wmi_handle, len);
4170 if (!buf) {
4171 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4172 return QDF_STATUS_E_FAILURE;
4173 }
4174
4175 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4176 wmi_buf_data(buf);
4177
4178 WMITLV_SET_HDR(
4179 &cmd->tlv_header,
4180 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4181 WMITLV_GET_STRUCT_TLVLEN(
4182 wmi_peer_set_rate_report_condition_fixed_param));
4183
4184 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4185 cmd->report_backoff_time = rate_report_params->backoff_time;
4186 cmd->report_timer_period = rate_report_params->timer_period;
4187 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4188 cmd->cond_per_phy[i].val_cond_flags =
4189 rate_report_params->report_per_phy[i].cond_flags;
4190 cmd->cond_per_phy[i].rate_delta.min_delta =
4191 rate_report_params->report_per_phy[i].delta.delta_min;
4192 cmd->cond_per_phy[i].rate_delta.percentage =
4193 rate_report_params->report_per_phy[i].delta.percent;
4194 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4195 cmd->cond_per_phy[i].rate_threshold[j] =
4196 rate_report_params->report_per_phy[i].
4197 report_rate_threshold[j];
4198 }
4199 }
4200
4201 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4202 cmd->enable_rate_report,
4203 cmd->report_backoff_time, cmd->report_timer_period);
4204
4205 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4206 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4207 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304208 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304209 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4210 __func__);
4211 }
4212 return status;
4213}
4214
4215/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304216 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4217 * @wmi_handle: wmi handle
4218 * @param: bcn ll cmd parameter
4219 *
Govind Singhb53420c2016-03-09 14:32:57 +05304220 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304221 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304222static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304223 wmi_bcn_send_from_host_cmd_fixed_param *param)
4224{
4225 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4226 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304227 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304228
4229 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4230 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304231 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4232 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304233 }
4234
4235 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4236 WMITLV_SET_HDR(&cmd->tlv_header,
4237 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4238 WMITLV_GET_STRUCT_TLVLEN
4239 (wmi_bcn_send_from_host_cmd_fixed_param));
4240 cmd->vdev_id = param->vdev_id;
4241 cmd->data_len = param->data_len;
4242 cmd->frame_ctrl = param->frame_ctrl;
4243 cmd->frag_ptr = param->frag_ptr;
4244 cmd->dtim_flag = param->dtim_flag;
4245
4246 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4247 WMI_PDEV_SEND_BCN_CMDID);
4248
Govind Singh67922e82016-04-01 16:48:57 +05304249 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304250 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304251 wmi_buf_free(wmi_buf);
4252 }
4253
4254 return ret;
4255}
4256
4257/**
4258 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4259 * @wmi_handle: wmi handle
4260 * @vdev_id: vdev id
4261 * @max_retries: max retries
4262 * @retry_interval: retry interval
4263 * This function sets sta query related parameters in fw.
4264 *
Govind Singhb53420c2016-03-09 14:32:57 +05304265 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304266 */
4267
Sathish Kumarfd347372017-02-13 12:29:09 +05304268static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304269 uint8_t vdev_id, uint32_t max_retries,
4270 uint32_t retry_interval)
4271{
4272 wmi_buf_t buf;
4273 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4274 int len;
4275
4276 len = sizeof(*cmd);
4277 buf = wmi_buf_alloc(wmi_handle, len);
4278 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304279 WMI_LOGE(FL("wmi_buf_alloc failed"));
4280 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304281 }
4282
4283 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4284 WMITLV_SET_HDR(&cmd->tlv_header,
4285 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4286 WMITLV_GET_STRUCT_TLVLEN
4287 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4288
4289
4290 cmd->vdev_id = vdev_id;
4291 cmd->sa_query_max_retry_count = max_retries;
4292 cmd->sa_query_retry_interval = retry_interval;
4293
Govind Singhb53420c2016-03-09 14:32:57 +05304294 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304295 vdev_id, retry_interval, max_retries);
4296
4297 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4298 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304299 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304300 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304301 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304302 }
4303
Govind Singhb53420c2016-03-09 14:32:57 +05304304 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304305 return 0;
4306}
4307
4308/**
4309 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4310 * @wmi_handle: wmi handle
4311 * @params: sta keep alive parameter
4312 *
4313 * This function sets keep alive related parameters in fw.
4314 *
4315 * Return: CDF status
4316 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304317static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304318 struct sta_params *params)
4319{
4320 wmi_buf_t buf;
4321 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4322 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4323 uint8_t *buf_ptr;
4324 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304325 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304326
Govind Singhb53420c2016-03-09 14:32:57 +05304327 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304328
Govind Singh4eacd2b2016-03-07 14:24:22 +05304329 len = sizeof(*cmd) + sizeof(*arp_rsp);
4330 buf = wmi_buf_alloc(wmi_handle, len);
4331 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304332 WMI_LOGE("wmi_buf_alloc failed");
4333 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304334 }
4335
4336 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4337 buf_ptr = (uint8_t *) cmd;
4338 WMITLV_SET_HDR(&cmd->tlv_header,
4339 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4340 WMITLV_GET_STRUCT_TLVLEN
4341 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4342 cmd->interval = params->timeperiod;
4343 cmd->enable = (params->timeperiod) ? 1 : 0;
4344 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304345 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304346 params->timeperiod, params->method);
4347 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4348 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4349 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4350 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4351
4352 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4353 if ((NULL == params->hostv4addr) ||
4354 (NULL == params->destv4addr) ||
4355 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304356 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304357 "destv4addr:%p destmac:%p ", __func__,
4358 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304359 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304360 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304361 }
4362 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304363 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304364 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304365 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304366 WMI_IPV4_ADDR_LEN);
4367 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4368 } else {
4369 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4370 }
4371
Govind Singh67922e82016-04-01 16:48:57 +05304372 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4373 WMI_STA_KEEPALIVE_CMDID);
4374 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304375 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304376 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304377 }
4378
Govind Singhb53420c2016-03-09 14:32:57 +05304379 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304380 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304381}
4382
4383/**
4384 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4385 * @wmi_handle: wmi handle
4386 * @if_id: vdev id
4387 * @gtx_info: GTX config params
4388 *
4389 * This function set GTX related params in firmware.
4390 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304391 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304392 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304393static 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 +05304394 struct wmi_gtx_config *gtx_info)
4395{
4396 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4397 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304398 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304399 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304400
Govind Singh4eacd2b2016-03-07 14:24:22 +05304401 buf = wmi_buf_alloc(wmi_handle, len);
4402 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304403 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304404 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304405 }
4406 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4407 WMITLV_SET_HDR(&cmd->tlv_header,
4408 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4409 WMITLV_GET_STRUCT_TLVLEN
4410 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4411 cmd->vdev_id = if_id;
4412
4413 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4414 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4415 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4416 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4417 cmd->gtxPERMargin = gtx_info->gtx_margin;
4418 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4419 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4420 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4421
Govind Singhb53420c2016-03-09 14:32:57 +05304422 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304423 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4424 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4425 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4426 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4427
Abhishek Singh716c46c2016-05-04 16:24:07 +05304428 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304429 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304430 if (QDF_IS_STATUS_ERROR(ret)) {
4431 WMI_LOGE("Failed to set GTX PARAMS");
4432 wmi_buf_free(buf);
4433 }
4434 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304435}
4436
4437/**
4438 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4439 * @wmi_handle: wmi handle
4440 * @edca_params: edca parameters
4441 *
4442 * This function updates EDCA parameters to the target
4443 *
4444 * Return: CDF Status
4445 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304446static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304447 uint8_t vdev_id,
4448 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4449{
4450 uint8_t *buf_ptr;
4451 wmi_buf_t buf;
4452 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4453 wmi_wmm_vparams *wmm_param, *twmm_param;
4454 int len = sizeof(*cmd);
4455 int ac;
4456
4457 buf = wmi_buf_alloc(wmi_handle, len);
4458
4459 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304460 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4461 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304462 }
4463
4464 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4465 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4466 WMITLV_SET_HDR(&cmd->tlv_header,
4467 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4468 WMITLV_GET_STRUCT_TLVLEN
4469 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4470 cmd->vdev_id = vdev_id;
4471
4472 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4473 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4474 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4475 WMITLV_SET_HDR(&wmm_param->tlv_header,
4476 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4477 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4478 wmm_param->cwmin = twmm_param->cwmin;
4479 wmm_param->cwmax = twmm_param->cwmax;
4480 wmm_param->aifs = twmm_param->aifs;
4481 wmm_param->txoplimit = twmm_param->txoplimit;
4482 wmm_param->acm = twmm_param->acm;
4483 wmm_param->no_ack = twmm_param->no_ack;
4484 }
4485
4486 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4487 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4488 goto fail;
4489
Govind Singhb53420c2016-03-09 14:32:57 +05304490 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304491
4492fail:
4493 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304494 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4495 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304496}
4497
4498/**
4499 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4500 * @wmi_handle: wmi handle
4501 * @vdev_id: vdev id
4502 * @probe_rsp_info: probe response info
4503 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304504 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304505 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304506static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304507 uint8_t vdev_id,
4508 struct wmi_probe_resp_params *probe_rsp_info,
4509 uint8_t *frm)
4510{
4511 wmi_prb_tmpl_cmd_fixed_param *cmd;
4512 wmi_bcn_prb_info *bcn_prb_info;
4513 wmi_buf_t wmi_buf;
4514 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4515 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304516 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304517
Govind Singhb53420c2016-03-09 14:32:57 +05304518 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304519
4520 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4521 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4522
4523 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4524 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4525 tmpl_len_aligned;
4526
4527 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304528 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304529 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304530 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304531 }
4532
4533 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4534 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304535 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304536 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304537 }
4538
4539 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4540
4541 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4542 WMITLV_SET_HDR(&cmd->tlv_header,
4543 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4544 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4545 cmd->vdev_id = vdev_id;
4546 cmd->buf_len = tmpl_len;
4547 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4548
4549 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4550 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4551 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4552 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4553 bcn_prb_info->caps = 0;
4554 bcn_prb_info->erp = 0;
4555 buf_ptr += sizeof(wmi_bcn_prb_info);
4556
4557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4558 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304559 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304560
4561 ret = wmi_unified_cmd_send(wmi_handle,
4562 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304563 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304564 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304565 wmi_buf_free(wmi_buf);
4566 }
4567
4568 return ret;
4569}
4570
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304571#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304572#define WPI_IV_LEN 16
4573
4574/**
4575 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4576 *
4577 * @dest_tx: destination address of tsc key counter
4578 * @src_tx: source address of tsc key counter
4579 * @dest_rx: destination address of rsc key counter
4580 * @src_rx: source address of rsc key counter
4581 *
4582 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4583 *
4584 * Return: None
4585 *
4586 */
4587static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4588 uint8_t *dest_rx, uint8_t *src_rx)
4589{
4590 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4591 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4592}
4593#else
4594static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4595 uint8_t *dest_rx, uint8_t *src_rx)
4596{
4597 return;
4598}
4599#endif
4600
4601/**
4602 * send_setup_install_key_cmd_tlv() - set key parameters
4603 * @wmi_handle: wmi handle
4604 * @key_params: key parameters
4605 *
4606 * This function fills structure from information
4607 * passed in key_params.
4608 *
4609 * Return: QDF_STATUS_SUCCESS - success
4610 * QDF_STATUS_E_FAILURE - failure
4611 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4612 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304613static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304614 struct set_key_params *key_params)
4615{
4616 wmi_vdev_install_key_cmd_fixed_param *cmd;
4617 wmi_buf_t buf;
4618 uint8_t *buf_ptr;
4619 uint32_t len;
4620 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304621 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304622
4623 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4624 WMI_TLV_HDR_SIZE;
4625
4626 buf = wmi_buf_alloc(wmi_handle, len);
4627 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304628 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304629 return QDF_STATUS_E_NOMEM;
4630 }
4631
4632 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4633 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4634 WMITLV_SET_HDR(&cmd->tlv_header,
4635 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4636 WMITLV_GET_STRUCT_TLVLEN
4637 (wmi_vdev_install_key_cmd_fixed_param));
4638 cmd->vdev_id = key_params->vdev_id;
4639 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304640
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304641
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304642 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4643 cmd->key_flags |= key_params->key_flags;
4644 cmd->key_cipher = key_params->key_cipher;
4645 if ((key_params->key_txmic_len) &&
4646 (key_params->key_rxmic_len)) {
4647 cmd->key_txmic_len = key_params->key_txmic_len;
4648 cmd->key_rxmic_len = key_params->key_rxmic_len;
4649 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304650#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304651 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4652 key_params->tx_iv,
4653 cmd->wpi_key_rsc_counter,
4654 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304655#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304656 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4657 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4658 roundup(key_params->key_len, sizeof(uint32_t)));
4659 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4660 qdf_mem_copy((void *)key_data,
4661 (const void *)key_params->key_data, key_params->key_len);
4662 cmd->key_len = key_params->key_len;
4663
4664 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4665 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304666 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304667 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304668
Govind Singh67922e82016-04-01 16:48:57 +05304669 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304670}
4671
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304672/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004673 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4674 * @wmi_handle: wmi handle
4675 * @params: sar limit params
4676 *
4677 * Return: QDF_STATUS_SUCCESS for success or error code
4678 */
4679static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4680 struct sar_limit_cmd_params *sar_limit_params)
4681{
4682 wmi_buf_t buf;
4683 QDF_STATUS qdf_status;
4684 wmi_sar_limits_cmd_fixed_param *cmd;
4685 int i;
4686 uint8_t *buf_ptr;
4687 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4688 struct sar_limit_cmd_row *sar_rows_list;
4689 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4690
4691 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4692 buf = wmi_buf_alloc(wmi_handle, len);
4693 if (!buf) {
4694 WMI_LOGE("Failed to allocate memory");
4695 qdf_status = QDF_STATUS_E_NOMEM;
4696 goto end;
4697 }
4698
4699 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4700 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4701 WMITLV_SET_HDR(&cmd->tlv_header,
4702 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4703 WMITLV_GET_STRUCT_TLVLEN
4704 (wmi_sar_limits_cmd_fixed_param));
4705 cmd->sar_enable = sar_limit_params->sar_enable;
4706 cmd->commit_limits = sar_limit_params->commit_limits;
4707 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4708
4709 WMI_LOGD("no of sar rows = %d, len = %d",
4710 sar_limit_params->num_limit_rows, len);
4711 buf_ptr += sizeof(*cmd);
4712 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4713 sizeof(wmi_sar_limit_cmd_row) *
4714 sar_limit_params->num_limit_rows);
4715 if (cmd->num_limit_rows == 0)
4716 goto send_sar_limits;
4717
4718 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4719 (buf_ptr + WMI_TLV_HDR_SIZE);
4720 sar_rows_list = sar_limit_params->sar_limit_row_list;
4721
4722 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4723 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4724 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4725 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4726 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4727 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4728 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4729 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4730 wmi_sar_rows_list->validity_bitmap =
4731 sar_rows_list->validity_bitmap;
4732 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4733 i, wmi_sar_rows_list->band_id,
4734 wmi_sar_rows_list->chain_id,
4735 wmi_sar_rows_list->mod_id,
4736 wmi_sar_rows_list->limit_value,
4737 wmi_sar_rows_list->validity_bitmap);
4738 sar_rows_list++;
4739 wmi_sar_rows_list++;
4740 }
4741send_sar_limits:
4742 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4743 WMI_SAR_LIMITS_CMDID);
4744
4745 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4746 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4747 wmi_buf_free(buf);
4748 }
4749
4750end:
4751 return qdf_status;
4752}
4753
4754/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304755 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4756 * @wmi_handle: wmi handle
4757 * @params: encrypt/decrypt params
4758 *
4759 * Return: QDF_STATUS_SUCCESS for success or error code
4760 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004761static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304762QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4763 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4764{
4765 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4766 wmi_buf_t wmi_buf;
4767 uint8_t *buf_ptr;
4768 QDF_STATUS ret;
4769 uint32_t len;
4770
4771 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4772
4773 len = sizeof(*cmd) +
4774 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4775 WMI_TLV_HDR_SIZE;
4776 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4777 if (!wmi_buf) {
4778 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4779 __func__);
4780 return QDF_STATUS_E_NOMEM;
4781 }
4782
4783 buf_ptr = wmi_buf_data(wmi_buf);
4784 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4785
4786 WMITLV_SET_HDR(&cmd->tlv_header,
4787 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4788 WMITLV_GET_STRUCT_TLVLEN(
4789 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4790
4791 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4792 cmd->key_flag = encrypt_decrypt_params->key_flag;
4793 cmd->key_idx = encrypt_decrypt_params->key_idx;
4794 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4795 cmd->key_len = encrypt_decrypt_params->key_len;
4796 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4797 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4798
4799 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4800 encrypt_decrypt_params->key_len);
4801
4802 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4803 MAX_MAC_HEADER_LEN);
4804
4805 cmd->data_len = encrypt_decrypt_params->data_len;
4806
4807 if (cmd->data_len) {
4808 buf_ptr += sizeof(*cmd);
4809 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4810 roundup(encrypt_decrypt_params->data_len,
4811 sizeof(A_UINT32)));
4812 buf_ptr += WMI_TLV_HDR_SIZE;
4813 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4814 encrypt_decrypt_params->data_len);
4815 }
4816
4817 /* This conversion is to facilitate data to FW in little endian */
4818 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4819 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4820 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4821 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4822 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4823 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4824
4825 ret = wmi_unified_cmd_send(wmi_handle,
4826 wmi_buf, len,
4827 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4828 if (QDF_IS_STATUS_ERROR(ret)) {
4829 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4830 wmi_buf_free(wmi_buf);
4831 }
4832
4833 return ret;
4834}
4835
4836
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304837
Govind Singh4eacd2b2016-03-07 14:24:22 +05304838/**
4839 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4840 * @wmi_handle: wmi handle
4841 * @vdev_id: vdev id
4842 * @p2p_ie: p2p IE
4843 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304844 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304845 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304846static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304847 A_UINT32 vdev_id, uint8_t *p2p_ie)
4848{
Govind Singh67922e82016-04-01 16:48:57 +05304849 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304850 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4851 wmi_buf_t wmi_buf;
4852 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4853 uint8_t *buf_ptr;
4854
4855 ie_len = (uint32_t) (p2p_ie[1] + 2);
4856
4857 /* More than one P2P IE may be included in a single frame.
4858 If multiple P2P IEs are present, the complete P2P attribute
4859 data consists of the concatenation of the P2P Attribute
4860 fields of the P2P IEs. The P2P Attributes field of each
4861 P2P IE may be any length up to the maximum (251 octets).
4862 In this case host sends one P2P IE to firmware so the length
4863 should not exceed more than 251 bytes
4864 */
4865 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304866 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304867 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304868 }
4869
4870 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4871
4872 wmi_buf_len =
4873 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4874 WMI_TLV_HDR_SIZE;
4875
4876 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4877 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304878 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304879 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304880 }
4881
4882 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4883
4884 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4885 WMITLV_SET_HDR(&cmd->tlv_header,
4886 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4887 WMITLV_GET_STRUCT_TLVLEN
4888 (wmi_p2p_go_set_beacon_ie_fixed_param));
4889 cmd->vdev_id = vdev_id;
4890 cmd->ie_buf_len = ie_len;
4891
4892 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4893 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4894 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304895 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304896
Govind Singhb53420c2016-03-09 14:32:57 +05304897 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304898
4899 ret = wmi_unified_cmd_send(wmi_handle,
4900 wmi_buf, wmi_buf_len,
4901 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304902 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304903 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304904 wmi_buf_free(wmi_buf);
4905 }
4906
Govind Singhb53420c2016-03-09 14:32:57 +05304907 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304908 return ret;
4909}
4910
4911/**
4912 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4913 * @wmi_handle: wmi handle
4914 * @req: gateway parameter update request structure
4915 *
4916 * This function reads the incoming @req and fill in the destination
4917 * WMI structure and sends down the gateway configs down to the firmware
4918 *
Govind Singhb53420c2016-03-09 14:32:57 +05304919 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304920 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304921static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304922 struct gateway_update_req_param *req)
4923{
4924 wmi_roam_subnet_change_config_fixed_param *cmd;
4925 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304926 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304927 int len = sizeof(*cmd);
4928
4929 buf = wmi_buf_alloc(wmi_handle, len);
4930 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304931 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4932 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304933 }
4934
4935 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4936 WMITLV_SET_HDR(&cmd->tlv_header,
4937 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4938 WMITLV_GET_STRUCT_TLVLEN(
4939 wmi_roam_subnet_change_config_fixed_param));
4940
4941 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304942 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4943 QDF_IPV4_ADDR_SIZE);
4944 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4945 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304946 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4947 &cmd->inet_gw_mac_addr);
4948 cmd->max_retries = req->max_retries;
4949 cmd->timeout = req->timeout;
4950 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4951 cmd->flag = 0;
4952 if (req->ipv4_addr_type)
4953 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4954
4955 if (req->ipv6_addr_type)
4956 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4957
4958 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4959 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304960 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304961 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304962 ret);
4963 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304964 }
4965
Govind Singh67922e82016-04-01 16:48:57 +05304966 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304967}
4968
4969/**
4970 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4971 * @wmi_handle: wmi handle
4972 * @req: rssi monitoring request structure
4973 *
4974 * This function reads the incoming @req and fill in the destination
4975 * WMI structure and send down the rssi monitoring configs down to the firmware
4976 *
4977 * Return: 0 on success; error number otherwise
4978 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304979static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304980 struct rssi_monitor_param *req)
4981{
4982 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4983 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304984 QDF_STATUS ret;
4985 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304986
4987 buf = wmi_buf_alloc(wmi_handle, len);
4988 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304989 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4990 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304991 }
4992
4993 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4994 WMITLV_SET_HDR(&cmd->tlv_header,
4995 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4996 WMITLV_GET_STRUCT_TLVLEN(
4997 wmi_rssi_breach_monitor_config_fixed_param));
4998
4999 cmd->vdev_id = req->session_id;
5000 cmd->request_id = req->request_id;
5001 cmd->lo_rssi_reenable_hysteresis = 0;
5002 cmd->hi_rssi_reenable_histeresis = 0;
5003 cmd->min_report_interval = 0;
5004 cmd->max_num_report = 1;
5005 if (req->control) {
5006 /* enable one threshold for each min/max */
5007 cmd->enabled_bitmap = 0x09;
5008 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5009 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5010 } else {
5011 cmd->enabled_bitmap = 0;
5012 cmd->low_rssi_breach_threshold[0] = 0;
5013 cmd->hi_rssi_breach_threshold[0] = 0;
5014 }
5015
5016 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5017 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305018 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305019 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305020 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 }
5022
Govind Singhb53420c2016-03-09 14:32:57 +05305023 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05305024 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305025}
5026
5027/**
5028 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5029 * @wmi_handle: wmi handle
5030 * @psetoui: OUI parameters
5031 *
5032 * set scan probe OUI parameters in firmware
5033 *
5034 * Return: CDF status
5035 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305036static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305037 struct scan_mac_oui *psetoui)
5038{
5039 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5040 wmi_buf_t wmi_buf;
5041 uint32_t len;
5042 uint8_t *buf_ptr;
5043 uint32_t *oui_buf;
5044
5045 len = sizeof(*cmd);
5046 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5047 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305048 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5049 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305050 }
5051 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5052 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5053 WMITLV_SET_HDR(&cmd->tlv_header,
5054 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5055 WMITLV_GET_STRUCT_TLVLEN
5056 (wmi_scan_prob_req_oui_cmd_fixed_param));
5057
5058 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305059 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305060 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5061 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305062 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305063 cmd->prob_req_oui);
5064
5065 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5066 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305067 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305068 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305069 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305070 }
Govind Singhb53420c2016-03-09 14:32:57 +05305071 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305072}
5073
5074/**
5075 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5076 * @wmi_handle: wmi handle
5077 * @req: passpoint network request structure
5078 *
5079 * This function sends down WMI command with network id set to wildcard id.
5080 * firmware shall clear all the config entries
5081 *
Govind Singhb53420c2016-03-09 14:32:57 +05305082 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305083 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305084static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305085 struct wifi_passpoint_req_param *req)
5086{
5087 wmi_passpoint_config_cmd_fixed_param *cmd;
5088 wmi_buf_t buf;
5089 uint32_t len;
5090 int ret;
5091
5092 len = sizeof(*cmd);
5093 buf = wmi_buf_alloc(wmi_handle, len);
5094 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305095 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5096 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305097 }
5098
5099 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5100
5101 WMITLV_SET_HDR(&cmd->tlv_header,
5102 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5103 WMITLV_GET_STRUCT_TLVLEN(
5104 wmi_passpoint_config_cmd_fixed_param));
5105 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5106
5107 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5108 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5109 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305110 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305111 __func__);
5112 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305113 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305114 }
5115
Govind Singhb53420c2016-03-09 14:32:57 +05305116 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305117}
5118
5119/**
5120 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5121 * @wmi_handle: wmi handle
5122 * @req: passpoint network request structure
5123 *
5124 * This function reads the incoming @req and fill in the destination
5125 * WMI structure and send down the passpoint configs down to the firmware
5126 *
Govind Singhb53420c2016-03-09 14:32:57 +05305127 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305128 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305129static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305130 struct wifi_passpoint_req_param *req)
5131{
5132 wmi_passpoint_config_cmd_fixed_param *cmd;
5133 u_int8_t i, j, *bytes;
5134 wmi_buf_t buf;
5135 uint32_t len;
5136 int ret;
5137
5138 len = sizeof(*cmd);
5139 for (i = 0; i < req->num_networks; i++) {
5140 buf = wmi_buf_alloc(wmi_handle, len);
5141 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305142 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5143 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305144 }
5145
5146 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5147 wmi_buf_data(buf);
5148
5149 WMITLV_SET_HDR(&cmd->tlv_header,
5150 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5151 WMITLV_GET_STRUCT_TLVLEN(
5152 wmi_passpoint_config_cmd_fixed_param));
5153 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305154 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5155 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305156 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305157 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305158 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5159 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305160 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305161 j, bytes[0], bytes[1], bytes[2], bytes[3],
5162 bytes[4], bytes[5], bytes[6], bytes[7]);
5163
Govind Singhb53420c2016-03-09 14:32:57 +05305164 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305165 &req->networks[i].roaming_consortium_ids[j],
5166 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5167 }
Govind Singhb53420c2016-03-09 14:32:57 +05305168 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305169 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305170 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305171 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5172
5173 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5174 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5175 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305176 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305177 __func__);
5178 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305179 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305180 }
5181 }
5182
Govind Singhb53420c2016-03-09 14:32:57 +05305183 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305184}
5185
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305186/**
5187 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5188 * @wmi_handle: wmi handle
5189 * @scan_cmd_fp: start scan command ptr
5190 * @roam_req: roam request param
5191 *
5192 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5193 * of WMI_ROAM_SCAN_MODE.
5194 *
5195 * Return: QDF status
5196 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305197static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305198 wmi_start_scan_cmd_fixed_param *
5199 scan_cmd_fp,
5200 struct roam_offload_scan_params *roam_req)
5201{
5202 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305203 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305204 int len;
5205 uint8_t *buf_ptr;
5206 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305207
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305208#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5209 int auth_mode = roam_req->auth_mode;
5210 wmi_roam_offload_tlv_param *roam_offload_params;
5211 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5212 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5213 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305214 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305215#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5216 /* Need to create a buf with roam_scan command at
5217 * front and piggyback with scan command */
5218 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5219#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5220 (2 * WMI_TLV_HDR_SIZE) +
5221#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5222 sizeof(wmi_start_scan_cmd_fixed_param);
5223#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5224 if (roam_req->is_roam_req_valid &&
5225 roam_req->roam_offload_enabled) {
5226 len += sizeof(wmi_roam_offload_tlv_param);
5227 len += WMI_TLV_HDR_SIZE;
5228 if ((auth_mode != WMI_AUTH_NONE) &&
5229 ((auth_mode != WMI_AUTH_OPEN) ||
5230 (auth_mode == WMI_AUTH_OPEN &&
5231 roam_req->mdid.mdie_present) ||
5232 roam_req->is_ese_assoc)) {
5233 len += WMI_TLV_HDR_SIZE;
5234 if (roam_req->is_ese_assoc)
5235 len +=
5236 sizeof(wmi_roam_ese_offload_tlv_param);
5237 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5238 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5239 (auth_mode == WMI_AUTH_OPEN &&
5240 roam_req->mdid.mdie_present))
5241 len +=
5242 sizeof(wmi_roam_11r_offload_tlv_param);
5243 else
5244 len +=
5245 sizeof(wmi_roam_11i_offload_tlv_param);
5246 } else {
5247 len += WMI_TLV_HDR_SIZE;
5248 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305249
5250 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5251 + roundup(roam_req->assoc_ie_length,
5252 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305253 } else {
5254 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305255 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305256 __func__, roam_req->roam_offload_enabled);
5257 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305258 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305259 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305260 }
5261 if (roam_req->is_roam_req_valid &&
5262 roam_req->roam_offload_enabled) {
5263 roam_req->mode = roam_req->mode |
5264 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5265 }
5266#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5267
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305268 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5269 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5270 len = sizeof(wmi_roam_scan_mode_fixed_param);
5271
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305272 buf = wmi_buf_alloc(wmi_handle, len);
5273 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305274 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305275 return QDF_STATUS_E_NOMEM;
5276 }
5277
5278 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305279
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305280 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5281 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5282 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5283 WMITLV_GET_STRUCT_TLVLEN
5284 (wmi_roam_scan_mode_fixed_param));
5285
5286 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5287 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305288 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5289 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5290 roam_scan_mode_fp->flags |=
5291 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305292 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305293 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305294
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305295 /* Fill in scan parameters suitable for roaming scan */
5296 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305297
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305298 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5299 sizeof(wmi_start_scan_cmd_fixed_param));
5300 /* Ensure there is no additional IEs */
5301 scan_cmd_fp->ie_len = 0;
5302 WMITLV_SET_HDR(buf_ptr,
5303 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5304 WMITLV_GET_STRUCT_TLVLEN
5305 (wmi_start_scan_cmd_fixed_param));
5306#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5307 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5308 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5309 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5310 sizeof(wmi_roam_offload_tlv_param));
5311 buf_ptr += WMI_TLV_HDR_SIZE;
5312 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5313 WMITLV_SET_HDR(buf_ptr,
5314 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5315 WMITLV_GET_STRUCT_TLVLEN
5316 (wmi_roam_offload_tlv_param));
5317 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5318 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5319 roam_offload_params->select_5g_margin =
5320 roam_req->select_5ghz_margin;
5321 roam_offload_params->reassoc_failure_timeout =
5322 roam_req->reassoc_failure_timeout;
5323
5324 /* Fill the capabilities */
5325 roam_offload_params->capability =
5326 roam_req->roam_offload_params.capability;
5327 roam_offload_params->ht_caps_info =
5328 roam_req->roam_offload_params.ht_caps_info;
5329 roam_offload_params->ampdu_param =
5330 roam_req->roam_offload_params.ampdu_param;
5331 roam_offload_params->ht_ext_cap =
5332 roam_req->roam_offload_params.ht_ext_cap;
5333 roam_offload_params->ht_txbf =
5334 roam_req->roam_offload_params.ht_txbf;
5335 roam_offload_params->asel_cap =
5336 roam_req->roam_offload_params.asel_cap;
5337 roam_offload_params->qos_caps =
5338 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005339 roam_offload_params->qos_enabled =
5340 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305341 roam_offload_params->wmm_caps =
5342 roam_req->roam_offload_params.wmm_caps;
5343 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5344 (uint8_t *)roam_req->roam_offload_params.mcsset,
5345 ROAM_OFFLOAD_NUM_MCS_SET);
5346
5347 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5348 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5349 * they are filled in the same order.Depending on the
5350 * authentication type, the other mode TLV's are nullified
5351 * and only headers are filled.*/
5352 if ((auth_mode != WMI_AUTH_NONE) &&
5353 ((auth_mode != WMI_AUTH_OPEN) ||
5354 (auth_mode == WMI_AUTH_OPEN
5355 && roam_req->mdid.mdie_present) ||
5356 roam_req->is_ese_assoc)) {
5357 if (roam_req->is_ese_assoc) {
5358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5359 WMITLV_GET_STRUCT_TLVLEN(0));
5360 buf_ptr += WMI_TLV_HDR_SIZE;
5361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5362 WMITLV_GET_STRUCT_TLVLEN(0));
5363 buf_ptr += WMI_TLV_HDR_SIZE;
5364 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5365 sizeof(wmi_roam_ese_offload_tlv_param));
5366 buf_ptr += WMI_TLV_HDR_SIZE;
5367 roam_offload_ese =
5368 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5369 qdf_mem_copy(roam_offload_ese->krk,
5370 roam_req->krk,
5371 sizeof(roam_req->krk));
5372 qdf_mem_copy(roam_offload_ese->btk,
5373 roam_req->btk,
5374 sizeof(roam_req->btk));
5375 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5376 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5377 WMITLV_GET_STRUCT_TLVLEN
5378 (wmi_roam_ese_offload_tlv_param));
5379 buf_ptr +=
5380 sizeof(wmi_roam_ese_offload_tlv_param);
5381 } else if (auth_mode == WMI_AUTH_FT_RSNA
5382 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5383 || (auth_mode == WMI_AUTH_OPEN
5384 && roam_req->mdid.mdie_present)) {
5385 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5386 0);
5387 buf_ptr += WMI_TLV_HDR_SIZE;
5388 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5389 sizeof(wmi_roam_11r_offload_tlv_param));
5390 buf_ptr += WMI_TLV_HDR_SIZE;
5391 roam_offload_11r =
5392 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5393 roam_offload_11r->r0kh_id_len =
5394 roam_req->rokh_id_length;
5395 qdf_mem_copy(roam_offload_11r->r0kh_id,
5396 roam_req->rokh_id,
5397 roam_offload_11r->r0kh_id_len);
5398 qdf_mem_copy(roam_offload_11r->psk_msk,
5399 roam_req->psk_pmk,
5400 sizeof(roam_req->psk_pmk));
5401 roam_offload_11r->psk_msk_len =
5402 roam_req->pmk_len;
5403 roam_offload_11r->mdie_present =
5404 roam_req->mdid.mdie_present;
5405 roam_offload_11r->mdid =
5406 roam_req->mdid.mobility_domain;
5407 if (auth_mode == WMI_AUTH_OPEN) {
5408 /* If FT-Open ensure pmk length
5409 and r0khid len are zero */
5410 roam_offload_11r->r0kh_id_len = 0;
5411 roam_offload_11r->psk_msk_len = 0;
5412 }
5413 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5414 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5415 WMITLV_GET_STRUCT_TLVLEN
5416 (wmi_roam_11r_offload_tlv_param));
5417 buf_ptr +=
5418 sizeof(wmi_roam_11r_offload_tlv_param);
5419 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5420 WMITLV_GET_STRUCT_TLVLEN(0));
5421 buf_ptr += WMI_TLV_HDR_SIZE;
5422 } else {
5423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5424 sizeof(wmi_roam_11i_offload_tlv_param));
5425 buf_ptr += WMI_TLV_HDR_SIZE;
5426 roam_offload_11i =
5427 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005428 if (roam_req->roam_key_mgmt_offload_enabled &&
5429 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305430 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5431 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305432 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305433 } else {
5434 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5435 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305436 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305437 }
5438
5439 qdf_mem_copy(roam_offload_11i->pmk,
5440 roam_req->psk_pmk,
5441 sizeof(roam_req->psk_pmk));
5442 roam_offload_11i->pmk_len = roam_req->pmk_len;
5443 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5444 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5445 WMITLV_GET_STRUCT_TLVLEN
5446 (wmi_roam_11i_offload_tlv_param));
5447 buf_ptr +=
5448 sizeof(wmi_roam_11i_offload_tlv_param);
5449 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5450 0);
5451 buf_ptr += WMI_TLV_HDR_SIZE;
5452 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5453 0);
5454 buf_ptr += WMI_TLV_HDR_SIZE;
5455 }
5456 } else {
5457 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5458 WMITLV_GET_STRUCT_TLVLEN(0));
5459 buf_ptr += WMI_TLV_HDR_SIZE;
5460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5461 WMITLV_GET_STRUCT_TLVLEN(0));
5462 buf_ptr += WMI_TLV_HDR_SIZE;
5463 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5464 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305465 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305466 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305467
5468 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5469 sizeof(*assoc_ies));
5470 buf_ptr += WMI_TLV_HDR_SIZE;
5471
5472 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5473 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5474 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5475 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5476 assoc_ies->buf_len = roam_req->assoc_ie_length;
5477
5478 buf_ptr += sizeof(*assoc_ies);
5479
5480 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5481 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5482 buf_ptr += WMI_TLV_HDR_SIZE;
5483
5484 if (assoc_ies->buf_len != 0) {
5485 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5486 assoc_ies->buf_len);
5487 }
5488
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305489 } else {
5490 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5491 WMITLV_GET_STRUCT_TLVLEN(0));
5492 buf_ptr += WMI_TLV_HDR_SIZE;
5493 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5494 WMITLV_GET_STRUCT_TLVLEN(0));
5495 buf_ptr += WMI_TLV_HDR_SIZE;
5496 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5497 WMITLV_GET_STRUCT_TLVLEN(0));
5498 buf_ptr += WMI_TLV_HDR_SIZE;
5499 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5500 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305501 buf_ptr += WMI_TLV_HDR_SIZE;
5502 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5503 WMITLV_GET_STRUCT_TLVLEN(0));
5504 buf_ptr += WMI_TLV_HDR_SIZE;
5505 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5506 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305507 }
5508#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305509
5510send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305511 status = wmi_unified_cmd_send(wmi_handle, buf,
5512 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305513 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305514 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305515 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5516 status);
5517 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305518 }
5519
Govind Singh67922e82016-04-01 16:48:57 +05305520 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305521}
5522
5523
5524/**
5525 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5526 * rssi threashold
5527 * @wmi_handle: wmi handle
5528 * @roam_req: Roaming request buffer
5529 *
5530 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5531 *
5532 * Return: QDF status
5533 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305534static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305535 struct roam_offload_scan_rssi_params *roam_req)
5536{
5537 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305538 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305539 int len;
5540 uint8_t *buf_ptr;
5541 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5542 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5543 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305544 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305545
5546 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5547 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5548 len += sizeof(wmi_roam_scan_extended_threshold_param);
5549 len += WMI_TLV_HDR_SIZE;
5550 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305551 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5552 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305553 buf = wmi_buf_alloc(wmi_handle, len);
5554 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305555 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305556 return QDF_STATUS_E_NOMEM;
5557 }
5558
5559 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5560 rssi_threshold_fp =
5561 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5562 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5563 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5564 WMITLV_GET_STRUCT_TLVLEN
5565 (wmi_roam_scan_rssi_threshold_fixed_param));
5566 /* fill in threshold values */
5567 rssi_threshold_fp->vdev_id = roam_req->session_id;
5568 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5569 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5570 rssi_threshold_fp->hirssi_scan_max_count =
5571 roam_req->hi_rssi_scan_max_count;
5572 rssi_threshold_fp->hirssi_scan_delta =
5573 roam_req->hi_rssi_scan_rssi_delta;
5574 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5575
5576 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5577 WMITLV_SET_HDR(buf_ptr,
5578 WMITLV_TAG_ARRAY_STRUC,
5579 sizeof(wmi_roam_scan_extended_threshold_param));
5580 buf_ptr += WMI_TLV_HDR_SIZE;
5581 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5582
5583 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5584 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5585 ext_thresholds->boost_threshold_5g =
5586 roam_req->boost_threshold_5g;
5587
5588 ext_thresholds->boost_algorithm_5g =
5589 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5590 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5591 ext_thresholds->penalty_algorithm_5g =
5592 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5593 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5594 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5595 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5596 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5597
5598 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5599 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5600 WMITLV_GET_STRUCT_TLVLEN
5601 (wmi_roam_scan_extended_threshold_param));
5602 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5603 WMITLV_SET_HDR(buf_ptr,
5604 WMITLV_TAG_ARRAY_STRUC,
5605 sizeof(wmi_roam_earlystop_rssi_thres_param));
5606 buf_ptr += WMI_TLV_HDR_SIZE;
5607 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5608 early_stop_thresholds->roam_earlystop_thres_min =
5609 roam_req->roam_earlystop_thres_min;
5610 early_stop_thresholds->roam_earlystop_thres_max =
5611 roam_req->roam_earlystop_thres_max;
5612 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5613 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5614 WMITLV_GET_STRUCT_TLVLEN
5615 (wmi_roam_earlystop_rssi_thres_param));
5616
Gupta, Kapil7e652922016-04-12 15:02:00 +05305617 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5618 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5619 sizeof(wmi_roam_dense_thres_param));
5620 buf_ptr += WMI_TLV_HDR_SIZE;
5621 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5622 dense_thresholds->roam_dense_rssi_thres_offset =
5623 roam_req->dense_rssi_thresh_offset;
5624 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5625 dense_thresholds->roam_dense_traffic_thres =
5626 roam_req->traffic_threshold;
5627 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5628 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5629 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5630 WMITLV_GET_STRUCT_TLVLEN
5631 (wmi_roam_dense_thres_param));
5632
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305633 status = wmi_unified_cmd_send(wmi_handle, buf,
5634 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305635 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305636 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305637 status);
5638 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305639 }
5640
Govind Singh67922e82016-04-01 16:48:57 +05305641 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305642}
5643
5644/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305645 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5646 * configuration params
5647 * @wma_handle: wma handler
5648 * @dwelltime_params: pointer to dwelltime_params
5649 *
5650 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5651 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005652static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305653QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5654 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5655{
5656 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5657 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5658 wmi_buf_t buf;
5659 uint8_t *buf_ptr;
5660 int32_t err;
5661 int len;
5662
5663 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5664 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5665 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5666 buf = wmi_buf_alloc(wmi_handle, len);
5667 if (!buf) {
5668 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5669 __func__);
5670 return QDF_STATUS_E_NOMEM;
5671 }
5672 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5673 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5674 WMITLV_SET_HDR(&dwell_param->tlv_header,
5675 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5676 WMITLV_GET_STRUCT_TLVLEN
5677 (wmi_scan_adaptive_dwell_config_fixed_param));
5678
5679 dwell_param->enable = dwelltime_params->is_enabled;
5680 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5681 WMITLV_SET_HDR(buf_ptr,
5682 WMITLV_TAG_ARRAY_STRUC,
5683 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5684 buf_ptr += WMI_TLV_HDR_SIZE;
5685
5686 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5687 WMITLV_SET_HDR(&cmd->tlv_header,
5688 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5689 WMITLV_GET_STRUCT_TLVLEN(
5690 wmi_scan_adaptive_dwell_parameters_tlv));
5691
5692 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5693 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5694 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5695 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5696 err = wmi_unified_cmd_send(wmi_handle, buf,
5697 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5698 if (err) {
5699 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5700 wmi_buf_free(buf);
5701 return QDF_STATUS_E_FAILURE;
5702 }
5703
5704 return QDF_STATUS_SUCCESS;
5705}
5706
5707
5708/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305709 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5710 * @wmi_handle: wmi handle
5711 * @roam_req: Request which contains the filters
5712 *
5713 * There are filters such as whitelist, blacklist and preferred
5714 * list that need to be applied to the scan results to form the
5715 * probable candidates for roaming.
5716 *
5717 * Return: Return success upon succesfully passing the
5718 * parameters to the firmware, otherwise failure.
5719 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305720static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305721 struct roam_scan_filter_params *roam_req)
5722{
5723 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305724 QDF_STATUS status;
5725 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305726 uint32_t len;
5727 uint8_t *buf_ptr;
5728 wmi_roam_filter_fixed_param *roam_filter;
5729 uint8_t *bssid_src_ptr = NULL;
5730 wmi_mac_addr *bssid_dst_ptr = NULL;
5731 wmi_ssid *ssid_ptr = NULL;
5732 uint32_t *bssid_preferred_factor_ptr = NULL;
5733
5734 len = sizeof(wmi_roam_filter_fixed_param);
5735 len += WMI_TLV_HDR_SIZE;
5736 len += roam_req->len;
5737
5738 buf = wmi_buf_alloc(wmi_handle, len);
5739 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305740 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305741 return QDF_STATUS_E_NOMEM;
5742 }
5743
5744 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5745 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5746 WMITLV_SET_HDR(&roam_filter->tlv_header,
5747 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5748 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5749 /* fill in fixed values */
5750 roam_filter->vdev_id = roam_req->session_id;
5751 roam_filter->flags = 0;
5752 roam_filter->op_bitmap = roam_req->op_bitmap;
5753 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5754 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5755 roam_filter->num_bssid_preferred_list =
5756 roam_req->num_bssid_preferred_list;
5757 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5758
5759 WMITLV_SET_HDR((buf_ptr),
5760 WMITLV_TAG_ARRAY_FIXED_STRUC,
5761 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5762 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5763 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5764 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5765 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5766 bssid_src_ptr += ATH_MAC_LEN;
5767 bssid_dst_ptr++;
5768 }
5769 buf_ptr += WMI_TLV_HDR_SIZE +
5770 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5771 WMITLV_SET_HDR((buf_ptr),
5772 WMITLV_TAG_ARRAY_FIXED_STRUC,
5773 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5774 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5775 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5776 qdf_mem_copy(&ssid_ptr->ssid,
5777 &roam_req->ssid_allowed_list[i].mac_ssid,
5778 roam_req->ssid_allowed_list[i].length);
5779 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5780 ssid_ptr++;
5781 }
5782 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5783 sizeof(wmi_ssid));
5784 WMITLV_SET_HDR((buf_ptr),
5785 WMITLV_TAG_ARRAY_FIXED_STRUC,
5786 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5787 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5788 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5789 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5790 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5791 (wmi_mac_addr *)bssid_dst_ptr);
5792 bssid_src_ptr += ATH_MAC_LEN;
5793 bssid_dst_ptr++;
5794 }
5795 buf_ptr += WMI_TLV_HDR_SIZE +
5796 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5797 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5798 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5799 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5800 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5801 *bssid_preferred_factor_ptr =
5802 roam_req->bssid_favored_factor[i];
5803 bssid_preferred_factor_ptr++;
5804 }
5805 buf_ptr += WMI_TLV_HDR_SIZE +
5806 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5807
5808 status = wmi_unified_cmd_send(wmi_handle, buf,
5809 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305810 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305811 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305812 status);
5813 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305814 }
Govind Singh67922e82016-04-01 16:48:57 +05305815
5816 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305817}
5818
Govind Singh4eacd2b2016-03-07 14:24:22 +05305819/** send_set_epno_network_list_cmd_tlv() - set epno network list
5820 * @wmi_handle: wmi handle
5821 * @req: epno config params request structure
5822 *
5823 * This function reads the incoming epno config request structure
5824 * and constructs the WMI message to the firmware.
5825 *
5826 * Returns: 0 on success, error number otherwise
5827 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305828static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305829 struct wifi_enhanched_pno_params *req)
5830{
5831 wmi_nlo_config_cmd_fixed_param *cmd;
5832 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305833 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305834 u_int8_t i, *buf_ptr;
5835 wmi_buf_t buf;
5836 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305837 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305838
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305839 /* Fixed Params */
5840 len = sizeof(*cmd);
5841 if (req->num_networks) {
5842 /* TLV place holder for array of structures
5843 * then each nlo_configured_parameters(nlo_list) TLV.
5844 */
5845 len += WMI_TLV_HDR_SIZE;
5846 len += (sizeof(nlo_configured_parameters)
5847 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5848 /* TLV for array of uint32 channel_list */
5849 len += WMI_TLV_HDR_SIZE;
5850 /* TLV for nlo_channel_prediction_cfg */
5851 len += WMI_TLV_HDR_SIZE;
5852 /* TLV for candidate score params */
5853 len += sizeof(enlo_candidate_score_params);
5854 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305855
5856 buf = wmi_buf_alloc(wmi_handle, len);
5857 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305858 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5859 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305860 }
5861
5862 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5863
5864 buf_ptr = (u_int8_t *) cmd;
5865 WMITLV_SET_HDR(&cmd->tlv_header,
5866 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5867 WMITLV_GET_STRUCT_TLVLEN(
5868 wmi_nlo_config_cmd_fixed_param));
5869 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305870
5871 /* set flag to reset if num of networks are 0 */
5872 cmd->flags = (req->num_networks == 0 ?
5873 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305874
5875 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5876
Govind Singhb53420c2016-03-09 14:32:57 +05305877 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305878 WMI_LOGD("SSID count: %d flags: %d",
5879 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305880
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305881 /* Fill nlo_config only when num_networks are non zero */
5882 if (cmd->no_of_ssids) {
5883 /* Fill networks */
5884 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5885 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5886 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305887
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305888 nlo_list = (nlo_configured_parameters *) buf_ptr;
5889 for (i = 0; i < cmd->no_of_ssids; i++) {
5890 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5891 WMITLV_TAG_ARRAY_BYTE,
5892 WMITLV_GET_STRUCT_TLVLEN(
5893 nlo_configured_parameters));
5894 /* Copy ssid and it's length */
5895 nlo_list[i].ssid.valid = true;
5896 nlo_list[i].ssid.ssid.ssid_len =
5897 req->networks[i].ssid.length;
5898 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5899 req->networks[i].ssid.mac_ssid,
5900 nlo_list[i].ssid.ssid.ssid_len);
5901 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5902 nlo_list[i].ssid.ssid.ssid_len,
5903 (char *) nlo_list[i].ssid.ssid.ssid,
5904 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305905
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305906 /* Copy pno flags */
5907 nlo_list[i].bcast_nw_type.valid = true;
5908 nlo_list[i].bcast_nw_type.bcast_nw_type =
5909 req->networks[i].flags;
5910 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305911 nlo_list[i].bcast_nw_type.bcast_nw_type);
5912
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305913 /* Copy auth bit field */
5914 nlo_list[i].auth_type.valid = true;
5915 nlo_list[i].auth_type.auth_type =
5916 req->networks[i].auth_bit_field;
5917 WMI_LOGD("Auth bit field (%u)",
5918 nlo_list[i].auth_type.auth_type);
5919 }
5920
5921 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5922 /* Fill the channel list */
5923 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5924 buf_ptr += WMI_TLV_HDR_SIZE;
5925
5926 /* Fill prediction_param */
5927 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5928 buf_ptr += WMI_TLV_HDR_SIZE;
5929
5930 /* Fill epno candidate score params */
5931 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5932 WMITLV_SET_HDR(buf_ptr,
5933 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5934 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5935 cand_score_params->min5GHz_rssi =
5936 req->min_5ghz_rssi;
5937 cand_score_params->min24GHz_rssi =
5938 req->min_24ghz_rssi;
5939 cand_score_params->initial_score_max =
5940 req->initial_score_max;
5941 cand_score_params->current_connection_bonus =
5942 req->current_connection_bonus;
5943 cand_score_params->same_network_bonus =
5944 req->same_network_bonus;
5945 cand_score_params->secure_bonus =
5946 req->secure_bonus;
5947 cand_score_params->band5GHz_bonus =
5948 req->band_5ghz_bonus;
5949 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305950 }
5951
Govind Singh4eacd2b2016-03-07 14:24:22 +05305952 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305953 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305954 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305955 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305956 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305957 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305958 }
5959
Govind Singhb53420c2016-03-09 14:32:57 +05305960 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305961 req->session_id);
5962
Govind Singh67922e82016-04-01 16:48:57 +05305963 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964}
5965
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305966
Govind Singh4eacd2b2016-03-07 14:24:22 +05305967/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5968 * @wmi_handle: wmi handle
5969 * @ipa_offload: ipa offload control parameter
5970 *
5971 * Returns: 0 on success, error number otherwise
5972 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305973static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305974 struct ipa_offload_control_params *ipa_offload)
5975{
5976 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5977 wmi_buf_t wmi_buf;
5978 uint32_t len;
5979 u_int8_t *buf_ptr;
5980
5981 len = sizeof(*cmd);
5982 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5983 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305984 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5985 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305986 }
5987
Govind Singhb53420c2016-03-09 14:32:57 +05305988 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305989 ipa_offload->offload_type, ipa_offload->enable);
5990
5991 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5992
5993 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5994 WMITLV_SET_HDR(&cmd->tlv_header,
5995 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5996 WMITLV_GET_STRUCT_TLVLEN(
5997 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5998
5999 cmd->offload_type = ipa_offload->offload_type;
6000 cmd->vdev_id = ipa_offload->vdev_id;
6001 cmd->enable = ipa_offload->enable;
6002
6003 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6004 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306005 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306007 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306008 }
6009
Govind Singhb53420c2016-03-09 14:32:57 +05306010 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306011}
6012
6013/**
6014 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6015 * @wmi_handle: wmi handle
6016 * @pgetcapab: get capabilities params
6017 *
6018 * This function send request to fw to get extscan capabilities.
6019 *
6020 * Return: CDF status
6021 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306022static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306023 struct extscan_capabilities_params *pgetcapab)
6024{
6025 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6026 wmi_buf_t wmi_buf;
6027 uint32_t len;
6028 uint8_t *buf_ptr;
6029
6030 len = sizeof(*cmd);
6031 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6032 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306033 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6034 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306035 }
6036 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6037
6038 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6039 WMITLV_SET_HDR(&cmd->tlv_header,
6040 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6041 WMITLV_GET_STRUCT_TLVLEN
6042 (wmi_extscan_get_capabilities_cmd_fixed_param));
6043
6044 cmd->request_id = pgetcapab->request_id;
6045
6046 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6047 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306048 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306049 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306050 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306051 }
Govind Singhb53420c2016-03-09 14:32:57 +05306052 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306053}
6054
6055/**
6056 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6057 * @wmi_handle: wmi handle
6058 * @pcached_results: cached results parameters
6059 *
6060 * This function send request to fw to get cached results.
6061 *
6062 * Return: CDF status
6063 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306064static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306065 struct extscan_cached_result_params *pcached_results)
6066{
6067 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6068 wmi_buf_t wmi_buf;
6069 uint32_t len;
6070 uint8_t *buf_ptr;
6071
6072 len = sizeof(*cmd);
6073 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6074 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306075 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6076 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306077 }
6078 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6079
6080 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6081 WMITLV_SET_HDR(&cmd->tlv_header,
6082 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6083 WMITLV_GET_STRUCT_TLVLEN
6084 (wmi_extscan_get_cached_results_cmd_fixed_param));
6085
6086 cmd->request_id = pcached_results->request_id;
6087 cmd->vdev_id = pcached_results->session_id;
6088 cmd->control_flags = pcached_results->flush;
6089
6090 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6091 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306092 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306093 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306094 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306095 }
Govind Singhb53420c2016-03-09 14:32:57 +05306096 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306097}
6098
6099/**
6100 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6101 * @wmi_handle: wmi handle
6102 * @reset_req: Reset change request params
6103 *
6104 * This function sends stop change monitor request to fw.
6105 *
6106 * Return: CDF status
6107 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306108static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306109 struct extscan_capabilities_reset_params *reset_req)
6110{
6111 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6112 wmi_buf_t wmi_buf;
6113 uint32_t len;
6114 uint8_t *buf_ptr;
6115 int change_list = 0;
6116
6117 len = sizeof(*cmd);
6118
6119 /* reset significant change tlv is set to 0 */
6120 len += WMI_TLV_HDR_SIZE;
6121 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6122 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6123 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306124 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6125 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306126 }
6127 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6128
6129 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6130 buf_ptr;
6131 WMITLV_SET_HDR(&cmd->tlv_header,
6132 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6133 WMITLV_GET_STRUCT_TLVLEN
6134 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6135
6136 cmd->request_id = reset_req->request_id;
6137 cmd->vdev_id = reset_req->session_id;
6138 cmd->mode = 0;
6139
6140 buf_ptr += sizeof(*cmd);
6141 WMITLV_SET_HDR(buf_ptr,
6142 WMITLV_TAG_ARRAY_STRUC,
6143 change_list *
6144 sizeof(wmi_extscan_wlan_change_bssid_param));
6145 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6146 sizeof
6147 (wmi_extscan_wlan_change_bssid_param));
6148
6149 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6150 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306151 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306152 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306153 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306154 }
Govind Singhb53420c2016-03-09 14:32:57 +05306155 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306156}
6157
6158/**
6159 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6160 * @wmi_handle: wmi handle
6161 * @psigchange: change monitor request params
6162 * @buf: wmi buffer
6163 * @buf_len: buffer length
6164 *
6165 * This function fills elements of change monitor request buffer.
6166 *
6167 * Return: CDF status
6168 */
Govind Singhb53420c2016-03-09 14:32:57 +05306169static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306170 struct extscan_set_sig_changereq_params
6171 *psigchange, wmi_buf_t *buf, int *buf_len)
6172{
6173 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6174 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6175 uint8_t *buf_ptr;
6176 int j;
6177 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006178 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306179 struct ap_threshold_params *src_ap = psigchange->ap;
6180
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006181 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306182 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6183 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306184 }
6185 len += WMI_TLV_HDR_SIZE;
6186 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6187
6188 *buf = wmi_buf_alloc(wmi_handle, len);
6189 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306190 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306191 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306192 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306193 }
6194 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6195 cmd =
6196 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6197 buf_ptr;
6198 WMITLV_SET_HDR(&cmd->tlv_header,
6199 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6200 WMITLV_GET_STRUCT_TLVLEN
6201 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6202
6203 cmd->request_id = psigchange->request_id;
6204 cmd->vdev_id = psigchange->session_id;
6205 cmd->total_entries = numap;
6206 cmd->mode = 1;
6207 cmd->num_entries_in_page = numap;
6208 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6209 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6210 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6211 cmd->max_out_of_range_count = psigchange->min_breaching;
6212
6213 buf_ptr += sizeof(*cmd);
6214 WMITLV_SET_HDR(buf_ptr,
6215 WMITLV_TAG_ARRAY_STRUC,
6216 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6217 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6218 (buf_ptr + WMI_TLV_HDR_SIZE);
6219
6220 for (j = 0; j < numap; j++) {
6221 WMITLV_SET_HDR(dest_chglist,
6222 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6223 WMITLV_GET_STRUCT_TLVLEN
6224 (wmi_extscan_wlan_change_bssid_param));
6225
6226 dest_chglist->lower_rssi_limit = src_ap->low;
6227 dest_chglist->upper_rssi_limit = src_ap->high;
6228 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6229 &dest_chglist->bssid);
6230
Govind Singhb53420c2016-03-09 14:32:57 +05306231 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306232 dest_chglist->lower_rssi_limit);
6233 dest_chglist++;
6234 src_ap++;
6235 }
6236 buf_ptr += WMI_TLV_HDR_SIZE +
6237 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6238 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306239 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306240}
6241
6242/**
6243 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6244 * @wmi_handle: wmi handle
6245 * @psigchange: change monitor request params
6246 *
6247 * This function sends start change monitor request to fw.
6248 *
6249 * Return: CDF status
6250 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306251static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306252 struct extscan_set_sig_changereq_params *
6253 psigchange)
6254{
Govind Singhb53420c2016-03-09 14:32:57 +05306255 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306256 wmi_buf_t buf;
6257 int len;
6258
6259
Govind Singhb53420c2016-03-09 14:32:57 +05306260 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306261 psigchange, &buf,
6262 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306263 if (qdf_status != QDF_STATUS_SUCCESS) {
6264 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306265 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306266 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306267 }
6268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306269 WMI_LOGE("%s: Failed to get buffer", __func__);
6270 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306271 }
6272 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6273 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306274 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306275 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306276 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306277 }
Govind Singhb53420c2016-03-09 14:32:57 +05306278 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306279}
6280
6281/**
6282 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6283 * @wmi_handle: wmi handle
6284 * @photlist_reset: hotlist reset params
6285 *
6286 * This function configures hotlist monitor to stop in fw.
6287 *
6288 * Return: CDF status
6289 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306290static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306291 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6292{
6293 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6294 wmi_buf_t wmi_buf;
6295 uint32_t len;
6296 uint8_t *buf_ptr;
6297 int hotlist_entries = 0;
6298
6299 len = sizeof(*cmd);
6300
6301 /* reset bssid hotlist with tlv set to 0 */
6302 len += WMI_TLV_HDR_SIZE;
6303 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6304
6305 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6306 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306307 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6308 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306309 }
6310
6311 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6312 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6313 buf_ptr;
6314 WMITLV_SET_HDR(&cmd->tlv_header,
6315 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6316 WMITLV_GET_STRUCT_TLVLEN
6317 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6318
6319 cmd->request_id = photlist_reset->request_id;
6320 cmd->vdev_id = photlist_reset->session_id;
6321 cmd->mode = 0;
6322
6323 buf_ptr += sizeof(*cmd);
6324 WMITLV_SET_HDR(buf_ptr,
6325 WMITLV_TAG_ARRAY_STRUC,
6326 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6327 buf_ptr += WMI_TLV_HDR_SIZE +
6328 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6329
6330 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6331 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306332 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306333 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306334 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306335 }
Govind Singhb53420c2016-03-09 14:32:57 +05306336 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306337}
6338
6339/**
6340 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6341 * @wmi_handle: wmi handle
6342 * @pstopcmd: stop scan command request params
6343 *
6344 * This function sends stop extscan request to fw.
6345 *
6346 * Return: CDF Status.
6347 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306348static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306349 struct extscan_stop_req_params *pstopcmd)
6350{
6351 wmi_extscan_stop_cmd_fixed_param *cmd;
6352 wmi_buf_t wmi_buf;
6353 uint32_t len;
6354 uint8_t *buf_ptr;
6355
6356 len = sizeof(*cmd);
6357 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6358 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306359 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6360 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306361 }
6362 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6363 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6364 WMITLV_SET_HDR(&cmd->tlv_header,
6365 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6366 WMITLV_GET_STRUCT_TLVLEN
6367 (wmi_extscan_stop_cmd_fixed_param));
6368
6369 cmd->request_id = pstopcmd->request_id;
6370 cmd->vdev_id = pstopcmd->session_id;
6371
6372 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6373 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306374 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306375 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306376 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306377 }
6378
Govind Singhb53420c2016-03-09 14:32:57 +05306379 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306380}
6381
6382/**
6383 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6384 * @wmi_handle: wmi handle
6385 * @pstart: scan command request params
6386 * @buf: event buffer
6387 * @buf_len: length of buffer
6388 *
6389 * This function fills individual elements of extscan request and
6390 * TLV for buckets, channel list.
6391 *
6392 * Return: CDF Status.
6393 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006394static
Govind Singhb53420c2016-03-09 14:32:57 +05306395QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306396 struct wifi_scan_cmd_req_params *pstart,
6397 wmi_buf_t *buf, int *buf_len)
6398{
6399 wmi_extscan_start_cmd_fixed_param *cmd;
6400 wmi_extscan_bucket *dest_blist;
6401 wmi_extscan_bucket_channel *dest_clist;
6402 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6403 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6404 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6405
6406 uint8_t *buf_ptr;
6407 int i, k, count = 0;
6408 int len = sizeof(*cmd);
6409 int nbuckets = pstart->numBuckets;
6410 int nchannels = 0;
6411
6412 /* These TLV's are are NULL by default */
6413 uint32_t ie_len_with_pad = 0;
6414 int num_ssid = 0;
6415 int num_bssid = 0;
6416 int ie_len = 0;
6417
6418 uint32_t base_period = pstart->basePeriod;
6419
6420 /* TLV placeholder for ssid_list (NULL) */
6421 len += WMI_TLV_HDR_SIZE;
6422 len += num_ssid * sizeof(wmi_ssid);
6423
6424 /* TLV placeholder for bssid_list (NULL) */
6425 len += WMI_TLV_HDR_SIZE;
6426 len += num_bssid * sizeof(wmi_mac_addr);
6427
6428 /* TLV placeholder for ie_data (NULL) */
6429 len += WMI_TLV_HDR_SIZE;
6430 len += ie_len * sizeof(uint32_t);
6431
6432 /* TLV placeholder for bucket */
6433 len += WMI_TLV_HDR_SIZE;
6434 len += nbuckets * sizeof(wmi_extscan_bucket);
6435
6436 /* TLV channel placeholder */
6437 len += WMI_TLV_HDR_SIZE;
6438 for (i = 0; i < nbuckets; i++) {
6439 nchannels += src_bucket->numChannels;
6440 src_bucket++;
6441 }
6442
Govind Singhb53420c2016-03-09 14:32:57 +05306443 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306444 __func__, nbuckets, nchannels);
6445 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6446 /* Allocate the memory */
6447 *buf = wmi_buf_alloc(wmi_handle, len);
6448 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306449 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306450 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306451 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306452 }
6453 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6454 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6455 WMITLV_SET_HDR(&cmd->tlv_header,
6456 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6457 WMITLV_GET_STRUCT_TLVLEN
6458 (wmi_extscan_start_cmd_fixed_param));
6459
6460 cmd->request_id = pstart->requestId;
6461 cmd->vdev_id = pstart->sessionId;
6462 cmd->base_period = pstart->basePeriod;
6463 cmd->num_buckets = nbuckets;
6464 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306465 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306466 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306467 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306468 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306469#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306470 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6471 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306472 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6473 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6474#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306475 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6476
6477 /* The max dwell time is retrieved from the first channel
6478 * of the first bucket and kept common for all channels.
6479 */
6480 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6481 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6482 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6483 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6484 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6485 cmd->max_table_usage = pstart->report_threshold_percent;
6486 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6487
6488 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306489 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306490 cmd->probe_delay = 0;
6491 cmd->probe_spacing_time = 0;
6492 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306493 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6494 WMI_SCAN_ADD_CCK_RATES |
6495 WMI_SCAN_ADD_OFDM_RATES |
6496 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6497 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306498 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6499 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306500 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306501 cmd->num_ssids = 0;
6502 cmd->num_bssid = 0;
6503 cmd->ie_len = 0;
6504 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6505 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6506
6507 buf_ptr += sizeof(*cmd);
6508 WMITLV_SET_HDR(buf_ptr,
6509 WMITLV_TAG_ARRAY_FIXED_STRUC,
6510 num_ssid * sizeof(wmi_ssid));
6511 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6512
6513 WMITLV_SET_HDR(buf_ptr,
6514 WMITLV_TAG_ARRAY_FIXED_STRUC,
6515 num_bssid * sizeof(wmi_mac_addr));
6516 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6517
6518 ie_len_with_pad = 0;
6519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6520 ie_len_with_pad);
6521 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6522
6523 WMITLV_SET_HDR(buf_ptr,
6524 WMITLV_TAG_ARRAY_STRUC,
6525 nbuckets * sizeof(wmi_extscan_bucket));
6526 dest_blist = (wmi_extscan_bucket *)
6527 (buf_ptr + WMI_TLV_HDR_SIZE);
6528 src_bucket = pstart->buckets;
6529
6530 /* Retrieve scanning information from each bucket and
6531 * channels and send it to the target
6532 */
6533 for (i = 0; i < nbuckets; i++) {
6534 WMITLV_SET_HDR(dest_blist,
6535 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6536 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6537
6538 dest_blist->bucket_id = src_bucket->bucket;
6539 dest_blist->base_period_multiplier =
6540 src_bucket->period / base_period;
6541 dest_blist->min_period = src_bucket->period;
6542 dest_blist->max_period = src_bucket->max_period;
6543 dest_blist->exp_backoff = src_bucket->exponent;
6544 dest_blist->exp_max_step_count = src_bucket->step_count;
6545 dest_blist->channel_band = src_bucket->band;
6546 dest_blist->num_channels = src_bucket->numChannels;
6547 dest_blist->notify_extscan_events = 0;
6548
6549 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6550 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006551 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6552 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306553
6554 if (src_bucket->reportEvents &
6555 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6556 dest_blist->forwarding_flags =
6557 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6558 dest_blist->notify_extscan_events |=
6559 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6560 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6561 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6562 } else {
6563 dest_blist->forwarding_flags =
6564 WMI_EXTSCAN_NO_FORWARDING;
6565 }
6566
6567 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6568 dest_blist->configuration_flags = 0;
6569 else
6570 dest_blist->configuration_flags =
6571 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6572
Govind Singhb53420c2016-03-09 14:32:57 +05306573 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306574 __func__, dest_blist->notify_extscan_events,
6575 dest_blist->configuration_flags,
6576 dest_blist->forwarding_flags);
6577
6578 dest_blist->min_dwell_time_active =
6579 src_bucket->min_dwell_time_active;
6580 dest_blist->max_dwell_time_active =
6581 src_bucket->max_dwell_time_active;
6582 dest_blist->min_dwell_time_passive =
6583 src_bucket->min_dwell_time_passive;
6584 dest_blist->max_dwell_time_passive =
6585 src_bucket->max_dwell_time_passive;
6586 src_channel = src_bucket->channels;
6587
6588 /* save the channel info to later populate
6589 * the channel TLV
6590 */
6591 for (k = 0; k < src_bucket->numChannels; k++) {
6592 save_channel[count++].channel = src_channel->channel;
6593 src_channel++;
6594 }
6595 dest_blist++;
6596 src_bucket++;
6597 }
6598 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6599 WMITLV_SET_HDR(buf_ptr,
6600 WMITLV_TAG_ARRAY_STRUC,
6601 nchannels * sizeof(wmi_extscan_bucket_channel));
6602 dest_clist = (wmi_extscan_bucket_channel *)
6603 (buf_ptr + WMI_TLV_HDR_SIZE);
6604
6605 /* Active or passive scan is based on the bucket dwell time
6606 * and channel specific active,passive scans are not
6607 * supported yet
6608 */
6609 for (i = 0; i < nchannels; i++) {
6610 WMITLV_SET_HDR(dest_clist,
6611 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6612 WMITLV_GET_STRUCT_TLVLEN
6613 (wmi_extscan_bucket_channel));
6614 dest_clist->channel = save_channel[i].channel;
6615 dest_clist++;
6616 }
6617 buf_ptr += WMI_TLV_HDR_SIZE +
6618 (nchannels * sizeof(wmi_extscan_bucket_channel));
6619 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306620 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306621}
6622
6623/**
6624 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6625 * @wmi_handle: wmi handle
6626 * @pstart: scan command request params
6627 *
6628 * This function sends start extscan request to fw.
6629 *
6630 * Return: CDF Status.
6631 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306632static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306633 struct wifi_scan_cmd_req_params *pstart)
6634{
Govind Singhb53420c2016-03-09 14:32:57 +05306635 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306636 wmi_buf_t buf;
6637 int len;
6638
6639 /* Fill individual elements of extscan request and
6640 * TLV for buckets, channel list.
6641 */
Govind Singhb53420c2016-03-09 14:32:57 +05306642 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306643 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306644 if (qdf_status != QDF_STATUS_SUCCESS) {
6645 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6646 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306647 }
6648 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306649 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306650 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306651 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306652 }
6653 if (wmi_unified_cmd_send(wmi_handle, buf,
6654 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306655 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306656 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306657 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306658 }
6659
Govind Singhb53420c2016-03-09 14:32:57 +05306660 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306661}
6662
6663/**
6664 * send_plm_stop_cmd_tlv() - plm stop request
6665 * @wmi_handle: wmi handle
6666 * @plm: plm request parameters
6667 *
6668 * This function request FW to stop PLM.
6669 *
6670 * Return: CDF status
6671 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306672static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306673 const struct plm_req_params *plm)
6674{
6675 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6676 int32_t len;
6677 wmi_buf_t buf;
6678 uint8_t *buf_ptr;
6679 int ret;
6680
6681 len = sizeof(*cmd);
6682 buf = wmi_buf_alloc(wmi_handle, len);
6683 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306684 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6685 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306686 }
6687
6688 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6689
6690 buf_ptr = (uint8_t *) cmd;
6691
6692 WMITLV_SET_HDR(&cmd->tlv_header,
6693 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6694 WMITLV_GET_STRUCT_TLVLEN
6695 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6696
6697 cmd->vdev_id = plm->session_id;
6698
6699 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306700 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306701
6702 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6703 WMI_VDEV_PLMREQ_STOP_CMDID);
6704 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306705 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306706 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306707 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306708 }
6709
Govind Singhb53420c2016-03-09 14:32:57 +05306710 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306711}
6712
6713/**
6714 * send_plm_start_cmd_tlv() - plm start request
6715 * @wmi_handle: wmi handle
6716 * @plm: plm request parameters
6717 *
6718 * This function request FW to start PLM.
6719 *
6720 * Return: CDF status
6721 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306722static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306723 const struct plm_req_params *plm,
6724 uint32_t *gchannel_list)
6725{
6726 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6727 uint32_t *channel_list;
6728 int32_t len;
6729 wmi_buf_t buf;
6730 uint8_t *buf_ptr;
6731 uint8_t count;
6732 int ret;
6733
6734 /* TLV place holder for channel_list */
6735 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6736 len += sizeof(uint32_t) * plm->plm_num_ch;
6737
6738 buf = wmi_buf_alloc(wmi_handle, len);
6739 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306740 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6741 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306742 }
6743 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6744
6745 buf_ptr = (uint8_t *) cmd;
6746
6747 WMITLV_SET_HDR(&cmd->tlv_header,
6748 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6749 WMITLV_GET_STRUCT_TLVLEN
6750 (wmi_vdev_plmreq_start_cmd_fixed_param));
6751
6752 cmd->vdev_id = plm->session_id;
6753
6754 cmd->meas_token = plm->meas_token;
6755 cmd->dialog_token = plm->diag_token;
6756 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306757 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306758 cmd->off_duration = plm->meas_duration;
6759 cmd->burst_cycle = plm->burst_len;
6760 cmd->tx_power = plm->desired_tx_pwr;
6761 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6762 cmd->num_chans = plm->plm_num_ch;
6763
6764 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6765
Govind Singhb53420c2016-03-09 14:32:57 +05306766 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6767 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6768 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6769 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6770 WMI_LOGD("off_duration: %d", cmd->off_duration);
6771 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6772 WMI_LOGD("tx_power: %d", cmd->tx_power);
6773 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306774
6775 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6776 (cmd->num_chans * sizeof(uint32_t)));
6777
6778 buf_ptr += WMI_TLV_HDR_SIZE;
6779 if (cmd->num_chans) {
6780 channel_list = (uint32_t *) buf_ptr;
6781 for (count = 0; count < cmd->num_chans; count++) {
6782 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306783 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306784 channel_list[count] =
6785 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306786 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306787 }
6788 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6789 }
6790
6791 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6792 WMI_VDEV_PLMREQ_START_CMDID);
6793 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306794 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306795 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306796 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306797 }
6798
Govind Singhb53420c2016-03-09 14:32:57 +05306799 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306800}
6801
6802/**
6803 * send_pno_stop_cmd_tlv() - PNO stop request
6804 * @wmi_handle: wmi handle
6805 * @vdev_id: vdev id
6806 *
6807 * This function request FW to stop ongoing PNO operation.
6808 *
6809 * Return: CDF status
6810 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306811static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306812{
6813 wmi_nlo_config_cmd_fixed_param *cmd;
6814 int32_t len = sizeof(*cmd);
6815 wmi_buf_t buf;
6816 uint8_t *buf_ptr;
6817 int ret;
6818
6819 /*
6820 * TLV place holder for array of structures nlo_configured_parameters
6821 * TLV place holder for array of uint32_t channel_list
6822 * TLV place holder for chnl prediction cfg
6823 */
6824 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6825 buf = wmi_buf_alloc(wmi_handle, len);
6826 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306827 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6828 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306829 }
6830
6831 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6832 buf_ptr = (uint8_t *) cmd;
6833
6834 WMITLV_SET_HDR(&cmd->tlv_header,
6835 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6836 WMITLV_GET_STRUCT_TLVLEN
6837 (wmi_nlo_config_cmd_fixed_param));
6838
6839 cmd->vdev_id = vdev_id;
6840 cmd->flags = WMI_NLO_CONFIG_STOP;
6841 buf_ptr += sizeof(*cmd);
6842
6843 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6844 buf_ptr += WMI_TLV_HDR_SIZE;
6845
6846 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6847 buf_ptr += WMI_TLV_HDR_SIZE;
6848
6849 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6850 buf_ptr += WMI_TLV_HDR_SIZE;
6851
6852
6853 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6854 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6855 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306856 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306857 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306858 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306859 }
6860
Govind Singhb53420c2016-03-09 14:32:57 +05306861 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306862}
6863
6864/**
Govind Singhccb0c272016-04-01 16:30:08 +05306865 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6866 * @buf_ptr: Buffer passed by upper layers
6867 * @pno: Buffer to be sent to the firmware
6868 *
6869 * Copy the PNO Channel prediction configuration parameters
6870 * passed by the upper layers to a WMI format TLV and send it
6871 * down to the firmware.
6872 *
6873 * Return: None
6874 */
6875static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6876 struct pno_scan_req_params *pno)
6877{
6878 nlo_channel_prediction_cfg *channel_prediction_cfg =
6879 (nlo_channel_prediction_cfg *) buf_ptr;
6880 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6881 WMITLV_TAG_ARRAY_BYTE,
6882 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306883#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306884 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6885 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6886 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6887 channel_prediction_cfg->full_scan_period_ms =
6888 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306889#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306890 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6891 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6892 channel_prediction_cfg->enable,
6893 channel_prediction_cfg->top_k_num,
6894 channel_prediction_cfg->stationary_threshold,
6895 channel_prediction_cfg->full_scan_period_ms);
6896}
6897
6898/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306899 * send_pno_start_cmd_tlv() - PNO start request
6900 * @wmi_handle: wmi handle
6901 * @pno: PNO request
6902 *
6903 * This function request FW to start PNO request.
6904 * Request: CDF status
6905 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306906static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05306907 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306908{
6909 wmi_nlo_config_cmd_fixed_param *cmd;
6910 nlo_configured_parameters *nlo_list;
6911 uint32_t *channel_list;
6912 int32_t len;
6913 wmi_buf_t buf;
6914 uint8_t *buf_ptr;
6915 uint8_t i;
6916 int ret;
6917
6918 /*
6919 * TLV place holder for array nlo_configured_parameters(nlo_list)
6920 * TLV place holder for array of uint32_t channel_list
6921 * TLV place holder for chnnl prediction cfg
6922 */
6923 len = sizeof(*cmd) +
6924 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6925
Abhishek Singh5987b632017-03-03 22:09:07 +05306926 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306927 WMI_NLO_MAX_CHAN);
6928 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05306929 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306930 len += sizeof(nlo_channel_prediction_cfg);
6931
6932 buf = wmi_buf_alloc(wmi_handle, len);
6933 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306934 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6935 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306936 }
6937
6938 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6939
6940 buf_ptr = (uint8_t *) cmd;
6941 WMITLV_SET_HDR(&cmd->tlv_header,
6942 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6943 WMITLV_GET_STRUCT_TLVLEN
6944 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05306945 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306946 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6947
Govind Singh87542482016-06-08 19:40:11 +05306948#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306949 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05306950 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306951#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306952 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05306953 cmd->active_dwell_time = pno->active_dwell_time;
6954 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306955
6956 /* Copy scan interval */
6957 cmd->fast_scan_period = pno->fast_scan_period;
6958 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08006959 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306960 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306961 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306962 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306963 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306964
6965 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6966
Abhishek Singh5987b632017-03-03 22:09:07 +05306967 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05306968 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306969 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6970 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6971 buf_ptr += WMI_TLV_HDR_SIZE;
6972
6973 nlo_list = (nlo_configured_parameters *) buf_ptr;
6974 for (i = 0; i < cmd->no_of_ssids; i++) {
6975 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6976 WMITLV_TAG_ARRAY_BYTE,
6977 WMITLV_GET_STRUCT_TLVLEN
6978 (nlo_configured_parameters));
6979 /* Copy ssid and it's length */
6980 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05306981 nlo_list[i].ssid.ssid.ssid_len =
6982 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306983 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05306984 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306985 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306986 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306987 nlo_list[i].ssid.ssid.ssid_len,
6988 (char *)nlo_list[i].ssid.ssid.ssid,
6989 nlo_list[i].ssid.ssid.ssid_len);
6990
6991 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05306992 if (pno->networks_list[i].rssi_thresh &&
6993 pno->networks_list[i].rssi_thresh >
6994 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05306995 nlo_list[i].rssi_cond.valid = true;
6996 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05306997 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05306998 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306999 nlo_list[i].rssi_cond.rssi);
7000 }
7001 nlo_list[i].bcast_nw_type.valid = true;
7002 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307003 pno->networks_list[i].bc_new_type;
Govind Singhb53420c2016-03-09 14:32:57 +05307004 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307005 nlo_list[i].bcast_nw_type.bcast_nw_type);
7006 }
7007 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7008
7009 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307010 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307011 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307012 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307013 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7014 (cmd->num_of_channels * sizeof(uint32_t)));
7015 buf_ptr += WMI_TLV_HDR_SIZE;
7016
7017 channel_list = (uint32_t *) buf_ptr;
7018 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307019 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307020
7021 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307022 channel_list[i] =
7023 wlan_chan_to_freq(pno->
7024 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307025
Govind Singhb53420c2016-03-09 14:32:57 +05307026 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307027 }
7028 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7029 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7030 sizeof(nlo_channel_prediction_cfg));
7031 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307032 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307033 buf_ptr += WMI_TLV_HDR_SIZE;
7034 /** TODO: Discrete firmware doesn't have command/option to configure
7035 * App IE which comes from wpa_supplicant as of part PNO start request.
7036 */
7037 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7038 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7039 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307040 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307041 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307042 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307043 }
7044
Govind Singhb53420c2016-03-09 14:32:57 +05307045 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307046}
7047
7048/* send_set_ric_req_cmd_tlv() - set ric request element
7049 * @wmi_handle: wmi handle
7050 * @msg: message
7051 * @is_add_ts: is addts required
7052 *
7053 * This function sets ric request element for 11r roaming.
7054 *
7055 * Return: CDF status
7056 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307057static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307058 void *msg, uint8_t is_add_ts)
7059{
7060 wmi_ric_request_fixed_param *cmd;
7061 wmi_ric_tspec *tspec_param;
7062 wmi_buf_t buf;
7063 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307064 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307065 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7066 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7067
7068 buf = wmi_buf_alloc(wmi_handle, len);
7069 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307070 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7071 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307072 }
7073
7074 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7075
7076 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7077 WMITLV_SET_HDR(&cmd->tlv_header,
7078 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7079 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7080 if (is_add_ts)
7081 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
7082 else
7083 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7084 cmd->num_ric_request = 1;
7085 cmd->is_add_ric = is_add_ts;
7086
7087 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7088 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7089
7090 buf_ptr += WMI_TLV_HDR_SIZE;
7091 tspec_param = (wmi_ric_tspec *) buf_ptr;
7092 WMITLV_SET_HDR(&tspec_param->tlv_header,
7093 WMITLV_TAG_STRUC_wmi_ric_tspec,
7094 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7095
7096 if (is_add_ts)
7097 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307098#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307099 else
7100 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307101#endif
7102 if (ptspecIE) {
7103 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307104#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307105 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7106 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307107#else
Govind Singh87542482016-06-08 19:40:11 +05307108 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7109 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307110#endif /* ANI_LITTLE_BIT_ENDIAN */
7111
Govind Singh87542482016-06-08 19:40:11 +05307112 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7113 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7114 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7115 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7116 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7117 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7118 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7119 tspec_param->min_data_rate = ptspecIE->minDataRate;
7120 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7121 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7122 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7123 tspec_param->delay_bound = ptspecIE->delayBound;
7124 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7125 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7126 tspec_param->medium_time = 0;
7127 }
Govind Singhb53420c2016-03-09 14:32:57 +05307128 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307129
7130 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7131 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307132 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307133 __func__);
7134 if (is_add_ts)
7135 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307136 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307137 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307138 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307139 }
7140
Govind Singhb53420c2016-03-09 14:32:57 +05307141 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307142}
7143
7144/**
7145 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7146 * @wmi_handle: wmi handle
7147 * @clear_req: ll stats clear request command params
7148 *
Govind Singhb53420c2016-03-09 14:32:57 +05307149 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307150 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307151static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307152 const struct ll_stats_clear_params *clear_req,
7153 uint8_t addr[IEEE80211_ADDR_LEN])
7154{
7155 wmi_clear_link_stats_cmd_fixed_param *cmd;
7156 int32_t len;
7157 wmi_buf_t buf;
7158 uint8_t *buf_ptr;
7159 int ret;
7160
7161 len = sizeof(*cmd);
7162 buf = wmi_buf_alloc(wmi_handle, len);
7163
7164 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307165 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7166 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307167 }
7168
7169 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307170 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307171 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7172
7173 WMITLV_SET_HDR(&cmd->tlv_header,
7174 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7175 WMITLV_GET_STRUCT_TLVLEN
7176 (wmi_clear_link_stats_cmd_fixed_param));
7177
7178 cmd->stop_stats_collection_req = clear_req->stop_req;
7179 cmd->vdev_id = clear_req->sta_id;
7180 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7181
7182 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7183 &cmd->peer_macaddr);
7184
Govind Singhb53420c2016-03-09 14:32:57 +05307185 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7186 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7187 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7188 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7189 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307190 cmd->peer_macaddr); */
7191
7192 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7193 WMI_CLEAR_LINK_STATS_CMDID);
7194 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307195 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307196 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307197 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307198 }
7199
Govind Singhb53420c2016-03-09 14:32:57 +05307200 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7201 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307202}
7203
7204/**
7205 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7206 * @wmi_handle: wmi handle
7207 * @setReq: ll stats set request command params
7208 *
Govind Singhb53420c2016-03-09 14:32:57 +05307209 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307210 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307211static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307212 const struct ll_stats_set_params *set_req)
7213{
7214 wmi_start_link_stats_cmd_fixed_param *cmd;
7215 int32_t len;
7216 wmi_buf_t buf;
7217 uint8_t *buf_ptr;
7218 int ret;
7219
7220 len = sizeof(*cmd);
7221 buf = wmi_buf_alloc(wmi_handle, len);
7222
7223 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7225 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307226 }
7227
7228 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307229 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307230 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7231
7232 WMITLV_SET_HDR(&cmd->tlv_header,
7233 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7234 WMITLV_GET_STRUCT_TLVLEN
7235 (wmi_start_link_stats_cmd_fixed_param));
7236
7237 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7238 cmd->aggressive_statistics_gathering =
7239 set_req->aggressive_statistics_gathering;
7240
Govind Singhb53420c2016-03-09 14:32:57 +05307241 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7242 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7243 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307244
7245 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7246 WMI_START_LINK_STATS_CMDID);
7247 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307248 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307249 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307250 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307251 }
7252
Govind Singhb53420c2016-03-09 14:32:57 +05307253 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307254}
7255
7256/**
7257 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7258 * @wmi_handle:wmi handle
7259 * @get_req:ll stats get request command params
7260 * @addr: mac address
7261 *
Govind Singhb53420c2016-03-09 14:32:57 +05307262 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307263 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307264static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307265 const struct ll_stats_get_params *get_req,
7266 uint8_t addr[IEEE80211_ADDR_LEN])
7267{
7268 wmi_request_link_stats_cmd_fixed_param *cmd;
7269 int32_t len;
7270 wmi_buf_t buf;
7271 uint8_t *buf_ptr;
7272 int ret;
7273
7274 len = sizeof(*cmd);
7275 buf = wmi_buf_alloc(wmi_handle, len);
7276
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307277 if (!buf) {
7278 WMI_LOGE("%s: buf allocation failed", __func__);
7279 return QDF_STATUS_E_NOMEM;
7280 }
7281
Govind Singh4eacd2b2016-03-07 14:24:22 +05307282 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307283 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307284 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7285
7286 WMITLV_SET_HDR(&cmd->tlv_header,
7287 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7288 WMITLV_GET_STRUCT_TLVLEN
7289 (wmi_request_link_stats_cmd_fixed_param));
7290
7291 cmd->request_id = get_req->req_id;
7292 cmd->stats_type = get_req->param_id_mask;
7293 cmd->vdev_id = get_req->sta_id;
7294
7295 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7296 &cmd->peer_macaddr);
7297
Govind Singhb53420c2016-03-09 14:32:57 +05307298 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007299 WMI_LOGD("Request ID : %u", cmd->request_id);
7300 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307301 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7302 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307303
7304 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7305 WMI_REQUEST_LINK_STATS_CMDID);
7306 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307307 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307308 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307309 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307310 }
7311
Govind Singhb53420c2016-03-09 14:32:57 +05307312 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307313}
7314
7315/**
7316 * send_get_stats_cmd_tlv() - get stats request
7317 * @wmi_handle: wmi handle
7318 * @get_stats_param: stats params
7319 * @addr: mac address
7320 *
7321 * Return: CDF status
7322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307323static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307324 struct pe_stats_req *get_stats_param,
7325 uint8_t addr[IEEE80211_ADDR_LEN])
7326{
7327 wmi_buf_t buf;
7328 wmi_request_stats_cmd_fixed_param *cmd;
7329 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7330
7331 buf = wmi_buf_alloc(wmi_handle, len);
7332 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307333 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7334 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307335 }
7336
7337
7338 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7339 WMITLV_SET_HDR(&cmd->tlv_header,
7340 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7341 WMITLV_GET_STRUCT_TLVLEN
7342 (wmi_request_stats_cmd_fixed_param));
7343 cmd->stats_id =
7344 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05307345 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307346 cmd->vdev_id = get_stats_param->session_id;
7347 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307348 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307349 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7350 WMI_REQUEST_STATS_CMDID)) {
7351
Govind Singhb53420c2016-03-09 14:32:57 +05307352 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307353 __func__);
7354 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307355 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307356 }
7357
Govind Singhb53420c2016-03-09 14:32:57 +05307358 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307359
7360}
7361
Govind Singh20c5dac2016-03-07 15:33:31 +05307362/**
7363 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7364 * @wmi_handle: wmi handle
7365 * @rssi_req: get RSSI request
7366 *
7367 * Return: CDF status
7368 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307369static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307370{
7371 wmi_buf_t buf;
7372 wmi_request_stats_cmd_fixed_param *cmd;
7373 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7374
7375 buf = wmi_buf_alloc(wmi_handle, len);
7376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307377 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7378 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307379 }
7380
7381 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7382 WMITLV_SET_HDR(&cmd->tlv_header,
7383 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7384 WMITLV_GET_STRUCT_TLVLEN
7385 (wmi_request_stats_cmd_fixed_param));
7386 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7387 if (wmi_unified_cmd_send
7388 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307389 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307390 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307391 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307392 }
7393
Govind Singhb53420c2016-03-09 14:32:57 +05307394 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307395}
7396
7397/**
7398 * send_snr_cmd_tlv() - get RSSI from fw
7399 * @wmi_handle: wmi handle
7400 * @vdev_id: vdev id
7401 *
7402 * Return: CDF status
7403 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307404static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307405{
7406 wmi_buf_t buf;
7407 wmi_request_stats_cmd_fixed_param *cmd;
7408 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7409
7410 buf = wmi_buf_alloc(wmi_handle, len);
7411 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307412 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7413 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307414 }
7415
7416 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7417 cmd->vdev_id = vdev_id;
7418
7419 WMITLV_SET_HDR(&cmd->tlv_header,
7420 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7421 WMITLV_GET_STRUCT_TLVLEN
7422 (wmi_request_stats_cmd_fixed_param));
7423 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7424 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7425 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307426 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307427 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307428 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307429 }
7430
Govind Singhb53420c2016-03-09 14:32:57 +05307431 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307432}
7433
7434/**
7435 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7436 * @wmi_handle: wmi handle
7437 * @link_status: get link params
7438 *
7439 * Return: CDF status
7440 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307441static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307442 struct link_status_params *link_status)
7443{
7444 wmi_buf_t buf;
7445 wmi_request_stats_cmd_fixed_param *cmd;
7446 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7447
7448 buf = wmi_buf_alloc(wmi_handle, len);
7449 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307450 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7451 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307452 }
7453
7454 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7455 WMITLV_SET_HDR(&cmd->tlv_header,
7456 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7457 WMITLV_GET_STRUCT_TLVLEN
7458 (wmi_request_stats_cmd_fixed_param));
7459 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7460 cmd->vdev_id = link_status->session_id;
7461 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7462 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307463 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307464 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307465 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307466 }
7467
Govind Singhb53420c2016-03-09 14:32:57 +05307468 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307469}
7470
Govind Singh20c5dac2016-03-07 15:33:31 +05307471/**
7472 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7473 * @wmi_handle: wmi handle
7474 * @ta_dhcp_ind: DHCP indication parameter
7475 *
7476 * Return: CDF Status
7477 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307478static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307479 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7480{
Govind Singh67922e82016-04-01 16:48:57 +05307481 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307482 wmi_buf_t buf = NULL;
7483 uint8_t *buf_ptr;
7484 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7485 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7486
7487
7488 buf = wmi_buf_alloc(wmi_handle, len);
7489 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307490 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7491 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307492 }
7493
7494 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7495 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7496 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7497 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7498 WMITLV_GET_STRUCT_TLVLEN
7499 (wmi_peer_set_param_cmd_fixed_param));
7500
7501 /* fill in values */
7502 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7503 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7504 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307505 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307506 &ta_dhcp_ind->peer_macaddr,
7507 sizeof(ta_dhcp_ind->peer_macaddr));
7508
7509 status = wmi_unified_cmd_send(wmi_handle, buf,
7510 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307511 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307512 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307513 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307514 wmi_buf_free(buf);
7515 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307516
Govind Singh67922e82016-04-01 16:48:57 +05307517 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307518}
7519
7520/**
7521 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7522 * @wmi_handle: wmi handle
7523 * @pLinkSpeed: link speed info
7524 *
7525 * Return: CDF status
7526 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307527static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307528 wmi_mac_addr peer_macaddr)
7529{
7530 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7531 wmi_buf_t wmi_buf;
7532 uint32_t len;
7533 uint8_t *buf_ptr;
7534
7535 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7536 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7537 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307538 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7539 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307540 }
7541 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7542
7543 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7544 WMITLV_SET_HDR(&cmd->tlv_header,
7545 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7546 WMITLV_GET_STRUCT_TLVLEN
7547 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7548
7549 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307550 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307551 &peer_macaddr,
7552 sizeof(peer_macaddr));
7553
7554
7555 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7556 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307557 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307558 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307559 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307560 }
Govind Singhb53420c2016-03-09 14:32:57 +05307561 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307562}
7563
7564/**
7565 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7566 * @wmi_handle: wmi handler
7567 * @egap_params: pointer to egap_params
7568 *
7569 * Return: 0 for success, otherwise appropriate error code
7570 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307571static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307572 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7573{
7574 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7575 wmi_buf_t buf;
7576 int32_t err;
7577
7578 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7579 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307580 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7581 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307582 }
7583 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7584 WMITLV_SET_HDR(&cmd->tlv_header,
7585 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7586 WMITLV_GET_STRUCT_TLVLEN(
7587 wmi_ap_ps_egap_param_cmd_fixed_param));
7588
7589 cmd->enable = egap_params->enable;
7590 cmd->inactivity_time = egap_params->inactivity_time;
7591 cmd->wait_time = egap_params->wait_time;
7592 cmd->flags = egap_params->flags;
7593 err = wmi_unified_cmd_send(wmi_handle, buf,
7594 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7595 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307596 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307597 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307598 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307599 }
7600
Govind Singhb53420c2016-03-09 14:32:57 +05307601 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307602}
7603
7604/**
7605 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7606 * @wmi_handl: wmi handle
7607 * @cmd: Profiling command index
7608 * @value1: parameter1 value
7609 * @value2: parameter2 value
7610 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307611 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307612 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307613static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307614 uint32_t cmd, uint32_t value1, uint32_t value2)
7615{
7616 wmi_buf_t buf;
7617 int32_t len = 0;
7618 int ret;
7619 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7620 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7621 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7622 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7623
7624 switch (cmd) {
7625 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7626 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7627 buf = wmi_buf_alloc(wmi_handle, len);
7628 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307629 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307630 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307631 }
7632 prof_trig_cmd =
7633 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7634 wmi_buf_data(buf);
7635 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7636 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7637 WMITLV_GET_STRUCT_TLVLEN
7638 (wmi_wlan_profile_trigger_cmd_fixed_param));
7639 prof_trig_cmd->enable = value1;
7640 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7641 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7642 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307643 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307644 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307645 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307646 return ret;
7647 }
7648 break;
7649
7650 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7651 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7652 buf = wmi_buf_alloc(wmi_handle, len);
7653 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307654 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307655 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307656 }
7657 profile_getdata_cmd =
7658 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7659 wmi_buf_data(buf);
7660 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7661 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7662 WMITLV_GET_STRUCT_TLVLEN
7663 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7664 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7665 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7666 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307667 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307668 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307669 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307670 return ret;
7671 }
7672 break;
7673
7674 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7675 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7676 buf = wmi_buf_alloc(wmi_handle, len);
7677 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307678 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307679 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307680 }
7681 hist_intvl_cmd =
7682 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7683 wmi_buf_data(buf);
7684 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7685 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7686 WMITLV_GET_STRUCT_TLVLEN
7687 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7688 hist_intvl_cmd->profile_id = value1;
7689 hist_intvl_cmd->value = value2;
7690 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7691 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7692 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307693 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307694 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307695 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307696 return ret;
7697 }
7698 break;
7699
7700 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7701 len =
7702 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7703 buf = wmi_buf_alloc(wmi_handle, len);
7704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307705 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307706 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307707 }
7708 profile_enable_cmd =
7709 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7710 wmi_buf_data(buf);
7711 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7712 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7713 WMITLV_GET_STRUCT_TLVLEN
7714 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7715 profile_enable_cmd->profile_id = value1;
7716 profile_enable_cmd->enable = value2;
7717 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7718 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7719 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307720 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307721 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307722 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307723 return ret;
7724 }
7725 break;
7726
7727 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307728 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307729 break;
7730 }
7731
7732 return 0;
7733}
7734
Govind Singh20c5dac2016-03-07 15:33:31 +05307735/**
7736 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7737 * @wmi_handle: wmi handle
7738 * @vdev_id: vdev id
7739 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307740 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307741 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307742static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307743{
7744 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7745 wmi_buf_t buf;
7746 int32_t len = sizeof(*cmd);
7747
Govind Singhb53420c2016-03-09 14:32:57 +05307748 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307749 buf = wmi_buf_alloc(wmi_handle, len);
7750 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307751 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307752 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307753 }
7754 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7755 wmi_buf_data(buf);
7756 WMITLV_SET_HDR(&cmd->tlv_header,
7757 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7758 WMITLV_GET_STRUCT_TLVLEN
7759 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7760 cmd->vdev_id = vdev_id;
7761 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7762 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7763 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307764 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307765 __func__);
7766 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307767 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307768 }
7769
7770 return 0;
7771}
7772
7773/**
7774 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7775 * @wmi_handle: wmi handle
7776 * @vdev_id: vdev id
7777 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307778 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307779 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307780static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307781 uint8_t vdev_id)
7782{
7783 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7784 wmi_buf_t buf;
7785 int32_t len = sizeof(*cmd);
7786
Govind Singhb53420c2016-03-09 14:32:57 +05307787 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307788 buf = wmi_buf_alloc(wmi_handle, len);
7789 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307790 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307791 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307792 }
7793 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7794 WMITLV_SET_HDR(&cmd->tlv_header,
7795 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7796 WMITLV_GET_STRUCT_TLVLEN
7797 (wmi_csa_offload_enable_cmd_fixed_param));
7798 cmd->vdev_id = vdev_id;
7799 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7800 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7801 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307802 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307803 __func__);
7804 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307805 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307806 }
7807
7808 return 0;
7809}
7810
7811/**
7812 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7813 * @wmi_handle: wmi handle
7814 * @startOemDataReq: start request params
7815 *
7816 * Return: CDF status
7817 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307818static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007819 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307820 uint8_t *data)
7821{
7822 wmi_buf_t buf;
7823 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307824 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307825
7826 buf = wmi_buf_alloc(wmi_handle,
7827 (data_len + WMI_TLV_HDR_SIZE));
7828 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307829 WMI_LOGE(FL("wmi_buf_alloc failed"));
7830 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307831 }
7832
7833 cmd = (uint8_t *) wmi_buf_data(buf);
7834
7835 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7836 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307837 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307838 data_len);
7839
Govind Singhb53420c2016-03-09 14:32:57 +05307840 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307841 data_len);
7842
7843 ret = wmi_unified_cmd_send(wmi_handle, buf,
7844 (data_len +
7845 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7846
Govind Singh67922e82016-04-01 16:48:57 +05307847 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307848 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307849 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307850 }
7851
Govind Singh67922e82016-04-01 16:48:57 +05307852 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307853}
7854
7855/**
7856 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7857 * @wmi_handle: wmi handle
7858 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7859 *
7860 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7861 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7862 * to firmware based on phyerr filtering
7863 * offload status.
7864 *
7865 * Return: 1 success, 0 failure
7866 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307867static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307868send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7869 bool dfs_phyerr_filter_offload)
7870{
7871 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7872 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7873 wmi_buf_t buf;
7874 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307875 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307876
7877
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007878 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307879 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307880 __func__);
7881 len = sizeof(*disable_phyerr_offload_cmd);
7882 buf = wmi_buf_alloc(wmi_handle, len);
7883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307884 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307885 return 0;
7886 }
7887 disable_phyerr_offload_cmd =
7888 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7889 wmi_buf_data(buf);
7890
7891 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7892 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7893 WMITLV_GET_STRUCT_TLVLEN
7894 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7895
7896 /*
7897 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7898 * to the firmware to disable the phyerror
7899 * filtering offload.
7900 */
7901 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7902 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307903 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307904 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307905 __func__, ret);
7906 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307907 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307908 }
Govind Singhb53420c2016-03-09 14:32:57 +05307909 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307910 __func__);
7911 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307912 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307913 __func__);
7914
7915 len = sizeof(*enable_phyerr_offload_cmd);
7916 buf = wmi_buf_alloc(wmi_handle, len);
7917 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307918 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7919 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307920 }
7921
7922 enable_phyerr_offload_cmd =
7923 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7924 wmi_buf_data(buf);
7925
7926 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7927 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7928 WMITLV_GET_STRUCT_TLVLEN
7929 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7930
7931 /*
7932 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7933 * to the firmware to enable the phyerror
7934 * filtering offload.
7935 */
7936 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7937 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7938
Govind Singh67922e82016-04-01 16:48:57 +05307939 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307940 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307941 __func__, ret);
7942 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307943 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307944 }
Govind Singhb53420c2016-03-09 14:32:57 +05307945 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307946 __func__);
7947 }
7948
Govind Singhb53420c2016-03-09 14:32:57 +05307949 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307950}
7951
7952#if !defined(REMOVE_PKT_LOG)
7953/**
7954 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7955 * @wmi_handle: wmi handle
7956 * @pktlog_event: pktlog event
7957 * @cmd_id: pktlog cmd id
7958 *
7959 * Return: CDF status
7960 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307961static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307962 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307963 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307964{
7965 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7966 WMI_CMD_ID CMD_ID;
7967 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7968 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7969 int len = 0;
7970 wmi_buf_t buf;
7971
7972 PKTLOG_EVENT = pktlog_event;
7973 CMD_ID = cmd_id;
7974
7975 switch (CMD_ID) {
7976 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7977 len = sizeof(*cmd);
7978 buf = wmi_buf_alloc(wmi_handle, len);
7979 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307980 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7981 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307982 }
7983 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7984 wmi_buf_data(buf);
7985 WMITLV_SET_HDR(&cmd->tlv_header,
7986 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7987 WMITLV_GET_STRUCT_TLVLEN
7988 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7989 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307990 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7991 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007992 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307993 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7994 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307995 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307996 goto wmi_send_failed;
7997 }
7998 break;
7999 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8000 len = sizeof(*disable_cmd);
8001 buf = wmi_buf_alloc(wmi_handle, len);
8002 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308003 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8004 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308005 }
8006 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8007 wmi_buf_data(buf);
8008 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8009 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8010 WMITLV_GET_STRUCT_TLVLEN
8011 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07008012 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05308013 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8014 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308015 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308016 goto wmi_send_failed;
8017 }
8018 break;
8019 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308020 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308021 break;
8022 }
8023
Govind Singhb53420c2016-03-09 14:32:57 +05308024 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308025
8026wmi_send_failed:
8027 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308028 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308029}
8030#endif /* REMOVE_PKT_LOG */
8031
8032/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308033 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8034 * @wmi_handle: wmi handle
8035 * @ptrn_id: pattern id
8036 * @vdev_id: vdev id
8037 *
8038 * Return: CDF status
8039 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308040static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8041 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308042{
8043 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8044 wmi_buf_t buf;
8045 int32_t len;
8046 int ret;
8047
8048 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8049
8050
8051 buf = wmi_buf_alloc(wmi_handle, len);
8052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308053 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8054 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308055 }
8056
8057 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8058
8059 WMITLV_SET_HDR(&cmd->tlv_header,
8060 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8061 WMITLV_GET_STRUCT_TLVLEN(
8062 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8063 cmd->vdev_id = vdev_id;
8064 cmd->pattern_id = ptrn_id;
8065 cmd->pattern_type = WOW_BITMAP_PATTERN;
8066
Govind Singhb53420c2016-03-09 14:32:57 +05308067 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308068 cmd->pattern_id, vdev_id);
8069
8070 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8071 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8072 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308073 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308074 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308075 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308076 }
8077
Govind Singhb53420c2016-03-09 14:32:57 +05308078 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308079}
8080
8081/**
8082 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8083 * @wmi_handle: wmi handle
8084 *
8085 * Sends host wakeup indication to FW. On receiving this indication,
8086 * FW will come out of WOW.
8087 *
8088 * Return: CDF status
8089 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308090static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308091{
8092 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8093 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308094 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308095 int32_t len;
8096 int ret;
8097
8098 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8099
8100 buf = wmi_buf_alloc(wmi_handle, len);
8101 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308102 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8103 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308104 }
8105
8106 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8107 wmi_buf_data(buf);
8108 WMITLV_SET_HDR(&cmd->tlv_header,
8109 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8110 WMITLV_GET_STRUCT_TLVLEN
8111 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8112
8113
8114 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8115 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8116 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308117 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308118 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308119 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308120 }
8121
Govind Singhb53420c2016-03-09 14:32:57 +05308122 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308123}
8124
8125/**
8126 * send_del_ts_cmd_tlv() - send DELTS request to fw
8127 * @wmi_handle: wmi handle
8128 * @msg: delts params
8129 *
8130 * Return: CDF status
8131 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308132static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308133 uint8_t ac)
8134{
8135 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8136 wmi_buf_t buf;
8137 int32_t len = sizeof(*cmd);
8138
8139 buf = wmi_buf_alloc(wmi_handle, len);
8140 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308141 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8142 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308143 }
8144 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8145 WMITLV_SET_HDR(&cmd->tlv_header,
8146 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8147 WMITLV_GET_STRUCT_TLVLEN
8148 (wmi_vdev_wmm_delts_cmd_fixed_param));
8149 cmd->vdev_id = vdev_id;
8150 cmd->ac = ac;
8151
Govind Singhb53420c2016-03-09 14:32:57 +05308152 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308153 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8154 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8155 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308156 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308157 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308158 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308159 }
8160
Govind Singhb53420c2016-03-09 14:32:57 +05308161 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308162}
8163
8164/**
8165 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8166 * @wmi_handle: handle to wmi
8167 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8168 *
Govind Singhb53420c2016-03-09 14:32:57 +05308169 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308170 * ADD_TS requestes to firmware in loop for all the ACs with
8171 * active flow.
8172 *
8173 * Return: CDF status
8174 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308175static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308176 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8177{
8178 int i = 0;
8179 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8180 wmi_buf_t buf;
8181 int32_t len = sizeof(*cmd);
8182
8183 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8184 /* if flow in this AC is active */
8185 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8186 /*
8187 * as per implementation of wma_add_ts_req() we
8188 * are not waiting any response from firmware so
8189 * apart from sending ADDTS to firmware just send
8190 * success to upper layers
8191 */
Govind Singhb53420c2016-03-09 14:32:57 +05308192 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308193
8194 buf = wmi_buf_alloc(wmi_handle, len);
8195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308196 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8197 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308198 }
8199 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8200 wmi_buf_data(buf);
8201 WMITLV_SET_HDR(&cmd->tlv_header,
8202 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8203 WMITLV_GET_STRUCT_TLVLEN
8204 (wmi_vdev_wmm_addts_cmd_fixed_param));
8205 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8206 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308207 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308208 traffic.userPrio);
8209 cmd->medium_time_us =
8210 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8211 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308212 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308213 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8214 cmd->medium_time_us, cmd->downgrade_type);
8215 if (wmi_unified_cmd_send
8216 (wmi_handle, buf, len,
8217 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308218 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308219 __func__);
8220 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308221 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308222 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308223 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308224 }
8225 }
8226 }
8227
Govind Singhb53420c2016-03-09 14:32:57 +05308228 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308229}
8230
8231/**
8232 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8233 * @wmi_handle: wmi handle
8234 * @msg: ADDTS params
8235 *
8236 * Return: CDF status
8237 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308238static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308239 struct add_ts_param *msg)
8240{
8241 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8242 wmi_buf_t buf;
8243 int32_t len = sizeof(*cmd);
8244
Govind Singhb53420c2016-03-09 14:32:57 +05308245 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308246
8247 buf = wmi_buf_alloc(wmi_handle, len);
8248 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308249 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8250 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308251 }
8252 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8253 WMITLV_SET_HDR(&cmd->tlv_header,
8254 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8255 WMITLV_GET_STRUCT_TLVLEN
8256 (wmi_vdev_wmm_addts_cmd_fixed_param));
8257 cmd->vdev_id = msg->sme_session_id;
8258 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8259 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8260 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308261 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308262 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8263 cmd->downgrade_type, __func__, __LINE__);
8264 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8265 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308266 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8267 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308268 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308269 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308270 }
8271
Govind Singhb53420c2016-03-09 14:32:57 +05308272 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308273}
8274
8275/**
8276 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8277 * @wmi_handle: wmi handle
8278 * @vdev_id: vdev id
8279 * @enable: Flag to enable/disable packet filter
8280 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308281 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308282 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308283static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308284 uint8_t vdev_id, bool enable)
8285{
8286 int32_t len;
8287 int ret = 0;
8288 wmi_buf_t buf;
8289 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8290
8291 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8292
8293 buf = wmi_buf_alloc(wmi_handle, len);
8294 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308295 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308296 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308297 }
8298
8299 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8300 WMITLV_SET_HDR(&cmd->tlv_header,
8301 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8302 WMITLV_GET_STRUCT_TLVLEN(
8303 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8304
8305 cmd->vdev_id = vdev_id;
8306 if (enable)
8307 cmd->enable = PACKET_FILTER_SET_ENABLE;
8308 else
8309 cmd->enable = PACKET_FILTER_SET_DISABLE;
8310
Govind Singhb53420c2016-03-09 14:32:57 +05308311 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308312 __func__, cmd->enable, vdev_id);
8313
8314 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8315 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308316 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308317 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308318 wmi_buf_free(buf);
8319 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308320
8321 return ret;
8322}
8323
8324/**
8325 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8326 * @wmi_handle: wmi handle
8327 * @vdev_id: vdev id
8328 * @rcv_filter_param: Packet filter parameters
8329 * @filter_id: Filter id
8330 * @enable: Flag to add/delete packet filter configuration
8331 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308332 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308333 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308334static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308335 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8336 uint8_t filter_id, bool enable)
8337{
8338 int len, i;
8339 int err = 0;
8340 wmi_buf_t buf;
8341 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8342
8343
8344 /* allocate the memory */
8345 len = sizeof(*cmd);
8346 buf = wmi_buf_alloc(wmi_handle, len);
8347 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308348 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308349 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308350 }
8351
8352 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8353 WMITLV_SET_HDR(&cmd->tlv_header,
8354 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8355 WMITLV_GET_STRUCT_TLVLEN
8356 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8357
8358 cmd->vdev_id = vdev_id;
8359 cmd->filter_id = filter_id;
8360 if (enable)
8361 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8362 else
8363 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8364
8365 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308366 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308367 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8368 rcv_filter_param->numFieldParams);
8369 cmd->filter_type = rcv_filter_param->filterType;
8370 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8371
8372 for (i = 0; i < cmd->num_params; i++) {
8373 cmd->paramsData[i].proto_type =
8374 rcv_filter_param->paramsData[i].protocolLayer;
8375 cmd->paramsData[i].cmp_type =
8376 rcv_filter_param->paramsData[i].cmpFlag;
8377 cmd->paramsData[i].data_length =
8378 rcv_filter_param->paramsData[i].dataLength;
8379 cmd->paramsData[i].data_offset =
8380 rcv_filter_param->paramsData[i].dataOffset;
8381 memcpy(&cmd->paramsData[i].compareData,
8382 rcv_filter_param->paramsData[i].compareData,
8383 sizeof(cmd->paramsData[i].compareData));
8384 memcpy(&cmd->paramsData[i].dataMask,
8385 rcv_filter_param->paramsData[i].dataMask,
8386 sizeof(cmd->paramsData[i].dataMask));
8387 }
8388 }
8389
Govind Singhb53420c2016-03-09 14:32:57 +05308390 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308391 cmd->filter_action, cmd->filter_id, cmd->num_params);
8392 /* send the command along with data */
8393 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8394 WMI_PACKET_FILTER_CONFIG_CMDID);
8395 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308396 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308397 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308398 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308399 }
8400
8401
8402 return 0;
8403}
8404
8405/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308406 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8407 * @wmi_handle: wmi handle
8408 * @pAddPeriodicTxPtrnParams: tx ptrn params
8409 *
8410 * Retrun: CDF status
8411 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308412static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308413 struct periodic_tx_pattern *
8414 pAddPeriodicTxPtrnParams,
8415 uint8_t vdev_id)
8416{
8417 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8418 wmi_buf_t wmi_buf;
8419 uint32_t len;
8420 uint8_t *buf_ptr;
8421 uint32_t ptrn_len, ptrn_len_aligned;
8422 int j;
8423
8424 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8425 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8426 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8427 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8428
8429 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8430 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308431 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8432 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308433 }
8434
8435 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8436
8437 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8438 WMITLV_SET_HDR(&cmd->tlv_header,
8439 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8440 WMITLV_GET_STRUCT_TLVLEN
8441 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8442
8443 /* Pass the pattern id to delete for the corresponding vdev id */
8444 cmd->vdev_id = vdev_id;
8445 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8446 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8447 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8448
8449 /* Pattern info */
8450 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8451 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8452 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308453 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308454 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308455 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308456
Govind Singhb53420c2016-03-09 14:32:57 +05308457 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308458 __func__, cmd->pattern_id, cmd->vdev_id);
8459
8460 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8461 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308462 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308463 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308464 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308465 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308466 }
Govind Singhb53420c2016-03-09 14:32:57 +05308467 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308468}
8469
8470/**
8471 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8472 * @wmi_handle: wmi handle
8473 * @vdev_id: vdev id
8474 * @pattern_id: pattern id
8475 *
8476 * Retrun: CDF status
8477 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308478static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308479 uint8_t vdev_id,
8480 uint8_t pattern_id)
8481{
8482 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8483 wmi_buf_t wmi_buf;
8484 uint32_t len =
8485 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8486
8487 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8488 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308489 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8490 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308491 }
8492
8493 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8494 wmi_buf_data(wmi_buf);
8495 WMITLV_SET_HDR(&cmd->tlv_header,
8496 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8497 WMITLV_GET_STRUCT_TLVLEN
8498 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8499
8500 /* Pass the pattern id to delete for the corresponding vdev id */
8501 cmd->vdev_id = vdev_id;
8502 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308503 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308504 __func__, cmd->pattern_id, cmd->vdev_id);
8505
8506 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8507 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308508 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308509 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308510 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308511 }
Govind Singhb53420c2016-03-09 14:32:57 +05308512 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308513}
8514
8515/**
8516 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8517 * @wmi_handle: wmi handle
8518 * @preq: stats ext params
8519 *
8520 * Return: CDF status
8521 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308522static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308523 struct stats_ext_params *preq)
8524{
Govind Singh67922e82016-04-01 16:48:57 +05308525 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308526 wmi_req_stats_ext_cmd_fixed_param *cmd;
8527 wmi_buf_t buf;
8528 uint16_t len;
8529 uint8_t *buf_ptr;
8530
8531 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8532
8533 buf = wmi_buf_alloc(wmi_handle, len);
8534 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308535 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308536 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308537 }
8538
8539 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8540 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8541
8542 WMITLV_SET_HDR(&cmd->tlv_header,
8543 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8544 WMITLV_GET_STRUCT_TLVLEN
8545 (wmi_req_stats_ext_cmd_fixed_param));
8546 cmd->vdev_id = preq->vdev_id;
8547 cmd->data_len = preq->request_data_len;
8548
Govind Singhb53420c2016-03-09 14:32:57 +05308549 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308550 __func__, preq->request_data_len, preq->vdev_id);
8551
8552 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8553 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8554
8555 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308556 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308557
8558 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8559 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308560 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308561 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308562 ret);
8563 wmi_buf_free(buf);
8564 }
8565
8566 return ret;
8567}
8568
8569/**
8570 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8571 * @wmi_handle: wmi handle
8572 * @params: ext wow params
8573 *
8574 * Return:0 for success or error code
8575 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308576static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308577 struct ext_wow_params *params)
8578{
8579 wmi_extwow_enable_cmd_fixed_param *cmd;
8580 wmi_buf_t buf;
8581 int32_t len;
8582 int ret;
8583
8584 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8585 buf = wmi_buf_alloc(wmi_handle, len);
8586 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308587 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8588 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308589 }
8590
8591 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8592
8593 WMITLV_SET_HDR(&cmd->tlv_header,
8594 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8595 WMITLV_GET_STRUCT_TLVLEN
8596 (wmi_extwow_enable_cmd_fixed_param));
8597
8598 cmd->vdev_id = params->vdev_id;
8599 cmd->type = params->type;
8600 cmd->wakeup_pin_num = params->wakeup_pin_num;
8601
Govind Singhb53420c2016-03-09 14:32:57 +05308602 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308603 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8604
8605 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8606 WMI_EXTWOW_ENABLE_CMDID);
8607 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308608 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308609 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308610 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308611 }
8612
Govind Singhb53420c2016-03-09 14:32:57 +05308613 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308614
8615}
8616
8617/**
8618 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8619 * @wmi_handle: wmi handle
8620 * @app_type1_params: app type1 params
8621 *
8622 * Return: CDF status
8623 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308624static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308625 struct app_type1_params *app_type1_params)
8626{
8627 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8628 wmi_buf_t buf;
8629 int32_t len;
8630 int ret;
8631
8632 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8633 buf = wmi_buf_alloc(wmi_handle, len);
8634 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308635 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8636 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308637 }
8638
8639 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8640 wmi_buf_data(buf);
8641
8642 WMITLV_SET_HDR(&cmd->tlv_header,
8643 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8644 WMITLV_GET_STRUCT_TLVLEN
8645 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8646
8647 cmd->vdev_id = app_type1_params->vdev_id;
8648 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8649 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308650 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308651 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308652 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308653 cmd->passwd_len = app_type1_params->pass_length;
8654
Govind Singhb53420c2016-03-09 14:32:57 +05308655 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308656 "identification_id %.8s id_length %u "
8657 "password %.16s pass_length %u",
8658 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8659 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8660
8661 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8662 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8663 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308664 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308665 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308666 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308667 }
8668
Govind Singhb53420c2016-03-09 14:32:57 +05308669 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308670}
8671
8672/**
8673 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8674 * @wmi_handle: wmi handle
8675 * @appType2Params: app type2 params
8676 *
8677 * Return: CDF status
8678 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308679static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308680 struct app_type2_params *appType2Params)
8681{
8682 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8683 wmi_buf_t buf;
8684 int32_t len;
8685 int ret;
8686
8687 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8688 buf = wmi_buf_alloc(wmi_handle, len);
8689 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308690 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8691 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308692 }
8693
8694 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8695 wmi_buf_data(buf);
8696
8697 WMITLV_SET_HDR(&cmd->tlv_header,
8698 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8699 WMITLV_GET_STRUCT_TLVLEN
8700 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8701
8702 cmd->vdev_id = appType2Params->vdev_id;
8703
Govind Singhb53420c2016-03-09 14:32:57 +05308704 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308705 cmd->rc4_key_len = appType2Params->rc4_key_len;
8706
8707 cmd->ip_id = appType2Params->ip_id;
8708 cmd->ip_device_ip = appType2Params->ip_device_ip;
8709 cmd->ip_server_ip = appType2Params->ip_server_ip;
8710
8711 cmd->tcp_src_port = appType2Params->tcp_src_port;
8712 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8713 cmd->tcp_seq = appType2Params->tcp_seq;
8714 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8715
8716 cmd->keepalive_init = appType2Params->keepalive_init;
8717 cmd->keepalive_min = appType2Params->keepalive_min;
8718 cmd->keepalive_max = appType2Params->keepalive_max;
8719 cmd->keepalive_inc = appType2Params->keepalive_inc;
8720
8721 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8722 &cmd->gateway_mac);
8723 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8724 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8725
Govind Singhb53420c2016-03-09 14:32:57 +05308726 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308727 "rc4_key %.16s rc4_key_len %u "
8728 "ip_id %x ip_device_ip %x ip_server_ip %x "
8729 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8730 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8731 "keepalive_max %u keepalive_inc %u "
8732 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8733 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8734 cmd->rc4_key, cmd->rc4_key_len,
8735 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8736 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8737 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8738 cmd->keepalive_max, cmd->keepalive_inc,
8739 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8740
8741 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8742 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8743 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308744 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308746 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308747 }
8748
Govind Singhb53420c2016-03-09 14:32:57 +05308749 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308750
8751}
8752
8753/**
8754 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8755 * @wmi_handle: wmi handle
8756 * @timer_val: auto shutdown timer value
8757 *
8758 * Return: CDF status
8759 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308760static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308761 uint32_t timer_val)
8762{
Govind Singh67922e82016-04-01 16:48:57 +05308763 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308764 wmi_buf_t buf = NULL;
8765 uint8_t *buf_ptr;
8766 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8767 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8768
Govind Singhb53420c2016-03-09 14:32:57 +05308769 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308770 __func__, timer_val);
8771
8772 buf = wmi_buf_alloc(wmi_handle, len);
8773 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308774 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8775 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308776 }
8777
8778 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8779 wmi_auto_sh_cmd =
8780 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8781 wmi_auto_sh_cmd->timer_value = timer_val;
8782
8783 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8784 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8785 WMITLV_GET_STRUCT_TLVLEN
8786 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8787
8788 status = wmi_unified_cmd_send(wmi_handle, buf,
8789 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308790 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308791 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308792 __func__, status);
8793 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308794 }
8795
Govind Singh67922e82016-04-01 16:48:57 +05308796 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308797}
8798
8799/**
8800 * send_nan_req_cmd_tlv() - to send nan request to target
8801 * @wmi_handle: wmi handle
8802 * @nan_req: request data which will be non-null
8803 *
8804 * Return: CDF status
8805 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308806static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308807 struct nan_req_params *nan_req)
8808{
Govind Singh67922e82016-04-01 16:48:57 +05308809 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308810 wmi_nan_cmd_param *cmd;
8811 wmi_buf_t buf;
8812 uint16_t len = sizeof(*cmd);
8813 uint16_t nan_data_len, nan_data_len_aligned;
8814 uint8_t *buf_ptr;
8815
8816 /*
8817 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8818 * +------------+----------+-----------------------+--------------+
8819 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8820 * +------------+----------+-----------------------+--------------+
8821 */
8822 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308823 WMI_LOGE("%s:nan req is not valid", __func__);
8824 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308825 }
8826 nan_data_len = nan_req->request_data_len;
8827 nan_data_len_aligned = roundup(nan_req->request_data_len,
8828 sizeof(uint32_t));
8829 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8830 buf = wmi_buf_alloc(wmi_handle, len);
8831 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308832 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8833 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308834 }
8835 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8836 cmd = (wmi_nan_cmd_param *) buf_ptr;
8837 WMITLV_SET_HDR(&cmd->tlv_header,
8838 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8839 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8840 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308841 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308842 __func__, nan_req->request_data_len);
8843 buf_ptr += sizeof(wmi_nan_cmd_param);
8844 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8845 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308846 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308847
8848 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8849 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308850 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308851 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308852 __func__, ret);
8853 wmi_buf_free(buf);
8854 }
8855
8856 return ret;
8857}
8858
8859/**
8860 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8861 * @wmi_handle: wmi handle
8862 * @pDhcpSrvOffloadInfo: DHCP server offload info
8863 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308864 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308865 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308866static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308867 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8868{
8869 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8870 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308871 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308872
8873 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8874 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308875 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308876 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308877 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 }
8879
8880 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308881 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308882
8883 WMITLV_SET_HDR(&cmd->tlv_header,
8884 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8885 WMITLV_GET_STRUCT_TLVLEN
8886 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8887 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8888 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8889 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8890 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8891 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308892 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308893 sizeof(*cmd),
8894 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308895 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308896 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308897 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308898 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308899 }
Govind Singhb53420c2016-03-09 14:32:57 +05308900 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308901 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308902
8903 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308904}
8905
8906/**
8907 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8908 * @wmi_handle: wmi handle
8909 * @flashing: flashing request
8910 *
8911 * Return: CDF status
8912 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308913static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308914 struct flashing_req_params *flashing)
8915{
8916 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308917 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308918 wmi_buf_t buf;
8919 uint8_t *buf_ptr;
8920 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8921
8922 buf = wmi_buf_alloc(wmi_handle, len);
8923 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308924 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308925 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308926 }
8927 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8928 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8929 WMITLV_SET_HDR(&cmd->tlv_header,
8930 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8931 WMITLV_GET_STRUCT_TLVLEN
8932 (wmi_set_led_flashing_cmd_fixed_param));
8933 cmd->pattern_id = flashing->pattern_id;
8934 cmd->led_x0 = flashing->led_x0;
8935 cmd->led_x1 = flashing->led_x1;
8936
8937 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8938 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308939 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308940 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308941 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308942 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308943 }
Govind Singh67922e82016-04-01 16:48:57 +05308944
8945 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308946}
8947
8948/**
8949 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8950 * @wmi_handle: wmi handle
8951 * @ch_avoid_update_req: channel avoid update params
8952 *
8953 * Return: CDF status
8954 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308955static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308956{
Govind Singh67922e82016-04-01 16:48:57 +05308957 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308958 wmi_buf_t buf = NULL;
8959 uint8_t *buf_ptr;
8960 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8961 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8962
8963
8964 buf = wmi_buf_alloc(wmi_handle, len);
8965 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308966 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8967 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308968 }
8969
8970 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8971 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8972 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8973 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8974 WMITLV_GET_STRUCT_TLVLEN
8975 (wmi_chan_avoid_update_cmd_param));
8976
8977 status = wmi_unified_cmd_send(wmi_handle, buf,
8978 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308979 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308980 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308981 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8982 " returned Error %d", status);
8983 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308984 }
8985
Govind Singh67922e82016-04-01 16:48:57 +05308986 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308987}
8988
8989/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05308990 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
8991 * @wmi_handle: wmi handle
8992 * @param: pointer to pdev regdomain params
8993 *
8994 * Return: 0 for success or error code
8995 */
8996static QDF_STATUS
8997send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
8998 struct pdev_set_regdomain_params *param)
8999{
9000 wmi_buf_t buf;
9001 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9002 int32_t len = sizeof(*cmd);
9003
9004
9005 buf = wmi_buf_alloc(wmi_handle, len);
9006 if (!buf) {
9007 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9008 return QDF_STATUS_E_NOMEM;
9009 }
9010 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9011 WMITLV_SET_HDR(&cmd->tlv_header,
9012 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9013 WMITLV_GET_STRUCT_TLVLEN
9014 (wmi_pdev_set_regdomain_cmd_fixed_param));
9015
9016 cmd->reg_domain = param->currentRDinuse;
9017 cmd->reg_domain_2G = param->currentRD2G;
9018 cmd->reg_domain_5G = param->currentRD5G;
9019 cmd->conformance_test_limit_2G = param->ctl_2G;
9020 cmd->conformance_test_limit_5G = param->ctl_5G;
9021 cmd->dfs_domain = param->dfsDomain;
9022 cmd->pdev_id = param->pdev_id;
9023
9024 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9025 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9026 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9027 __func__);
9028 wmi_buf_free(buf);
9029 return QDF_STATUS_E_FAILURE;
9030 }
9031
9032 return QDF_STATUS_SUCCESS;
9033}
9034
9035/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309036 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9037 * @wmi_handle: wmi handle
9038 * @reg_dmn: reg domain
9039 * @regdmn2G: 2G reg domain
9040 * @regdmn5G: 5G reg domain
9041 * @ctl2G: 2G test limit
9042 * @ctl5G: 5G test limit
9043 *
9044 * Return: none
9045 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309046static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309047 uint32_t reg_dmn, uint16_t regdmn2G,
9048 uint16_t regdmn5G, int8_t ctl2G,
9049 int8_t ctl5G)
9050{
9051 wmi_buf_t buf;
9052 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9053 int32_t len = sizeof(*cmd);
9054
9055
9056 buf = wmi_buf_alloc(wmi_handle, len);
9057 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309058 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9059 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309060 }
9061 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9062 WMITLV_SET_HDR(&cmd->tlv_header,
9063 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9064 WMITLV_GET_STRUCT_TLVLEN
9065 (wmi_pdev_set_regdomain_cmd_fixed_param));
9066 cmd->reg_domain = reg_dmn;
9067 cmd->reg_domain_2G = regdmn2G;
9068 cmd->reg_domain_5G = regdmn5G;
9069 cmd->conformance_test_limit_2G = ctl2G;
9070 cmd->conformance_test_limit_5G = ctl5G;
9071
9072 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9073 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309074 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309075 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309076 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309077 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309078 }
9079
Govind Singhb53420c2016-03-09 14:32:57 +05309080 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309081}
9082
9083
9084/**
9085 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9086 * @wmi_handle: wmi handle
9087 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9088 *
9089 * This function sets tdls off channel mode
9090 *
9091 * Return: 0 on success; Negative errno otherwise
9092 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309093static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309094 struct tdls_channel_switch_params *chan_switch_params)
9095{
9096 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9097 wmi_buf_t wmi_buf;
9098 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9099
9100 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9101 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309102 WMI_LOGE(FL("wmi_buf_alloc failed"));
9103 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 }
9105 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9106 wmi_buf_data(wmi_buf);
9107 WMITLV_SET_HDR(&cmd->tlv_header,
9108 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9109 WMITLV_GET_STRUCT_TLVLEN(
9110 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9111
9112 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9113 &cmd->peer_macaddr);
9114 cmd->vdev_id = chan_switch_params->vdev_id;
9115 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9116 cmd->is_peer_responder = chan_switch_params->is_responder;
9117 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9118 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9119 cmd->offchan_oper_class = chan_switch_params->oper_class;
9120
Govind Singhb53420c2016-03-09 14:32:57 +05309121 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309122 cmd->peer_macaddr.mac_addr31to0,
9123 cmd->peer_macaddr.mac_addr47to32);
9124
Govind Singhb53420c2016-03-09 14:32:57 +05309125 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309126 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9127 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9128 ),
9129 cmd->vdev_id,
9130 cmd->offchan_mode,
9131 cmd->offchan_num,
9132 cmd->offchan_bw_bitmap,
9133 cmd->is_peer_responder,
9134 cmd->offchan_oper_class);
9135
9136 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9137 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309138 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309139 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309140 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309141 }
9142
9143
Govind Singhb53420c2016-03-09 14:32:57 +05309144 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309145}
9146
9147/**
9148 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9149 * @wmi_handle: wmi handle
9150 * @pwmaTdlsparams: TDLS params
9151 *
9152 * Return: 0 for sucess or error code
9153 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309154static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309155 void *tdls_param, uint8_t tdls_state)
9156{
9157 wmi_tdls_set_state_cmd_fixed_param *cmd;
9158 wmi_buf_t wmi_buf;
9159
9160 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9161 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9162
9163 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9164 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309165 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9166 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309167 }
9168 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9169 WMITLV_SET_HDR(&cmd->tlv_header,
9170 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9171 WMITLV_GET_STRUCT_TLVLEN
9172 (wmi_tdls_set_state_cmd_fixed_param));
9173 cmd->vdev_id = wmi_tdls->vdev_id;
9174 cmd->state = tdls_state;
9175 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9176 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9177 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9178 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9179 cmd->rssi_delta = wmi_tdls->rssi_delta;
9180 cmd->tdls_options = wmi_tdls->tdls_options;
9181 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9182 cmd->tdls_peer_traffic_response_timeout_ms =
9183 wmi_tdls->peer_traffic_response_timeout;
9184 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9185 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9186 cmd->tdls_puapsd_rx_frame_threshold =
9187 wmi_tdls->puapsd_rx_frame_threshold;
9188 cmd->teardown_notification_ms =
9189 wmi_tdls->teardown_notification_ms;
9190 cmd->tdls_peer_kickout_threshold =
9191 wmi_tdls->tdls_peer_kickout_threshold;
9192
Govind Singhb53420c2016-03-09 14:32:57 +05309193 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309194 "notification_interval_ms: %d, "
9195 "tx_discovery_threshold: %d, "
9196 "tx_teardown_threshold: %d, "
9197 "rssi_teardown_threshold: %d, "
9198 "rssi_delta: %d, "
9199 "tdls_options: 0x%x, "
9200 "tdls_peer_traffic_ind_window: %d, "
9201 "tdls_peer_traffic_response_timeout: %d, "
9202 "tdls_puapsd_mask: 0x%x, "
9203 "tdls_puapsd_inactivity_time: %d, "
9204 "tdls_puapsd_rx_frame_threshold: %d, "
9205 "teardown_notification_ms: %d, "
9206 "tdls_peer_kickout_threshold: %d",
9207 __func__, tdls_state, cmd->state,
9208 cmd->notification_interval_ms,
9209 cmd->tx_discovery_threshold,
9210 cmd->tx_teardown_threshold,
9211 cmd->rssi_teardown_threshold,
9212 cmd->rssi_delta,
9213 cmd->tdls_options,
9214 cmd->tdls_peer_traffic_ind_window,
9215 cmd->tdls_peer_traffic_response_timeout_ms,
9216 cmd->tdls_puapsd_mask,
9217 cmd->tdls_puapsd_inactivity_time_ms,
9218 cmd->tdls_puapsd_rx_frame_threshold,
9219 cmd->teardown_notification_ms,
9220 cmd->tdls_peer_kickout_threshold);
9221
9222 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9223 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309224 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309225 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309226 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309227 }
Govind Singhb53420c2016-03-09 14:32:57 +05309228 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309229
Govind Singhb53420c2016-03-09 14:32:57 +05309230 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309231}
9232
9233/**
9234 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9235 * @wmi_handle: wmi handle
9236 * @peerStateParams: TDLS peer state params
9237 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309238 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309239 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309240static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309241 struct tdls_peer_state_params *peerStateParams,
9242 uint32_t *ch_mhz)
9243{
9244 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9245 wmi_tdls_peer_capabilities *peer_cap;
9246 wmi_channel *chan_info;
9247 wmi_buf_t wmi_buf;
9248 uint8_t *buf_ptr;
9249 uint32_t i;
9250 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9251 sizeof(wmi_tdls_peer_capabilities);
9252
9253
9254 len += WMI_TLV_HDR_SIZE +
9255 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9256
9257 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9258 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309259 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9260 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309261 }
9262
9263 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9264 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9265 WMITLV_SET_HDR(&cmd->tlv_header,
9266 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9267 WMITLV_GET_STRUCT_TLVLEN
9268 (wmi_tdls_peer_update_cmd_fixed_param));
9269
9270 cmd->vdev_id = peerStateParams->vdevId;
9271 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9272 &cmd->peer_macaddr);
9273
9274
9275 cmd->peer_state = peerStateParams->peerState;
9276
Govind Singhb53420c2016-03-09 14:32:57 +05309277 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309278 "peer_macaddr.mac_addr31to0: 0x%x, "
9279 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9280 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9281 cmd->peer_macaddr.mac_addr31to0,
9282 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9283
9284 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9285 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9286 WMITLV_SET_HDR(&peer_cap->tlv_header,
9287 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9288 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9289
9290 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9291 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9292 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9293 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9294 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9295 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9296 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9297 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9298
9299 /* Ack and More Data Ack are sent as 0, so no need to set
9300 * but fill SP
9301 */
9302 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9303 peerStateParams->peerCap.peerMaxSp);
9304
9305 peer_cap->buff_sta_support =
9306 peerStateParams->peerCap.peerBuffStaSupport;
9307 peer_cap->off_chan_support =
9308 peerStateParams->peerCap.peerOffChanSupport;
9309 peer_cap->peer_curr_operclass =
9310 peerStateParams->peerCap.peerCurrOperClass;
9311 /* self curr operclass is not being used and so pass op class for
9312 * preferred off chan in it.
9313 */
9314 peer_cap->self_curr_operclass =
9315 peerStateParams->peerCap.opClassForPrefOffChan;
9316 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9317 peer_cap->peer_operclass_len =
9318 peerStateParams->peerCap.peerOperClassLen;
9319
Govind Singhb53420c2016-03-09 14:32:57 +05309320 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309321 __func__, peer_cap->peer_operclass_len);
9322 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9323 peer_cap->peer_operclass[i] =
9324 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309325 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309326 __func__, i, peer_cap->peer_operclass[i]);
9327 }
9328
9329 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9330 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9331 peer_cap->pref_offchan_bw =
9332 peerStateParams->peerCap.prefOffChanBandwidth;
9333
Govind Singhb53420c2016-03-09 14:32:57 +05309334 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309335 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9336 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9337 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9338 " %d, pref_offchan_bw: %d",
9339 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9340 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9341 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9342 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9343 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9344
9345 /* next fill variable size array of peer chan info */
9346 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9347 WMITLV_SET_HDR(buf_ptr,
9348 WMITLV_TAG_ARRAY_STRUC,
9349 sizeof(wmi_channel) *
9350 peerStateParams->peerCap.peerChanLen);
9351 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9352
9353 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9354 WMITLV_SET_HDR(&chan_info->tlv_header,
9355 WMITLV_TAG_STRUC_wmi_channel,
9356 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9357 chan_info->mhz = ch_mhz[i];
9358 chan_info->band_center_freq1 = chan_info->mhz;
9359 chan_info->band_center_freq2 = 0;
9360
Govind Singhb53420c2016-03-09 14:32:57 +05309361 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309362
9363 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9364 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309365 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309366 peerStateParams->peerCap.peerChan[i].chanId,
9367 peerStateParams->peerCap.peerChan[i].dfsSet);
9368 }
9369
9370 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9371 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9372 else
9373 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9374
9375 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9376 peerStateParams->peerCap.
9377 peerChan[i].pwr);
9378
9379 WMI_SET_CHANNEL_REG_POWER(chan_info,
9380 peerStateParams->peerCap.peerChan[i].
9381 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309382 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309383 peerStateParams->peerCap.peerChan[i].pwr);
9384
9385 chan_info++;
9386 }
9387
9388 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9389 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309390 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309391 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309392 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309393 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309394 }
9395
9396
Govind Singhb53420c2016-03-09 14:32:57 +05309397 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309398}
9399
9400/*
9401 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9402 * firmware
9403 * @wmi_handle: Pointer to wmi handle
9404 * @mem_dump_req: Pointer for mem_dump_req
9405 *
9406 * This function sends memory dump request to firmware
9407 *
Govind Singhb53420c2016-03-09 14:32:57 +05309408 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309409 *
9410 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309411static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309412 struct fw_dump_req_param *mem_dump_req)
9413{
9414 wmi_get_fw_mem_dump_fixed_param *cmd;
9415 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309416 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309417 int32_t len;
9418 wmi_buf_t buf;
9419 u_int8_t *buf_ptr;
9420 int ret, loop;
9421
9422 /*
9423 * len = sizeof(fixed param) that includes tlv header +
9424 * tlv header for array of struc +
9425 * sizeof (each struct)
9426 */
9427 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9428 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9429 buf = wmi_buf_alloc(wmi_handle, len);
9430
9431 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309432 WMI_LOGE(FL("Failed allocate wmi buffer"));
9433 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309434 }
9435
9436 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309437 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309438 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9439
9440 WMITLV_SET_HDR(&cmd->tlv_header,
9441 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9442 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9443
9444 cmd->request_id = mem_dump_req->request_id;
9445 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9446
9447 /* TLV indicating array of structures to follow */
9448 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9449 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9450 sizeof(wmi_fw_mem_dump) *
9451 cmd->num_fw_mem_dump_segs);
9452
9453 buf_ptr += WMI_TLV_HDR_SIZE;
9454 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9455
Govind Singhb53420c2016-03-09 14:32:57 +05309456 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309457 mem_dump_req->request_id, mem_dump_req->num_seg);
9458 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309459 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309460 ((uint8_t *)(mem_dump_req->segment) +
9461 loop * sizeof(*seg_req));
9462 WMITLV_SET_HDR(&dump_params->tlv_header,
9463 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9464 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9465 dump_params->seg_id = seg_req->seg_id;
9466 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9467 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9468 dump_params->seg_length = seg_req->seg_length;
9469 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9470 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309471 WMI_LOGI(FL("seg_number:%d"), loop);
9472 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309473 dump_params->seg_id, dump_params->seg_start_addr_lo,
9474 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309475 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309476 dump_params->seg_length, dump_params->dest_addr_lo,
9477 dump_params->dest_addr_hi);
9478 dump_params++;
9479 }
9480
9481 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9482 WMI_GET_FW_MEM_DUMP_CMDID);
9483 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309484 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309485 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309486 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309487 }
9488
Govind Singhb53420c2016-03-09 14:32:57 +05309489 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9490 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309491}
9492
9493/*
9494 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9495 * @wmi_handle: Pointer to WMi handle
9496 * @ie_data: Pointer for ie data
9497 *
9498 * This function sends IE information to firmware
9499 *
Govind Singhb53420c2016-03-09 14:32:57 +05309500 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309501 *
9502 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309503static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309504 struct vdev_ie_info_param *ie_info)
9505{
9506 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9507 wmi_buf_t buf;
9508 uint8_t *buf_ptr;
9509 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309510 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309511
9512
9513 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9514 /* Allocate memory for the WMI command */
9515 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9516
9517 buf = wmi_buf_alloc(wmi_handle, len);
9518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309519 WMI_LOGE(FL("wmi_buf_alloc failed"));
9520 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309521 }
9522
9523 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309524 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309525
9526 /* Populate the WMI command */
9527 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9528
9529 WMITLV_SET_HDR(&cmd->tlv_header,
9530 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9531 WMITLV_GET_STRUCT_TLVLEN(
9532 wmi_vdev_set_ie_cmd_fixed_param));
9533 cmd->vdev_id = ie_info->vdev_id;
9534 cmd->ie_id = ie_info->ie_id;
9535 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009536 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309537
Govind Singhb53420c2016-03-09 14:32:57 +05309538 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309539 ie_info->length, ie_info->vdev_id);
9540
9541 buf_ptr += sizeof(*cmd);
9542 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9543 buf_ptr += WMI_TLV_HDR_SIZE;
9544
Govind Singhb53420c2016-03-09 14:32:57 +05309545 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309546
9547 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9548 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309549 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309550 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309551 wmi_buf_free(buf);
9552 }
9553
9554 return ret;
9555}
9556
Sathish Kumar497bef42017-03-01 14:02:36 +05309557/**
9558 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9559 *
9560 * @param wmi_handle : handle to WMI.
9561 * @param param : pointer to antenna param
9562 *
9563 * This function sends smart antenna enable command to FW
9564 *
9565 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9566 */
9567static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9568 struct smart_ant_enable_params *param)
9569{
9570 /* Send WMI COMMAND to Enable */
9571 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9572 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9573 wmi_buf_t buf;
9574 uint8_t *buf_ptr;
9575 int len = 0;
9576 QDF_STATUS ret;
9577 int loop = 0;
9578
9579 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9580 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9581 buf = wmi_buf_alloc(wmi_handle, len);
9582
9583 if (!buf) {
9584 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9585 return QDF_STATUS_E_NOMEM;
9586 }
9587
9588 buf_ptr = wmi_buf_data(buf);
9589 qdf_mem_zero(buf_ptr, len);
9590 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9591
9592 WMITLV_SET_HDR(&cmd->tlv_header,
9593 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9594 WMITLV_GET_STRUCT_TLVLEN(
9595 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9596
9597 cmd->pdev_id = param->pdev_id;
9598 cmd->enable = param->enable;
9599 cmd->mode = param->mode;
9600 cmd->rx_antenna = param->rx_antenna;
9601 cmd->tx_default_antenna = param->rx_antenna;
9602
9603 /* TLV indicating array of structures to follow */
9604 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9605 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9606 WMI_HAL_MAX_SANTENNA *
9607 sizeof(wmi_pdev_smart_ant_gpio_handle));
9608
9609 buf_ptr += WMI_TLV_HDR_SIZE;
9610 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9611
9612 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9613 WMITLV_SET_HDR(&gpio_param->tlv_header,
9614 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9615 WMITLV_GET_STRUCT_TLVLEN(
9616 wmi_pdev_smart_ant_gpio_handle));
9617 if (param->mode == SMART_ANT_MODE_SERIAL) {
9618 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9619 gpio_param->gpio_pin = param->gpio_pin[loop];
9620 gpio_param->gpio_func = param->gpio_func[loop];
9621 } else {
9622 gpio_param->gpio_pin = 0;
9623 gpio_param->gpio_func = 0;
9624 }
9625 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9626 gpio_param->gpio_pin = param->gpio_pin[loop];
9627 gpio_param->gpio_func = param->gpio_func[loop];
9628 }
9629 /* Setting it to 0 for now */
9630 gpio_param->pdev_id = param->pdev_id;
9631 gpio_param++;
9632 }
9633
9634 ret = wmi_unified_cmd_send(wmi_handle,
9635 buf,
9636 len,
9637 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9638
9639 if (ret != 0) {
9640 WMI_LOGE(" %s :WMI Failed\n", __func__);
9641 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9642 cmd->enable,
9643 cmd->mode,
9644 cmd->rx_antenna,
9645 param->gpio_pin[0], param->gpio_pin[1],
9646 param->gpio_pin[2], param->gpio_pin[3],
9647 param->gpio_func[0], param->gpio_func[1],
9648 param->gpio_func[2], param->gpio_func[3],
9649 ret);
9650 wmi_buf_free(buf);
9651 }
9652
9653 return ret;
9654}
9655
9656/**
9657 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9658 *
9659 * @param wmi_handle : handle to WMI.
9660 * @param param : pointer to rx antenna param
9661 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9662 */
9663static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9664 struct smart_ant_rx_ant_params *param)
9665{
9666 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9667 wmi_buf_t buf;
9668 uint8_t *buf_ptr;
9669 uint32_t len;
9670 QDF_STATUS ret;
9671
9672 len = sizeof(*cmd);
9673 buf = wmi_buf_alloc(wmi_handle, len);
9674 WMI_LOGD("%s:\n", __func__);
9675 if (!buf) {
9676 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9677 return QDF_STATUS_E_NOMEM;
9678 }
9679
9680 buf_ptr = wmi_buf_data(buf);
9681 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9682 WMITLV_SET_HDR(&cmd->tlv_header,
9683 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9684 WMITLV_GET_STRUCT_TLVLEN(
9685 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9686 cmd->rx_antenna = param->antenna;
9687 cmd->pdev_id = param->pdev_id;
9688
9689 ret = wmi_unified_cmd_send(wmi_handle,
9690 buf,
9691 len,
9692 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9693
9694 if (ret != 0) {
9695 WMI_LOGE(" %s :WMI Failed\n", __func__);
9696 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9697 __func__,
9698 cmd->rx_antenna,
9699 ret);
9700 wmi_buf_free(buf);
9701 }
9702
9703 return ret;
9704}
9705
9706/**
9707 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9708 * @wmi_handle: wmi handle
9709 * @param: pointer to hold ctl table param
9710 *
9711 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9712 */
9713static QDF_STATUS
9714send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9715 struct ctl_table_params *param)
9716{
9717 uint16_t len, ctl_tlv_len;
9718 uint8_t *buf_ptr;
9719 wmi_buf_t buf;
9720 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9721 uint32_t *ctl_array;
9722
9723 if (!param->ctl_array)
9724 return QDF_STATUS_E_FAILURE;
9725
9726 if (param->ctl_cmd_len !=
9727 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9728 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9729 qdf_print("CTL array len not correct\n");
9730 return QDF_STATUS_E_FAILURE;
9731 }
9732
9733 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9734 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9735 len = sizeof(*cmd) + ctl_tlv_len;
9736
9737 buf = wmi_buf_alloc(wmi_handle, len);
9738 if (!buf) {
9739 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9740 return QDF_STATUS_E_FAILURE;
9741 }
9742
9743 buf_ptr = wmi_buf_data(buf);
9744 qdf_mem_zero(buf_ptr, len);
9745
9746 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9747
9748 WMITLV_SET_HDR(&cmd->tlv_header,
9749 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9750 WMITLV_GET_STRUCT_TLVLEN(
9751 wmi_pdev_set_ctl_table_cmd_fixed_param));
9752 cmd->ctl_len = param->ctl_cmd_len;
9753 cmd->pdev_id = param->pdev_id;
9754
9755 buf_ptr += sizeof(*cmd);
9756 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9757 (cmd->ctl_len));
9758 buf_ptr += WMI_TLV_HDR_SIZE;
9759 ctl_array = (uint32_t *)buf_ptr;
9760
9761 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9762 sizeof(param->ctl_band));
9763 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9764 param->ctl_cmd_len -
9765 sizeof(param->ctl_band));
9766
9767 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9768 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9769 WMI_LOGE("%s:Failed to send command\n", __func__);
9770 wmi_buf_free(buf);
9771 return QDF_STATUS_E_FAILURE;
9772 }
9773
9774 return QDF_STATUS_SUCCESS;
9775}
9776
9777/**
9778 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9779 * @wmi_handle: wmi handle
9780 * @param: pointer to hold mimogain table param
9781 *
9782 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9783 */
9784static QDF_STATUS
9785send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9786 struct mimogain_table_params *param)
9787{
9788 uint16_t len, table_tlv_len;
9789 wmi_buf_t buf;
9790 uint8_t *buf_ptr;
9791 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
9792 uint32_t *gain_table;
9793
9794 if (!param->array_gain)
9795 return QDF_STATUS_E_FAILURE;
9796
9797 /* len must be multiple of a single array gain table */
9798 if (param->tbl_len %
9799 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
9800 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
9801 WMI_LOGE("Array gain table len not correct\n");
9802 return QDF_STATUS_E_FAILURE;
9803 }
9804
9805 table_tlv_len = WMI_TLV_HDR_SIZE +
9806 roundup(param->tbl_len, sizeof(uint32_t));
9807 len = sizeof(*cmd) + table_tlv_len;
9808
9809 buf = wmi_buf_alloc(wmi_handle, len);
9810 if (!buf) {
9811 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9812 return QDF_STATUS_E_FAILURE;
9813 }
9814
9815 buf_ptr = wmi_buf_data(buf);
9816 qdf_mem_zero(buf_ptr, len);
9817
9818 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
9819
9820 WMITLV_SET_HDR(&cmd->tlv_header,
9821 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
9822 WMITLV_GET_STRUCT_TLVLEN(
9823 wmi_pdev_set_mimogain_table_cmd_fixed_param));
9824
9825 cmd->pdev_id = param->pdev_id;
9826 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
9827 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
9828 param->multichain_gain_bypass);
9829
9830 buf_ptr += sizeof(*cmd);
9831 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9832 (param->tbl_len));
9833 buf_ptr += WMI_TLV_HDR_SIZE;
9834 gain_table = (uint32_t *)buf_ptr;
9835
9836 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
9837 param->array_gain,
9838 param->tbl_len);
9839
9840 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9841 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
9842 return QDF_STATUS_E_FAILURE;
9843 }
9844
9845 return QDF_STATUS_SUCCESS;
9846}
9847
9848/**
9849 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
9850 * info to fw
9851 * @wmi_handle: wmi handle
9852 * @param: pointer to hold packet power info param
9853 *
9854 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9855 */
9856static QDF_STATUS
9857send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
9858 struct packet_power_info_params *param)
9859{
9860 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
9861 wmi_buf_t wmibuf;
9862 uint8_t *buf_ptr;
9863 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
9864
9865 wmibuf = wmi_buf_alloc(wmi_handle, len);
9866 if (wmibuf == NULL)
9867 return QDF_STATUS_E_NOMEM;
9868
9869 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
9870
9871 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
9872 WMITLV_SET_HDR(&cmd->tlv_header,
9873 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
9874 WMITLV_GET_STRUCT_TLVLEN(
9875 wmi_pdev_get_tpc_cmd_fixed_param));
9876 cmd->pdev_id = param->pdev_id;
9877 cmd->rate_flags = param->rate_flags;
9878 cmd->nss = param->nss;
9879 cmd->preamble = param->preamble;
9880 cmd->hw_rate = param->hw_rate;
9881 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
9882 __func__,
9883 __LINE__,
9884 WMI_PDEV_GET_TPC_CMDID,
9885 *((u_int32_t *)cmd));
9886 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
9887 WMI_PDEV_GET_TPC_CMDID)) {
9888 WMI_LOGE(FL("Failed to get tpc command\n"));
9889 wmi_buf_free(wmibuf);
9890 return QDF_STATUS_E_FAILURE;
9891 }
9892
9893 return QDF_STATUS_SUCCESS;
9894}
9895
9896/**
9897 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
9898 * @wmi_handle: wmi handle
9899 * @param: pointer to hold config ratemask params
9900 *
9901 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9902 */
9903static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
9904 struct config_ratemask_params *param)
9905{
9906 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
9907 wmi_buf_t buf;
9908 int32_t len = sizeof(*cmd);
9909
9910 buf = wmi_buf_alloc(wmi_handle, len);
9911 if (!buf) {
9912 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9913 return QDF_STATUS_E_FAILURE;
9914 }
9915 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
9916 WMITLV_SET_HDR(&cmd->tlv_header,
9917 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
9918 WMITLV_GET_STRUCT_TLVLEN(
9919 wmi_vdev_config_ratemask_cmd_fixed_param));
9920 cmd->vdev_id = param->vdev_id;
9921 cmd->type = param->type;
9922 cmd->mask_lower32 = param->lower32;
9923 cmd->mask_higher32 = param->higher32;
9924 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
9925 param->vdev_id, param->type, param->lower32, param->higher32);
9926
9927 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9928 WMI_VDEV_RATEMASK_CMDID)) {
9929 WMI_LOGE("Seting vdev ratemask failed\n");
9930 wmi_buf_free(buf);
9931 return QDF_STATUS_E_FAILURE;
9932 }
9933
9934 return QDF_STATUS_SUCCESS;
9935}
9936
9937/**
9938 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
9939 * @wmi_handle: wmi handle
9940 * @param: pointer to hold vap dscp tid map param
9941 *
9942 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9943 */
9944static QDF_STATUS
9945send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
9946 struct vap_dscp_tid_map_params *param)
9947{
9948 wmi_buf_t buf;
9949 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
9950 int32_t len = sizeof(*cmd);
9951
9952 buf = wmi_buf_alloc(wmi_handle, len);
9953 if (!buf) {
9954 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9955 return QDF_STATUS_E_FAILURE;
9956 }
9957
9958 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
9959 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
9960 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
9961
9962 cmd->vdev_id = param->vdev_id;
9963 cmd->enable_override = 0;
9964
9965 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
9966 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9967 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
9968 WMI_LOGE("Failed to set dscp cmd\n");
9969 wmi_buf_free(buf);
9970 return QDF_STATUS_E_FAILURE;
9971 }
9972
9973 return QDF_STATUS_SUCCESS;
9974}
9975
9976/**
9977 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
9978 * @wmi_handle: wmi handle
9979 * @macaddr: vdev mac address
9980 * @param: pointer to hold neigbour rx param
9981 *
9982 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9983 */
9984static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
9985 uint8_t macaddr[IEEE80211_ADDR_LEN],
9986 struct set_neighbour_rx_params *param)
9987{
9988 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
9989 wmi_buf_t buf;
9990 int32_t len = sizeof(*cmd);
9991
9992 buf = wmi_buf_alloc(wmi_handle, len);
9993 if (!buf) {
9994 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9995 return QDF_STATUS_E_FAILURE;
9996 }
9997 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
9998 WMITLV_SET_HDR(&cmd->tlv_header,
9999 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
10000 WMITLV_GET_STRUCT_TLVLEN(
10001 wmi_vdev_filter_nrp_config_cmd_fixed_param));
10002 cmd->vdev_id = param->vdev_id;
10003 cmd->bssid_idx = param->idx;
10004 cmd->action = param->action;
10005 cmd->type = param->type;
10006 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
10007 cmd->flag = 0;
10008
10009 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10010 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
10011 WMI_LOGE("Failed to set neighbour rx param\n");
10012 wmi_buf_free(buf);
10013 return QDF_STATUS_E_FAILURE;
10014 }
10015
10016 return QDF_STATUS_SUCCESS;
10017}
10018
10019/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010020 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010021 * @param wmi_handle : handle to WMI.
10022 * @param macaddr : vdev mac address
10023 * @param param : pointer to tx antenna param
10024 *
10025 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10026 */
10027static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10028 uint8_t macaddr[IEEE80211_ADDR_LEN],
10029 struct smart_ant_tx_ant_params *param)
10030{
10031 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10032 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10033 wmi_buf_t buf;
10034 int32_t len = 0;
10035 int i;
10036 uint8_t *buf_ptr;
10037 QDF_STATUS ret;
10038
10039 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10040 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10041 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10042 buf = wmi_buf_alloc(wmi_handle, len);
10043
10044 if (!buf) {
10045 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10046 return QDF_STATUS_E_NOMEM;
10047 }
10048
10049 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10050 qdf_mem_zero(buf_ptr, len);
10051 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10052
10053 WMITLV_SET_HDR(&cmd->tlv_header,
10054 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10055 WMITLV_GET_STRUCT_TLVLEN(
10056 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10057
10058 cmd->vdev_id = param->vdev_id;
10059 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10060
10061 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10062 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10063 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10064 buf_ptr += WMI_TLV_HDR_SIZE;
10065 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10066
10067 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10068 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10069 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10070 WMITLV_GET_STRUCT_TLVLEN(
10071 wmi_peer_smart_ant_set_tx_antenna_series));
10072 ant_tx_series->antenna_series = param->antenna_array[i];
10073 ant_tx_series++;
10074 }
10075
10076 ret = wmi_unified_cmd_send(wmi_handle,
10077 buf,
10078 len,
10079 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10080
10081 if (ret != 0) {
10082 WMI_LOGE(" %s :WMI Failed\n", __func__);
10083 wmi_buf_free(buf);
10084 }
10085
10086 return ret;
10087}
10088
Sathish Kumar02c3b542017-02-22 17:24:45 +053010089/**
10090 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10091 * @wmi_handle: wmi handle
10092 * @param: pointer to hold ant switch tbl param
10093 *
10094 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10095 */
10096static QDF_STATUS
10097send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10098 struct ant_switch_tbl_params *param)
10099{
10100 uint8_t len;
10101 wmi_buf_t buf;
10102 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10103 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10104 uint8_t *buf_ptr;
10105
10106 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10107 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10108 buf = wmi_buf_alloc(wmi_handle, len);
10109
10110 if (!buf) {
10111 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10112 return QDF_STATUS_E_NOMEM;
10113 }
10114
10115 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10116 qdf_mem_zero(buf_ptr, len);
10117 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10118
10119 WMITLV_SET_HDR(&cmd->tlv_header,
10120 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10121 WMITLV_GET_STRUCT_TLVLEN(
10122 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10123
10124 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10125 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
10126 cmd->mac_id = param->pdev_id; /* Setting it to 0 for now */
10127
10128 /* TLV indicating array of structures to follow */
10129 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10130 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10131 sizeof(wmi_pdev_set_ant_ctrl_chain));
10132 buf_ptr += WMI_TLV_HDR_SIZE;
10133 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10134
10135 ctrl_chain->pdev_id = param->pdev_id;
10136 ctrl_chain->antCtrlChain = param->antCtrlChain;
10137
10138 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10139 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10140 wmi_buf_free(buf);
10141 return QDF_STATUS_E_FAILURE;
10142 }
10143
10144 return QDF_STATUS_SUCCESS;
10145}
10146
10147/**
10148 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10149 * training information function
10150 * @param wmi_handle : handle to WMI.
10151 * @macaddr : vdev mac address
10152 * @param param : pointer to tx antenna param
10153 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10154 */
10155static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10156 wmi_unified_t wmi_handle,
10157 uint8_t macaddr[IEEE80211_ADDR_LEN],
10158 struct smart_ant_training_info_params *param)
10159{
10160 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10161 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10162 wmi_buf_t buf;
10163 uint8_t *buf_ptr;
10164 int32_t len = 0;
10165 QDF_STATUS ret;
10166 int loop;
10167
10168 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10169 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10170 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10171 buf = wmi_buf_alloc(wmi_handle, len);
10172
10173 if (!buf) {
10174 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10175 return QDF_STATUS_E_NOMEM;
10176 }
10177
10178 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10179 qdf_mem_zero(buf_ptr, len);
10180 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10181
10182 WMITLV_SET_HDR(&cmd->tlv_header,
10183 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10184 WMITLV_GET_STRUCT_TLVLEN(
10185 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10186
10187 cmd->vdev_id = param->vdev_id;
10188 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10189 cmd->num_pkts = param->numpkts;
10190
10191 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10192 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10193 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10194 WMI_SMART_ANT_MAX_RATE_SERIES);
10195
10196 buf_ptr += WMI_TLV_HDR_SIZE;
10197 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10198
10199 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10200 WMITLV_SET_HDR(&train_param->tlv_header,
10201 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10202 WMITLV_GET_STRUCT_TLVLEN(
10203 wmi_peer_smart_ant_set_train_antenna_param));
10204 train_param->train_rate_series = param->rate_array[loop];
10205 train_param->train_antenna_series = param->antenna_array[loop];
10206 train_param->rc_flags = 0;
10207 WMI_LOGI(FL("Series number:%d\n"), loop);
10208 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10209 train_param->train_rate_series,
10210 train_param->train_antenna_series);
10211 train_param++;
10212 }
10213
10214 ret = wmi_unified_cmd_send(wmi_handle,
10215 buf,
10216 len,
10217 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10218
10219 if (ret != 0) {
10220 WMI_LOGE(" %s :WMI Failed\n", __func__);
10221 wmi_buf_free(buf);
10222 return QDF_STATUS_E_FAILURE;
10223 }
10224
10225 return ret;
10226}
10227
10228/**
10229 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10230 * configuration function
10231 * @param wmi_handle : handle to WMI.
10232 * @macaddr : vdev mad address
10233 * @param param : pointer to tx antenna param
10234 *
10235 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10236 */
10237static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10238 wmi_unified_t wmi_handle,
10239 uint8_t macaddr[IEEE80211_ADDR_LEN],
10240 struct smart_ant_node_config_params *param)
10241{
10242 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10243 wmi_buf_t buf;
10244 uint8_t *buf_ptr;
10245 int32_t len = 0, args_tlv_len;
10246 int ret;
10247 int i = 0;
10248 A_UINT32 *node_config_args;
10249
10250 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10251 len = sizeof(*cmd) + args_tlv_len;
10252
10253 if ((param->args_count == 0)) {
10254 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10255 __func__, param->args_count);
10256 return QDF_STATUS_E_FAILURE;
10257 }
10258
10259 buf = wmi_buf_alloc(wmi_handle, len);
10260 if (!buf) {
10261 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10262 return QDF_STATUS_E_NOMEM;
10263 }
10264
10265 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10266 wmi_buf_data(buf);
10267 buf_ptr = (uint8_t *)cmd;
10268 WMITLV_SET_HDR(&cmd->tlv_header,
10269 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10270 WMITLV_GET_STRUCT_TLVLEN(
10271 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10272 cmd->vdev_id = param->vdev_id;
10273 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10274 cmd->cmd_id = param->cmd_id;
10275 cmd->args_count = param->args_count;
10276 buf_ptr += sizeof(
10277 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10278 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10279 (cmd->args_count * sizeof(A_UINT32)));
10280 buf_ptr += WMI_TLV_HDR_SIZE;
10281 node_config_args = (A_UINT32 *)buf_ptr;
10282
10283 for (i = 0; i < param->args_count; i++) {
10284 node_config_args[i] = param->args_arr[i];
10285 WMI_LOGI("%d", param->args_arr[i]);
10286 }
10287
10288 ret = wmi_unified_cmd_send(wmi_handle,
10289 buf,
10290 len,
10291 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10292
10293 if (ret != 0) {
10294 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10295 __func__, param->cmd_id, macaddr[0],
10296 macaddr[1], macaddr[2], macaddr[3],
10297 macaddr[4], macaddr[5], ret);
10298 wmi_buf_free(buf);
10299 }
10300
10301 return ret;
10302}
10303
10304/**
10305 * send_set_atf_cmd_tlv() - send set atf command to fw
10306 * @wmi_handle: wmi handle
10307 * @param: pointer to set atf param
10308 *
10309 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10310 */
10311static QDF_STATUS
10312send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10313 struct set_atf_params *param)
10314{
10315 wmi_atf_peer_info *peer_info;
10316 wmi_peer_atf_request_fixed_param *cmd;
10317 wmi_buf_t buf;
10318 uint8_t *buf_ptr;
10319 int i;
10320 int32_t len = 0;
10321 QDF_STATUS retval;
10322
10323 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10324 len += param->num_peers * sizeof(wmi_atf_peer_info);
10325 buf = wmi_buf_alloc(wmi_handle, len);
10326 if (!buf) {
10327 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10328 return QDF_STATUS_E_FAILURE;
10329 }
10330 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10331 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10332 WMITLV_SET_HDR(&cmd->tlv_header,
10333 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10334 WMITLV_GET_STRUCT_TLVLEN(
10335 wmi_peer_atf_request_fixed_param));
10336 cmd->num_peers = param->num_peers;
10337
10338 buf_ptr += sizeof(*cmd);
10339 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10340 sizeof(wmi_atf_peer_info) *
10341 cmd->num_peers);
10342 buf_ptr += WMI_TLV_HDR_SIZE;
10343 peer_info = (wmi_atf_peer_info *)buf_ptr;
10344
10345 for (i = 0; i < cmd->num_peers; i++) {
10346 WMITLV_SET_HDR(&peer_info->tlv_header,
10347 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10348 WMITLV_GET_STRUCT_TLVLEN(
10349 wmi_atf_peer_info));
10350 peer_info->atf_units = param->peer_info[i].percentage_peer;
10351 /*
10352 * TLV definition for peer atf request fixed param combines
10353 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10354 * stats and atf extension stats as two different
10355 * implementations.
10356 * Need to discuss with FW on this.
10357 *
10358 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10359 * peer_info->atf_units_reserved =
10360 * param->peer_ext_info[i].atf_index_reserved;
10361 */
10362 peer_info++;
10363 }
10364
10365 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10366 WMI_PEER_ATF_REQUEST_CMDID);
10367
10368 if (retval != QDF_STATUS_SUCCESS) {
10369 WMI_LOGE("%s : WMI Failed\n", __func__);
10370 wmi_buf_free(buf);
10371 }
10372
10373 return retval;
10374}
10375
10376/**
10377 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10378 * @wmi_handle: wmi handle
10379 * @param: pointer to hold fwtest param
10380 *
10381 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10382 */
10383static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10384 struct set_fwtest_params *param)
10385{
10386 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10387 wmi_buf_t buf;
10388 int32_t len = sizeof(*cmd);
10389
10390 buf = wmi_buf_alloc(wmi_handle, len);
10391
10392 if (!buf) {
10393 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10394 return QDF_STATUS_E_FAILURE;
10395 }
10396
10397 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10398 WMITLV_SET_HDR(&cmd->tlv_header,
10399 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10400 WMITLV_GET_STRUCT_TLVLEN(
10401 wmi_fwtest_set_param_cmd_fixed_param));
10402 cmd->param_id = param->arg;
10403 cmd->param_value = param->value;
10404
10405 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10406 WMI_LOGE("Setting FW test param failed\n");
10407 wmi_buf_free(buf);
10408 return QDF_STATUS_E_FAILURE;
10409 }
10410
10411 return QDF_STATUS_SUCCESS;
10412}
10413
10414/**
10415 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10416 * @wmi_handle: wmi handle
10417 * @param: pointer to qboost params
10418 * @macaddr: vdev mac address
10419 *
10420 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10421 */
10422static QDF_STATUS
10423send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10424 uint8_t macaddr[IEEE80211_ADDR_LEN],
10425 struct set_qboost_params *param)
10426{
10427 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10428 wmi_buf_t buf;
10429 int32_t len;
10430 QDF_STATUS ret;
10431
10432 len = sizeof(*cmd);
10433
10434 buf = wmi_buf_alloc(wmi_handle, len);
10435 if (!buf) {
10436 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10437 return QDF_STATUS_E_FAILURE;
10438 }
10439
10440 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10441 WMITLV_SET_HDR(&cmd->tlv_header,
10442 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10443 WMITLV_GET_STRUCT_TLVLEN(
10444 WMI_QBOOST_CFG_CMD_fixed_param));
10445 cmd->vdev_id = param->vdev_id;
10446 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10447 cmd->qb_enable = param->value;
10448
10449 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10450 WMI_QBOOST_CFG_CMDID);
10451
10452 if (ret != 0) {
10453 WMI_LOGE("Setting qboost cmd failed\n");
10454 wmi_buf_free(buf);
10455 }
10456
10457 return ret;
10458}
10459
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010460/**
10461 * send_gpio_config_cmd_tlv() - send gpio config to fw
10462 * @wmi_handle: wmi handle
10463 * @param: pointer to hold gpio config param
10464 *
10465 * Return: 0 for success or error code
10466 */
10467static QDF_STATUS
10468send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10469 struct gpio_config_params *param)
10470{
10471 wmi_gpio_config_cmd_fixed_param *cmd;
10472 wmi_buf_t buf;
10473 int32_t len;
10474 QDF_STATUS ret;
10475
10476 len = sizeof(*cmd);
10477
10478 /* Sanity Checks */
10479 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10480 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10481 return QDF_STATUS_E_FAILURE;
10482 }
10483
10484 buf = wmi_buf_alloc(wmi_handle, len);
10485 if (!buf) {
10486 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10487 return QDF_STATUS_E_FAILURE;
10488 }
10489
10490 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10491 WMITLV_SET_HDR(&cmd->tlv_header,
10492 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10493 WMITLV_GET_STRUCT_TLVLEN(
10494 wmi_gpio_config_cmd_fixed_param));
10495 cmd->gpio_num = param->gpio_num;
10496 cmd->input = param->input;
10497 cmd->pull_type = param->pull_type;
10498 cmd->intr_mode = param->intr_mode;
10499
10500 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10501 WMI_GPIO_CONFIG_CMDID);
10502
10503 if (ret != 0) {
10504 WMI_LOGE("Sending GPIO config cmd failed\n");
10505 wmi_buf_free(buf);
10506 }
10507
10508 return ret;
10509}
10510
10511/**
10512 * send_gpio_output_cmd_tlv() - send gpio output to fw
10513 * @wmi_handle: wmi handle
10514 * @param: pointer to hold gpio output param
10515 *
10516 * Return: 0 for success or error code
10517 */
10518static QDF_STATUS
10519send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10520 struct gpio_output_params *param)
10521{
10522 wmi_gpio_output_cmd_fixed_param *cmd;
10523 wmi_buf_t buf;
10524 int32_t len;
10525 QDF_STATUS ret;
10526
10527 len = sizeof(*cmd);
10528
10529 buf = wmi_buf_alloc(wmi_handle, len);
10530 if (!buf) {
10531 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10532 return QDF_STATUS_E_FAILURE;
10533 }
10534
10535 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10536 WMITLV_SET_HDR(&cmd->tlv_header,
10537 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10538 WMITLV_GET_STRUCT_TLVLEN(
10539 wmi_gpio_output_cmd_fixed_param));
10540 cmd->gpio_num = param->gpio_num;
10541 cmd->set = param->set;
10542
10543 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10544 WMI_GPIO_OUTPUT_CMDID);
10545
10546 if (ret != 0) {
10547 WMI_LOGE("Sending GPIO output cmd failed\n");
10548 wmi_buf_free(buf);
10549 }
10550
10551 return ret;
10552
10553}
10554
10555/**
10556 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10557 *
10558 * @param wmi_handle : handle to WMI.
10559 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10560 */
10561static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10562{
10563 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10564 wmi_buf_t buf;
10565 QDF_STATUS ret;
10566 int32_t len;
10567
10568 len = sizeof(*cmd);
10569
10570 buf = wmi_buf_alloc(wmi_handle, len);
10571 if (!buf) {
10572 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10573 return QDF_STATUS_E_FAILURE;
10574 }
10575
10576 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10577 WMITLV_SET_HDR(&cmd->tlv_header,
10578 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10579 WMITLV_GET_STRUCT_TLVLEN(
10580 wmi_pdev_dfs_disable_cmd_fixed_param));
10581 /* Filling it with WMI_PDEV_ID_SOC for now */
10582 cmd->pdev_id = WMI_PDEV_ID_SOC;
10583
10584 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10585 WMI_PDEV_DFS_DISABLE_CMDID);
10586
10587 if (ret != 0) {
10588 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10589 wmi_buf_free(buf);
10590 }
10591
10592 return ret;
10593}
10594
10595/**
10596 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10597 *
10598 * @param wmi_handle : handle to WMI.
10599 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10600 */
10601static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10602{
10603 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10604 wmi_buf_t buf;
10605 QDF_STATUS ret;
10606 int32_t len;
10607
10608 len = sizeof(*cmd);
10609
10610 buf = wmi_buf_alloc(wmi_handle, len);
10611 if (!buf) {
10612 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10613 return QDF_STATUS_E_FAILURE;
10614 }
10615
10616 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10617 WMITLV_SET_HDR(&cmd->tlv_header,
10618 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10619 WMITLV_GET_STRUCT_TLVLEN(
10620 wmi_pdev_dfs_enable_cmd_fixed_param));
10621 /* Reserved for future use */
10622 cmd->reserved0 = 0;
10623
10624 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10625 WMI_PDEV_DFS_ENABLE_CMDID);
10626
10627 if (ret != 0) {
10628 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10629 wmi_buf_free(buf);
10630 }
10631
10632 return ret;
10633}
10634
10635/**
10636 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10637 * @wmi_handle: wmi handle
10638 *
10639 * Return: 0 for success or error code
10640 */
10641static QDF_STATUS
10642send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10643{
10644 wmi_buf_t buf;
10645 QDF_STATUS ret;
10646
10647 buf = wmi_buf_alloc(wmi_handle, 0);
10648 if (buf == NULL)
10649 return QDF_STATUS_E_NOMEM;
10650
10651 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10652 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10653 if (ret != 0) {
10654 WMI_LOGE("Sending get nfcal power cmd failed\n");
10655 wmi_buf_free(buf);
10656 }
10657
10658 return ret;
10659}
10660
10661/**
10662 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10663 * @wmi_handle: wmi handle
10664 * @param: pointer to ht ie param
10665 *
10666 * Return: 0 for success or error code
10667 */
10668static QDF_STATUS
10669send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10670 struct ht_ie_params *param)
10671{
10672 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10673 wmi_buf_t buf;
10674 QDF_STATUS ret;
10675 int32_t len;
10676 uint8_t *buf_ptr;
10677
10678 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10679 roundup(param->ie_len, sizeof(uint32_t));
10680
10681 buf = wmi_buf_alloc(wmi_handle, len);
10682 if (!buf) {
10683 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10684 return QDF_STATUS_E_FAILURE;
10685 }
10686
10687 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10688 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10689 WMITLV_SET_HDR(&cmd->tlv_header,
10690 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10691 WMITLV_GET_STRUCT_TLVLEN(
10692 wmi_pdev_set_ht_ie_cmd_fixed_param));
10693 cmd->reserved0 = 0;
10694 cmd->ie_len = param->ie_len;
10695 cmd->tx_streams = param->tx_streams;
10696 cmd->rx_streams = param->rx_streams;
10697
10698 buf_ptr += sizeof(*cmd);
10699 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10700 buf_ptr += WMI_TLV_HDR_SIZE;
10701 if (param->ie_len)
10702 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10703 cmd->ie_len);
10704
10705 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10706 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10707
10708 if (ret != 0) {
10709 WMI_LOGE("Sending set ht ie cmd failed\n");
10710 wmi_buf_free(buf);
10711 }
10712
10713 return ret;
10714}
10715
10716/**
10717 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10718 * @wmi_handle: wmi handle
10719 * @param: pointer to vht ie param
10720 *
10721 * Return: 0 for success or error code
10722 */
10723static QDF_STATUS
10724send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10725 struct vht_ie_params *param)
10726{
10727 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10728 wmi_buf_t buf;
10729 QDF_STATUS ret;
10730 int32_t len;
10731 uint8_t *buf_ptr;
10732
10733 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10734 roundup(param->ie_len, sizeof(uint32_t));
10735
10736 buf = wmi_buf_alloc(wmi_handle, len);
10737 if (!buf) {
10738 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10739 return QDF_STATUS_E_FAILURE;
10740 }
10741
10742 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10743 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10744 WMITLV_SET_HDR(&cmd->tlv_header,
10745 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10746 WMITLV_GET_STRUCT_TLVLEN(
10747 wmi_pdev_set_vht_ie_cmd_fixed_param));
10748 cmd->reserved0 = 0;
10749 cmd->ie_len = param->ie_len;
10750 cmd->tx_streams = param->tx_streams;
10751 cmd->rx_streams = param->rx_streams;
10752
10753 buf_ptr += sizeof(*cmd);
10754 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10755 buf_ptr += WMI_TLV_HDR_SIZE;
10756 if (param->ie_len)
10757 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10758 cmd->ie_len);
10759
10760 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10761 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
10762
10763 if (ret != 0) {
10764 WMI_LOGE("Sending set vht ie cmd failed\n");
10765 wmi_buf_free(buf);
10766 }
10767
10768 return ret;
10769}
10770
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053010771/**
10772 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
10773 * @wmi_handle: wmi handle
10774 * @param: pointer to quiet mode params
10775 *
10776 * Return: 0 for success or error code
10777 */
10778static QDF_STATUS
10779send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
10780 struct set_quiet_mode_params *param)
10781{
10782 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
10783 wmi_buf_t buf;
10784 QDF_STATUS ret;
10785 int32_t len;
10786
10787 len = sizeof(*quiet_cmd);
10788 buf = wmi_buf_alloc(wmi_handle, len);
10789 if (!buf) {
10790 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10791 return QDF_STATUS_E_FAILURE;
10792 }
10793
10794 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
10795 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
10796 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
10797 WMITLV_GET_STRUCT_TLVLEN(
10798 wmi_pdev_set_quiet_cmd_fixed_param));
10799 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
10800 quiet_cmd->enabled = param->enabled;
10801 quiet_cmd->period = (param->period)*(param->intval);
10802 quiet_cmd->duration = param->duration;
10803 quiet_cmd->next_start = param->offset;
10804 quiet_cmd->pdev_id = WMI_PDEV_ID_SOC;
10805
10806 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10807 WMI_PDEV_SET_QUIET_MODE_CMDID);
10808
10809 if (ret != 0) {
10810 WMI_LOGE("Sending set quiet cmd failed\n");
10811 wmi_buf_free(buf);
10812 }
10813
10814 return ret;
10815}
10816
10817/**
10818 * send_set_bwf_cmd_tlv() - send set bwf command to fw
10819 * @wmi_handle: wmi handle
10820 * @param: pointer to set bwf param
10821 *
10822 * Return: 0 for success or error code
10823 */
10824static QDF_STATUS
10825send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
10826 struct set_bwf_params *param)
10827{
10828 wmi_bwf_peer_info *peer_info;
10829 wmi_peer_bwf_request_fixed_param *cmd;
10830 wmi_buf_t buf;
10831 QDF_STATUS retval;
10832 int32_t len;
10833 uint8_t *buf_ptr;
10834 int i;
10835
10836 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10837 len += param->num_peers * sizeof(wmi_bwf_peer_info);
10838 buf = wmi_buf_alloc(wmi_handle, len);
10839 if (!buf) {
10840 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10841 return QDF_STATUS_E_FAILURE;
10842 }
10843 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10844 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
10845 WMITLV_SET_HDR(&cmd->tlv_header,
10846 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
10847 WMITLV_GET_STRUCT_TLVLEN(
10848 wmi_peer_bwf_request_fixed_param));
10849 cmd->num_peers = param->num_peers;
10850
10851 buf_ptr += sizeof(*cmd);
10852 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10853 sizeof(wmi_bwf_peer_info) *
10854 cmd->num_peers);
10855 buf_ptr += WMI_TLV_HDR_SIZE;
10856 peer_info = (wmi_bwf_peer_info *)buf_ptr;
10857
10858 for (i = 0; i < cmd->num_peers; i++) {
10859 WMITLV_SET_HDR(&peer_info->tlv_header,
10860 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
10861 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
10862 peer_info->bwf_guaranteed_bandwidth =
10863 param->peer_info[i].throughput;
10864 peer_info->bwf_max_airtime =
10865 param->peer_info[i].max_airtime;
10866 peer_info->bwf_peer_priority =
10867 param->peer_info[i].priority;
10868 qdf_mem_copy(&peer_info->peer_macaddr,
10869 &param->peer_info[i].peer_macaddr,
10870 sizeof(param->peer_info[i].peer_macaddr));
10871 peer_info++;
10872 }
10873
10874 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10875 WMI_PEER_BWF_REQUEST_CMDID);
10876
10877 if (retval != QDF_STATUS_SUCCESS) {
10878 WMI_LOGE("%s : WMI Failed\n", __func__);
10879 wmi_buf_free(buf);
10880 }
10881
10882 return retval;
10883}
10884
10885/**
10886 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
10887 * @wmi_handle: wmi handle
10888 * @param: pointer to hold mcast update param
10889 *
10890 * Return: 0 for success or error code
10891 */
10892static QDF_STATUS
10893send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
10894 struct mcast_group_update_params *param)
10895{
10896 wmi_peer_mcast_group_cmd_fixed_param *cmd;
10897 wmi_buf_t buf;
10898 QDF_STATUS ret;
10899 int32_t len;
10900 int offset = 0;
10901 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
10902
10903 len = sizeof(*cmd);
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 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
10910 WMITLV_SET_HDR(&cmd->tlv_header,
10911 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
10912 WMITLV_GET_STRUCT_TLVLEN(
10913 wmi_peer_mcast_group_cmd_fixed_param));
10914 /* confirm the buffer is 4-byte aligned */
10915 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
10916 qdf_mem_zero(cmd, sizeof(*cmd));
10917
10918 cmd->vdev_id = param->vap_id;
10919 /* construct the message assuming our endianness matches the target */
10920 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
10921 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
10922 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
10923 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
10924 if (param->is_action_delete)
10925 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
10926
10927 if (param->is_mcast_addr_len)
10928 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
10929
10930 if (param->is_filter_mode_snoop)
10931 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
10932
10933 /* unicast address spec only applies for non-wildcard cases */
10934 if (!param->wildcard && param->ucast_mac_addr) {
10935 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
10936 &cmd->ucast_mac_addr);
10937 }
10938 if (param->mcast_ip_addr) {
10939 QDF_ASSERT(param->mcast_ip_addr_bytes <=
10940 sizeof(cmd->mcast_ip_addr));
10941 offset = sizeof(cmd->mcast_ip_addr) -
10942 param->mcast_ip_addr_bytes;
10943 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
10944 param->mcast_ip_addr,
10945 param->mcast_ip_addr_bytes);
10946 }
10947 if (!param->mask)
10948 param->mask = &dummymask[0];
10949
10950 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
10951 param->mask,
10952 param->mcast_ip_addr_bytes);
10953
10954 if (param->srcs && param->nsrcs) {
10955 cmd->num_filter_addr = param->nsrcs;
10956 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
10957 sizeof(cmd->filter_addr));
10958
10959 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
10960 param->nsrcs * param->mcast_ip_addr_bytes);
10961 }
10962
10963 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10964 WMI_PEER_MCAST_GROUP_CMDID);
10965
10966 if (ret != QDF_STATUS_SUCCESS) {
10967 WMI_LOGE("%s : WMI Failed\n", __func__);
10968 wmi_buf_free(buf);
10969 }
10970
10971 return ret;
10972}
10973
10974/**
10975 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
10976 * command to fw
10977 * @wmi_handle: wmi handle
10978 * @param: pointer to hold spectral config parameter
10979 *
10980 * Return: 0 for success or error code
10981 */
10982static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
10983 struct vdev_spectral_configure_params *param)
10984{
10985 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
10986 wmi_buf_t buf;
10987 QDF_STATUS ret;
10988 int32_t len;
10989
10990 len = sizeof(*cmd);
10991 buf = wmi_buf_alloc(wmi_handle, len);
10992 if (!buf) {
10993 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10994 return QDF_STATUS_E_FAILURE;
10995 }
10996
10997 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
10998 WMITLV_SET_HDR(&cmd->tlv_header,
10999 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11000 WMITLV_GET_STRUCT_TLVLEN(
11001 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param));
11002
11003 cmd->vdev_id = param->vdev_id;
11004 cmd->spectral_scan_count = param->count;
11005 cmd->spectral_scan_period = param->period;
11006 cmd->spectral_scan_priority = param->spectral_pri;
11007 cmd->spectral_scan_fft_size = param->fft_size;
11008 cmd->spectral_scan_gc_ena = param->gc_enable;
11009 cmd->spectral_scan_restart_ena = param->restart_enable;
11010 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11011 cmd->spectral_scan_init_delay = param->init_delay;
11012 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11013 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11014 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11015 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11016 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11017 cmd->spectral_scan_pwr_format = param->pwr_format;
11018 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11019 cmd->spectral_scan_bin_scale = param->bin_scale;
11020 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11021 cmd->spectral_scan_chn_mask = param->chn_mask;
11022
11023 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11024 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11025
11026 if (ret != 0) {
11027 WMI_LOGE("Sending set quiet cmd failed\n");
11028 wmi_buf_free(buf);
11029 }
11030
11031 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11032 __func__);
11033
11034 WMI_LOGI("vdev_id = %u\n"
11035 "spectral_scan_count = %u\n"
11036 "spectral_scan_period = %u\n"
11037 "spectral_scan_priority = %u\n"
11038 "spectral_scan_fft_size = %u\n"
11039 "spectral_scan_gc_ena = %u\n"
11040 "spectral_scan_restart_ena = %u\n"
11041 "spectral_scan_noise_floor_ref = %u\n"
11042 "spectral_scan_init_delay = %u\n"
11043 "spectral_scan_nb_tone_thr = %u\n"
11044 "spectral_scan_str_bin_thr = %u\n"
11045 "spectral_scan_wb_rpt_mode = %u\n"
11046 "spectral_scan_rssi_rpt_mode = %u\n"
11047 "spectral_scan_rssi_thr = %u\n"
11048 "spectral_scan_pwr_format = %u\n"
11049 "spectral_scan_rpt_mode = %u\n"
11050 "spectral_scan_bin_scale = %u\n"
11051 "spectral_scan_dBm_adj = %u\n"
11052 "spectral_scan_chn_mask = %u\n",
11053 param->vdev_id,
11054 param->count,
11055 param->period,
11056 param->spectral_pri,
11057 param->fft_size,
11058 param->gc_enable,
11059 param->restart_enable,
11060 param->noise_floor_ref,
11061 param->init_delay,
11062 param->nb_tone_thr,
11063 param->str_bin_thr,
11064 param->wb_rpt_mode,
11065 param->rssi_rpt_mode,
11066 param->rssi_thr,
11067 param->pwr_format,
11068 param->rpt_mode,
11069 param->bin_scale,
11070 param->dBm_adj,
11071 param->chn_mask);
11072 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11073
11074 return ret;
11075}
11076
11077/**
11078 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11079 * command to fw
11080 * @wmi_handle: wmi handle
11081 * @param: pointer to hold spectral enable parameter
11082 *
11083 * Return: 0 for success or error code
11084 */
11085static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11086 struct vdev_spectral_enable_params *param)
11087{
11088 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11089 wmi_buf_t buf;
11090 QDF_STATUS ret;
11091 int32_t len;
11092
11093 len = sizeof(*cmd);
11094 buf = wmi_buf_alloc(wmi_handle, len);
11095 if (!buf) {
11096 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11097 return QDF_STATUS_E_FAILURE;
11098 }
11099
11100 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11101 WMITLV_SET_HDR(&cmd->tlv_header,
11102 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11103 WMITLV_GET_STRUCT_TLVLEN(
11104 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param));
11105
11106 cmd->vdev_id = param->vdev_id;
11107
11108 if (param->active_valid) {
11109 cmd->trigger_cmd = param->active ? 1 : 2;
11110 /* 1: Trigger, 2: Clear Trigger */
11111 } else {
11112 cmd->trigger_cmd = 0; /* 0: Ignore */
11113 }
11114
11115 if (param->enabled_valid) {
11116 cmd->enable_cmd = param->enabled ? 1 : 2;
11117 /* 1: Enable 2: Disable */
11118 } else {
11119 cmd->enable_cmd = 0; /* 0: Ignore */
11120 }
11121
11122 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11123 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11124
11125 if (ret != 0) {
11126 WMI_LOGE("Sending scan enable CMD failed\n");
11127 wmi_buf_free(buf);
11128 }
11129
11130 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11131
11132 WMI_LOGI("vdev_id = %u\n"
11133 "trigger_cmd = %u\n"
11134 "enable_cmd = %u\n",
11135 cmd->vdev_id,
11136 cmd->trigger_cmd,
11137 cmd->enable_cmd);
11138
11139 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11140
11141 return ret;
11142}
11143
11144/**
11145 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11146 * @wmi_handle: wmi handle
11147 * @param: pointer to pdev_qvit_params
11148 *
11149 * Return: 0 for success or error code
11150 */
11151static QDF_STATUS
11152send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11153 struct pdev_qvit_params *param)
11154{
11155 wmi_buf_t buf;
11156 QDF_STATUS ret;
11157 uint8_t *cmd;
11158 static uint8_t msgref = 1;
11159 uint8_t segnumber = 0, seginfo, numsegments;
11160 uint16_t chunk_len, total_bytes;
11161 uint8_t *bufpos;
11162 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11163
11164 bufpos = param->utf_payload;
11165 total_bytes = param->len;
11166 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11167 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11168 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11169
11170 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11171 numsegments++;
11172
11173 while (param->len) {
11174 if (param->len > MAX_WMI_QVIT_LEN)
11175 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11176 else
11177 chunk_len = param->len;
11178
11179 buf = wmi_buf_alloc(wmi_handle,
11180 (chunk_len + sizeof(seghdrinfo) +
11181 WMI_TLV_HDR_SIZE));
11182 if (!buf) {
11183 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11184 return QDF_STATUS_E_NOMEM;
11185 }
11186
11187 cmd = (uint8_t *) wmi_buf_data(buf);
11188
11189 seghdrinfo.len = total_bytes;
11190 seghdrinfo.msgref = msgref;
11191 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11192 seghdrinfo.segmentInfo = seginfo;
11193
11194 segnumber++;
11195
11196 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11197 (chunk_len + sizeof(seghdrinfo)));
11198 cmd += WMI_TLV_HDR_SIZE;
11199 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11200 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11201
11202 ret = wmi_unified_cmd_send(wmi_handle, buf,
11203 (chunk_len + sizeof(seghdrinfo) +
11204 WMI_TLV_HDR_SIZE),
11205 WMI_PDEV_QVIT_CMDID);
11206
11207 if (ret != 0) {
11208 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11209 wmi_buf_free(buf);
11210 break;
11211 }
11212
11213 param->len -= chunk_len;
11214 bufpos += chunk_len;
11215 }
11216 msgref++;
11217
11218 return ret;
11219}
11220
11221/**
11222 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11223 * @wmi_handle: wmi handle
11224 * @param: pointer to wmm update param
11225 *
11226 * Return: 0 for success or error code
11227 */
11228static QDF_STATUS
11229send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11230 struct wmm_update_params *param)
11231{
11232 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11233 wmi_wmm_params *wmm_param;
11234 wmi_buf_t buf;
11235 QDF_STATUS ret;
11236 int32_t len;
11237 int ac = 0;
11238 struct wmi_host_wmeParams *wmep;
11239 uint8_t *buf_ptr;
11240
11241 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11242 buf = wmi_buf_alloc(wmi_handle, len);
11243 if (!buf) {
11244 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11245 return QDF_STATUS_E_FAILURE;
11246 }
11247
11248 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11249 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11250 WMITLV_SET_HDR(&cmd->tlv_header,
11251 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11252 WMITLV_GET_STRUCT_TLVLEN
11253 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11254
11255 cmd->reserved0 = WMI_PDEV_ID_SOC;
11256
11257 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11258
11259 for (ac = 0; ac < WME_NUM_AC; ac++) {
11260 wmep = &param->wmep_array[ac];
11261 wmm_param = (wmi_wmm_params *)buf_ptr;
11262 WMITLV_SET_HDR(&wmm_param->tlv_header,
11263 WMITLV_TAG_STRUC_wmi_wmm_params,
11264 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11265 wmm_param->aifs = wmep->wmep_aifsn;
11266 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11267 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11268 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11269 wmm_param->acm = wmep->wmep_acm;
11270 wmm_param->no_ack = wmep->wmep_noackPolicy;
11271 buf_ptr += sizeof(wmi_wmm_params);
11272 }
11273 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11274 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11275
11276 if (ret != 0) {
11277 WMI_LOGE("Sending WMM update CMD failed\n");
11278 wmi_buf_free(buf);
11279 }
11280
11281 return ret;
11282}
11283
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011284static
Govind Singh9ddd5162016-03-07 16:30:32 +053011285void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011286 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011287{
Govind Singhe7f2f342016-05-23 12:12:52 +053011288 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011289 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11290 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11291 resource_cfg->num_offload_reorder_buffs =
11292 tgt_res_cfg->num_offload_reorder_buffs;
11293 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11294 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11295 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11296 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11297 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11298 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11299 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11300 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11301 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11302 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11303 resource_cfg->scan_max_pending_req =
11304 tgt_res_cfg->scan_max_pending_req;
11305 resource_cfg->bmiss_offload_max_vdev =
11306 tgt_res_cfg->bmiss_offload_max_vdev;
11307 resource_cfg->roam_offload_max_vdev =
11308 tgt_res_cfg->roam_offload_max_vdev;
11309 resource_cfg->roam_offload_max_ap_profiles =
11310 tgt_res_cfg->roam_offload_max_ap_profiles;
11311 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11312 resource_cfg->num_mcast_table_elems =
11313 tgt_res_cfg->num_mcast_table_elems;
11314 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11315 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11316 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11317 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11318 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11319 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11320 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11321 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11322 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11323 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11324 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11325 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11326 resource_cfg->num_tdls_conn_table_entries =
11327 tgt_res_cfg->num_tdls_conn_table_entries;
11328 resource_cfg->beacon_tx_offload_max_vdev =
11329 tgt_res_cfg->beacon_tx_offload_max_vdev;
11330 resource_cfg->num_multicast_filter_entries =
11331 tgt_res_cfg->num_multicast_filter_entries;
11332 resource_cfg->num_wow_filters =
11333 tgt_res_cfg->num_wow_filters;
11334 resource_cfg->num_keep_alive_pattern =
11335 tgt_res_cfg->num_keep_alive_pattern;
11336 resource_cfg->keep_alive_pattern_size =
11337 tgt_res_cfg->keep_alive_pattern_size;
11338 resource_cfg->max_tdls_concurrent_sleep_sta =
11339 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11340 resource_cfg->max_tdls_concurrent_buffer_sta =
11341 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11342 resource_cfg->wmi_send_separate =
11343 tgt_res_cfg->wmi_send_separate;
11344 resource_cfg->num_ocb_vdevs =
11345 tgt_res_cfg->num_ocb_vdevs;
11346 resource_cfg->num_ocb_channels =
11347 tgt_res_cfg->num_ocb_channels;
11348 resource_cfg->num_ocb_schedules =
11349 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011350 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11351 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11352 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Govind Singh9ddd5162016-03-07 16:30:32 +053011353}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011354#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011355/**
11356 * send_init_cmd_tlv() - wmi init command
11357 * @wmi_handle: pointer to wmi handle
11358 * @res_cfg: resource config
11359 * @num_mem_chunks: no of mem chunck
11360 * @mem_chunk: pointer to mem chunck structure
11361 *
11362 * This function sends IE information to firmware
11363 *
Govind Singhb53420c2016-03-09 14:32:57 +053011364 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011365 *
11366 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011367static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011368 wmi_resource_config *tgt_res_cfg,
11369 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11370 bool action)
11371{
11372 wmi_buf_t buf;
11373 wmi_init_cmd_fixed_param *cmd;
11374 wmi_abi_version my_vers;
11375 int num_whitelist;
11376 uint8_t *buf_ptr;
11377 wmi_resource_config *resource_cfg;
11378 wlan_host_memory_chunk *host_mem_chunks;
11379 uint32_t mem_chunk_len = 0;
11380 uint16_t idx;
11381 int len;
11382 int ret;
11383
11384 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11385 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11386 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11387 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011388 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11389 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011390 }
11391
11392 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11393 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11394 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11395
11396 host_mem_chunks = (wlan_host_memory_chunk *)
11397 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11398 + WMI_TLV_HDR_SIZE);
11399
11400 WMITLV_SET_HDR(&cmd->tlv_header,
11401 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11402 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11403
Govind Singhb53420c2016-03-09 14:32:57 +053011404 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011405 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11406 WMITLV_TAG_STRUC_wmi_resource_config,
11407 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11408
11409 for (idx = 0; idx < num_mem_chunks; ++idx) {
11410 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11411 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11412 WMITLV_GET_STRUCT_TLVLEN
11413 (wlan_host_memory_chunk));
11414 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11415 host_mem_chunks[idx].size = mem_chunks[idx].len;
11416 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011417 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011418 idx, host_mem_chunks[idx].size,
11419 host_mem_chunks[idx].ptr);
11420 }
11421 cmd->num_host_mem_chunks = num_mem_chunks;
11422 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11423 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11424 WMITLV_TAG_ARRAY_STRUC,
11425 (sizeof(wlan_host_memory_chunk) *
11426 num_mem_chunks));
11427
11428 num_whitelist = sizeof(version_whitelist) /
11429 sizeof(wmi_whitelist_version_info);
11430 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11431 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11432 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11433 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11434 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11435 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011436#ifdef CONFIG_MCL
11437 /* This needs to be enabled for WIN Lithium after removing dependency
11438 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011439 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11440 &my_vers,
11441 &wmi_handle->fw_abi_version,
11442 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011443#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011444 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011445 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11446 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11447 cmd->host_abi_vers.abi_version_ns_0,
11448 cmd->host_abi_vers.abi_version_ns_1,
11449 cmd->host_abi_vers.abi_version_ns_2,
11450 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011451#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011452 /* Save version sent from host -
11453 * Will be used to check ready event
11454 */
Govind Singhb53420c2016-03-09 14:32:57 +053011455 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011456 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011457#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011458 if (action) {
11459 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11460 WMI_INIT_CMDID);
11461 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011462 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011463 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011464 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011465 }
11466 } else {
11467 wmi_handle->saved_wmi_init_cmd.buf = buf;
11468 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11469 }
11470
Govind Singhb53420c2016-03-09 14:32:57 +053011471 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011472
11473}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011474#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011475/**
11476 * send_saved_init_cmd_tlv() - wmi init command
11477 * @wmi_handle: pointer to wmi handle
11478 *
11479 * This function sends IE information to firmware
11480 *
Govind Singhb53420c2016-03-09 14:32:57 +053011481 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011482 *
11483 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011484static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053011485{
11486 int status;
11487
11488 if (!wmi_handle->saved_wmi_init_cmd.buf ||
11489 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053011490 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
11491 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011492 }
11493 status = wmi_unified_cmd_send(wmi_handle,
11494 wmi_handle->saved_wmi_init_cmd.buf,
11495 wmi_handle->saved_wmi_init_cmd.buf_len,
11496 WMI_INIT_CMDID);
11497 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053011498 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053011499 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011500 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011501 }
11502 wmi_handle->saved_wmi_init_cmd.buf = NULL;
11503 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
11504
Govind Singhb53420c2016-03-09 14:32:57 +053011505 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011506}
11507
Sathish Kumarfd347372017-02-13 12:29:09 +053011508static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053011509{
11510 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11511 wmi_service_ready_event_fixed_param *ev;
11512
11513
11514 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11515
11516 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11517 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053011518 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011519
Govind Singh87542482016-06-08 19:40:11 +053011520#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011521 /*Save fw version from service ready message */
11522 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053011523 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011524 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011525#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011526 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011527}
11528
11529/**
11530 * wmi_unified_save_fw_version_cmd() - save fw version
11531 * @wmi_handle: pointer to wmi handle
11532 * @res_cfg: resource config
11533 * @num_mem_chunks: no of mem chunck
11534 * @mem_chunk: pointer to mem chunck structure
11535 *
11536 * This function sends IE information to firmware
11537 *
Govind Singhb53420c2016-03-09 14:32:57 +053011538 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011539 *
11540 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011541static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011542 void *evt_buf)
11543{
11544 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11545 wmi_ready_event_fixed_param *ev = NULL;
11546
11547 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11548 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053011549#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011550 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
11551 &ev->fw_abi_vers)) {
11552 /*
11553 * Error: Our host version and the given firmware version
11554 * are incompatible.
11555 **/
Govind Singhb53420c2016-03-09 14:32:57 +053011556 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053011557 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
11558 __func__,
11559 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
11560 abi_version_0),
11561 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
11562 abi_version_0),
11563 wmi_handle->final_abi_vers.abi_version_ns_0,
11564 wmi_handle->final_abi_vers.abi_version_ns_1,
11565 wmi_handle->final_abi_vers.abi_version_ns_2,
11566 wmi_handle->final_abi_vers.abi_version_ns_3,
11567 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
11568 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
11569 ev->fw_abi_vers.abi_version_ns_0,
11570 ev->fw_abi_vers.abi_version_ns_1,
11571 ev->fw_abi_vers.abi_version_ns_2,
11572 ev->fw_abi_vers.abi_version_ns_3);
11573
Govind Singhb53420c2016-03-09 14:32:57 +053011574 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011575 }
Govind Singhb53420c2016-03-09 14:32:57 +053011576 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011577 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053011578 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011579 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011580#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011581
Govind Singhb53420c2016-03-09 14:32:57 +053011582 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011583}
Govind Singha4836fd2016-03-07 16:45:38 +053011584
11585/**
11586 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
11587 * @wmi_handle: wmi handle
11588 * @custom_addr: base mac address
11589 *
Govind Singhe7f2f342016-05-23 12:12:52 +053011590 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053011591 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011592static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011593 uint8_t *custom_addr)
11594{
11595 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
11596 wmi_buf_t buf;
11597 int err;
11598
11599 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11600 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011601 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053011602 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011603 }
11604
11605 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011606 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053011607
11608 WMITLV_SET_HDR(&cmd->tlv_header,
11609 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
11610 WMITLV_GET_STRUCT_TLVLEN
11611 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
11612 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070011613 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011614 err = wmi_unified_cmd_send(wmi_handle, buf,
11615 sizeof(*cmd),
11616 WMI_PDEV_SET_BASE_MACADDR_CMDID);
11617 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053011618 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053011619 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011620 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011621 }
11622
11623 return 0;
11624}
11625
11626/**
11627 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
11628 * @handle: wmi handle
11629 * @event: Event received from FW
11630 * @len: Length of the event
11631 *
11632 * Enables the low frequency events and disables the high frequency
11633 * events. Bit 17 indicates if the event if low/high frequency.
11634 * 1 - high frequency, 0 - low frequency
11635 *
11636 * Return: 0 on successfully enabling/disabling the events
11637 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011638static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011639 uint8_t *event,
11640 uint32_t len)
11641{
11642 uint32_t num_of_diag_events_logs;
11643 wmi_diag_event_log_config_fixed_param *cmd;
11644 wmi_buf_t buf;
11645 uint8_t *buf_ptr;
11646 uint32_t *cmd_args, *evt_args;
11647 uint32_t buf_len, i;
11648
11649 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
11650 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
11651
Govind Singhb53420c2016-03-09 14:32:57 +053011652 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053011653
11654 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
11655 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011656 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053011657 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011658 }
11659 wmi_event = param_buf->fixed_param;
11660 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
11661 evt_args = param_buf->diag_events_logs_list;
11662 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053011663 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011664 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053011665 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011666 }
11667
Govind Singhb53420c2016-03-09 14:32:57 +053011668 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011669 __func__, num_of_diag_events_logs);
11670
11671 /* Free any previous allocation */
11672 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053011673 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053011674
11675 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053011676 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053011677 sizeof(uint32_t));
11678 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011679 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011680 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011681 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011682 }
11683 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
11684
11685 /* Prepare the send buffer */
11686 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11687 (num_of_diag_events_logs * sizeof(uint32_t));
11688
11689 buf = wmi_buf_alloc(wmi_handle, buf_len);
11690 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011691 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11692 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053011693 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011694 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011695 }
11696
11697 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11698 buf_ptr = (uint8_t *) cmd;
11699
11700 WMITLV_SET_HDR(&cmd->tlv_header,
11701 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11702 WMITLV_GET_STRUCT_TLVLEN(
11703 wmi_diag_event_log_config_fixed_param));
11704
11705 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
11706
11707 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11708
11709 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11710 (num_of_diag_events_logs * sizeof(uint32_t)));
11711
11712 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11713
11714 /* Populate the events */
11715 for (i = 0; i < num_of_diag_events_logs; i++) {
11716 /* Low freq (0) - Enable (1) the event
11717 * High freq (1) - Disable (0) the event
11718 */
11719 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
11720 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
11721 /* Set the event ID */
11722 WMI_DIAG_ID_SET(cmd_args[i],
11723 WMI_DIAG_ID_GET(evt_args[i]));
11724 /* Set the type */
11725 WMI_DIAG_TYPE_SET(cmd_args[i],
11726 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053011727 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053011728 wmi_handle->events_logs_list[i] = evt_args[i];
11729 }
11730
11731 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
11732 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011733 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011734 __func__);
11735 wmi_buf_free(buf);
11736 /* Not clearing events_logs_list, though wmi cmd failed.
11737 * Host can still have this list
11738 */
Govind Singh67922e82016-04-01 16:48:57 +053011739 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011740 }
11741
11742 return 0;
11743}
11744
11745/**
11746 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
11747 * @wmi_handle: wmi handle
11748 * @start_log: Start logging related parameters
11749 *
11750 * Send the command to the FW based on which specific logging of diag
11751 * event/log id can be started/stopped
11752 *
11753 * Return: None
11754 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011755static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011756 struct wmi_wifi_start_log *start_log)
11757{
11758 wmi_diag_event_log_config_fixed_param *cmd;
11759 wmi_buf_t buf;
11760 uint8_t *buf_ptr;
11761 uint32_t len, count, log_level, i;
11762 uint32_t *cmd_args;
11763 uint32_t total_len;
11764 count = 0;
11765
11766 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011767 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053011768 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011769 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011770 }
11771 /* total_len stores the number of events where BITS 17 and 18 are set.
11772 * i.e., events of high frequency (17) and for extended debugging (18)
11773 */
11774 total_len = 0;
11775 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11776 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
11777 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
11778 total_len++;
11779 }
11780
11781 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11782 (total_len * sizeof(uint32_t));
11783
11784 buf = wmi_buf_alloc(wmi_handle, len);
11785 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011786 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011787 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011788 }
11789 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11790 buf_ptr = (uint8_t *) cmd;
11791
11792 WMITLV_SET_HDR(&cmd->tlv_header,
11793 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11794 WMITLV_GET_STRUCT_TLVLEN(
11795 wmi_diag_event_log_config_fixed_param));
11796
11797 cmd->num_of_diag_events_logs = total_len;
11798
11799 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11800
11801 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11802 (total_len * sizeof(uint32_t)));
11803
11804 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11805
Govind Singh224a7312016-06-21 14:33:26 +053011806 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053011807 log_level = 1;
11808 else
11809 log_level = 0;
11810
Govind Singhb53420c2016-03-09 14:32:57 +053011811 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053011812 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11813 uint32_t val = wmi_handle->events_logs_list[i];
11814 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
11815 (WMI_DIAG_EXT_FEATURE_GET(val))) {
11816
11817 WMI_DIAG_ID_SET(cmd_args[count],
11818 WMI_DIAG_ID_GET(val));
11819 WMI_DIAG_TYPE_SET(cmd_args[count],
11820 WMI_DIAG_TYPE_GET(val));
11821 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
11822 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053011823 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053011824 count++;
11825 }
11826 }
11827
11828 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11829 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011830 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011831 __func__);
11832 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011833 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011834 }
11835
Govind Singhb53420c2016-03-09 14:32:57 +053011836 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011837}
11838
11839/**
11840 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
11841 * @wmi_handle: WMI handle
11842 *
11843 * This function is used to send the flush command to the FW,
11844 * that will flush the fw logs that are residue in the FW
11845 *
11846 * Return: None
11847 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011848static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053011849{
11850 wmi_debug_mesg_flush_fixed_param *cmd;
11851 wmi_buf_t buf;
11852 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053011853 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011854
11855 buf = wmi_buf_alloc(wmi_handle, len);
11856 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011857 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011858 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011859 }
11860
11861 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
11862 WMITLV_SET_HDR(&cmd->tlv_header,
11863 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
11864 WMITLV_GET_STRUCT_TLVLEN(
11865 wmi_debug_mesg_flush_fixed_param));
11866 cmd->reserved0 = 0;
11867
11868 ret = wmi_unified_cmd_send(wmi_handle,
11869 buf,
11870 len,
11871 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011872 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011873 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053011874 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011875 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011876 }
Govind Singhb53420c2016-03-09 14:32:57 +053011877 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053011878
Govind Singh67922e82016-04-01 16:48:57 +053011879 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011880}
11881
11882/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011883 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011884 * @wmi_handle: wmi handle
11885 * @msg: PCL structure containing the PCL and the number of channels
11886 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011887 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053011888 * firmware. The DBS Manager is the consumer of this information in the WLAN
11889 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
11890 * to migrate to a new channel without host driver involvement. An example of
11891 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
11892 * manage the channel selection without firmware involvement.
11893 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011894 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
11895 * channel list. The weights corresponds to the channels sent in
11896 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
11897 * weightage compared to the non PCL channels.
11898 *
Govind Singha4836fd2016-03-07 16:45:38 +053011899 * Return: Success if the cmd is sent successfully to the firmware
11900 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011901static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011902 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053011903{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011904 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011905 wmi_buf_t buf;
11906 uint8_t *buf_ptr;
11907 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011908 uint32_t chan_len;
11909
11910 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053011911
11912 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011913 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053011914
11915 buf = wmi_buf_alloc(wmi_handle, len);
11916 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011917 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11918 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011919 }
11920
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011921 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011922 buf_ptr = (uint8_t *) cmd;
11923 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011924 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
11925 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053011926
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011927 cmd->pdev_id = WMI_PDEV_ID_SOC;
11928 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053011929 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011930
11931 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053011932 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011933 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053011934 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011935 for (i = 0; i < chan_len ; i++) {
11936 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053011937 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011938 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011939 }
11940 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011941 WMI_PDEV_SET_PCL_CMDID)) {
11942 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011943 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011944 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011945 }
Govind Singhb53420c2016-03-09 14:32:57 +053011946 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011947}
11948
11949/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011950 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011951 * @wmi_handle: wmi handle
11952 * @msg: Structure containing the following parameters
11953 *
11954 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
11955 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
11956 *
11957 * Provides notification to the WLAN firmware that host driver is requesting a
11958 * HardWare (HW) Mode change. This command is needed to support iHelium in the
11959 * configurations that include the Dual Band Simultaneous (DBS) feature.
11960 *
11961 * Return: Success if the cmd is sent successfully to the firmware
11962 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011963static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011964 uint32_t hw_mode_index)
11965{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011966 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011967 wmi_buf_t buf;
11968 uint32_t len;
11969
11970 len = sizeof(*cmd);
11971
11972 buf = wmi_buf_alloc(wmi_handle, len);
11973 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011974 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11975 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011976 }
11977
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011978 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011979 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011980 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
11981 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
11982
11983 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011984 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053011985 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053011986
11987 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011988 WMI_PDEV_SET_HW_MODE_CMDID)) {
11989 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011990 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011991 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011992 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011993 }
11994
Govind Singhb53420c2016-03-09 14:32:57 +053011995 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011996}
11997
11998/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011999 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012000 * @wmi_handle: wmi handle
12001 * @msg: Dual MAC config parameters
12002 *
12003 * Configures WLAN firmware with the dual MAC features
12004 *
Govind Singhb53420c2016-03-09 14:32:57 +053012005 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012006 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012007static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012008QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012009 struct wmi_dual_mac_config *msg)
12010{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012011 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012012 wmi_buf_t buf;
12013 uint32_t len;
12014
12015 len = sizeof(*cmd);
12016
12017 buf = wmi_buf_alloc(wmi_handle, len);
12018 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012019 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12020 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012021 }
12022
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012023 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012024 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012025 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012026 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012027 wmi_pdev_set_mac_config_cmd_fixed_param));
12028
12029 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053012030 cmd->concurrent_scan_config_bits = msg->scan_config;
12031 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012032 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012033 __func__, msg->scan_config, msg->fw_mode_config);
12034
12035 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012036 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12037 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012038 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012039 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012040 }
Govind Singhb53420c2016-03-09 14:32:57 +053012041 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012042}
12043
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012044#ifdef BIG_ENDIAN_HOST
12045/**
12046* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12047* @param data_len - data length
12048* @param data - pointer to data
12049*
12050* Return: QDF_STATUS - success or error status
12051*/
12052static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12053 struct fips_params *param)
12054{
12055 unsigned char *key_unaligned, *data_unaligned;
12056 int c;
12057 u_int8_t *key_aligned = NULL;
12058 u_int8_t *data_aligned = NULL;
12059
12060 /* Assigning unaligned space to copy the key */
12061 key_unaligned = qdf_mem_malloc(
12062 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12063 data_unaligned = qdf_mem_malloc(
12064 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12065
12066 /* Checking if kmalloc is succesful to allocate space */
12067 if (key_unaligned == NULL)
12068 return QDF_STATUS_SUCCESS;
12069 /* Checking if space is aligned */
12070 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12071 /* align to 4 */
12072 key_aligned =
12073 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12074 FIPS_ALIGN);
12075 } else {
12076 key_aligned = (u_int8_t *)key_unaligned;
12077 }
12078
12079 /* memset and copy content from key to key aligned */
12080 OS_MEMSET(key_aligned, 0, param->key_len);
12081 OS_MEMCPY(key_aligned, param->key, param->key_len);
12082
12083 /* print a hexdump for host debug */
12084 print_hex_dump(KERN_DEBUG,
12085 "\t Aligned and Copied Key:@@@@ ",
12086 DUMP_PREFIX_NONE,
12087 16, 1, key_aligned, param->key_len, true);
12088
12089 /* Checking if kmalloc is succesful to allocate space */
12090 if (data_unaligned == NULL)
12091 return QDF_STATUS_SUCCESS;
12092 /* Checking of space is aligned */
12093 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12094 /* align to 4 */
12095 data_aligned =
12096 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12097 FIPS_ALIGN);
12098 } else {
12099 data_aligned = (u_int8_t *)data_unaligned;
12100 }
12101
12102 /* memset and copy content from data to data aligned */
12103 OS_MEMSET(data_aligned, 0, param->data_len);
12104 OS_MEMCPY(data_aligned, param->data, param->data_len);
12105
12106 /* print a hexdump for host debug */
12107 print_hex_dump(KERN_DEBUG,
12108 "\t Properly Aligned and Copied Data:@@@@ ",
12109 DUMP_PREFIX_NONE,
12110 16, 1, data_aligned, param->data_len, true);
12111
12112 /* converting to little Endian both key_aligned and
12113 * data_aligned*/
12114 for (c = 0; c < param->key_len/4; c++) {
12115 *((u_int32_t *)key_aligned+c) =
12116 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12117 }
12118 for (c = 0; c < param->data_len/4; c++) {
12119 *((u_int32_t *)data_aligned+c) =
12120 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12121 }
12122
12123 /* update endian data to key and data vectors */
12124 OS_MEMCPY(param->key, key_aligned, param->key_len);
12125 OS_MEMCPY(param->data, data_aligned, param->data_len);
12126
12127 /* clean up allocated spaces */
12128 qdf_mem_free(key_unaligned);
12129 key_unaligned = NULL;
12130 key_aligned = NULL;
12131
12132 qdf_mem_free(data_unaligned);
12133 data_unaligned = NULL;
12134 data_aligned = NULL;
12135
12136 return QDF_STATUS_SUCCESS;
12137}
12138#else
12139/**
12140* fips_align_data_be() - DUMMY for LE platform
12141*
12142* Return: QDF_STATUS - success
12143*/
12144static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12145 struct fips_params *param)
12146{
12147 return QDF_STATUS_SUCCESS;
12148}
12149#endif
12150
12151
12152/**
12153 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12154 * @wmi_handle: wmi handle
12155 * @param: pointer to hold pdev fips param
12156 *
12157 * Return: 0 for success or error code
12158 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012159static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012160send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12161 struct fips_params *param)
12162{
12163 wmi_pdev_fips_cmd_fixed_param *cmd;
12164 wmi_buf_t buf;
12165 uint8_t *buf_ptr;
12166 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12167 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12168
12169 /* Length TLV placeholder for array of bytes */
12170 len += WMI_TLV_HDR_SIZE;
12171 if (param->data_len)
12172 len += (param->data_len*sizeof(uint8_t));
12173
12174 /*
12175 * Data length must be multiples of 16 bytes - checked against 0xF -
12176 * and must be less than WMI_SVC_MSG_SIZE - static size of
12177 * wmi_pdev_fips_cmd structure
12178 */
12179
12180 /* do sanity on the input */
12181 if (!(((param->data_len & 0xF) == 0) &&
12182 ((param->data_len > 0) &&
12183 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12184 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12185 return QDF_STATUS_E_INVAL;
12186 }
12187
12188 buf = wmi_buf_alloc(wmi_handle, len);
12189 if (!buf) {
12190 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12191 return QDF_STATUS_E_FAILURE;
12192 }
12193
12194 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12195 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12196 WMITLV_SET_HDR(&cmd->tlv_header,
12197 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12198 WMITLV_GET_STRUCT_TLVLEN
12199 (wmi_pdev_fips_cmd_fixed_param));
12200
12201 cmd->pdev_id = param->pdev_id;
12202 if (param->key != NULL && param->data != NULL) {
12203 cmd->key_len = param->key_len;
12204 cmd->data_len = param->data_len;
12205 cmd->fips_cmd = !!(param->op);
12206
12207 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12208 return QDF_STATUS_E_FAILURE;
12209
12210 qdf_mem_copy(cmd->key, param->key, param->key_len);
12211
12212 if (param->mode == FIPS_ENGINE_AES_CTR ||
12213 param->mode == FIPS_ENGINE_AES_MIC) {
12214 cmd->mode = param->mode;
12215 } else {
12216 cmd->mode = FIPS_ENGINE_AES_CTR;
12217 }
12218 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12219 cmd->key_len, cmd->data_len);
12220
12221 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12222 cmd->key, cmd->key_len, true);
12223 buf_ptr += sizeof(*cmd);
12224
12225 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12226
12227 buf_ptr += WMI_TLV_HDR_SIZE;
12228 if (param->data_len)
12229 qdf_mem_copy(buf_ptr,
12230 (uint8_t *) param->data, param->data_len);
12231
12232 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12233 16, 1, buf_ptr, cmd->data_len, true);
12234
12235 buf_ptr += param->data_len;
12236
12237 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12238 WMI_PDEV_FIPS_CMDID);
12239 qdf_print("%s return value %d\n", __func__, retval);
12240 } else {
12241 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12242 wmi_buf_free(buf);
12243 retval = -QDF_STATUS_E_BADMSG;
12244 }
12245
12246 return retval;
12247}
12248
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012249#ifdef WLAN_PMO_ENABLE
12250/**
12251 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12252 * @wmi_handle: wmi handle
12253 * @vdev_id: vdev id
12254 * @bitmap: Event bitmap
12255 * @enable: enable/disable
12256 *
12257 * Return: CDF status
12258 */
12259static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12260 uint32_t vdev_id,
12261 uint32_t bitmap,
12262 bool enable)
12263{
12264 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12265 uint16_t len;
12266 wmi_buf_t buf;
12267 int ret;
12268
12269 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12270 buf = wmi_buf_alloc(wmi_handle, len);
12271 if (!buf) {
12272 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12273 return QDF_STATUS_E_NOMEM;
12274 }
12275 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12276 WMITLV_SET_HDR(&cmd->tlv_header,
12277 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12278 WMITLV_GET_STRUCT_TLVLEN
12279 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12280 cmd->vdev_id = vdev_id;
12281 cmd->is_add = enable;
12282 cmd->event_bitmap = bitmap;
12283
12284 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12285 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12286 if (ret) {
12287 WMI_LOGE("Failed to config wow wakeup event");
12288 wmi_buf_free(buf);
12289 return QDF_STATUS_E_FAILURE;
12290 }
12291
12292 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
12293 enable ? "enabled" : "disabled");
12294
12295 return QDF_STATUS_SUCCESS;
12296}
12297
12298/**
12299 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12300 * @wmi_handle: wmi handle
12301 * @vdev_id: vdev id
12302 * @ptrn_id: pattern id
12303 * @ptrn: pattern
12304 * @ptrn_len: pattern length
12305 * @ptrn_offset: pattern offset
12306 * @mask: mask
12307 * @mask_len: mask length
12308 * @user: true for user configured pattern and false for default pattern
12309 * @default_patterns: default patterns
12310 *
12311 * Return: CDF status
12312 */
12313static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12314 uint8_t vdev_id, uint8_t ptrn_id,
12315 const uint8_t *ptrn, uint8_t ptrn_len,
12316 uint8_t ptrn_offset, const uint8_t *mask,
12317 uint8_t mask_len, bool user,
12318 uint8_t default_patterns)
12319{
12320 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12321 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12322 wmi_buf_t buf;
12323 uint8_t *buf_ptr;
12324 int32_t len;
12325 int ret;
12326
12327 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12328 WMI_TLV_HDR_SIZE +
12329 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12330 WMI_TLV_HDR_SIZE +
12331 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12332 WMI_TLV_HDR_SIZE +
12333 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12334 WMI_TLV_HDR_SIZE +
12335 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12336 WMI_TLV_HDR_SIZE +
12337 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12338
12339 buf = wmi_buf_alloc(wmi_handle, len);
12340 if (!buf) {
12341 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12342 return QDF_STATUS_E_NOMEM;
12343 }
12344
12345 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12346 buf_ptr = (uint8_t *) cmd;
12347
12348 WMITLV_SET_HDR(&cmd->tlv_header,
12349 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12350 WMITLV_GET_STRUCT_TLVLEN
12351 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12352 cmd->vdev_id = vdev_id;
12353 cmd->pattern_id = ptrn_id;
12354
12355 cmd->pattern_type = WOW_BITMAP_PATTERN;
12356 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12357
12358 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12359 sizeof(WOW_BITMAP_PATTERN_T));
12360 buf_ptr += WMI_TLV_HDR_SIZE;
12361 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12362
12363 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12364 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12365 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12366
12367 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12368 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12369
12370 bitmap_pattern->pattern_offset = ptrn_offset;
12371 bitmap_pattern->pattern_len = ptrn_len;
12372
12373 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12374 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12375
12376 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12377 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12378
12379 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12380 bitmap_pattern->pattern_id = ptrn_id;
12381
12382 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12383 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12384 bitmap_pattern->pattern_offset, user);
12385 WMI_LOGI("Pattern : ");
12386 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12387 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12388
12389 WMI_LOGI("Mask : ");
12390 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12391 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12392
12393 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12394
12395 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12396 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12397 buf_ptr += WMI_TLV_HDR_SIZE;
12398
12399 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12400 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12401 buf_ptr += WMI_TLV_HDR_SIZE;
12402
12403 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12404 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12405 buf_ptr += WMI_TLV_HDR_SIZE;
12406
12407 /* Fill TLV for pattern_info_timeout but no data. */
12408 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12409 buf_ptr += WMI_TLV_HDR_SIZE;
12410
12411 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12412 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12413 buf_ptr += WMI_TLV_HDR_SIZE;
12414 *(A_UINT32 *) buf_ptr = 0;
12415
12416 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12417 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12418 if (ret) {
12419 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12420 wmi_buf_free(buf);
12421 return QDF_STATUS_E_FAILURE;
12422 }
12423
12424 return QDF_STATUS_SUCCESS;
12425}
12426
Govind Singha4836fd2016-03-07 16:45:38 +053012427/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012428 * fill_arp_offload_params_tlv() - Fill ARP offload data
12429 * @wmi_handle: wmi handle
12430 * @offload_req: offload request
12431 * @buf_ptr: buffer pointer
12432 *
12433 * To fill ARP offload data to firmware
12434 * when target goes to wow mode.
12435 *
12436 * Return: None
12437 */
12438static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012439 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012440{
12441
12442 int i;
12443 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012444 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012445
12446 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12447 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12448 *buf_ptr += WMI_TLV_HDR_SIZE;
12449 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12450 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12451 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12452 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12453 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12454
12455 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012456 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012457 /* Copy the target ip addr and flags */
12458 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12459 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012460 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012461 WMI_IPV4_ADDR_LEN);
12462 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012463 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012464 }
12465 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12466 }
12467}
12468
12469#ifdef WLAN_NS_OFFLOAD
12470/**
12471 * fill_ns_offload_params_tlv() - Fill NS offload data
12472 * @wmi|_handle: wmi handle
12473 * @offload_req: offload request
12474 * @buf_ptr: buffer pointer
12475 *
12476 * To fill NS offload data to firmware
12477 * when target goes to wow mode.
12478 *
12479 * Return: None
12480 */
12481static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012482 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012483{
12484
12485 int i;
12486 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012487
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012488 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12489 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12490 *buf_ptr += WMI_TLV_HDR_SIZE;
12491 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
12492 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12493 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12494 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12495 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
12496
12497 /*
12498 * Fill data only for NS offload in the first ARP tuple for LA
12499 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012500 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012501 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12502 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012503 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012504 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012505 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012506 sizeof(WMI_IPV6_ADDR));
12507 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012508 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012509 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012510 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012511 ns_tuple->flags |=
12512 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12513 }
12514 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012515 i, &ns_req->self_ipv6_addr[i],
12516 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012517
12518 /* target MAC is optional, check if it is valid,
12519 * if this is not valid, the target will use the known
12520 * local MAC address rather than the tuple
12521 */
12522 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012523 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012524 &ns_tuple->target_mac);
12525 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12526 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12527 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12528 }
12529 }
12530 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12531 }
12532}
12533
12534
12535/**
12536 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
12537 * @wmi: wmi handle
12538 * @offload_req: offload request
12539 * @buf_ptr: buffer pointer
12540 *
12541 * To fill extended NS offload extended data to firmware
12542 * when target goes to wow mode.
12543 *
12544 * Return: None
12545 */
12546static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012547 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012548{
12549 int i;
12550 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
12551 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012552
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012553 count = ns_req->num_ns_offload_count;
12554 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012555 WMI_MAX_NS_OFFLOADS;
12556
12557 /* Populate extended NS offload tuples */
12558 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12559 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12560 *buf_ptr += WMI_TLV_HDR_SIZE;
12561 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
12562 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12563 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12564 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12565 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
12566
12567 /*
12568 * Fill data only for NS offload in the first ARP tuple for LA
12569 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012570 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012571 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12572 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012573 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012574 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012575 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012576 sizeof(WMI_IPV6_ADDR));
12577 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012578 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012579 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012580 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012581 ns_tuple->flags |=
12582 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12583 }
12584 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012585 i, &ns_req->self_ipv6_addr[i],
12586 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012587
12588 /* target MAC is optional, check if it is valid,
12589 * if this is not valid, the target will use the
12590 * known local MAC address rather than the tuple
12591 */
12592 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012593 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012594 &ns_tuple->target_mac);
12595 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12596 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12597 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12598 }
12599 }
12600 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12601 }
12602}
12603#else
12604static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012605 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012606{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012607}
12608
12609static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012610 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012611{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012612}
12613#endif
12614
12615/**
Govind Singha4836fd2016-03-07 16:45:38 +053012616 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
12617 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012618 * @arp_offload_req: arp offload request
12619 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053012620 * @arp_only: flag
12621 *
12622 * To configure ARP NS off load data to firmware
12623 * when target goes to wow mode.
12624 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012625 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053012626 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012627static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012628 struct pmo_arp_offload_params *arp_offload_req,
12629 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053012630 uint8_t vdev_id)
12631{
Govind Singha4836fd2016-03-07 16:45:38 +053012632 int32_t res;
12633 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012634 A_UINT8 *buf_ptr;
12635 wmi_buf_t buf;
12636 int32_t len;
12637 uint32_t count = 0, num_ns_ext_tuples = 0;
12638
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012639 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053012640
Govind Singha4836fd2016-03-07 16:45:38 +053012641 /*
12642 * TLV place holder size for array of NS tuples
12643 * TLV place holder size for array of ARP tuples
12644 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012645 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
12646 WMI_TLV_HDR_SIZE +
12647 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
12648 WMI_TLV_HDR_SIZE +
12649 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053012650
12651 /*
12652 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
12653 * extra length for extended NS offload tuples which follows ARP offload
12654 * tuples. Host needs to fill this structure in following format:
12655 * 2 NS ofload tuples
12656 * 2 ARP offload tuples
12657 * N numbers of extended NS offload tuples if HDD has given more than
12658 * 2 NS offload addresses
12659 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012660 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053012661 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012662 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
12663 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053012664 }
12665
12666 buf = wmi_buf_alloc(wmi_handle, len);
12667 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012668 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053012669 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012670 }
12671
12672 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
12673 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
12674 WMITLV_SET_HDR(&cmd->tlv_header,
12675 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
12676 WMITLV_GET_STRUCT_TLVLEN
12677 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
12678 cmd->flags = 0;
12679 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012680 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053012681
Govind Singhb53420c2016-03-09 14:32:57 +053012682 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053012683
Govind Singha4836fd2016-03-07 16:45:38 +053012684 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012685 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
12686 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
12687 if (num_ns_ext_tuples)
12688 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053012689
12690 res = wmi_unified_cmd_send(wmi_handle, buf, len,
12691 WMI_SET_ARP_NS_OFFLOAD_CMDID);
12692 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053012693 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053012694 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012695 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012696 }
12697
Govind Singhb53420c2016-03-09 14:32:57 +053012698 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012699}
12700
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012701/**
12702 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
12703 * @wmi_handle: wmi handle
12704 * @vdev_id: vdev id
12705 * @action: true for enable else false
12706 *
12707 * To enable enhance multicast offload to firmware
12708 * when target goes to wow mode.
12709 *
12710 * Return: QDF Status
12711 */
12712
12713static
12714QDF_STATUS send_enable_enhance_multicast_offload_tlv(
12715 wmi_unified_t wmi_handle,
12716 uint8_t vdev_id, bool action)
12717{
12718 QDF_STATUS status;
12719 wmi_buf_t buf;
12720 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
12721
12722 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12723 if (!buf) {
12724 WMI_LOGE("Failed to allocate buffer to send set key cmd");
12725 return QDF_STATUS_E_NOMEM;
12726 }
12727
12728 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
12729 wmi_buf_data(buf);
12730
12731 WMITLV_SET_HDR(&cmd->tlv_header,
12732 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
12733 WMITLV_GET_STRUCT_TLVLEN(
12734 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
12735
12736 cmd->vdev_id = vdev_id;
12737 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
12738 ENHANCED_MCAST_FILTER_ENABLED);
12739 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
12740 __func__, action, vdev_id);
12741 status = wmi_unified_cmd_send(wmi_handle, buf,
12742 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
12743 if (status != QDF_STATUS_SUCCESS) {
12744 qdf_nbuf_free(buf);
12745 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
12746 __func__);
12747 }
12748
12749 return status;
12750}
12751
12752/**
12753 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
12754 * @wmi_handle: wmi handle
12755 * @param evt_buf: pointer to event buffer
12756 * @param hdr: Pointer to hold header
12757 * @param bufp: Pointer to hold pointer to rx param buffer
12758 *
12759 * Return: QDF_STATUS_SUCCESS for success or error code
12760 */
12761static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
12762 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
12763{
12764 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
12765 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
12766
12767 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
12768 if (!param_buf) {
12769 WMI_LOGE("gtk param_buf is NULL");
12770 return QDF_STATUS_E_INVAL;
12771 }
12772
12773 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
12774 WMI_LOGE("Invalid length for GTK status");
12775 return QDF_STATUS_E_INVAL;
12776 }
12777
12778 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
12779 param_buf->fixed_param;
12780 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
12781 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
12782 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
12783 qdf_mem_copy(&gtk_rsp_param->replay_counter,
12784 &fixed_param->replay_counter,
12785 GTK_REPLAY_COUNTER_BYTES);
12786
12787 return QDF_STATUS_SUCCESS;
12788
12789}
12790
12791#ifdef FEATURE_WLAN_RA_FILTERING
12792/**
12793 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
12794 * @wmi_handle: wmi handle
12795 * @vdev_id: vdev id
12796 *
12797 * Return: CDF status
12798 */
12799static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
12800 uint8_t vdev_id, uint8_t default_pattern,
12801 uint16_t rate_limit_interval)
12802{
12803
12804 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12805 wmi_buf_t buf;
12806 uint8_t *buf_ptr;
12807 int32_t len;
12808 int ret;
12809
12810 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12811 WMI_TLV_HDR_SIZE +
12812 0 * sizeof(WOW_BITMAP_PATTERN_T) +
12813 WMI_TLV_HDR_SIZE +
12814 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12815 WMI_TLV_HDR_SIZE +
12816 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12817 WMI_TLV_HDR_SIZE +
12818 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12819 WMI_TLV_HDR_SIZE +
12820 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12821
12822 buf = wmi_buf_alloc(wmi_handle, len);
12823 if (!buf) {
12824 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12825 return QDF_STATUS_E_NOMEM;
12826 }
12827
12828 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12829 buf_ptr = (uint8_t *) cmd;
12830
12831 WMITLV_SET_HDR(&cmd->tlv_header,
12832 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12833 WMITLV_GET_STRUCT_TLVLEN
12834 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12835 cmd->vdev_id = vdev_id;
12836 cmd->pattern_id = default_pattern,
12837 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
12838 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12839
12840 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
12841 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12842 buf_ptr += WMI_TLV_HDR_SIZE;
12843
12844 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12845 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12846 buf_ptr += WMI_TLV_HDR_SIZE;
12847
12848 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12849 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12850 buf_ptr += WMI_TLV_HDR_SIZE;
12851
12852 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12853 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12854 buf_ptr += WMI_TLV_HDR_SIZE;
12855
12856 /* Fill TLV for pattern_info_timeout but no data. */
12857 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12858 buf_ptr += WMI_TLV_HDR_SIZE;
12859
12860 /* Fill TLV for ra_ratelimit_interval. */
12861 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
12862 buf_ptr += WMI_TLV_HDR_SIZE;
12863
12864 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
12865
12866 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
12867 rate_limit_interval, vdev_id);
12868
12869 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12870 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12871 if (ret) {
12872 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
12873 wmi_buf_free(buf);
12874 return QDF_STATUS_E_FAILURE;
12875 }
12876
12877 return QDF_STATUS_SUCCESS;
12878
12879}
12880#endif /* FEATURE_WLAN_RA_FILTERING */
12881
12882/**
12883 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
12884 * @wmi_handle: wmi handle
12885 * @vdev_id: vdev id
12886 * @multicastAddr: mcast address
12887 * @clearList: clear list flag
12888 *
12889 * Return: QDF_STATUS_SUCCESS for success or error code
12890 */
12891static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
12892 uint8_t vdev_id,
12893 struct qdf_mac_addr multicast_addr,
12894 bool clearList)
12895{
12896 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
12897 wmi_buf_t buf;
12898 int err;
12899
12900 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12901 if (!buf) {
12902 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
12903 return QDF_STATUS_E_NOMEM;
12904 }
12905
12906 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
12907 qdf_mem_zero(cmd, sizeof(*cmd));
12908
12909 WMITLV_SET_HDR(&cmd->tlv_header,
12910 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
12911 WMITLV_GET_STRUCT_TLVLEN
12912 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
12913 cmd->action =
12914 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
12915 cmd->vdev_id = vdev_id;
12916 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
12917
12918 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
12919 cmd->action, vdev_id, clearList, multicast_addr.bytes);
12920
12921 err = wmi_unified_cmd_send(wmi_handle, buf,
12922 sizeof(*cmd),
12923 WMI_SET_MCASTBCAST_FILTER_CMDID);
12924 if (err) {
12925 WMI_LOGE("Failed to send set_param cmd");
12926 wmi_buf_free(buf);
12927 return QDF_STATUS_E_FAILURE;
12928 }
12929
12930 return QDF_STATUS_SUCCESS;
12931}
12932
12933/**
12934 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
12935 * @wmi_handle: wmi handle
12936 * @vdev_id: vdev id
12937 * @params: GTK offload parameters
12938 *
12939 * Return: CDF status
12940 */
12941static
12942QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
12943 struct pmo_gtk_req *params,
12944 bool enable_offload,
12945 uint32_t gtk_offload_opcode)
12946{
12947 int len;
12948 wmi_buf_t buf;
12949 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12950 QDF_STATUS status = QDF_STATUS_SUCCESS;
12951
12952 WMI_LOGD("%s Enter", __func__);
12953
12954 len = sizeof(*cmd);
12955
12956 /* alloc wmi buffer */
12957 buf = wmi_buf_alloc(wmi_handle, len);
12958 if (!buf) {
12959 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12960 status = QDF_STATUS_E_NOMEM;
12961 goto out;
12962 }
12963
12964 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12965 WMITLV_SET_HDR(&cmd->tlv_header,
12966 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12967 WMITLV_GET_STRUCT_TLVLEN
12968 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12969
12970 cmd->vdev_id = vdev_id;
12971
12972 /* Request target to enable GTK offload */
12973 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
12974 cmd->flags = gtk_offload_opcode;
12975
12976 /* Copy the keys and replay counter */
12977 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
12978 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
12979 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
12980 GTK_REPLAY_COUNTER_BYTES);
12981 } else {
12982 cmd->flags = gtk_offload_opcode;
12983 }
12984
12985 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
12986
12987 /* send the wmi command */
12988 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12989 WMI_GTK_OFFLOAD_CMDID)) {
12990 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
12991 wmi_buf_free(buf);
12992 status = QDF_STATUS_E_FAILURE;
12993 }
12994
12995out:
12996 WMI_LOGD("%s Exit", __func__);
12997 return status;
12998}
12999
13000/**
13001 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13002 * @wmi_handle: wmi handle
13003 * @params: GTK offload params
13004 *
13005 * Return: CDF status
13006 */
13007static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13008 wmi_unified_t wmi_handle,
13009 uint8_t vdev_id,
13010 uint64_t offload_req_opcode)
13011{
13012 int len;
13013 wmi_buf_t buf;
13014 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13015 QDF_STATUS status = QDF_STATUS_SUCCESS;
13016
13017 len = sizeof(*cmd);
13018
13019 /* alloc wmi buffer */
13020 buf = wmi_buf_alloc(wmi_handle, len);
13021 if (!buf) {
13022 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13023 status = QDF_STATUS_E_NOMEM;
13024 goto out;
13025 }
13026
13027 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13028 WMITLV_SET_HDR(&cmd->tlv_header,
13029 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13030 WMITLV_GET_STRUCT_TLVLEN
13031 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13032
13033 /* Request for GTK offload status */
13034 cmd->flags = offload_req_opcode;
13035 cmd->vdev_id = vdev_id;
13036
13037 /* send the wmi command */
13038 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13039 WMI_GTK_OFFLOAD_CMDID)) {
13040 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13041 wmi_buf_free(buf);
13042 status = QDF_STATUS_E_FAILURE;
13043 }
13044
13045out:
13046 return status;
13047}
13048
13049/**
13050 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13051 * @wmi_handle: wmi handler
13052 * @action_params: pointer to action_params
13053 *
13054 * Return: 0 for success, otherwise appropriate error code
13055 */
13056static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13057 struct pmo_action_wakeup_set_params *action_params)
13058{
13059 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13060 wmi_buf_t buf;
13061 int i;
13062 int32_t err;
13063
13064 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13065 if (!buf) {
13066 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13067 return QDF_STATUS_E_NOMEM;
13068 }
13069 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13070 WMITLV_SET_HDR(&cmd->tlv_header,
13071 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13072 WMITLV_GET_STRUCT_TLVLEN(
13073 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13074
13075 cmd->vdev_id = action_params->vdev_id;
13076 cmd->operation = action_params->operation;
13077
13078 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13079 cmd->action_category_map[i] =
13080 action_params->action_category_map[i];
13081
13082 err = wmi_unified_cmd_send(wmi_handle, buf,
13083 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13084 if (err) {
13085 WMI_LOGE("Failed to send ap_ps_egap cmd");
13086 wmi_buf_free(buf);
13087 return QDF_STATUS_E_FAILURE;
13088 }
13089
13090 return QDF_STATUS_SUCCESS;
13091}
13092
13093#ifdef FEATURE_WLAN_LPHB
13094
13095/**
13096 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13097 * @wmi_handle: wmi handle
13098 * @lphb_conf_req: configuration info
13099 *
13100 * Return: CDF status
13101 */
13102static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13103 wmi_hb_set_enable_cmd_fixed_param *params)
13104{
13105 QDF_STATUS status;
13106 wmi_buf_t buf = NULL;
13107 uint8_t *buf_ptr;
13108 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13109 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13110
13111
13112 buf = wmi_buf_alloc(wmi_handle, len);
13113 if (!buf) {
13114 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13115 return QDF_STATUS_E_NOMEM;
13116 }
13117
13118 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13119 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13120 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13121 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13122 WMITLV_GET_STRUCT_TLVLEN
13123 (wmi_hb_set_enable_cmd_fixed_param));
13124
13125 /* fill in values */
13126 hb_enable_fp->vdev_id = params->session;
13127 hb_enable_fp->enable = params->enable;
13128 hb_enable_fp->item = params->item;
13129 hb_enable_fp->session = params->session;
13130
13131 status = wmi_unified_cmd_send(wmi_handle, buf,
13132 len, WMI_HB_SET_ENABLE_CMDID);
13133 if (QDF_IS_STATUS_ERROR(status)) {
13134 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13135 status);
13136 wmi_buf_free(buf);
13137 }
13138
13139 return status;
13140}
13141
13142/**
13143 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13144 * @wmi_handle: wmi handle
13145 * @lphb_conf_req: lphb config request
13146 *
13147 * Return: CDF status
13148 */
13149static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13150 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13151{
13152 QDF_STATUS status;
13153 wmi_buf_t buf = NULL;
13154 uint8_t *buf_ptr;
13155 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13156 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13157
13158 buf = wmi_buf_alloc(wmi_handle, len);
13159 if (!buf) {
13160 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13161 return QDF_STATUS_E_NOMEM;
13162 }
13163
13164 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13165 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13166 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13167 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13168 WMITLV_GET_STRUCT_TLVLEN
13169 (wmi_hb_set_tcp_params_cmd_fixed_param));
13170
13171 /* fill in values */
13172 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13173 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13174 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13175 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13176 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13177 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13178 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13179 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13180 hb_tcp_params_fp->session = lphb_conf_req->session;
13181 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13182 &lphb_conf_req->gateway_mac,
13183 sizeof(hb_tcp_params_fp->gateway_mac));
13184
13185 status = wmi_unified_cmd_send(wmi_handle, buf,
13186 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13187 if (QDF_IS_STATUS_ERROR(status)) {
13188 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13189 status);
13190 wmi_buf_free(buf);
13191 }
13192
13193 return status;
13194}
13195
13196/**
13197 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13198 * @wmi_handle: wmi handle
13199 * @lphb_conf_req: lphb config request
13200 *
13201 * Return: CDF status
13202 */
13203static
13204QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13205 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13206{
13207 QDF_STATUS status;
13208 wmi_buf_t buf = NULL;
13209 uint8_t *buf_ptr;
13210 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13211 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13212
13213 buf = wmi_buf_alloc(wmi_handle, len);
13214 if (!buf) {
13215 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13216 return QDF_STATUS_E_NOMEM;
13217 }
13218
13219 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13220 hb_tcp_filter_fp =
13221 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13222 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13223 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13224 WMITLV_GET_STRUCT_TLVLEN
13225 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13226
13227 /* fill in values */
13228 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13229 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13230 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13231 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13232 memcpy((void *)&hb_tcp_filter_fp->filter,
13233 (void *)&g_hb_tcp_filter_fp->filter,
13234 WMI_WLAN_HB_MAX_FILTER_SIZE);
13235
13236 status = wmi_unified_cmd_send(wmi_handle, buf,
13237 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13238 if (QDF_IS_STATUS_ERROR(status)) {
13239 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13240 status);
13241 wmi_buf_free(buf);
13242 }
13243
13244 return status;
13245}
13246
13247/**
13248 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13249 * @wmi_handle: wmi handle
13250 * @lphb_conf_req: lphb config request
13251 *
13252 * Return: CDF status
13253 */
13254static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13255 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13256{
13257 QDF_STATUS status;
13258 wmi_buf_t buf = NULL;
13259 uint8_t *buf_ptr;
13260 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13261 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13262
13263 buf = wmi_buf_alloc(wmi_handle, len);
13264 if (!buf) {
13265 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13266 return QDF_STATUS_E_NOMEM;
13267 }
13268
13269 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13270 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13271 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13272 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13273 WMITLV_GET_STRUCT_TLVLEN
13274 (wmi_hb_set_udp_params_cmd_fixed_param));
13275
13276 /* fill in values */
13277 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13278 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13279 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13280 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13281 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13282 hb_udp_params_fp->interval = lphb_conf_req->interval;
13283 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13284 hb_udp_params_fp->session = lphb_conf_req->session;
13285 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13286 &lphb_conf_req->gateway_mac,
13287 sizeof(lphb_conf_req->gateway_mac));
13288
13289 status = wmi_unified_cmd_send(wmi_handle, buf,
13290 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13291 if (QDF_IS_STATUS_ERROR(status)) {
13292 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13293 status);
13294 wmi_buf_free(buf);
13295 }
13296
13297 return status;
13298}
13299
13300/**
13301 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13302 * @wmi_handle: wmi handle
13303 * @lphb_conf_req: lphb config request
13304 *
13305 * Return: CDF status
13306 */
13307static
13308QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13309 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13310{
13311 QDF_STATUS status;
13312 wmi_buf_t buf = NULL;
13313 uint8_t *buf_ptr;
13314 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13315 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13316
13317 buf = wmi_buf_alloc(wmi_handle, len);
13318 if (!buf) {
13319 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13320 return QDF_STATUS_E_NOMEM;
13321 }
13322
13323 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13324 hb_udp_filter_fp =
13325 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13326 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13327 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13328 WMITLV_GET_STRUCT_TLVLEN
13329 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13330
13331 /* fill in values */
13332 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13333 hb_udp_filter_fp->length = lphb_conf_req->length;
13334 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13335 hb_udp_filter_fp->session = lphb_conf_req->session;
13336 memcpy((void *)&hb_udp_filter_fp->filter,
13337 (void *)&lphb_conf_req->filter,
13338 WMI_WLAN_HB_MAX_FILTER_SIZE);
13339
13340 status = wmi_unified_cmd_send(wmi_handle, buf,
13341 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13342 if (QDF_IS_STATUS_ERROR(status)) {
13343 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13344 status);
13345 wmi_buf_free(buf);
13346 }
13347
13348 return status;
13349}
13350#endif /* FEATURE_WLAN_LPHB */
13351#endif /* End of WLAN_PMO_ENABLE */
13352
Sathish Kumarfd347372017-02-13 12:29:09 +053013353static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013354 uint8_t vdev_id, bool enable)
13355{
13356 int32_t res;
13357 wmi_hw_data_filter_cmd_fixed_param *cmd;
13358 A_UINT8 *buf_ptr;
13359 wmi_buf_t buf;
13360 int32_t len;
13361
13362 /*
13363 * TLV place holder size for array of ARP tuples
13364 */
13365 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
13366
13367 buf = wmi_buf_alloc(wmi_handle, len);
13368 if (!buf) {
13369 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13370 return QDF_STATUS_E_NOMEM;
13371 }
13372
13373 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13374 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
13375 WMITLV_SET_HDR(&cmd->tlv_header,
13376 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13377 WMITLV_GET_STRUCT_TLVLEN
13378 (wmi_hw_data_filter_cmd_fixed_param));
13379 cmd->vdev_id = vdev_id;
13380 cmd->enable = enable;
13381 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
13382
13383 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
13384
13385 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13386 WMI_HW_DATA_FILTER_CMDID);
13387 if (res) {
13388 WMI_LOGE("Failed to enable ARP NDP/NSffload");
13389 wmi_buf_free(buf);
13390 return QDF_STATUS_E_FAILURE;
13391 }
13392
13393 return QDF_STATUS_SUCCESS;
13394}
13395
Govind Singha4836fd2016-03-07 16:45:38 +053013396/**
13397 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
13398 * @wmi_handle: wmi handle
13399 * @request: SSID hotlist set request
13400 *
Govind Singhb53420c2016-03-09 14:32:57 +053013401 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053013402 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013403static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053013404send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
13405 struct ssid_hotlist_request_params *request)
13406{
13407 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
13408 wmi_buf_t wmi_buf;
13409 uint32_t len;
13410 uint32_t array_size;
13411 uint8_t *buf_ptr;
13412
13413 /* length of fixed portion */
13414 len = sizeof(*cmd);
13415
13416 /* length of variable portion */
13417 array_size =
13418 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
13419 len += WMI_TLV_HDR_SIZE + array_size;
13420
13421 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13422 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013423 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13424 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013425 }
13426
13427 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
13428 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
13429 buf_ptr;
13430 WMITLV_SET_HDR
13431 (&cmd->tlv_header,
13432 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
13433 WMITLV_GET_STRUCT_TLVLEN
13434 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
13435
13436 cmd->request_id = request->request_id;
13437 cmd->requestor_id = 0;
13438 cmd->vdev_id = request->session_id;
13439 cmd->table_id = 0;
13440 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
13441 cmd->total_entries = request->ssid_count;
13442 cmd->num_entries_in_page = request->ssid_count;
13443 cmd->first_entry_index = 0;
13444
13445 buf_ptr += sizeof(*cmd);
13446 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
13447
13448 if (request->ssid_count) {
13449 wmi_extscan_hotlist_ssid_entry *entry;
13450 int i;
13451
13452 buf_ptr += WMI_TLV_HDR_SIZE;
13453 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
13454 for (i = 0; i < request->ssid_count; i++) {
13455 WMITLV_SET_HDR
13456 (entry,
13457 WMITLV_TAG_ARRAY_STRUC,
13458 WMITLV_GET_STRUCT_TLVLEN
13459 (wmi_extscan_hotlist_ssid_entry));
13460 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053013461 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053013462 request->ssids[i].ssid.mac_ssid,
13463 request->ssids[i].ssid.length);
13464 entry->band = request->ssids[i].band;
13465 entry->min_rssi = request->ssids[i].rssi_low;
13466 entry->max_rssi = request->ssids[i].rssi_high;
13467 entry++;
13468 }
13469 cmd->mode = WMI_EXTSCAN_MODE_START;
13470 } else {
13471 cmd->mode = WMI_EXTSCAN_MODE_STOP;
13472 }
13473
13474 if (wmi_unified_cmd_send
13475 (wmi_handle, wmi_buf, len,
13476 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013477 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013478 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013479 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013480 }
13481
Govind Singhb53420c2016-03-09 14:32:57 +053013482 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013483}
13484
13485/**
13486 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
13487 * @wmi_handle: wmi handle
13488 * @vdev_id: vdev id
13489 *
13490 * This function sends roam synch complete event to fw.
13491 *
13492 * Return: CDF STATUS
13493 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013494static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013495 uint8_t vdev_id)
13496{
13497 wmi_roam_synch_complete_fixed_param *cmd;
13498 wmi_buf_t wmi_buf;
13499 uint8_t *buf_ptr;
13500 uint16_t len;
13501 len = sizeof(wmi_roam_synch_complete_fixed_param);
13502
13503 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13504 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013505 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13506 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013507 }
13508 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
13509 buf_ptr = (uint8_t *) cmd;
13510 WMITLV_SET_HDR(&cmd->tlv_header,
13511 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
13512 WMITLV_GET_STRUCT_TLVLEN
13513 (wmi_roam_synch_complete_fixed_param));
13514 cmd->vdev_id = vdev_id;
13515 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13516 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013517 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053013518 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013519 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013520 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013521 }
13522
Govind Singhb53420c2016-03-09 14:32:57 +053013523 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013524}
13525
13526/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053013527 * send_fw_test_cmd_tlv() - send fw test command to fw.
13528 * @wmi_handle: wmi handle
13529 * @wmi_fwtest: fw test command
13530 *
13531 * This function sends fw test command to fw.
13532 *
13533 * Return: CDF STATUS
13534 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013535static
Anurag Chouhan459e0152016-07-22 20:19:54 +053013536QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
13537 struct set_fwtest_params *wmi_fwtest)
13538{
13539 wmi_fwtest_set_param_cmd_fixed_param *cmd;
13540 wmi_buf_t wmi_buf;
13541 uint16_t len;
13542
13543 len = sizeof(*cmd);
13544
13545 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13546 if (!wmi_buf) {
13547 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13548 return QDF_STATUS_E_NOMEM;
13549 }
13550
13551 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
13552 WMITLV_SET_HDR(&cmd->tlv_header,
13553 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
13554 WMITLV_GET_STRUCT_TLVLEN(
13555 wmi_fwtest_set_param_cmd_fixed_param));
13556 cmd->param_id = wmi_fwtest->arg;
13557 cmd->param_value = wmi_fwtest->value;
13558
13559 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13560 WMI_FWTEST_CMDID)) {
13561 WMI_LOGP("%s: failed to send fw test command", __func__);
13562 qdf_nbuf_free(wmi_buf);
13563 return QDF_STATUS_E_FAILURE;
13564 }
13565
13566 return QDF_STATUS_SUCCESS;
13567}
13568
13569/**
Govind Singha4836fd2016-03-07 16:45:38 +053013570 * send_unit_test_cmd_tlv() - send unit test command to fw.
13571 * @wmi_handle: wmi handle
13572 * @wmi_utest: unit test command
13573 *
13574 * This function send unit test command to fw.
13575 *
13576 * Return: CDF STATUS
13577 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013578static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013579 struct wmi_unit_test_cmd *wmi_utest)
13580{
13581 wmi_unit_test_cmd_fixed_param *cmd;
13582 wmi_buf_t wmi_buf;
13583 uint8_t *buf_ptr;
13584 int i;
13585 uint16_t len, args_tlv_len;
13586 A_UINT32 *unit_test_cmd_args;
13587
13588 args_tlv_len =
13589 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
13590 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
13591
13592 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13593 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013594 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13595 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013596 }
13597
13598 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
13599 buf_ptr = (uint8_t *) cmd;
13600 WMITLV_SET_HDR(&cmd->tlv_header,
13601 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
13602 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
13603 cmd->vdev_id = wmi_utest->vdev_id;
13604 cmd->module_id = wmi_utest->module_id;
13605 cmd->num_args = wmi_utest->num_args;
13606 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
13607 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13608 (wmi_utest->num_args * sizeof(uint32_t)));
13609 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013610 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053013611 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
13612 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013613 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013614 }
13615 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13616 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013617 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013618 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013619 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013620 }
13621
Govind Singhb53420c2016-03-09 14:32:57 +053013622 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013623}
13624
13625/**
13626 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
13627 * @wmi_handle: wma handle
13628 * @roaminvoke: roam invoke command
13629 *
13630 * Send roam invoke command to fw for fastreassoc.
13631 *
13632 * Return: CDF STATUS
13633 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013634static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013635 struct wmi_roam_invoke_cmd *roaminvoke,
13636 uint32_t ch_hz)
13637{
13638 wmi_roam_invoke_cmd_fixed_param *cmd;
13639 wmi_buf_t wmi_buf;
13640 u_int8_t *buf_ptr;
13641 u_int16_t len, args_tlv_len;
13642 A_UINT32 *channel_list;
13643 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080013644 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053013645
13646 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080013647 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
13648 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
13649 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013650 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
13651 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13652 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013653 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13654 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013655 }
13656
13657 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
13658 buf_ptr = (u_int8_t *) cmd;
13659 WMITLV_SET_HDR(&cmd->tlv_header,
13660 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
13661 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
13662 cmd->vdev_id = roaminvoke->vdev_id;
13663 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080013664
13665 if (roaminvoke->frame_len)
13666 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
13667 else
13668 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
13669
Govind Singha4836fd2016-03-07 16:45:38 +053013670 cmd->roam_ap_sel_mode = 0;
13671 cmd->roam_delay = 0;
13672 cmd->num_chan = 1;
13673 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080013674 /* packing 1 beacon/probe_rsp frame with WMI cmd */
13675 cmd->num_buf = 1;
13676
Govind Singha4836fd2016-03-07 16:45:38 +053013677 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
13678 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13679 (sizeof(u_int32_t)));
13680 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
13681 *channel_list = ch_hz;
13682 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
13683 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
13684 (sizeof(wmi_mac_addr)));
13685 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
13686 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080013687
13688 /* move to next tlv i.e. bcn_prb_buf_list */
13689 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
13690
13691 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
13692 sizeof(wmi_tlv_buf_len_param));
13693
13694 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
13695 buf_len_tlv->buf_len = roaminvoke->frame_len;
13696
13697 /* move to next tlv i.e. bcn_prb_frm */
13698 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
13699 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
13700 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
13701
13702 /* copy frame after the header */
13703 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
13704 roaminvoke->frame_buf,
13705 roaminvoke->frame_len);
13706
13707 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
13708 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
13709 buf_ptr + WMI_TLV_HDR_SIZE,
13710 roaminvoke->frame_len);
13711
Govind Singha4836fd2016-03-07 16:45:38 +053013712 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13713 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013714 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013715 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013716 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013717 }
13718
Govind Singhb53420c2016-03-09 14:32:57 +053013719 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013720}
13721
13722/**
13723 * send_roam_scan_offload_cmd_tlv() - set roam offload command
13724 * @wmi_handle: wmi handle
13725 * @command: command
13726 * @vdev_id: vdev id
13727 *
13728 * This function set roam offload command to fw.
13729 *
13730 * Return: CDF status
13731 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013732static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013733 uint32_t command, uint32_t vdev_id)
13734{
Govind Singh67922e82016-04-01 16:48:57 +053013735 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013736 wmi_roam_scan_cmd_fixed_param *cmd_fp;
13737 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013738 int len;
13739 uint8_t *buf_ptr;
13740
13741 len = sizeof(wmi_roam_scan_cmd_fixed_param);
13742 buf = wmi_buf_alloc(wmi_handle, len);
13743 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013744 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13745 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013746 }
13747
13748 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13749
13750 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
13751 WMITLV_SET_HDR(&cmd_fp->tlv_header,
13752 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
13753 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
13754 cmd_fp->vdev_id = vdev_id;
13755 cmd_fp->command_arg = command;
13756
13757 status = wmi_unified_cmd_send(wmi_handle, buf,
13758 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053013759 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013760 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013761 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013762 goto error;
13763 }
13764
Govind Singhb53420c2016-03-09 14:32:57 +053013765 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
13766 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013767
13768error:
13769 wmi_buf_free(buf);
13770
Govind Singh67922e82016-04-01 16:48:57 +053013771 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013772}
13773
13774/**
13775 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
13776 * @wmi_handle: wmi handle
13777 * @ap_profile_p: ap profile
13778 * @vdev_id: vdev id
13779 *
13780 * Send WMI_ROAM_AP_PROFILE to firmware
13781 *
13782 * Return: CDF status
13783 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013784static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013785 wmi_ap_profile *ap_profile_p,
13786 uint32_t vdev_id)
13787{
Govind Singha4836fd2016-03-07 16:45:38 +053013788 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013789 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013790 int len;
13791 uint8_t *buf_ptr;
13792 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
13793
13794 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
13795
13796 buf = wmi_buf_alloc(wmi_handle, len);
13797 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013798 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13799 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013800 }
13801
13802 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13803 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
13804 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
13805 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
13806 WMITLV_GET_STRUCT_TLVLEN
13807 (wmi_roam_ap_profile_fixed_param));
13808 /* fill in threshold values */
13809 roam_ap_profile_fp->vdev_id = vdev_id;
13810 roam_ap_profile_fp->id = 0;
13811 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
13812
Govind Singhb53420c2016-03-09 14:32:57 +053013813 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053013814 WMITLV_SET_HDR(buf_ptr,
13815 WMITLV_TAG_STRUC_wmi_ap_profile,
13816 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
13817 status = wmi_unified_cmd_send(wmi_handle, buf,
13818 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053013819 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013820 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013821 status);
Govind Singh67922e82016-04-01 16:48:57 +053013822 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013823 }
13824
Govind Singhb53420c2016-03-09 14:32:57 +053013825 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053013826
Govind Singh67922e82016-04-01 16:48:57 +053013827 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013828}
13829
13830/**
13831 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
13832 * @wmi_handle: wmi handle
13833 * @scan_period: scan period
13834 * @scan_age: scan age
13835 * @vdev_id: vdev id
13836 *
13837 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
13838 *
13839 * Return: CDF status
13840 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013841static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013842 uint32_t scan_period,
13843 uint32_t scan_age,
13844 uint32_t vdev_id)
13845{
Govind Singh67922e82016-04-01 16:48:57 +053013846 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013847 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013848 int len;
13849 uint8_t *buf_ptr;
13850 wmi_roam_scan_period_fixed_param *scan_period_fp;
13851
13852 /* Send scan period values */
13853 len = sizeof(wmi_roam_scan_period_fixed_param);
13854 buf = wmi_buf_alloc(wmi_handle, len);
13855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013856 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13857 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013858 }
13859
13860 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13861 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
13862 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
13863 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
13864 WMITLV_GET_STRUCT_TLVLEN
13865 (wmi_roam_scan_period_fixed_param));
13866 /* fill in scan period values */
13867 scan_period_fp->vdev_id = vdev_id;
13868 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
13869 scan_period_fp->roam_scan_age = scan_age;
13870
13871 status = wmi_unified_cmd_send(wmi_handle, buf,
13872 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053013873 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013874 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013875 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013876 goto error;
13877 }
13878
Govind Singhb53420c2016-03-09 14:32:57 +053013879 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013880 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053013881 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013882error:
13883 wmi_buf_free(buf);
13884
Govind Singh67922e82016-04-01 16:48:57 +053013885 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013886}
13887
13888/**
13889 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
13890 * @wmi_handle: wmi handle
13891 * @chan_count: channel count
13892 * @chan_list: channel list
13893 * @list_type: list type
13894 * @vdev_id: vdev id
13895 *
13896 * Set roam offload channel list.
13897 *
13898 * Return: CDF status
13899 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013900static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013901 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070013902 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053013903 uint8_t list_type, uint32_t vdev_id)
13904{
Govind Singha4836fd2016-03-07 16:45:38 +053013905 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013906 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013907 int len, list_tlv_len;
13908 int i;
13909 uint8_t *buf_ptr;
13910 wmi_roam_chan_list_fixed_param *chan_list_fp;
13911 A_UINT32 *roam_chan_list_array;
13912
13913 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053013914 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053013915 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053013916 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053013917 }
13918 /* Channel list is a table of 2 TLV's */
13919 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
13920 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
13921 buf = wmi_buf_alloc(wmi_handle, len);
13922 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013923 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13924 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013925 }
13926
13927 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13928 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
13929 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
13930 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
13931 WMITLV_GET_STRUCT_TLVLEN
13932 (wmi_roam_chan_list_fixed_param));
13933 chan_list_fp->vdev_id = vdev_id;
13934 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053013935 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053013936 /* external app is controlling channel list */
13937 chan_list_fp->chan_list_type =
13938 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
13939 } else {
13940 /* umac supplied occupied channel list in LFR */
13941 chan_list_fp->chan_list_type =
13942 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
13943 }
13944
13945 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
13946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13947 (chan_list_fp->num_chan * sizeof(uint32_t)));
13948 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013949 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053013950 for (i = 0; ((i < chan_list_fp->num_chan) &&
13951 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
13952 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013953 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013954 }
13955
13956 status = wmi_unified_cmd_send(wmi_handle, buf,
13957 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053013958 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013959 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013960 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013961 goto error;
13962 }
13963
Govind Singhb53420c2016-03-09 14:32:57 +053013964 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
13965 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013966error:
13967 wmi_buf_free(buf);
13968
Govind Singh67922e82016-04-01 16:48:57 +053013969 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013970}
13971
13972/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013973 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
13974 * @wmi_handle: wmi handle
13975 * @req_buf: per roam config buffer
13976 *
13977 * Return: QDF status
13978 */
13979static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
13980 struct wmi_per_roam_config_req *req_buf)
13981{
13982 wmi_buf_t buf = NULL;
13983 QDF_STATUS status;
13984 int len;
13985 uint8_t *buf_ptr;
13986 wmi_roam_per_config_fixed_param *wmi_per_config;
13987
13988 len = sizeof(wmi_roam_per_config_fixed_param);
13989 buf = wmi_buf_alloc(wmi_handle, len);
13990 if (!buf) {
13991 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13992 return QDF_STATUS_E_NOMEM;
13993 }
13994
13995 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13996 wmi_per_config =
13997 (wmi_roam_per_config_fixed_param *) buf_ptr;
13998 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
13999 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14000 WMITLV_GET_STRUCT_TLVLEN
14001 (wmi_roam_per_config_fixed_param));
14002
14003 /* fill in per roam config values */
14004 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014005
14006 wmi_per_config->enable = req_buf->per_config.enable;
14007 wmi_per_config->high_rate_thresh =
14008 (req_buf->per_config.tx_high_rate_thresh << 16) |
14009 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14010 wmi_per_config->low_rate_thresh =
14011 (req_buf->per_config.tx_low_rate_thresh << 16) |
14012 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14013 wmi_per_config->pkt_err_rate_thresh_pct =
14014 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14015 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14016 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014017 wmi_per_config->pkt_err_rate_mon_time =
14018 (req_buf->per_config.tx_per_mon_time << 16) |
14019 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014020
14021 /* Send per roam config parameters */
14022 status = wmi_unified_cmd_send(wmi_handle, buf,
14023 len, WMI_ROAM_PER_CONFIG_CMDID);
14024 if (QDF_IS_STATUS_ERROR(status)) {
14025 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14026 status);
14027 wmi_buf_free(buf);
14028 return status;
14029 }
14030
14031 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14032 req_buf->per_config.enable, req_buf->vdev_id);
14033 return QDF_STATUS_SUCCESS;
14034}
14035
14036/**
Govind Singha4836fd2016-03-07 16:45:38 +053014037 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14038 * @wmi_handle: wmi handle
14039 * @rssi_change_thresh: RSSI Change threshold
14040 * @bcn_rssi_weight: beacon RSSI weight
14041 * @vdev_id: vdev id
14042 *
14043 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14044 *
14045 * Return: CDF status
14046 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014047static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014048 uint32_t vdev_id,
14049 int32_t rssi_change_thresh,
14050 uint32_t bcn_rssi_weight,
14051 uint32_t hirssi_delay_btw_scans)
14052{
Govind Singha4836fd2016-03-07 16:45:38 +053014053 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014054 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014055 int len;
14056 uint8_t *buf_ptr;
14057 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14058
14059 /* Send rssi change parameters */
14060 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14061 buf = wmi_buf_alloc(wmi_handle, len);
14062 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014063 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14064 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014065 }
14066
14067 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14068 rssi_change_fp =
14069 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14070 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14071 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14072 WMITLV_GET_STRUCT_TLVLEN
14073 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14074 /* fill in rssi change threshold (hysteresis) values */
14075 rssi_change_fp->vdev_id = vdev_id;
14076 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14077 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
14078 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
14079
14080 status = wmi_unified_cmd_send(wmi_handle, buf,
14081 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014082 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014083 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014084 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014085 goto error;
14086 }
14087
Govind Singhb53420c2016-03-09 14:32:57 +053014088 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014089 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014090 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14091 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014092error:
14093 wmi_buf_free(buf);
14094
Govind Singh67922e82016-04-01 16:48:57 +053014095 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014096}
14097
14098/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14099 * @wmi_handle: wmi handle.
14100 * @cmd: size of command structure.
14101 * @per_entry_size: per entry size.
14102 *
14103 * This utility function calculates how many hotlist entries can
14104 * fit in one page.
14105 *
14106 * Return: number of entries
14107 */
14108static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14109 size_t cmd_size,
14110 size_t per_entry_size)
14111{
14112 uint32_t avail_space = 0;
14113 int num_entries = 0;
14114 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14115
14116 /* Calculate number of hotlist entries that can
14117 * be passed in wma message request.
14118 */
14119 avail_space = max_msg_len - cmd_size;
14120 num_entries = avail_space / per_entry_size;
14121 return num_entries;
14122}
14123
14124/**
14125 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14126 * @wmi_handle: wmi handle
14127 * @photlist: hotlist command params
14128 * @buf_len: buffer length
14129 *
14130 * This function fills individual elements for hotlist request and
14131 * TLV for bssid entries
14132 *
14133 * Return: CDF Status.
14134 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014135static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014136 struct ext_scan_setbssi_hotlist_params *
14137 photlist, int *buf_len)
14138{
14139 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14140 wmi_extscan_hotlist_entry *dest_hotlist;
14141 struct ap_threshold_params *src_ap = photlist->ap;
14142 wmi_buf_t buf;
14143 uint8_t *buf_ptr;
14144
14145 int j, index = 0;
14146 int cmd_len = 0;
14147 int num_entries;
14148 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014149 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014150 int len = sizeof(*cmd);
14151
14152 len += WMI_TLV_HDR_SIZE;
14153 cmd_len = len;
14154
14155 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14156 cmd_len,
14157 sizeof(*dest_hotlist));
14158 /* setbssid hotlist expects the bssid list
14159 * to be non zero value
14160 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014161 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014162 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014163 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014164 }
14165
14166 /* Split the hot list entry pages and send multiple command
14167 * requests if the buffer reaches the maximum request size
14168 */
14169 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014170 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014171 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14172 buf = wmi_buf_alloc(wmi_handle, len);
14173 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014174 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14175 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014176 }
14177 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14178 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14179 buf_ptr;
14180 WMITLV_SET_HDR(&cmd->tlv_header,
14181 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14182 WMITLV_GET_STRUCT_TLVLEN
14183 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14184
14185 /* Multiple requests are sent until the num_entries_in_page
14186 * matches the total_entries
14187 */
14188 cmd->request_id = photlist->requestId;
14189 cmd->vdev_id = photlist->sessionId;
14190 cmd->total_entries = numap;
14191 cmd->mode = 1;
14192 cmd->num_entries_in_page = min_entries;
14193 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14194 cmd->first_entry_index = index;
14195
Govind Singhb53420c2016-03-09 14:32:57 +053014196 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014197 __func__, cmd->vdev_id, cmd->total_entries,
14198 cmd->num_entries_in_page,
14199 cmd->lost_ap_scan_count);
14200
14201 buf_ptr += sizeof(*cmd);
14202 WMITLV_SET_HDR(buf_ptr,
14203 WMITLV_TAG_ARRAY_STRUC,
14204 min_entries * sizeof(wmi_extscan_hotlist_entry));
14205 dest_hotlist = (wmi_extscan_hotlist_entry *)
14206 (buf_ptr + WMI_TLV_HDR_SIZE);
14207
14208 /* Populate bssid, channel info and rssi
14209 * for the bssid's that are sent as hotlists.
14210 */
14211 for (j = 0; j < min_entries; j++) {
14212 WMITLV_SET_HDR(dest_hotlist,
14213 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14214 WMITLV_GET_STRUCT_TLVLEN
14215 (wmi_extscan_hotlist_entry));
14216
14217 dest_hotlist->min_rssi = src_ap->low;
14218 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14219 &dest_hotlist->bssid);
14220
Govind Singhb53420c2016-03-09 14:32:57 +053014221 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014222 __func__, dest_hotlist->channel,
14223 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014224 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014225 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14226 __func__, dest_hotlist->bssid.mac_addr31to0,
14227 dest_hotlist->bssid.mac_addr47to32);
14228 dest_hotlist++;
14229 src_ap++;
14230 }
14231 buf_ptr += WMI_TLV_HDR_SIZE +
14232 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14233
14234 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14235 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014236 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014237 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014238 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014239 }
14240 index = index + min_entries;
14241 num_entries = numap - min_entries;
14242 len = cmd_len;
14243 }
Govind Singhb53420c2016-03-09 14:32:57 +053014244 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014245}
14246
Govind Singhbca3b1b2016-05-02 17:59:24 +053014247/**
Dustin Brown4423f632017-01-13 15:24:07 -080014248 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14249 * @wmi_handle: the WMI handle
14250 * @vdev_id: the Id of the vdev to apply the configuration to
14251 * @ucast_mode: the active BPF mode to configure for unicast packets
14252 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14253 * packets
14254 *
14255 * Return: QDF status
14256 */
14257static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14258 uint8_t vdev_id,
14259 enum wmi_host_active_bpf_mode ucast_mode,
14260 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14261{
14262 const WMITLV_TAG_ID tag_id =
14263 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14264 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14265 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14266 QDF_STATUS status;
14267 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14268 wmi_buf_t buf;
14269
14270 WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
14271 vdev_id, ucast_mode, mcast_bcast_mode);
14272
14273 /* allocate command buffer */
14274 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14275 if (!buf) {
14276 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14277 return QDF_STATUS_E_NOMEM;
14278 }
14279
14280 /* set TLV header */
14281 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14282 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14283
14284 /* populate data */
14285 cmd->vdev_id = vdev_id;
14286 cmd->uc_mode = ucast_mode;
14287 cmd->mcbc_mode = mcast_bcast_mode;
14288
14289 /* send to FW */
14290 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14291 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14292 if (QDF_IS_STATUS_ERROR(status)) {
14293 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14294 status);
14295 wmi_buf_free(buf);
14296 return status;
14297 }
14298
14299 WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
14300
14301 return QDF_STATUS_SUCCESS;
14302}
14303
14304/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014305 * send_power_dbg_cmd_tlv() - send power debug commands
14306 * @wmi_handle: wmi handle
14307 * @param: wmi power debug parameter
14308 *
14309 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14310 *
14311 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14312 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014313static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14314 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014315{
14316 wmi_buf_t buf = NULL;
14317 QDF_STATUS status;
14318 int len, args_tlv_len;
14319 uint8_t *buf_ptr;
14320 uint8_t i;
14321 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14322 uint32_t *cmd_args;
14323
14324 /* Prepare and send power debug cmd parameters */
14325 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14326 len = sizeof(*cmd) + args_tlv_len;
14327 buf = wmi_buf_alloc(wmi_handle, len);
14328 if (!buf) {
14329 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14330 return QDF_STATUS_E_NOMEM;
14331 }
14332
14333 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14334 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
14335 WMITLV_SET_HDR(&cmd->tlv_header,
14336 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
14337 WMITLV_GET_STRUCT_TLVLEN
14338 (wmi_pdev_wal_power_debug_cmd_fixed_param));
14339
14340 cmd->pdev_id = param->pdev_id;
14341 cmd->module_id = param->module_id;
14342 cmd->num_args = param->num_args;
14343 buf_ptr += sizeof(*cmd);
14344 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14345 (param->num_args * sizeof(uint32_t)));
14346 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
14347 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
14348 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14349 cmd_args[i] = param->args[i];
14350 WMI_LOGI("%d,", param->args[i]);
14351 }
14352
14353 status = wmi_unified_cmd_send(wmi_handle, buf,
14354 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
14355 if (QDF_IS_STATUS_ERROR(status)) {
14356 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
14357 status);
14358 goto error;
14359 }
14360
14361 return QDF_STATUS_SUCCESS;
14362error:
14363 wmi_buf_free(buf);
14364
14365 return status;
14366}
14367
Kiran Venkatappa26117052016-12-23 19:58:54 +053014368/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
14369 * @buf_ptr: pointer to current position in init command buffer
14370 * @len: pointer to length. This will be updated with current lenght of cmd
14371 * @param: point host parameters for init command
14372 *
14373 * Return: Updated pointer of buf_ptr.
14374 */
14375static inline uint8_t *copy_hw_mode_in_init_cmd(uint8_t *buf_ptr,
14376 int *len, struct wmi_init_cmd_param *param)
14377{
14378 uint16_t idx;
14379
14380 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
14381 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
14382 wmi_pdev_band_to_mac *band_to_mac;
14383
14384 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
14385 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
14386 sizeof(wmi_resource_config) +
14387 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
14388 sizeof(wlan_host_memory_chunk)));
14389
14390 WMITLV_SET_HDR(&hw_mode->tlv_header,
14391 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
14392 (WMITLV_GET_STRUCT_TLVLEN
14393 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
14394
14395 hw_mode->hw_mode_index = param->hw_mode_id;
14396 hw_mode->num_band_to_mac = param->num_band_to_mac;
14397
14398 buf_ptr = (uint8_t *) (hw_mode + 1);
14399 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
14400 WMI_TLV_HDR_SIZE);
14401 for (idx = 0; idx < param->num_band_to_mac; idx++) {
14402 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
14403 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
14404 WMITLV_GET_STRUCT_TLVLEN
14405 (wmi_pdev_band_to_mac));
14406 band_to_mac[idx].pdev_id =
14407 param->band_to_mac[idx].pdev_id;
14408 band_to_mac[idx].start_freq =
14409 param->band_to_mac[idx].start_freq;
14410 band_to_mac[idx].end_freq =
14411 param->band_to_mac[idx].end_freq;
14412 }
14413 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14414 (param->num_band_to_mac *
14415 sizeof(wmi_pdev_band_to_mac)) +
14416 WMI_TLV_HDR_SIZE;
14417
14418 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14419 (param->num_band_to_mac *
14420 sizeof(wmi_pdev_band_to_mac)));
14421 }
14422
14423 return buf_ptr;
14424}
14425
Govind Singhe7f2f342016-05-23 12:12:52 +053014426/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014427 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
14428 * @wmi_handle: wmi handle
14429 * @param: wmi multiple vdev restart req param
14430 *
14431 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
14432 *
14433 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14434 */
14435static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
14436 wmi_unified_t wmi_handle,
14437 struct multiple_vdev_restart_params *param)
14438{
14439 wmi_buf_t buf;
14440 QDF_STATUS qdf_status;
14441 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
14442 int i;
14443 uint8_t *buf_ptr;
14444 uint32_t *vdev_ids;
14445 wmi_channel *chan_info;
14446 struct channel_param *tchan_info;
14447 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
14448
14449 len += sizeof(wmi_channel);
14450 if (param->num_vdevs)
14451 len += sizeof(uint32_t) * param->num_vdevs;
14452
14453 buf = wmi_buf_alloc(wmi_handle, len);
14454 if (!buf) {
14455 WMI_LOGE("Failed to allocate memory\n");
14456 qdf_status = QDF_STATUS_E_NOMEM;
14457 goto end;
14458 }
14459
14460 buf_ptr = (uint8_t *)wmi_buf_data(buf);
14461 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
14462 buf_ptr;
14463
14464 WMITLV_SET_HDR(&cmd->tlv_header,
14465 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
14466 WMITLV_GET_STRUCT_TLVLEN
14467 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
14468 cmd->pdev_id = param->pdev_id;
14469 cmd->requestor_id = param->requestor_id;
14470 cmd->disable_hw_ack = param->disable_hw_ack;
14471 cmd->cac_duration_ms = param->cac_duration_ms;
14472 cmd->num_vdevs = param->num_vdevs;
14473
14474 buf_ptr += sizeof(*cmd);
14475
14476 WMITLV_SET_HDR(buf_ptr,
14477 WMITLV_TAG_ARRAY_UINT32,
14478 sizeof(A_UINT32) * param->num_vdevs);
14479 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
14480 for (i = 0; i < param->num_vdevs; i++) {
14481 vdev_ids[i] = param->vdev_ids[i];
14482 }
14483
14484 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
14485
14486 WMITLV_SET_HDR(buf_ptr,
14487 WMITLV_TAG_STRUC_wmi_channel,
14488 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053014489 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053014490 tchan_info = &(param->ch_param);
14491 chan_info->mhz = tchan_info->mhz;
14492 chan_info->band_center_freq1 = tchan_info->cfreq1;
14493 chan_info->band_center_freq2 = tchan_info->cfreq2;
14494 if (tchan_info->is_chan_passive)
14495 WMI_SET_CHANNEL_FLAG(chan_info,
14496 WMI_CHAN_FLAG_PASSIVE);
14497 if (tchan_info->allow_vht)
14498 WMI_SET_CHANNEL_FLAG(chan_info,
14499 WMI_CHAN_FLAG_ALLOW_VHT);
14500 else if (tchan_info->allow_ht)
14501 WMI_SET_CHANNEL_FLAG(chan_info,
14502 WMI_CHAN_FLAG_ALLOW_HT);
14503 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
14504 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
14505 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
14506 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
14507 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
14508 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
14509
14510 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
14511 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
14512
14513 if (QDF_IS_STATUS_ERROR(qdf_status)) {
14514 WMI_LOGE("%s: Failed to send\n", __func__);
14515 wmi_buf_free(buf);
14516 }
14517
14518end:
14519 return qdf_status;
14520}
14521
14522/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080014523 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
14524 * @wmi_handle: wmi handle
14525 * @pdev_id: pdev id
14526 *
14527 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
14528 *
14529 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14530 */
14531static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
14532 uint32_t pdev_id)
14533{
14534 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
14535 wmi_buf_t buf;
14536 uint16_t len;
14537 QDF_STATUS ret;
14538
14539 len = sizeof(*cmd);
14540 buf = wmi_buf_alloc(wmi_handle, len);
14541
14542 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
14543
14544 if (!buf) {
14545 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14546 return QDF_STATUS_E_NOMEM;
14547 }
14548
14549 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
14550 wmi_buf_data(buf);
14551
14552 WMITLV_SET_HDR(&cmd->tlv_header,
14553 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
14554 WMITLV_GET_STRUCT_TLVLEN(
14555 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
14556
14557 cmd->pdev_id = pdev_id;
14558 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14559 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
14560 if (QDF_IS_STATUS_ERROR(ret)) {
14561 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
14562 __func__, ret, pdev_id);
14563 wmi_buf_free(buf);
14564 return QDF_STATUS_E_FAILURE;
14565 }
14566
14567 return QDF_STATUS_SUCCESS;
14568}
14569
14570/**
14571 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
14572 * @wmi_handle: wmi handle
14573 * @pdev_id: pdev id
14574 *
14575 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
14576 *
14577 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14578 */
14579static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
14580 uint32_t pdev_id)
14581{
14582 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
14583 wmi_buf_t buf;
14584 uint16_t len;
14585 QDF_STATUS ret;
14586
14587 len = sizeof(*cmd);
14588 buf = wmi_buf_alloc(wmi_handle, len);
14589
14590 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
14591
14592 if (!buf) {
14593 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14594 return QDF_STATUS_E_NOMEM;
14595 }
14596
14597 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
14598 wmi_buf_data(buf);
14599
14600 WMITLV_SET_HDR(&cmd->tlv_header,
14601 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
14602 WMITLV_GET_STRUCT_TLVLEN(
14603 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
14604
14605 cmd->pdev_id = pdev_id;
14606 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14607 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
14608 if (QDF_IS_STATUS_ERROR(ret)) {
14609 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
14610 __func__, ret, pdev_id);
14611 wmi_buf_free(buf);
14612 return QDF_STATUS_E_FAILURE;
14613 }
14614
14615 return QDF_STATUS_SUCCESS;
14616}
14617
14618/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014619 * init_cmd_send_tlv() - send initialization cmd to fw
14620 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014621 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053014622 *
14623 * Return: QDF_STATUS_SUCCESS for success or error code
14624 */
14625static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053014626 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053014627{
14628 wmi_buf_t buf;
14629 wmi_init_cmd_fixed_param *cmd;
14630 wmi_abi_version my_vers;
14631 int num_whitelist;
14632 uint8_t *buf_ptr;
14633 wmi_resource_config *resource_cfg;
14634 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053014635 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053014636 uint16_t idx;
14637 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053014638 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053014639
Kiran Venkatappa26117052016-12-23 19:58:54 +053014640 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
14641 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053014642 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053014643
14644 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
14645 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14646 WMI_TLV_HDR_SIZE +
14647 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
14648
14649 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053014650 if (!buf) {
14651 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14652 return QDF_STATUS_E_FAILURE;
14653 }
14654
14655 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14656 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
14657 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
14658
14659 host_mem_chunks = (wlan_host_memory_chunk *)
14660 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
14661 + WMI_TLV_HDR_SIZE);
14662
14663 WMITLV_SET_HDR(&cmd->tlv_header,
14664 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
14665 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
14666
Kiran Venkatappa26117052016-12-23 19:58:54 +053014667 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053014668 WMITLV_SET_HDR(&resource_cfg->tlv_header,
14669 WMITLV_TAG_STRUC_wmi_resource_config,
14670 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
14671
Kiran Venkatappa26117052016-12-23 19:58:54 +053014672 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053014673 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
14674 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
14675 WMITLV_GET_STRUCT_TLVLEN
14676 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053014677 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
14678 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
14679 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014680 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
14681 idx, host_mem_chunks[idx].size,
14682 host_mem_chunks[idx].ptr);
14683 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053014684 cmd->num_host_mem_chunks = param->num_mem_chunks;
14685 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
14686
Govind Singhe7f2f342016-05-23 12:12:52 +053014687 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
14688 WMITLV_TAG_ARRAY_STRUC,
14689 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053014690 param->num_mem_chunks));
14691
14692 /* Fill hw mode id config */
14693 buf_ptr = copy_hw_mode_in_init_cmd(buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053014694
14695 num_whitelist = sizeof(version_whitelist) /
14696 sizeof(wmi_whitelist_version_info);
14697 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
14698 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
14699 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
14700 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
14701 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
14702 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
14703
Govind Singh87542482016-06-08 19:40:11 +053014704#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014705 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
14706 &my_vers,
14707 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
14708 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053014709#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053014710 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
14711 __func__,
14712 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
14713 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
14714 cmd->host_abi_vers.abi_version_ns_0,
14715 cmd->host_abi_vers.abi_version_ns_1,
14716 cmd->host_abi_vers.abi_version_ns_2,
14717 cmd->host_abi_vers.abi_version_ns_3);
14718
14719 /* Save version sent from host -
14720 * Will be used to check ready event
14721 */
Govind Singh87542482016-06-08 19:40:11 +053014722#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014723 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
14724 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053014725#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053014726 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
14727 if (QDF_IS_STATUS_ERROR(ret)) {
14728 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
14729 ret);
14730 wmi_buf_free(buf);
14731 }
14732 return ret;
14733
Govind Singhe7f2f342016-05-23 12:12:52 +053014734}
14735
14736/**
14737 * save_service_bitmap_tlv() - save service bitmap
14738 * @wmi_handle: wmi handle
14739 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080014740 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053014741 *
14742 * Return: None
14743 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014744#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014745static
Rajeev Kumar77901472017-02-12 02:12:17 -080014746void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
14747 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053014748{
14749 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14750 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14751
14752 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
14753 param_buf->wmi_service_bitmap,
14754 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080014755
14756 if (bitmap_buf)
14757 qdf_mem_copy(bitmap_buf,
14758 param_buf->wmi_service_bitmap,
14759 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053014760}
14761#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014762static
Rajeev Kumar77901472017-02-12 02:12:17 -080014763void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
14764 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053014765{
Rajeev Kumar77901472017-02-12 02:12:17 -080014766 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14767 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053014768
Rajeev Kumar77901472017-02-12 02:12:17 -080014769 if (bitmap_buf)
14770 qdf_mem_copy(bitmap_buf,
14771 param_buf->wmi_service_bitmap,
14772 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
14773}
Govind Singhe7f2f342016-05-23 12:12:52 +053014774#endif
14775
14776/**
14777 * is_service_enabled_tlv() - Check if service enabled
14778 * @param wmi_handle: wmi handle
14779 * @param service_id: service identifier
14780 *
14781 * Return: 1 enabled, 0 disabled
14782 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014783#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014784static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
14785 uint32_t service_id)
14786{
14787 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
14788 service_id);
14789}
14790#else
14791static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
14792 uint32_t service_id)
14793{
14794 return false;
14795}
14796#endif
14797
14798/**
14799 * extract_service_ready_tlv() - extract service ready event
14800 * @wmi_handle: wmi handle
14801 * @param evt_buf: pointer to received event buffer
14802 * @param cap: pointer to hold target capability information extracted from even
14803 *
14804 * Return: QDF_STATUS_SUCCESS for success or error code
14805 */
14806static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014807 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053014808{
14809 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14810 wmi_service_ready_event_fixed_param *ev;
14811
14812
14813 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14814
14815 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14816 if (!ev) {
14817 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14818 return QDF_STATUS_E_FAILURE;
14819 }
14820
14821 cap->phy_capability = ev->phy_capability;
14822 cap->max_frag_entry = ev->max_frag_entry;
14823 cap->num_rf_chains = ev->num_rf_chains;
14824 cap->ht_cap_info = ev->ht_cap_info;
14825 cap->vht_cap_info = ev->vht_cap_info;
14826 cap->vht_supp_mcs = ev->vht_supp_mcs;
14827 cap->hw_min_tx_power = ev->hw_min_tx_power;
14828 cap->hw_max_tx_power = ev->hw_max_tx_power;
14829 cap->sys_cap_info = ev->sys_cap_info;
14830 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
14831 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
14832 cap->max_num_scan_channels = ev->max_num_scan_channels;
14833 cap->max_supported_macs = ev->max_supported_macs;
14834 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
14835 cap->txrx_chainmask = ev->txrx_chainmask;
14836 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
14837 cap->num_msdu_desc = ev->num_msdu_desc;
14838
14839 return QDF_STATUS_SUCCESS;
14840}
14841
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014842/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
14843 * to host internal WMI_HOST_REGDMN_MODE values.
14844 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
14845 * host currently. Add this in the future if required.
14846 * 11AX (Phase II) : 11ax related values are not currently
14847 * advertised separately by FW. As part of phase II regulatory bring-up,
14848 * finalize the advertisement mechanism.
14849 * @target_wireless_mode: target wireless mode received in message
14850 *
14851 * Return: returns the host internal wireless mode.
14852 */
14853static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
14854{
14855
14856 uint32_t wireless_modes = 0;
14857
14858 if (target_wireless_mode & REGDMN_MODE_11A)
14859 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
14860
14861 if (target_wireless_mode & REGDMN_MODE_TURBO)
14862 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
14863
14864 if (target_wireless_mode & REGDMN_MODE_11B)
14865 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
14866
14867 if (target_wireless_mode & REGDMN_MODE_PUREG)
14868 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
14869
14870 if (target_wireless_mode & REGDMN_MODE_11G)
14871 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
14872
14873 if (target_wireless_mode & REGDMN_MODE_108G)
14874 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
14875
14876 if (target_wireless_mode & REGDMN_MODE_108A)
14877 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
14878
14879 if (target_wireless_mode & REGDMN_MODE_XR)
14880 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
14881
14882 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
14883 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
14884
14885 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
14886 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
14887
14888 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
14889 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
14890
14891 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
14892 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
14893
14894 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
14895 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
14896
14897 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
14898 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
14899
14900 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
14901 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
14902
14903 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
14904 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
14905
14906 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
14907 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
14908
14909 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
14910 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
14911
14912 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
14913 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
14914
14915 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
14916 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
14917
14918 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
14919 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
14920
14921 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
14922 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
14923
14924 return wireless_modes;
14925}
14926
Govind Singhe7f2f342016-05-23 12:12:52 +053014927/**
14928 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
14929 * @wmi_handle: wmi handle
14930 * @param evt_buf: Pointer to event buffer
14931 * @param cap: pointer to hold HAL reg capabilities
14932 *
14933 * Return: QDF_STATUS_SUCCESS for success or error code
14934 */
14935static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014936 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053014937{
14938 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14939
14940 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14941
14942 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
14943 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080014944 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053014945
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014946 cap->wireless_modes = convert_wireless_modes_tlv(
14947 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053014948
Govind Singhe7f2f342016-05-23 12:12:52 +053014949 return QDF_STATUS_SUCCESS;
14950}
14951
14952/**
14953 * extract_host_mem_req_tlv() - Extract host memory request event
14954 * @wmi_handle: wmi handle
14955 * @param evt_buf: pointer to event buffer
14956 * @param num_entries: pointer to hold number of entries requested
14957 *
14958 * Return: Number of entries requested
14959 */
14960static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
14961 void *evt_buf, uint8_t *num_entries)
14962{
14963 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14964 wmi_service_ready_event_fixed_param *ev;
14965
14966 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14967
14968 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14969 if (!ev) {
14970 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14971 return NULL;
14972 }
14973
14974 *num_entries = ev->num_mem_reqs;
14975
14976 return (host_mem_req *)param_buf->mem_reqs;
14977}
14978
14979/**
14980 * save_fw_version_in_service_ready_tlv() - Save fw version in service
14981 * ready function
14982 * @wmi_handle: wmi handle
14983 * @param evt_buf: pointer to event buffer
14984 *
14985 * Return: QDF_STATUS_SUCCESS for success or error code
14986 */
14987static QDF_STATUS
14988save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
14989{
14990 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14991 wmi_service_ready_event_fixed_param *ev;
14992
14993
14994 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14995
14996 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14997 if (!ev) {
14998 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14999 return QDF_STATUS_E_FAILURE;
15000 }
15001
Govind Singh87542482016-06-08 19:40:11 +053015002#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015003 /*Save fw version from service ready message */
15004 /*This will be used while sending INIT message */
15005 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15006 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015007#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015008 return QDF_STATUS_SUCCESS;
15009}
15010
15011/**
15012 * ready_extract_init_status_tlv() - Extract init status from ready event
15013 * @wmi_handle: wmi handle
15014 * @param evt_buf: Pointer to event buffer
15015 *
15016 * Return: ready status
15017 */
15018static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15019 void *evt_buf)
15020{
15021 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15022 wmi_ready_event_fixed_param *ev = NULL;
15023
15024
15025 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15026 ev = param_buf->fixed_param;
15027
15028 qdf_print("%s:%d\n", __func__, ev->status);
15029
15030 return ev->status;
15031}
15032
15033/**
15034 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15035 * @wmi_handle: wmi handle
15036 * @param evt_buf: pointer to event buffer
15037 * @param macaddr: Pointer to hold MAC address
15038 *
15039 * Return: QDF_STATUS_SUCCESS for success or error code
15040 */
15041static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15042 void *evt_buf, uint8_t *macaddr)
15043{
15044 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15045 wmi_ready_event_fixed_param *ev = NULL;
15046
15047
15048 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15049 ev = param_buf->fixed_param;
15050
15051 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
15052
15053 return QDF_STATUS_SUCCESS;
15054}
15055
15056/**
15057 * extract_dbglog_data_len_tlv() - extract debuglog data length
15058 * @wmi_handle: wmi handle
15059 * @param evt_buf: pointer to event buffer
15060 *
15061 * Return: length
15062 */
15063static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080015064 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053015065{
15066 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
15067
15068 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
15069
15070 *len = param_buf->num_bufp;
15071
15072 return param_buf->bufp;
15073}
15074
15075/**
15076 * extract_vdev_start_resp_tlv() - extract vdev start response
15077 * @wmi_handle: wmi handle
15078 * @param evt_buf: pointer to event buffer
15079 * @param vdev_rsp: Pointer to hold vdev response
15080 *
15081 * Return: QDF_STATUS_SUCCESS for success or error code
15082 */
15083static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15084 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15085{
15086 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15087 wmi_vdev_start_response_event_fixed_param *ev;
15088
15089 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15090 if (!param_buf) {
15091 qdf_print("Invalid start response event buffer\n");
15092 return QDF_STATUS_E_INVAL;
15093 }
15094
15095 ev = param_buf->fixed_param;
15096 if (!ev) {
15097 qdf_print("Invalid start response event buffer\n");
15098 return QDF_STATUS_E_INVAL;
15099 }
15100
15101 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15102
15103 vdev_rsp->vdev_id = ev->vdev_id;
15104 vdev_rsp->requestor_id = ev->requestor_id;
15105 vdev_rsp->resp_type = ev->resp_type;
15106 vdev_rsp->status = ev->status;
15107 vdev_rsp->chain_mask = ev->chain_mask;
15108 vdev_rsp->smps_mode = ev->smps_mode;
15109 vdev_rsp->mac_id = ev->mac_id;
15110 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15111 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15112
15113 return QDF_STATUS_SUCCESS;
15114}
15115
15116/**
15117 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
15118 * @wmi_handle: wmi handle
15119 * @param evt_buf: pointer to event buffer
15120 * @param vdev_map: Pointer to hold vdev map
15121 * @param tbttoffset_list: Pointer to tbtt offset list
15122 *
15123 * Return: QDF_STATUS_SUCCESS for success or error code
15124 */
15125static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
15126 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
15127{
15128 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15129 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15130
15131 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15132 if (!param_buf) {
15133 qdf_print("Invalid tbtt update event buffer\n");
15134 return QDF_STATUS_E_INVAL;
15135 }
15136 tbtt_offset_event = param_buf->fixed_param;
15137
15138 *vdev_map = tbtt_offset_event->vdev_map;
15139 *tbttoffset_list = param_buf->tbttoffset_list;
15140
15141 return QDF_STATUS_SUCCESS;
15142}
15143
15144/**
15145 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15146 * @wmi_handle: wmi handle
15147 * @param evt_buf: pointer to event buffer
15148 * @param hdr: Pointer to hold header
15149 * @param bufp: Pointer to hold pointer to rx param buffer
15150 *
15151 * Return: QDF_STATUS_SUCCESS for success or error code
15152 */
15153static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015154 void *evt_buf, struct mgmt_rx_event_params *hdr,
15155 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015156{
15157 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15158 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15159
15160 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15161 if (!param_tlvs) {
15162 WMI_LOGE("Get NULL point message from FW");
15163 return QDF_STATUS_E_INVAL;
15164 }
15165
15166 ev_hdr = param_tlvs->hdr;
15167 if (!hdr) {
15168 WMI_LOGE("Rx event is NULL");
15169 return QDF_STATUS_E_INVAL;
15170 }
15171
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053015172 hdr->pdev_id = ev_hdr->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053015173
15174 hdr->channel = ev_hdr->channel;
15175 hdr->snr = ev_hdr->snr;
15176 hdr->rate = ev_hdr->rate;
15177 hdr->phy_mode = ev_hdr->phy_mode;
15178 hdr->buf_len = ev_hdr->buf_len;
15179 hdr->status = ev_hdr->status;
15180 hdr->flags = ev_hdr->flags;
15181 hdr->rssi = ev_hdr->rssi;
15182 hdr->tsf_delta = ev_hdr->tsf_delta;
15183 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15184
15185 *bufp = param_tlvs->bufp;
15186
15187 return QDF_STATUS_SUCCESS;
15188}
15189
15190/**
15191 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15192 * @wmi_handle: wmi handle
15193 * @param evt_buf: pointer to event buffer
15194 * @param vdev_id: Pointer to hold vdev identifier
15195 *
15196 * Return: QDF_STATUS_SUCCESS for success or error code
15197 */
15198static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15199 void *evt_buf, uint32_t *vdev_id)
15200{
15201 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15202 wmi_vdev_stopped_event_fixed_param *resp_event;
15203
15204 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15205 if (!param_buf) {
15206 WMI_LOGE("Invalid event buffer");
15207 return QDF_STATUS_E_INVAL;
15208 }
15209 resp_event = param_buf->fixed_param;
15210 *vdev_id = resp_event->vdev_id;
15211
15212 return QDF_STATUS_SUCCESS;
15213}
15214
15215/**
15216 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
15217 * @wmi_handle: wmi handle
15218 * @param evt_buf: pointer to event buffer
15219 * @param param: Pointer to hold roam param
15220 *
15221 * Return: QDF_STATUS_SUCCESS for success or error code
15222 */
15223static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
15224 void *evt_buf, wmi_host_roam_event *param)
15225{
15226 WMI_ROAM_EVENTID_param_tlvs *param_buf;
15227 wmi_roam_event_fixed_param *evt;
15228
15229 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
15230 if (!param_buf) {
15231 WMI_LOGE("Invalid roam event buffer");
15232 return QDF_STATUS_E_INVAL;
15233 }
15234
15235 evt = param_buf->fixed_param;
15236 qdf_mem_zero(param, sizeof(*param));
15237
15238 param->vdev_id = evt->vdev_id;
15239 param->reason = evt->reason;
15240 param->rssi = evt->rssi;
15241
15242 return QDF_STATUS_SUCCESS;
15243}
15244
15245/**
15246 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
15247 * @wmi_handle: wmi handle
15248 * @param evt_buf: pointer to event buffer
15249 * @param param: Pointer to hold vdev scan param
15250 *
15251 * Return: QDF_STATUS_SUCCESS for success or error code
15252 */
15253static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015254 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015255{
15256 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
15257 wmi_scan_event_fixed_param *evt = NULL;
15258
15259 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
15260 evt = param_buf->fixed_param;
15261
15262 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015263
Govind Singhe7f2f342016-05-23 12:12:52 +053015264 switch (evt->event) {
15265 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015266 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015267 break;
15268 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015269 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015270 break;
15271 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015272 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015273 break;
15274 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015275 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015276 break;
15277 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015278 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015279 break;
15280 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015281 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015282 break;
15283 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015284 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015285 break;
15286 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015287 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015288 break;
15289 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015290 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015291 break;
15292 case WMI_SCAN_EVENT_MAX:
15293 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015294 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015295 break;
15296 };
15297
15298 switch (evt->reason) {
15299 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015300 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015301 break;
15302 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015303 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015304 break;
15305 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015306 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015307 break;
15308 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015309 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015310 break;
15311 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015312 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015313 break;
15314 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015315 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015316 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015317 case WMI_SCAN_REASON_SUSPENDED:
15318 param->reason = SCAN_REASON_SUSPENDED;
15319 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015320 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015321 param->reason = SCAN_REASON_MAX;
15322 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015323 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015324 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015325 break;
15326 };
15327
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015328 param->chan_freq = evt->channel_freq;
15329 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053015330 param->scan_id = evt->scan_id;
15331 param->vdev_id = evt->vdev_id;
15332
15333 return QDF_STATUS_SUCCESS;
15334}
15335
15336/**
15337 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
15338 * @wmi_handle: wmi handle
15339 * @param evt_buf: pointer to event buffer
15340 * @param param: Pointer to hold MGMT TX completion params
15341 *
15342 * Return: QDF_STATUS_SUCCESS for success or error code
15343 */
15344static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
15345 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
15346{
15347 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
15348 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
15349
15350 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
15351 evt_buf;
15352 if (!param_buf) {
15353 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
15354 return QDF_STATUS_E_INVAL;
15355 }
15356 cmpl_params = param_buf->fixed_param;
15357
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053015358 param->pdev_id = cmpl_params->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053015359 param->desc_id = cmpl_params->desc_id;
15360 param->status = cmpl_params->status;
15361
15362 return QDF_STATUS_SUCCESS;
15363}
15364
15365/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053015366 * extract_offchan_data_tx_compl_param_tlv() -
15367 * extract Offchan data tx completion event params
15368 * @wmi_handle: wmi handle
15369 * @param evt_buf: pointer to event buffer
15370 * @param param: Pointer to hold offchan data TX completion params
15371 *
15372 * Return: QDF_STATUS_SUCCESS for success or error code
15373 */
15374static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
15375 wmi_unified_t wmi_handle, void *evt_buf,
15376 struct wmi_host_offchan_data_tx_compl_event *param)
15377{
15378 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
15379 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
15380
15381 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
15382 evt_buf;
15383 if (!param_buf) {
15384 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
15385 return QDF_STATUS_E_INVAL;
15386 }
15387 cmpl_params = param_buf->fixed_param;
15388
15389 param->pdev_id = cmpl_params->pdev_id;
15390 param->desc_id = cmpl_params->desc_id;
15391 param->status = cmpl_params->status;
15392
15393 return QDF_STATUS_SUCCESS;
15394}
15395
15396/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015397 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
15398 * status tlv
15399 * @wmi_handle: wmi handle
15400 * @param evt_buf: pointer to event buffer
15401 * @param param: Pointer to hold csa switch count status event param
15402 *
15403 * Return: QDF_STATUS_SUCCESS for success or error code
15404 */
15405static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
15406 wmi_unified_t wmi_handle,
15407 void *evt_buf,
15408 struct pdev_csa_switch_count_status *param)
15409{
15410 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
15411 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
15412
15413 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
15414 evt_buf;
15415 if (!param_buf) {
15416 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
15417 return QDF_STATUS_E_INVAL;
15418 }
15419
15420 csa_status = param_buf->fixed_param;
15421
15422 param->pdev_id = csa_status->pdev_id;
15423 param->current_switch_count = csa_status->current_switch_count;
15424 param->num_vdevs = csa_status->num_vdevs;
15425 param->vdev_ids = param_buf->vdev_ids;
15426
15427 return QDF_STATUS_SUCCESS;
15428}
15429
15430/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015431 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
15432 * @wmi_handle: wmi handle
15433 * @param evt_buf: pointer to event buffer
15434 * @param vdev_map: Pointer to hold vdev map
15435 *
15436 * Return: QDF_STATUS_SUCCESS for success or error code
15437 */
15438static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
15439 void *evt_buf, uint32_t *vdev_map)
15440{
15441 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15442 wmi_host_swba_event_fixed_param *swba_event;
15443
15444 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15445 if (!param_buf) {
15446 WMI_LOGE("Invalid swba event buffer");
15447 return QDF_STATUS_E_INVAL;
15448 }
15449 swba_event = param_buf->fixed_param;
15450 *vdev_map = swba_event->vdev_map;
15451
15452 return QDF_STATUS_SUCCESS;
15453}
15454
15455/**
15456 * extract_swba_tim_info_tlv() - extract swba tim info from event
15457 * @wmi_handle: wmi handle
15458 * @param evt_buf: pointer to event buffer
15459 * @param idx: Index to bcn info
15460 * @param tim_info: Pointer to hold tim info
15461 *
15462 * Return: QDF_STATUS_SUCCESS for success or error code
15463 */
15464static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
15465 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
15466{
15467 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15468 wmi_tim_info *tim_info_ev;
15469
15470 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15471 if (!param_buf) {
15472 WMI_LOGE("Invalid swba event buffer");
15473 return QDF_STATUS_E_INVAL;
15474 }
15475
15476 tim_info_ev = &param_buf->tim_info[idx];
15477
15478 tim_info->tim_len = tim_info_ev->tim_len;
15479 tim_info->tim_mcast = tim_info_ev->tim_mcast;
15480 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
15481 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
15482 tim_info->tim_changed = tim_info_ev->tim_changed;
15483 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
15484
15485 return QDF_STATUS_SUCCESS;
15486}
15487
15488/**
15489 * extract_swba_noa_info_tlv() - extract swba NoA information from event
15490 * @wmi_handle: wmi handle
15491 * @param evt_buf: pointer to event buffer
15492 * @param idx: Index to bcn info
15493 * @param p2p_desc: Pointer to hold p2p NoA info
15494 *
15495 * Return: QDF_STATUS_SUCCESS for success or error code
15496 */
15497static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
15498 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
15499{
15500 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15501 wmi_p2p_noa_info *p2p_noa_info;
15502 uint8_t i = 0;
15503
15504 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15505 if (!param_buf) {
15506 WMI_LOGE("Invalid swba event buffer");
15507 return QDF_STATUS_E_INVAL;
15508 }
15509
15510 p2p_noa_info = &param_buf->p2p_noa_info[idx];
15511
15512 p2p_desc->modified = false;
15513 p2p_desc->num_descriptors = 0;
15514 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
15515 p2p_desc->modified = true;
15516 p2p_desc->index =
15517 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
15518 p2p_desc->oppPS =
15519 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
15520 p2p_desc->ctwindow =
15521 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
15522 p2p_desc->num_descriptors =
15523 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
15524 (p2p_noa_info);
15525 for (i = 0; i < p2p_desc->num_descriptors; i++) {
15526 p2p_desc->noa_descriptors[i].type_count =
15527 (uint8_t) p2p_noa_info->noa_descriptors[i].
15528 type_count;
15529 p2p_desc->noa_descriptors[i].duration =
15530 p2p_noa_info->noa_descriptors[i].duration;
15531 p2p_desc->noa_descriptors[i].interval =
15532 p2p_noa_info->noa_descriptors[i].interval;
15533 p2p_desc->noa_descriptors[i].start_time =
15534 p2p_noa_info->noa_descriptors[i].start_time;
15535 }
15536 }
15537
15538 return QDF_STATUS_SUCCESS;
15539}
15540
Wu Gaocd3a8512017-03-13 20:17:34 +080015541#ifdef CONVERGED_P2P_ENABLE
15542/**
15543 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
15544 * @wmi_handle: wmi handle
15545 * @param evt_buf: pointer to event buffer
15546 * @param param: Pointer to hold p2p noa info
15547 *
15548 * Return: QDF_STATUS_SUCCESS for success or error code
15549 */
15550static QDF_STATUS extract_p2p_noa_ev_param_tlv(
15551 wmi_unified_t wmi_handle, void *evt_buf,
15552 struct p2p_noa_info *param)
15553{
15554 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
15555 wmi_p2p_noa_event_fixed_param *fixed_param;
15556 uint8_t i;
15557 wmi_p2p_noa_info *wmi_noa_info;
15558 uint8_t *buf_ptr;
15559 uint32_t descriptors;
15560
15561 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
15562 if (!param_tlvs) {
15563 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
15564 return QDF_STATUS_E_INVAL;
15565 }
15566
15567 if (!param) {
15568 WMI_LOGE("noa information param is null");
15569 return QDF_STATUS_E_INVAL;
15570 }
15571
15572 fixed_param = param_tlvs->fixed_param;
15573 buf_ptr = (uint8_t *) fixed_param;
15574 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
15575 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
15576
15577 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
15578 WMI_LOGE("%s: noa attr is not modified", __func__);
15579 return QDF_STATUS_E_INVAL;
15580 }
15581
15582 param->vdev_id = fixed_param->vdev_id;
15583 param->index =
15584 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
15585 param->opps_ps =
15586 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
15587 param->ct_window =
15588 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
15589 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
15590 param->num_desc = (uint8_t) descriptors;
15591
15592 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
15593 param->index, param->opps_ps, param->ct_window,
15594 param->num_desc);
15595 for (i = 0; i < param->num_desc; i++) {
15596 param->noa_desc[i].type_count =
15597 (uint8_t) wmi_noa_info->noa_descriptors[i].
15598 type_count;
15599 param->noa_desc[i].duration =
15600 wmi_noa_info->noa_descriptors[i].duration;
15601 param->noa_desc[i].interval =
15602 wmi_noa_info->noa_descriptors[i].interval;
15603 param->noa_desc[i].start_time =
15604 wmi_noa_info->noa_descriptors[i].start_time;
15605 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
15606 __func__, i, param->noa_desc[i].type_count,
15607 param->noa_desc[i].duration,
15608 param->noa_desc[i].interval,
15609 param->noa_desc[i].start_time);
15610 }
15611
15612 return QDF_STATUS_SUCCESS;
15613}
15614
15615/**
15616 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
15617 * information from event
15618 * @wmi_handle: wmi handle
15619 * @param evt_buf: pointer to event buffer
15620 * @param param: Pointer to hold p2p lo stop event information
15621 *
15622 * Return: QDF_STATUS_SUCCESS for success or error code
15623 */
15624static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
15625 wmi_unified_t wmi_handle, void *evt_buf,
15626 struct p2p_lo_event *param)
15627{
15628 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
15629 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
15630
15631 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
15632 evt_buf;
15633 if (!param_tlvs) {
15634 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
15635 return QDF_STATUS_E_INVAL;
15636 }
15637
15638 if (!param) {
15639 WMI_LOGE("lo stop event param is null");
15640 return QDF_STATUS_E_INVAL;
15641 }
15642
15643 lo_param = param_tlvs->fixed_param;
15644 param->vdev_id = lo_param->vdev_id;
15645 param->reason_code = lo_param->reason;
15646 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
15647 param->vdev_id, param->reason_code);
15648
15649 return QDF_STATUS_SUCCESS;
15650}
15651#endif /* End of CONVERGED_P2P_ENABLE */
15652
Govind Singhe7f2f342016-05-23 12:12:52 +053015653/**
15654 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
15655 * @wmi_handle: wmi handle
15656 * @param evt_buf: pointer to event buffer
15657 * @param ev: Pointer to hold peer param
15658 *
15659 * Return: QDF_STATUS_SUCCESS for success or error code
15660 */
15661static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
15662 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
15663{
15664 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
15665 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
15666
15667 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
15668 kickout_event = param_buf->fixed_param;
15669
15670 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
15671 ev->peer_macaddr);
15672
15673 ev->reason = kickout_event->reason;
15674 ev->rssi = kickout_event->rssi;
15675
15676 return QDF_STATUS_SUCCESS;
15677}
15678
15679/**
15680 * extract_all_stats_counts_tlv() - extract all stats count from event
15681 * @wmi_handle: wmi handle
15682 * @param evt_buf: pointer to event buffer
15683 * @param stats_param: Pointer to hold stats count
15684 *
15685 * Return: QDF_STATUS_SUCCESS for success or error code
15686 */
15687static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
15688 void *evt_buf, wmi_host_stats_event *stats_param)
15689{
15690 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15691 wmi_stats_event_fixed_param *ev;
15692
15693 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15694
15695 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15696 if (!ev) {
15697 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
15698 return QDF_STATUS_E_FAILURE;
15699 }
15700
15701 switch (ev->stats_id) {
15702 case WMI_REQUEST_PEER_STAT:
15703 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
15704 break;
15705
15706 case WMI_REQUEST_AP_STAT:
15707 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
15708 break;
15709
15710 case WMI_REQUEST_PDEV_STAT:
15711 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
15712 break;
15713
15714 case WMI_REQUEST_VDEV_STAT:
15715 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
15716 break;
15717
15718 case WMI_REQUEST_BCNFLT_STAT:
15719 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
15720 break;
15721
15722 case WMI_REQUEST_VDEV_RATE_STAT:
15723 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
15724 break;
15725
15726 default:
15727 stats_param->stats_id = 0;
15728 break;
15729
15730 }
15731
15732 stats_param->num_pdev_stats = ev->num_pdev_stats;
15733 stats_param->num_pdev_ext_stats = 0;
15734 stats_param->num_vdev_stats = ev->num_vdev_stats;
15735 stats_param->num_peer_stats = ev->num_peer_stats;
15736 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
15737 stats_param->num_chan_stats = ev->num_chan_stats;
15738
15739 return QDF_STATUS_SUCCESS;
15740}
15741
15742/**
15743 * extract_pdev_stats_tlv() - extract pdev stats from event
15744 * @wmi_handle: wmi handle
15745 * @param evt_buf: pointer to event buffer
15746 * @param index: Index into pdev stats
15747 * @param pdev_stats: Pointer to hold pdev stats
15748 *
15749 * Return: QDF_STATUS_SUCCESS for success or error code
15750 */
15751static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
15752 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
15753{
15754 return QDF_STATUS_SUCCESS;
15755}
15756
15757/**
15758 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
15759 * @wmi_handle: wmi handle
15760 * @param evt_buf: pointer to event buffer
15761 * @param index: Index into extended pdev stats
15762 * @param pdev_ext_stats: Pointer to hold extended pdev stats
15763 *
15764 * Return: QDF_STATUS_SUCCESS for success or error code
15765 */
15766static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
15767 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
15768{
15769 return QDF_STATUS_SUCCESS;
15770}
15771
15772/**
15773 * extract_vdev_stats_tlv() - extract vdev stats from event
15774 * @wmi_handle: wmi handle
15775 * @param evt_buf: pointer to event buffer
15776 * @param index: Index into vdev stats
15777 * @param vdev_stats: Pointer to hold vdev stats
15778 *
15779 * Return: QDF_STATUS_SUCCESS for success or error code
15780 */
15781static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
15782 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
15783{
15784 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15785 wmi_stats_event_fixed_param *ev_param;
15786 uint8_t *data;
15787
15788 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15789 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15790 data = (uint8_t *) param_buf->data;
15791
15792 if (index < ev_param->num_vdev_stats) {
15793 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
15794 ((ev_param->num_pdev_stats) *
15795 sizeof(wmi_pdev_stats)) +
15796 (index * sizeof(wmi_vdev_stats)));
15797
15798 vdev_stats->vdev_id = ev->vdev_id;
15799 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
15800 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
15801
15802 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
15803 sizeof(ev->tx_frm_cnt));
15804 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
15805 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
15806 ev->multiple_retry_cnt,
15807 sizeof(ev->multiple_retry_cnt));
15808 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
15809 sizeof(ev->fail_cnt));
15810 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
15811 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
15812 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
15813 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
15814 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
15815 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
15816 sizeof(ev->tx_rate_history));
15817 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
15818 sizeof(ev->bcn_rssi_history));
15819
15820 }
15821
15822 return QDF_STATUS_SUCCESS;
15823}
15824
15825/**
15826 * extract_peer_stats_tlv() - extract peer stats from event
15827 * @wmi_handle: wmi handle
15828 * @param evt_buf: pointer to event buffer
15829 * @param index: Index into peer stats
15830 * @param peer_stats: Pointer to hold peer stats
15831 *
15832 * Return: QDF_STATUS_SUCCESS for success or error code
15833 */
15834static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
15835 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
15836{
15837 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15838 wmi_stats_event_fixed_param *ev_param;
15839 uint8_t *data;
15840
15841 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15842 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15843 data = (uint8_t *) param_buf->data;
15844
15845 if (index < ev_param->num_peer_stats) {
15846 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
15847 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
15848 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
15849 (index * sizeof(wmi_peer_stats)));
15850
15851 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
15852
15853 OS_MEMCPY(&(peer_stats->peer_macaddr),
15854 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
15855
15856 peer_stats->peer_rssi = ev->peer_rssi;
15857 peer_stats->peer_tx_rate = ev->peer_tx_rate;
15858 peer_stats->peer_rx_rate = ev->peer_rx_rate;
15859 }
15860
15861 return QDF_STATUS_SUCCESS;
15862}
15863
15864/**
15865 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
15866 * @wmi_handle: wmi handle
15867 * @param evt_buf: pointer to event buffer
15868 * @param index: Index into bcn fault stats
15869 * @param bcnflt_stats: Pointer to hold bcn fault stats
15870 *
15871 * Return: QDF_STATUS_SUCCESS for success or error code
15872 */
15873static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
15874 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
15875{
15876 return QDF_STATUS_SUCCESS;
15877}
15878
15879/**
15880 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
15881 * @wmi_handle: wmi handle
15882 * @param evt_buf: pointer to event buffer
15883 * @param index: Index into extended peer stats
15884 * @param peer_extd_stats: Pointer to hold extended peer stats
15885 *
15886 * Return: QDF_STATUS_SUCCESS for success or error code
15887 */
15888static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
15889 void *evt_buf, uint32_t index,
15890 wmi_host_peer_extd_stats *peer_extd_stats)
15891{
15892 return QDF_STATUS_SUCCESS;
15893}
15894
15895/**
15896 * extract_chan_stats_tlv() - extract chan stats from event
15897 * @wmi_handle: wmi handle
15898 * @param evt_buf: pointer to event buffer
15899 * @param index: Index into chan stats
15900 * @param vdev_extd_stats: Pointer to hold chan stats
15901 *
15902 * Return: QDF_STATUS_SUCCESS for success or error code
15903 */
15904static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
15905 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
15906{
15907 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15908 wmi_stats_event_fixed_param *ev_param;
15909 uint8_t *data;
15910
15911 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15912 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15913 data = (uint8_t *) param_buf->data;
15914
15915 if (index < ev_param->num_chan_stats) {
15916 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
15917 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
15918 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
15919 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
15920 (index * sizeof(wmi_chan_stats)));
15921
15922
15923 /* Non-TLV doesnt have num_chan_stats */
15924 chan_stats->chan_mhz = ev->chan_mhz;
15925 chan_stats->sampling_period_us = ev->sampling_period_us;
15926 chan_stats->rx_clear_count = ev->rx_clear_count;
15927 chan_stats->tx_duration_us = ev->tx_duration_us;
15928 chan_stats->rx_duration_us = ev->rx_duration_us;
15929 }
15930
15931 return QDF_STATUS_SUCCESS;
15932}
15933
15934/**
15935 * extract_profile_ctx_tlv() - extract profile context from event
15936 * @wmi_handle: wmi handle
15937 * @param evt_buf: pointer to event buffer
15938 * @idx: profile stats index to extract
15939 * @param profile_ctx: Pointer to hold profile context
15940 *
15941 * Return: QDF_STATUS_SUCCESS for success or error code
15942 */
15943static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
15944 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
15945{
15946 return QDF_STATUS_SUCCESS;
15947}
15948
15949/**
15950 * extract_profile_data_tlv() - extract profile data from event
15951 * @wmi_handle: wmi handle
15952 * @param evt_buf: pointer to event buffer
15953 * @param profile_data: Pointer to hold profile data
15954 *
15955 * Return: QDF_STATUS_SUCCESS for success or error code
15956 */
15957static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
15958 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
15959{
15960
15961 return QDF_STATUS_SUCCESS;
15962}
15963
15964/**
15965 * extract_chan_info_event_tlv() - extract chan information from event
15966 * @wmi_handle: wmi handle
15967 * @param evt_buf: pointer to event buffer
15968 * @param chan_info: Pointer to hold chan information
15969 *
15970 * Return: QDF_STATUS_SUCCESS for success or error code
15971 */
15972static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
15973 void *evt_buf, wmi_host_chan_info_event *chan_info)
15974{
15975 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
15976 wmi_chan_info_event_fixed_param *ev;
15977
15978 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
15979
15980 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
15981 if (!ev) {
15982 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
15983 return QDF_STATUS_E_FAILURE;
15984 }
15985
15986 chan_info->err_code = ev->err_code;
15987 chan_info->freq = ev->freq;
15988 chan_info->cmd_flags = ev->cmd_flags;
15989 chan_info->noise_floor = ev->noise_floor;
15990 chan_info->rx_clear_count = ev->rx_clear_count;
15991 chan_info->cycle_count = ev->cycle_count;
15992
15993 return QDF_STATUS_SUCCESS;
15994}
15995
15996/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015997 * extract_pdev_utf_event_tlv() - extract UTF data info from event
15998 * @wmi_handle: WMI handle
15999 * @param evt_buf: Pointer to event buffer
16000 * @param param: Pointer to hold data
16001 *
16002 * Return : QDF_STATUS_SUCCESS for success or error code
16003 */
16004static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
16005 uint8_t *evt_buf,
16006 struct wmi_host_pdev_utf_event *event)
16007{
16008 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
16009
16010 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
16011 event->data = param_buf->data;
16012 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053016013 /* Set pdev_id=1 until FW adds support to include pdev_id */
16014 event->pdev_id = 1;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016015
16016 return QDF_STATUS_SUCCESS;
16017}
Govind Singhe7f2f342016-05-23 12:12:52 +053016018
Kiran Venkatappa06520822016-08-10 23:55:40 +053016019/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016020 * extract_chainmask_tables_tlv() - extract chain mask tables from event
16021 * @wmi_handle: wmi handle
16022 * @param evt_buf: pointer to event buffer
16023 * @param param: Pointer to hold evt buf
16024 *
16025 * Return: QDF_STATUS_SUCCESS for success or error code
16026 */
16027static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
16028 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
16029{
16030 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16031 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
16032 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16033 uint8_t i = 0, j = 0;
16034
16035 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16036 if (!param_buf)
16037 return QDF_STATUS_E_INVAL;
16038
16039 hw_caps = param_buf->soc_hw_mode_caps;
16040 if (!hw_caps)
16041 return QDF_STATUS_E_INVAL;
16042
16043 if (!hw_caps->num_chainmask_tables)
16044 return QDF_STATUS_E_INVAL;
16045
16046 chainmask_caps = param_buf->mac_phy_chainmask_caps;
16047
16048 if (chainmask_caps == NULL)
16049 return QDF_STATUS_E_INVAL;
16050
16051 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
16052
16053 qdf_print("Dumping chain mask combo data for table : %d\n", i);
16054 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
16055
16056 chainmask_table[i].cap_list[j].chainmask =
16057 chainmask_caps->chainmask;
16058
16059 chainmask_table[i].cap_list[j].supports_chan_width_20 =
16060 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
16061
16062 chainmask_table[i].cap_list[j].supports_chan_width_40 =
16063 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
16064
16065 chainmask_table[i].cap_list[j].supports_chan_width_80 =
16066 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
16067
16068 chainmask_table[i].cap_list[j].supports_chan_width_160 =
16069 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
16070
16071 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
16072 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
16073
16074 chainmask_table[i].cap_list[j].chain_mask_2G =
16075 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
16076
16077 chainmask_table[i].cap_list[j].chain_mask_5G =
16078 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
16079
16080 chainmask_table[i].cap_list[j].chain_mask_tx =
16081 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
16082
16083 chainmask_table[i].cap_list[j].chain_mask_rx =
16084 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
16085
16086 chainmask_table[i].cap_list[j].supports_aDFS =
16087 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
16088
16089 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
16090 chainmask_caps->supported_flags,
16091 chainmask_caps->chainmask
16092 );
16093 chainmask_caps++;
16094 }
16095 }
16096
16097 return QDF_STATUS_SUCCESS;
16098}
16099
16100/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053016101 * extract_service_ready_ext_tlv() - extract basic extended service ready params
16102 * from event
16103 * @wmi_handle: wmi handle
16104 * @param evt_buf: pointer to event buffer
16105 * @param param: Pointer to hold evt buf
16106 *
16107 * Return: QDF_STATUS_SUCCESS for success or error code
16108 */
16109static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016110 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016111{
16112 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16113 wmi_service_ready_ext_event_fixed_param *ev;
16114 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16115 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016116 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
16117 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016118
16119 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16120 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016121 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016122
16123 ev = param_buf->fixed_param;
16124 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016125 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016126
16127 /* Move this to host based bitmap */
16128 param->default_conc_scan_config_bits =
16129 ev->default_conc_scan_config_bits;
16130 param->default_fw_config_bits = ev->default_fw_config_bits;
16131 param->he_cap_info = ev->he_cap_info;
16132 param->mpdu_density = ev->mpdu_density;
16133 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
16134 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
16135
16136 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016137 if (hw_caps)
16138 param->num_hw_modes = hw_caps->num_hw_modes;
16139 else
16140 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016141
16142 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016143 if (reg_caps)
16144 param->num_phy = reg_caps->num_phy;
16145 else
16146 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016147
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016148 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
16149
16150 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
16151
16152 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
16153
16154 if (chain_mask_combo == NULL)
16155 return QDF_STATUS_SUCCESS;
16156
16157 qdf_print("Dumping chain mask combo data\n");
16158
16159 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
16160
16161 qdf_print("table_id : %d Num valid chainmasks: %d\n",
16162 chain_mask_combo->chainmask_table_id,
16163 chain_mask_combo->num_valid_chainmask
16164 );
16165
16166 param->chainmask_table[i].table_id =
16167 chain_mask_combo->chainmask_table_id;
16168 param->chainmask_table[i].num_valid_chainmasks =
16169 chain_mask_combo->num_valid_chainmask;
16170 chain_mask_combo++;
16171 }
16172 qdf_print("chain mask combo end\n");
16173
Kiran Venkatappa06520822016-08-10 23:55:40 +053016174 return QDF_STATUS_SUCCESS;
16175}
16176
16177/**
16178 * extract_hw_mode_cap_service_ready_ext_tlv() -
16179 * extract HW mode cap from service ready event
16180 * @wmi_handle: wmi handle
16181 * @param evt_buf: pointer to event buffer
16182 * @param param: Pointer to hold evt buf
16183 * @param hw_mode_idx: hw mode idx should be less than num_mode
16184 *
16185 * Return: QDF_STATUS_SUCCESS for success or error code
16186 */
16187static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
16188 wmi_unified_t wmi_handle,
16189 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016190 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016191{
16192 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16193 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16194
16195 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16196 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016197 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016198
16199 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016200 if (!hw_caps)
16201 return QDF_STATUS_E_INVAL;
16202
Kiran Venkatappa06520822016-08-10 23:55:40 +053016203 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016204 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016205
16206 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
16207 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
16208
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016209 param->hw_mode_config_type =
16210 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
16211
Kiran Venkatappa06520822016-08-10 23:55:40 +053016212 return QDF_STATUS_SUCCESS;
16213}
16214
16215/**
16216 * extract_mac_phy_cap_service_ready_ext_tlv() -
16217 * extract MAC phy cap from service ready event
16218 * @wmi_handle: wmi handle
16219 * @param evt_buf: pointer to event buffer
16220 * @param param: Pointer to hold evt buf
16221 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016222 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053016223 *
16224 * Return: QDF_STATUS_SUCCESS for success or error code
16225 */
16226static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
16227 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016228 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016229 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016230{
16231 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016232 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016233 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16234 uint32_t phy_map;
16235 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016236
16237 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16238 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016239 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016240
16241 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016242 if (!hw_caps)
16243 return QDF_STATUS_E_INVAL;
16244
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016245 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
16246 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
16247 break;
16248
16249 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
16250 while (phy_map) {
16251 phy_map >>= 1;
16252 phy_idx++;
16253 }
16254 }
16255
16256 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016257 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016258
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016259 phy_idx += phy_id;
16260 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016261 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016262
16263 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053016264
16265 param->hw_mode_id = mac_phy_caps->hw_mode_id;
16266 param->pdev_id = mac_phy_caps->pdev_id;
16267 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016268 param->supports_11b =
16269 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
16270 param->supports_11g =
16271 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
16272 param->supports_11a =
16273 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
16274 param->supports_11n =
16275 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
16276 param->supports_11ac =
16277 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
16278 param->supports_11ax =
16279 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016280
16281 param->supported_bands = mac_phy_caps->supported_bands;
16282 param->ampdu_density = mac_phy_caps->ampdu_density;
16283 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
16284 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
16285 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
16286 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
16287 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
16288 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
16289 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
16290 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
16291 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
16292 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
16293 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
16294 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
16295 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
16296 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
16297 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
16298 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080016299 qdf_mem_copy(&param->he_cap_phy_info_2G,
16300 &mac_phy_caps->he_cap_phy_info_2G,
16301 sizeof(param->he_cap_phy_info_2G));
16302 qdf_mem_copy(&param->he_cap_phy_info_5G,
16303 &mac_phy_caps->he_cap_phy_info_5G,
16304 sizeof(param->he_cap_phy_info_5G));
16305 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
16306 sizeof(param->he_ppet2G));
16307 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
16308 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016309 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016310
16311 return QDF_STATUS_SUCCESS;
16312}
16313
16314/**
16315 * extract_reg_cap_service_ready_ext_tlv() -
16316 * extract REG cap from service ready event
16317 * @wmi_handle: wmi handle
16318 * @param evt_buf: pointer to event buffer
16319 * @param param: Pointer to hold evt buf
16320 * @param phy_idx: phy idx should be less than num_mode
16321 *
16322 * Return: QDF_STATUS_SUCCESS for success or error code
16323 */
16324static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
16325 wmi_unified_t wmi_handle,
16326 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016327 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016328{
16329 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16330 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
16331 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
16332
16333 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16334 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016335 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016336
16337 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016338 if (!reg_caps)
16339 return QDF_STATUS_E_INVAL;
16340
Kiran Venkatappa06520822016-08-10 23:55:40 +053016341 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016342 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016343
16344 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
16345
16346 param->phy_id = ext_reg_cap->phy_id;
16347 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
16348 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
16349 param->regcap1 = ext_reg_cap->regcap1;
16350 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053016351 param->wireless_modes = convert_wireless_modes_tlv(
16352 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016353 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
16354 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
16355 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
16356 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
16357
16358 return QDF_STATUS_SUCCESS;
16359}
16360
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016361/**
16362 * extract_dcs_interference_type_tlv() - extract dcs interference type
16363 * from event
16364 * @wmi_handle: wmi handle
16365 * @param evt_buf: pointer to event buffer
16366 * @param param: Pointer to hold dcs interference param
16367 *
16368 * Return: 0 for success or error code
16369 */
16370static QDF_STATUS extract_dcs_interference_type_tlv(
16371 wmi_unified_t wmi_handle,
16372 void *evt_buf, struct wmi_host_dcs_interference_param *param)
16373{
16374 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16375
16376 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16377 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016378 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016379
16380 param->interference_type = param_buf->fixed_param->interference_type;
16381 param->pdev_id = param_buf->fixed_param->pdev_id;
16382
16383 return QDF_STATUS_SUCCESS;
16384}
16385
16386/*
16387 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
16388 * @wmi_handle: wmi handle
16389 * @param evt_buf: pointer to event buffer
16390 * @param cw_int: Pointer to hold cw interference
16391 *
16392 * Return: 0 for success or error code
16393 */
16394static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
16395 void *evt_buf,
16396 wmi_host_ath_dcs_cw_int *cw_int)
16397{
16398 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16399 wlan_dcs_cw_int *ev;
16400
16401 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16402 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016403 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016404
16405 ev = param_buf->cw_int;
16406
16407 cw_int->channel = ev->channel;
16408
16409 return QDF_STATUS_SUCCESS;
16410}
16411
16412/**
16413 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
16414 * @wmi_handle: wmi handle
16415 * @param evt_buf: pointer to event buffer
16416 * @param wlan_stat: Pointer to hold wlan stats
16417 *
16418 * Return: 0 for success or error code
16419 */
16420static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
16421 void *evt_buf,
16422 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
16423{
16424 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16425 wlan_dcs_im_tgt_stats_t *ev;
16426
16427 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16428 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016429 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016430
16431 ev = param_buf->wlan_stat;
16432 wlan_stat->reg_tsf32 = ev->reg_tsf32;
16433 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
16434 wlan_stat->tx_waste_time = ev->tx_waste_time;
16435 wlan_stat->rx_time = ev->rx_time;
16436 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
16437 wlan_stat->mib_stats.listen_time = ev->listen_time;
16438 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
16439 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
16440 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
16441 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
16442 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
16443 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
16444 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
16445 wlan_stat->chan_nf = ev->chan_nf;
16446 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
16447
16448 return QDF_STATUS_SUCCESS;
16449}
16450
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016451#ifdef BIG_ENDIAN_HOST
16452/**
16453 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
16454 * @param data_len - data length
16455 * @param data - pointer to data
16456 *
16457 * Return: QDF_STATUS - success or error status
16458 */
16459static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
16460{
16461 uint8_t *data_aligned = NULL;
16462 int c;
16463 unsigned char *data_unaligned;
16464
16465 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
16466 FIPS_ALIGN));
16467 /* Assigning unaligned space to copy the data */
16468 /* Checking if kmalloc does succesful allocation */
16469 if (data_unaligned == NULL)
16470 return QDF_STATUS_E_FAILURE;
16471
16472 /* Checking if space is alligned */
16473 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
16474 /* align the data space */
16475 data_aligned =
16476 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
16477 } else {
16478 data_aligned = (u_int8_t *)data_unaligned;
16479 }
16480
16481 /* memset and copy content from data to data aligned */
16482 OS_MEMSET(data_aligned, 0, data_len);
16483 OS_MEMCPY(data_aligned, data, data_len);
16484 /* Endianness to LE */
16485 for (c = 0; c < data_len/4; c++) {
16486 *((u_int32_t *)data_aligned + c) =
16487 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
16488 }
16489
16490 /* Copy content to event->data */
16491 OS_MEMCPY(data, data_aligned, data_len);
16492
16493 /* clean up allocated space */
16494 qdf_mem_free(data_unaligned);
16495 data_aligned = NULL;
16496 data_unaligned = NULL;
16497
16498 /*************************************************************/
16499
16500 return QDF_STATUS_SUCCESS;
16501}
16502#else
16503/**
16504 * fips_conv_data_be() - DUMMY for LE platform
16505 *
16506 * Return: QDF_STATUS - success
16507 */
16508static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
16509{
16510 return QDF_STATUS_SUCCESS;
16511}
16512#endif
16513
16514/**
16515 * extract_fips_event_data_tlv() - extract fips event data
16516 * @wmi_handle: wmi handle
16517 * @param evt_buf: pointer to event buffer
16518 * @param param: pointer FIPS event params
16519 *
16520 * Return: 0 for success or error code
16521 */
16522static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
16523 void *evt_buf, struct wmi_host_fips_event_param *param)
16524{
16525 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
16526 wmi_pdev_fips_event_fixed_param *event;
16527
16528 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
16529 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
16530
16531 if (fips_conv_data_be(event->data_len, param_buf->data) !=
16532 QDF_STATUS_SUCCESS)
16533 return QDF_STATUS_E_FAILURE;
16534
16535 param->data = (uint32_t *)param_buf->data;
16536 param->data_len = event->data_len;
16537 param->error_status = event->error_status;
Kiran Venkatappaaa075142017-03-30 15:22:50 +053016538 param->pdev_id = event->pdev_id;
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016539
16540 return QDF_STATUS_SUCCESS;
16541}
16542
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053016543/*
16544 * extract_peer_delete_response_event_tlv() - extract peer delete response event
16545 * @wmi_handle: wmi handle
16546 * @param evt_buf: pointer to event buffer
16547 * @param vdev_id: Pointer to hold vdev_id
16548 * @param mac_addr: Pointer to hold peer mac address
16549 *
16550 * Return: QDF_STATUS_SUCCESS for success or error code
16551 */
16552static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
16553 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
16554{
16555 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
16556 wmi_peer_delete_resp_event_fixed_param *ev;
16557
16558 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
16559
16560 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
16561 if (!ev) {
16562 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
16563 return QDF_STATUS_E_FAILURE;
16564 }
16565
16566 param->vdev_id = ev->vdev_id;
16567 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
16568 &param->mac_address.bytes[0]);
16569
16570 return QDF_STATUS_SUCCESS;
16571}
16572
Govind Singhecf03cd2016-05-12 12:45:51 +053016573static bool is_management_record_tlv(uint32_t cmd_id)
16574{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053016575 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053016576 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053016577
Govind Singhecf03cd2016-05-12 12:45:51 +053016578 return false;
16579}
16580
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053016581static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
16582{
16583 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
16584
16585 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
16586
16587 switch (set_cmd->param_id) {
16588 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
16589 case WMI_VDEV_PARAM_DTIM_POLICY:
16590 return HTC_TX_PACKET_TAG_AUTO_PM;
16591 default:
16592 break;
16593 }
16594
16595 return 0;
16596}
16597
16598static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
16599{
16600 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
16601
16602 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
16603
16604 switch (ps_cmd->param) {
16605 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
16606 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
16607 case WMI_STA_PS_ENABLE_QPOWER:
16608 return HTC_TX_PACKET_TAG_AUTO_PM;
16609 default:
16610 break;
16611 }
16612
16613 return 0;
16614}
16615
16616static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
16617 uint32_t cmd_id)
16618{
16619 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
16620 return 0;
16621
16622 switch (cmd_id) {
16623 case WMI_VDEV_SET_PARAM_CMDID:
16624 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
16625 case WMI_STA_POWERSAVE_PARAM_CMDID:
16626 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
16627 default:
16628 break;
16629 }
16630
16631 return 0;
16632}
16633
16634static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
16635{
16636 uint16_t tag = 0;
16637
16638 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
16639 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
16640 __func__);
16641 return tag;
16642 }
16643
16644 if (wmi_handle->tag_crash_inject)
16645 tag = HTC_TX_PACKET_TAG_AUTO_PM;
16646
16647 wmi_handle->tag_crash_inject = false;
16648 return tag;
16649}
16650
16651/**
16652 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
16653 * @wmi_handle: WMI handle
16654 * @buf: WMI buffer
16655 * @cmd_id: WMI command Id
16656 *
16657 * Return htc_tx_tag
16658 */
16659static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
16660 wmi_buf_t buf,
16661 uint32_t cmd_id)
16662{
16663 uint16_t htc_tx_tag = 0;
16664
16665 switch (cmd_id) {
16666 case WMI_WOW_ENABLE_CMDID:
16667 case WMI_PDEV_SUSPEND_CMDID:
16668 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
16669 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
16670 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
16671 case WMI_PDEV_RESUME_CMDID:
16672 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
16673 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
16674#ifdef FEATURE_WLAN_D0WOW
16675 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
16676#endif
16677 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
16678 break;
16679 case WMI_FORCE_FW_HANG_CMDID:
16680 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
16681 break;
16682 case WMI_VDEV_SET_PARAM_CMDID:
16683 case WMI_STA_POWERSAVE_PARAM_CMDID:
16684 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
16685 default:
16686 break;
16687 }
16688
16689 return htc_tx_tag;
16690}
16691
Sathish Kumard3ab1002017-02-07 17:10:59 +053016692/**
16693 * extract_channel_hopping_event_tlv() - extract channel hopping param
16694 * from event
16695 * @wmi_handle: wmi handle
16696 * @param evt_buf: pointer to event buffer
16697 * @param ch_hopping: Pointer to hold channel hopping param
16698 *
16699 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16700 */
16701static QDF_STATUS extract_channel_hopping_event_tlv(
16702 wmi_unified_t wmi_handle, void *evt_buf,
16703 wmi_host_pdev_channel_hopping_event *ch_hopping)
16704{
16705 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
16706 wmi_pdev_channel_hopping_event_fixed_param *event;
16707
16708 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
16709 event = (wmi_pdev_channel_hopping_event_fixed_param *)
16710 param_buf->fixed_param;
16711
16712 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
16713 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappaaa075142017-03-30 15:22:50 +053016714 ch_hopping->pdev_id = event->pdev_id;
Sathish Kumard3ab1002017-02-07 17:10:59 +053016715
16716 return QDF_STATUS_SUCCESS;
16717}
16718
16719/**
16720 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
16721 * @wmi_handle: wmi handle
16722 * @param evt_buf: pointer to event buffer
16723 * @param param: Pointer to hold tpc param
16724 *
16725 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16726 */
16727static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
16728 void *evt_buf,
16729 wmi_host_pdev_tpc_event *param)
16730{
16731 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
16732 wmi_pdev_tpc_event_fixed_param *event;
16733
16734 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
16735 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
16736
Kiran Venkatappaaa075142017-03-30 15:22:50 +053016737 param->pdev_id = event->pdev_id;
Sathish Kumard3ab1002017-02-07 17:10:59 +053016738 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
16739
16740 return QDF_STATUS_SUCCESS;
16741}
16742
16743
16744#ifdef BIG_ENDIAN_HOST
16745/**
16746 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
16747 * @param data_len - data length
16748 * @param data - pointer to data
16749 *
16750 * Return: QDF_STATUS - success or error status
16751 */
16752static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
16753{
16754 uint8_t *datap = (uint8_t *)ev;
16755 /* Skip swapping the first word */
16756 datap += sizeof(uint32_t);
16757 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
16758 i++, datap += sizeof(uint32_t)) {
16759 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
16760 }
16761
16762 return QDF_STATUS_SUCCESS;
16763}
16764#else
16765/**
16766 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
16767 * @param data_len - data length
16768 * @param data - pointer to data
16769 *
16770 * Return: QDF_STATUS - success or error status
16771 */
16772static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
16773{
16774 return QDF_STATUS_SUCCESS;
16775}
16776#endif
16777
16778/**
16779 * extract_wds_addr_event_tlv() - extract wds address from event
16780 * @wmi_handle: wmi handle
16781 * @param evt_buf: pointer to event buffer
16782 * @param wds_ev: Pointer to hold wds address
16783 *
16784 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16785 */
16786static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
16787 void *evt_buf,
16788 uint16_t len, wds_addr_event_t *wds_ev)
16789{
16790 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
16791 wmi_wds_addr_event_fixed_param *ev;
16792 int i;
16793
16794 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
16795 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
16796
16797 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
16798 return QDF_STATUS_E_FAILURE;
16799
16800 qdf_mem_copy(wds_ev->event_type, ev->event_type,
16801 sizeof(wds_ev->event_type));
16802 for (i = 0; i < 4; i++) {
16803 wds_ev->peer_mac[i] =
16804 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
16805 wds_ev->dest_mac[i] =
16806 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
16807 }
16808 for (i = 0; i < 2; i++) {
16809 wds_ev->peer_mac[4+i] =
16810 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
16811 wds_ev->dest_mac[4+i] =
16812 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
16813 }
16814 return QDF_STATUS_SUCCESS;
16815}
16816
16817/**
16818 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
16819 * from event
16820 * @wmi_handle: wmi handle
16821 * @param evt_buf: pointer to event buffer
16822 * @param ev: Pointer to hold peer param and ps state
16823 *
16824 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16825 */
16826static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
16827 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
16828{
16829 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
16830 wmi_peer_sta_ps_statechange_event_fixed_param *event;
16831
16832 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
16833 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
16834 param_buf->fixed_param;
16835
16836 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
16837 ev->peer_ps_state = event->peer_ps_state;
16838
16839 return QDF_STATUS_SUCCESS;
16840}
16841
16842/**
16843 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
16844 * @wmi_handle: wmi handle
16845 * @param evt_buf: pointer to event buffer
16846 * @param inst_rssi_resp: Pointer to hold inst rssi response
16847 *
16848 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16849 */
16850static QDF_STATUS extract_inst_rssi_stats_event_tlv(
16851 wmi_unified_t wmi_handle, void *evt_buf,
16852 wmi_host_inst_stats_resp *inst_rssi_resp)
16853{
16854 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
16855 wmi_inst_rssi_stats_resp_fixed_param *event;
16856
16857 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
16858 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
16859
16860 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
16861 &(event->peer_macaddr), sizeof(wmi_mac_addr));
16862 inst_rssi_resp->iRSSI = event->iRSSI;
16863
16864 return QDF_STATUS_SUCCESS;
16865}
16866
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016867static struct cur_reg_rule
16868*create_reg_rules_from_wmi(uint32_t num_reg_rules,
16869 wmi_regulatory_rule_struct *wmi_reg_rule)
16870{
16871 struct cur_reg_rule *reg_rule_ptr;
16872 uint32_t count;
16873
16874 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
16875
16876 if (NULL == reg_rule_ptr) {
16877 WMI_LOGE("memory allocation failure");
16878 return NULL;
16879 }
16880
16881 for (count = 0; count < num_reg_rules; count++) {
16882 reg_rule_ptr[count].start_freq =
16883 WMI_REG_RULE_START_FREQ_GET(
16884 wmi_reg_rule[count].freq_info);
16885 reg_rule_ptr[count].end_freq =
16886 WMI_REG_RULE_END_FREQ_GET(
16887 wmi_reg_rule[count].freq_info);
16888 reg_rule_ptr[count].max_bw =
16889 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070016890 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016891 reg_rule_ptr[count].reg_power =
16892 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070016893 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016894 reg_rule_ptr[count].flags =
16895 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070016896 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016897 }
16898
16899 return reg_rule_ptr;
16900}
16901
16902static QDF_STATUS extract_reg_chan_list_update_event_tlv(
16903 wmi_unified_t wmi_handle, uint8_t *evt_buf,
16904 struct cur_regulatory_info *reg_info, uint32_t len)
16905{
16906 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
16907 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
16908 wmi_regulatory_rule_struct *wmi_reg_rule;
16909 uint32_t num_2g_reg_rules, num_5g_reg_rules;
16910
16911 WMI_LOGD("processing regulatory channel list");
16912
16913 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
16914 if (!param_buf) {
16915 WMI_LOGE("invalid channel list event buf");
16916 return QDF_STATUS_E_FAILURE;
16917 }
16918
16919 chan_list_event_hdr = param_buf->fixed_param;
16920
16921 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
16922 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
16923 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
16924 REG_ALPHA2_LEN);
16925 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
16926 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
16927 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
16928 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
16929 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
16930 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
16931
16932 num_2g_reg_rules = reg_info->num_2g_reg_rules;
16933 num_5g_reg_rules = reg_info->num_5g_reg_rules;
16934
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016935
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070016936 wmi_reg_rule =
16937 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
16938 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
16939 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016940 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
16941 wmi_reg_rule);
16942 wmi_reg_rule += num_2g_reg_rules;
16943
16944 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
16945 wmi_reg_rule);
16946
16947 WMI_LOGD("processed regulatory channel list");
16948
16949 return QDF_STATUS_SUCCESS;
16950}
16951
Govind Singh5eb51532016-03-09 11:34:12 +053016952struct wmi_ops tlv_ops = {
16953 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
16954 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
16955 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053016956 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
16957 .send_hidden_ssid_vdev_restart_cmd =
16958 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016959 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
16960 .send_peer_param_cmd = send_peer_param_cmd_tlv,
16961 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016962 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016963 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016964 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070016965 .send_peer_rx_reorder_queue_setup_cmd =
16966 send_peer_rx_reorder_queue_setup_cmd_tlv,
16967 .send_peer_rx_reorder_queue_remove_cmd =
16968 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053016969 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
16970 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
16971 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016972 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
16973 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
16974 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
16975 .send_suspend_cmd = send_suspend_cmd_tlv,
16976 .send_resume_cmd = send_resume_cmd_tlv,
16977 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
16978 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
16979 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
16980 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
16981 .send_dbglog_cmd = send_dbglog_cmd_tlv,
16982 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
16983 .send_stats_request_cmd = send_stats_request_cmd_tlv,
16984 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
16985 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016986#ifndef CONFIG_MCL
16987 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
16988#endif
Govind Singh5eb51532016-03-09 11:34:12 +053016989 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
16990 .send_scan_start_cmd = send_scan_start_cmd_tlv,
16991 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
16992 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016993 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053016994 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016995 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
16996 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016997 .send_set_sta_uapsd_auto_trig_cmd =
16998 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016999 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
17000 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
17001 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080017002#ifdef CONVERGED_P2P_ENABLE
17003 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
17004 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
17005#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053017006 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
17007 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053017008 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
17009 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
17010 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
17011 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
17012 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
17013 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
17014 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017015 .send_ocb_start_timing_advert_cmd =
17016 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053017017 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
17018 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
17019 .send_set_mcc_channel_time_latency_cmd =
17020 send_set_mcc_channel_time_latency_cmd_tlv,
17021 .send_set_mcc_channel_time_quota_cmd =
17022 send_set_mcc_channel_time_quota_cmd_tlv,
17023 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
17024 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053017025 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017026 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
17027 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
17028 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017029 .send_probe_rsp_tmpl_send_cmd =
17030 send_probe_rsp_tmpl_send_cmd_tlv,
17031 .send_p2p_go_set_beacon_ie_cmd =
17032 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053017033 .send_setup_install_key_cmd =
17034 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017035 .send_set_gateway_params_cmd =
17036 send_set_gateway_params_cmd_tlv,
17037 .send_set_rssi_monitoring_cmd =
17038 send_set_rssi_monitoring_cmd_tlv,
17039 .send_scan_probe_setoui_cmd =
17040 send_scan_probe_setoui_cmd_tlv,
17041 .send_reset_passpoint_network_list_cmd =
17042 send_reset_passpoint_network_list_cmd_tlv,
17043 .send_set_passpoint_network_list_cmd =
17044 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053017045 .send_roam_scan_offload_rssi_thresh_cmd =
17046 send_roam_scan_offload_rssi_thresh_cmd_tlv,
17047 .send_roam_scan_filter_cmd =
17048 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017049 .send_set_epno_network_list_cmd =
17050 send_set_epno_network_list_cmd_tlv,
17051 .send_ipa_offload_control_cmd =
17052 send_ipa_offload_control_cmd_tlv,
17053 .send_extscan_get_capabilities_cmd =
17054 send_extscan_get_capabilities_cmd_tlv,
17055 .send_extscan_get_cached_results_cmd =
17056 send_extscan_get_cached_results_cmd_tlv,
17057 .send_extscan_stop_change_monitor_cmd =
17058 send_extscan_stop_change_monitor_cmd_tlv,
17059 .send_extscan_start_change_monitor_cmd =
17060 send_extscan_start_change_monitor_cmd_tlv,
17061 .send_extscan_stop_hotlist_monitor_cmd =
17062 send_extscan_stop_hotlist_monitor_cmd_tlv,
17063 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
17064 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
17065 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
17066 .send_plm_start_cmd = send_plm_start_cmd_tlv,
17067 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
17068 .send_pno_start_cmd = send_pno_start_cmd_tlv,
17069 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
17070 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
17071 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
17072 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
17073 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017074 .send_snr_request_cmd = send_snr_request_cmd_tlv,
17075 .send_snr_cmd = send_snr_cmd_tlv,
17076 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017077#ifdef WLAN_PMO_ENABLE
17078 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
17079 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
17080 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
17081 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
17082 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
17083 .send_process_gtk_offload_getinfo_cmd =
17084 send_process_gtk_offload_getinfo_cmd_tlv,
17085 .send_enable_enhance_multicast_offload_cmd =
17086 send_enable_enhance_multicast_offload_tlv,
17087 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
17088#ifdef FEATURE_WLAN_RA_FILTERING
17089 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
17090#endif
17091 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017092 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
17093 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017094 .send_lphb_config_tcp_pkt_filter_cmd =
17095 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017096 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
17097 .send_lphb_config_udp_pkt_filter_cmd =
17098 send_lphb_config_udp_pkt_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017099#endif /* End of WLAN_PMO_ENABLE */
17100#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053017101 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
17102 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
17103 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053017104 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
17105 .send_process_update_edca_param_cmd =
17106 send_process_update_edca_param_cmd_tlv,
17107 .send_roam_scan_offload_mode_cmd =
17108 send_roam_scan_offload_mode_cmd_tlv,
17109 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
17110 .send_roam_scan_offload_ap_profile_cmd =
17111 send_roam_scan_offload_ap_profile_cmd_tlv,
17112#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053017113 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
17114 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017115 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
17116 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
17117 .send_dfs_phyerr_filter_offload_en_cmd =
17118 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017119 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
17120 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
17121 .send_del_ts_cmd = send_del_ts_cmd_tlv,
17122 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
17123 .send_add_ts_cmd = send_add_ts_cmd_tlv,
17124 .send_enable_disable_packet_filter_cmd =
17125 send_enable_disable_packet_filter_cmd_tlv,
17126 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017127 .send_process_add_periodic_tx_ptrn_cmd =
17128 send_process_add_periodic_tx_ptrn_cmd_tlv,
17129 .send_process_del_periodic_tx_ptrn_cmd =
17130 send_process_del_periodic_tx_ptrn_cmd_tlv,
17131 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
17132 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
17133 .send_set_app_type2_params_in_fw_cmd =
17134 send_set_app_type2_params_in_fw_cmd_tlv,
17135 .send_set_auto_shutdown_timer_cmd =
17136 send_set_auto_shutdown_timer_cmd_tlv,
17137 .send_nan_req_cmd = send_nan_req_cmd_tlv,
17138 .send_process_dhcpserver_offload_cmd =
17139 send_process_dhcpserver_offload_cmd_tlv,
17140 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
17141 .send_process_ch_avoid_update_cmd =
17142 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053017143 .send_pdev_set_regdomain_cmd =
17144 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017145 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
17146 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
17147 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
17148 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
17149 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
17150 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053017151#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053017152 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053017153#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053017154 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017155 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053017156 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053017157 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053017158 .send_set_base_macaddr_indicate_cmd =
17159 send_set_base_macaddr_indicate_cmd_tlv,
17160 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
17161 .send_enable_specific_fw_logs_cmd =
17162 send_enable_specific_fw_logs_cmd_tlv,
17163 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053017164 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053017165 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053017166 .send_pdev_set_dual_mac_config_cmd =
17167 send_pdev_set_dual_mac_config_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053017168 .send_enable_broadcast_filter_cmd =
17169 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053017170 .send_app_type1_params_in_fw_cmd =
17171 send_app_type1_params_in_fw_cmd_tlv,
17172 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
17173 .send_process_roam_synch_complete_cmd =
17174 send_process_roam_synch_complete_cmd_tlv,
17175 .send_unit_test_cmd = send_unit_test_cmd_tlv,
17176 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
17177 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053017178 .send_roam_scan_offload_scan_period_cmd =
17179 send_roam_scan_offload_scan_period_cmd_tlv,
17180 .send_roam_scan_offload_chan_list_cmd =
17181 send_roam_scan_offload_chan_list_cmd_tlv,
17182 .send_roam_scan_offload_rssi_change_cmd =
17183 send_roam_scan_offload_rssi_change_cmd_tlv,
17184 .send_get_buf_extscan_hotlist_cmd =
17185 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080017186 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053017187 .send_adapt_dwelltime_params_cmd =
17188 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017189 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053017190 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
17191 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
17192 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
17193 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
17194 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
17195 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
17196 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
17197 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
17198 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053017199 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
17200 .send_smart_ant_set_training_info_cmd =
17201 send_smart_ant_set_training_info_cmd_tlv,
17202 .send_smart_ant_set_node_config_cmd =
17203 send_smart_ant_set_node_config_cmd_tlv,
17204 .send_set_atf_cmd = send_set_atf_cmd_tlv,
17205 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
17206 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053017207 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
17208 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
17209 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
17210 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
17211 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
17212 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
17213 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053017214 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
17215 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
17216 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
17217 .send_vdev_spectral_configure_cmd =
17218 send_vdev_spectral_configure_cmd_tlv,
17219 .send_vdev_spectral_enable_cmd =
17220 send_vdev_spectral_enable_cmd_tlv,
17221 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
17222 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017223 .get_target_cap_from_service_ready = extract_service_ready_tlv,
17224 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
17225 .extract_host_mem_req = extract_host_mem_req_tlv,
17226 .save_service_bitmap = save_service_bitmap_tlv,
17227 .is_service_enabled = is_service_enabled_tlv,
17228 .save_fw_version = save_fw_version_in_service_ready_tlv,
17229 .ready_extract_init_status = ready_extract_init_status_tlv,
17230 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
17231 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
17232 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
17233 .extract_tbttoffset_update_params =
17234 extract_tbttoffset_update_params_tlv,
17235 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
17236 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
17237 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
17238 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
17239 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
17240 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
17241 .extract_swba_tim_info = extract_swba_tim_info_tlv,
17242 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080017243#ifdef CONVERGED_P2P_ENABLE
17244 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
17245 .extract_p2p_lo_stop_ev_param =
17246 extract_p2p_lo_stop_ev_param_tlv,
17247#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017248 .extract_offchan_data_tx_compl_param =
17249 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017250 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
17251 .extract_all_stats_count = extract_all_stats_counts_tlv,
17252 .extract_pdev_stats = extract_pdev_stats_tlv,
17253 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
17254 .extract_vdev_stats = extract_vdev_stats_tlv,
17255 .extract_peer_stats = extract_peer_stats_tlv,
17256 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
17257 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
17258 .extract_chan_stats = extract_chan_stats_tlv,
17259 .extract_profile_ctx = extract_profile_ctx_tlv,
17260 .extract_profile_data = extract_profile_data_tlv,
17261 .extract_chan_info_event = extract_chan_info_event_tlv,
17262 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053017263 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053017264 .send_encrypt_decrypt_send_cmd =
17265 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080017266 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053017267 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053017268 .send_multiple_vdev_restart_req_cmd =
17269 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053017270 .extract_service_ready_ext = extract_service_ready_ext_tlv,
17271 .extract_hw_mode_cap_service_ready_ext =
17272 extract_hw_mode_cap_service_ready_ext_tlv,
17273 .extract_mac_phy_cap_service_ready_ext =
17274 extract_mac_phy_cap_service_ready_ext_tlv,
17275 .extract_reg_cap_service_ready_ext =
17276 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017277 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017278 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017279 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
17280 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
17281 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017282 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053017283 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017284 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017285 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017286 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053017287 .extract_pdev_csa_switch_count_status =
17288 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053017289 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
17290 .extract_wds_addr_event = extract_wds_addr_event_tlv,
17291 .extract_peer_sta_ps_statechange_ev =
17292 extract_peer_sta_ps_statechange_ev_tlv,
17293 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053017294 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080017295 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
17296 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017297 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017298 extract_reg_chan_list_update_event_tlv,
17299 .extract_chainmask_tables =
17300 extract_chainmask_tables_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053017301};
17302
Govind Singhe7f2f342016-05-23 12:12:52 +053017303/**
17304 * populate_tlv_event_id() - populates wmi event ids
17305 *
17306 * @param event_ids: Pointer to hold event ids
17307 * Return: None
17308 */
17309static void populate_tlv_events_id(uint32_t *event_ids)
17310{
17311 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
17312 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
17313 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
17314 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
17315 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
17316 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
17317 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
17318 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
17319 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
17320 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
17321 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
17322 event_ids[wmi_service_ready_ext_event_id] =
17323 WMI_SERVICE_READY_EXT_EVENTID;
17324 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
17325 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
17326 event_ids[wmi_vdev_install_key_complete_event_id] =
17327 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
17328 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
17329 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
17330
17331 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
17332 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
17333 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
17334 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
17335 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
17336 event_ids[wmi_peer_estimated_linkspeed_event_id] =
17337 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
17338 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017339 event_ids[wmi_peer_delete_response_event_id] =
17340 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017341 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
17342 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
17343 event_ids[wmi_tbttoffset_update_event_id] =
17344 WMI_TBTTOFFSET_UPDATE_EVENTID;
17345 event_ids[wmi_offload_bcn_tx_status_event_id] =
17346 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
17347 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
17348 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
17349 event_ids[wmi_mgmt_tx_completion_event_id] =
17350 WMI_MGMT_TX_COMPLETION_EVENTID;
17351
17352 event_ids[wmi_tx_delba_complete_event_id] =
17353 WMI_TX_DELBA_COMPLETE_EVENTID;
17354 event_ids[wmi_tx_addba_complete_event_id] =
17355 WMI_TX_ADDBA_COMPLETE_EVENTID;
17356 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
17357
17358 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
17359
17360 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
17361 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
17362
17363 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
17364
17365 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
17366
17367 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080017368 event_ids[wmi_p2p_lo_stop_event_id] =
17369 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017370 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
17371 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
17372 event_ids[wmi_do_wow_disable_ack_event_id] =
17373 WMI_D0_WOW_DISABLE_ACK_EVENTID;
17374 event_ids[wmi_wow_initial_wakeup_event_id] =
17375 WMI_WOW_INITIAL_WAKEUP_EVENTID;
17376
17377 event_ids[wmi_rtt_meas_report_event_id] =
17378 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
17379 event_ids[wmi_tsf_meas_report_event_id] =
17380 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
17381 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
17382 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
17383 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
17384 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
17385 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
17386 event_ids[wmi_update_fw_mem_dump_event_id] =
17387 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
17388 event_ids[wmi_diag_event_id_log_supported_event_id] =
17389 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
17390 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
17391 event_ids[wmi_nlo_scan_complete_event_id] =
17392 WMI_NLO_SCAN_COMPLETE_EVENTID;
17393 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
17394 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
17395
17396 event_ids[wmi_gtk_offload_status_event_id] =
17397 WMI_GTK_OFFLOAD_STATUS_EVENTID;
17398 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
17399 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
17400 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
17401
17402 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
17403
17404 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
17405
17406 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
17407 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
17408 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
17409 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
17410 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
17411 event_ids[wmi_wlan_profile_data_event_id] =
17412 WMI_WLAN_PROFILE_DATA_EVENTID;
17413 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
17414 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
17415 event_ids[wmi_vdev_get_keepalive_event_id] =
17416 WMI_VDEV_GET_KEEPALIVE_EVENTID;
17417 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
17418
17419 event_ids[wmi_diag_container_event_id] =
17420 WMI_DIAG_DATA_CONTAINER_EVENTID;
17421
17422 event_ids[wmi_host_auto_shutdown_event_id] =
17423 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
17424
17425 event_ids[wmi_update_whal_mib_stats_event_id] =
17426 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
17427
17428 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
17429 event_ids[wmi_update_vdev_rate_stats_event_id] =
17430 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
17431
17432 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
17433
17434 /** Set OCB Sched Response, deprecated */
17435 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
17436
17437 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
17438 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
17439 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
17440
17441 /* GPIO Event */
17442 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
17443 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
17444
17445 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
17446 event_ids[wmi_rfkill_state_change_event_id] =
17447 WMI_RFKILL_STATE_CHANGE_EVENTID;
17448
17449 /* TDLS Event */
17450 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
17451
17452 event_ids[wmi_batch_scan_enabled_event_id] =
17453 WMI_BATCH_SCAN_ENABLED_EVENTID;
17454 event_ids[wmi_batch_scan_result_event_id] =
17455 WMI_BATCH_SCAN_RESULT_EVENTID;
17456 /* OEM Event */
17457 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
17458 event_ids[wmi_oem_meas_report_event_id] =
17459 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
17460 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
17461
17462 /* NAN Event */
17463 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
17464
17465 /* LPI Event */
17466 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
17467 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
17468 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
17469
17470 /* ExtScan events */
17471 event_ids[wmi_extscan_start_stop_event_id] =
17472 WMI_EXTSCAN_START_STOP_EVENTID;
17473 event_ids[wmi_extscan_operation_event_id] =
17474 WMI_EXTSCAN_OPERATION_EVENTID;
17475 event_ids[wmi_extscan_table_usage_event_id] =
17476 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
17477 event_ids[wmi_extscan_cached_results_event_id] =
17478 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
17479 event_ids[wmi_extscan_wlan_change_results_event_id] =
17480 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
17481 event_ids[wmi_extscan_hotlist_match_event_id] =
17482 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
17483 event_ids[wmi_extscan_capabilities_event_id] =
17484 WMI_EXTSCAN_CAPABILITIES_EVENTID;
17485 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
17486 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
17487
17488 /* mDNS offload events */
17489 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
17490
17491 /* SAP Authentication offload events */
17492 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
17493 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
17494
17495 /** Out-of-context-of-bss (OCB) events */
17496 event_ids[wmi_ocb_set_config_resp_event_id] =
17497 WMI_OCB_SET_CONFIG_RESP_EVENTID;
17498 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
17499 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
17500 event_ids[wmi_dcc_get_stats_resp_event_id] =
17501 WMI_DCC_GET_STATS_RESP_EVENTID;
17502 event_ids[wmi_dcc_update_ndl_resp_event_id] =
17503 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
17504 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
17505 /* System-On-Chip events */
17506 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
17507 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
17508 event_ids[wmi_soc_hw_mode_transition_event_id] =
17509 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
17510 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
17511 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053017512 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053017513 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
17514 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017515 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053017516 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
17517 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
17518 event_ids[wmi_peer_sta_ps_statechg_event_id] =
17519 WMI_PEER_STA_PS_STATECHG_EVENTID;
17520 event_ids[wmi_pdev_channel_hopping_event_id] =
17521 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
17522 event_ids[wmi_wds_peer_event_id] = WMI_WDS_PEER_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017523 event_ids[wmi_offchan_data_tx_completion_event] =
17524 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017525}
17526
Soumya Bhat488092d2017-03-22 14:41:01 +053017527#ifndef CONFIG_MCL
17528/**
17529 * populate_tlv_service() - populates wmi services
17530 *
17531 * @param wmi_service: Pointer to hold wmi_service
17532 * Return: None
17533 */
17534static void populate_tlv_service(uint32_t *wmi_service)
17535{
17536 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
17537 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
17538 wmi_service[wmi_service_roam_scan_offload] =
17539 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
17540 wmi_service[wmi_service_bcn_miss_offload] =
17541 WMI_SERVICE_BCN_MISS_OFFLOAD;
17542 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
17543 wmi_service[wmi_service_sta_advanced_pwrsave] =
17544 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
17545 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
17546 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
17547 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
17548 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
17549 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
17550 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
17551 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
17552 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
17553 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
17554 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
17555 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
17556 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
17557 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
17558 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
17559 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
17560 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
17561 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
17562 wmi_service[wmi_service_packet_power_save] =
17563 WMI_SERVICE_PACKET_POWER_SAVE;
17564 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
17565 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
17566 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
17567 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
17568 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
17569 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
17570 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
17571 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
17572 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
17573 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
17574 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
17575 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
17576 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
17577 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
17578 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
17579 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
17580 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
17581 wmi_service[wmi_service_mcc_bcn_interval_change] =
17582 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
17583 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
17584 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
17585 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
17586 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
17587 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
17588 wmi_service[wmi_service_lte_ant_share_support] =
17589 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
17590 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
17591 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
17592 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
17593 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
17594 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
17595 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
17596 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
17597 wmi_service[wmi_service_bcn_txrate_override] =
17598 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
17599 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
17600 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
17601 wmi_service[wmi_service_estimate_linkspeed] =
17602 WMI_SERVICE_ESTIMATE_LINKSPEED;
17603 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
17604 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
17605 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
17606 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
17607 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
17608 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
17609 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
17610 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
17611 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
17612 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
17613 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
17614 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
17615 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
17616 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
17617 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
17618 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
17619 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
17620 wmi_service[wmi_service_sap_auth_offload] =
17621 WMI_SERVICE_SAP_AUTH_OFFLOAD;
17622 wmi_service[wmi_service_dual_band_simultaneous_support] =
17623 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
17624 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
17625 wmi_service[wmi_service_ap_arpns_offload] =
17626 WMI_SERVICE_AP_ARPNS_OFFLOAD;
17627 wmi_service[wmi_service_per_band_chainmask_support] =
17628 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
17629 wmi_service[wmi_service_packet_filter_offload] =
17630 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
17631 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
17632 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
17633 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
17634 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
17635 wmi_service[wmi_service_multiple_vdev_restart] =
17636 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
17637
17638 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
17639 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
17640 wmi_service[wmi_service_smart_antenna_sw_support] =
17641 WMI_SERVICE_UNAVAILABLE;
17642 wmi_service[wmi_service_smart_antenna_hw_support] =
17643 WMI_SERVICE_UNAVAILABLE;
17644 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
17645 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
17646 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
17647 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
17648 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
17649 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
17650 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
17651 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
17652 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
17653 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
17654 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
17655
17656 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
17657 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
17658 wmi_service[wmi_service_periodic_chan_stat_support] =
17659 WMI_SERVICE_UNAVAILABLE;
17660 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
17661 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
17662 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
17663 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
17664 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
17665 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
17666}
17667
Govind Singhe7f2f342016-05-23 12:12:52 +053017668/**
17669 * populate_pdev_param_tlv() - populates pdev params
17670 *
17671 * @param pdev_param: Pointer to hold pdev params
17672 * Return: None
17673 */
17674static void populate_pdev_param_tlv(uint32_t *pdev_param)
17675{
17676 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
17677 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
17678 pdev_param[wmi_pdev_param_txpower_limit2g] =
17679 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
17680 pdev_param[wmi_pdev_param_txpower_limit5g] =
17681 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
17682 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
17683 pdev_param[wmi_pdev_param_beacon_gen_mode] =
17684 WMI_PDEV_PARAM_BEACON_GEN_MODE;
17685 pdev_param[wmi_pdev_param_beacon_tx_mode] =
17686 WMI_PDEV_PARAM_BEACON_TX_MODE;
17687 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
17688 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
17689 pdev_param[wmi_pdev_param_protection_mode] =
17690 WMI_PDEV_PARAM_PROTECTION_MODE;
17691 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
17692 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
17693 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
17694 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
17695 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
17696 pdev_param[wmi_pdev_param_sta_kickout_th] =
17697 WMI_PDEV_PARAM_STA_KICKOUT_TH;
17698 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
17699 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
17700 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
17701 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
17702 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
17703 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
17704 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
17705 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
17706 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
17707 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
17708 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
17709 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
17710 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
17711 pdev_param[wmi_pdev_param_ltr_sleep_override] =
17712 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
17713 pdev_param[wmi_pdev_param_ltr_rx_override] =
17714 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
17715 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
17716 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
17717 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
17718 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
17719 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
17720 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
17721 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
17722 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
17723 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
17724 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
17725 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
17726 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
17727 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
17728 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
17729 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
17730 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
17731 pdev_param[wmi_pdev_param_peer_stats_update_period] =
17732 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
17733 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
17734 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
17735 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
17736 pdev_param[wmi_pdev_param_arp_ac_override] =
17737 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
17738 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
17739 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
17740 pdev_param[wmi_pdev_param_ani_poll_period] =
17741 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
17742 pdev_param[wmi_pdev_param_ani_listen_period] =
17743 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
17744 pdev_param[wmi_pdev_param_ani_ofdm_level] =
17745 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
17746 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
17747 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
17748 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
17749 pdev_param[wmi_pdev_param_idle_ps_config] =
17750 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
17751 pdev_param[wmi_pdev_param_power_gating_sleep] =
17752 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
17753 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
17754 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
17755 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
17756 pdev_param[wmi_pdev_param_hw_rfkill_config] =
17757 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
17758 pdev_param[wmi_pdev_param_low_power_rf_enable] =
17759 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
17760 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
17761 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
17762 pdev_param[wmi_pdev_param_power_collapse_enable] =
17763 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
17764 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
17765 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
17766 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
17767 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
17768 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
17769 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
17770 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
17771 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
17772 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
17773 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
17774 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
17775 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
17776 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
17777 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
17778 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
17779 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
17780 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
17781 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
17782 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
17783 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
17784 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
17785 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
17786 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
17787 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
17788 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
17789 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
17790 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
17791 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
17792 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
17793 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
17794 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
17795 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
17796 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
17797 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
17798 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
17799 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
17800 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
17801 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
17802 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
17803 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
17804 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
17805 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
17806 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
17807 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
17808 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
17809 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
17810 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
17811 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
17812 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
17813 WMI_UNAVAILABLE_PARAM;
17814 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
17815 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
17816 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
17817 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
17818 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
17819 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
17820 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
17821 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
17822 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
17823 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
17824 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
17825 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
17826 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
17827 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
17828 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
17829 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
17830 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
17831 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
17832 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
17833 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
17834 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
17835 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
17836 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
17837 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
17838 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
17839 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
17840 WMI_UNAVAILABLE_PARAM;
17841 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
17842 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
17843 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
17844 WMI_UNAVAILABLE_PARAM;
17845 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
17846 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
17847 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
17848 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
17849 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
17850 WMI_UNAVAILABLE_PARAM;
17851 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
17852 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
17853 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053017854 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
17855 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017856 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053017857 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
17858 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053017859 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
17860 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
17861 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
17862 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
17863 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
17864 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
17865 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
17866 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
17867 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
17868 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
17869 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
17870 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
17871 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
17872 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
17873 pdev_param[wmi_pdev_param_fast_channel_reset] =
17874 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
17875 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017876}
17877
17878/**
17879 * populate_vdev_param_tlv() - populates vdev params
17880 *
17881 * @param vdev_param: Pointer to hold vdev params
17882 * Return: None
17883 */
17884static void populate_vdev_param_tlv(uint32_t *vdev_param)
17885{
17886 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
17887 vdev_param[wmi_vdev_param_fragmentation_threshold] =
17888 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
17889 vdev_param[wmi_vdev_param_beacon_interval] =
17890 WMI_VDEV_PARAM_BEACON_INTERVAL;
17891 vdev_param[wmi_vdev_param_listen_interval] =
17892 WMI_VDEV_PARAM_LISTEN_INTERVAL;
17893 vdev_param[wmi_vdev_param_multicast_rate] =
17894 WMI_VDEV_PARAM_MULTICAST_RATE;
17895 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
17896 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
17897 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
17898 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
17899 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
17900 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
17901 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
17902 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
17903 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
17904 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
17905 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
17906 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
17907 vdev_param[wmi_vdev_param_bmiss_count_max] =
17908 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
17909 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
17910 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
17911 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
17912 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
17913 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
17914 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
17915 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
17916 vdev_param[wmi_vdev_param_disable_htprotection] =
17917 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
17918 vdev_param[wmi_vdev_param_sta_quickkickout] =
17919 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
17920 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
17921 vdev_param[wmi_vdev_param_protection_mode] =
17922 WMI_VDEV_PARAM_PROTECTION_MODE;
17923 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
17924 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
17925 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
17926 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
17927 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
17928 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
17929 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
17930 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
17931 vdev_param[wmi_vdev_param_bcast_data_rate] =
17932 WMI_VDEV_PARAM_BCAST_DATA_RATE;
17933 vdev_param[wmi_vdev_param_mcast_data_rate] =
17934 WMI_VDEV_PARAM_MCAST_DATA_RATE;
17935 vdev_param[wmi_vdev_param_mcast_indicate] =
17936 WMI_VDEV_PARAM_MCAST_INDICATE;
17937 vdev_param[wmi_vdev_param_dhcp_indicate] =
17938 WMI_VDEV_PARAM_DHCP_INDICATE;
17939 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
17940 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
17941 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
17942 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
17943 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
17944 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
17945 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
17946 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
17947 vdev_param[wmi_vdev_param_ap_enable_nawds] =
17948 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
17949 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
17950 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
17951 vdev_param[wmi_vdev_param_packet_powersave] =
17952 WMI_VDEV_PARAM_PACKET_POWERSAVE;
17953 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
17954 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
17955 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
17956 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
17957 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
17958 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
17959 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
17960 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
17961 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
17962 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
17963 vdev_param[wmi_vdev_param_early_rx_slop_step] =
17964 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
17965 vdev_param[wmi_vdev_param_early_rx_init_slop] =
17966 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
17967 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
17968 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
17969 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
17970 vdev_param[wmi_vdev_param_snr_num_for_cal] =
17971 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
17972 vdev_param[wmi_vdev_param_roam_fw_offload] =
17973 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
17974 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
17975 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
17976 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
17977 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
17978 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
17979 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
17980 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
17981 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
17982 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
17983 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
17984 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
17985 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
17986 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
17987 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
17988 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
17989 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
17990 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
17991 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
17992 vdev_param[wmi_vdev_param_inactivity_cnt] =
17993 WMI_VDEV_PARAM_INACTIVITY_CNT;
17994 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
17995 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
17996 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
17997 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
17998 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
17999 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
18000 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
18001 vdev_param[wmi_vdev_param_rx_leak_window] =
18002 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
18003 vdev_param[wmi_vdev_param_stats_avg_factor] =
18004 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
18005 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
18006 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
18007 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
18008 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
18009 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
18010 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053018011 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
18012 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053018013 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080018014 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
18015 vdev_param[wmi_vdev_param_he_range_ext_enable] =
18016 WMI_VDEV_PARAM_HE_RANGE_EXT;
18017 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
18018 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053018019 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
18020 vdev_param[wmi_vdev_param_dtim_enable_cts] =
18021 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
18022 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
18023 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
18024 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
18025 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053018026 vdev_param[wmi_vdev_param_mcast2ucast_set] =
18027 WMI_VDEV_PARAM_MCAST2UCAST_SET;
18028 vdev_param[wmi_vdev_param_rc_num_retries] =
18029 WMI_VDEV_PARAM_RC_NUM_RETRIES;
18030 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
18031 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
18032 vdev_param[wmi_vdev_param_rts_fixed_rate] =
18033 WMI_VDEV_PARAM_RTS_FIXED_RATE;
18034 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
18035 vdev_param[wmi_vdev_param_vht80_ratemask] =
18036 WMI_VDEV_PARAM_VHT80_RATEMASK;
18037 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
18038 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
18039 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053018040}
18041#endif
18042
Govind Singh5eb51532016-03-09 11:34:12 +053018043/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018044 * populate_target_defines_tlv() - Populate target defines and params
18045 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053018046 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053018047 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053018048 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053018049#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018050static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053018051{
Govind Singhe7f2f342016-05-23 12:12:52 +053018052 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053018053 populate_pdev_param_tlv(wmi_handle->pdev_param);
18054 populate_vdev_param_tlv(wmi_handle->vdev_param);
18055}
18056#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018057static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
18058{ }
18059#endif
18060
18061/**
18062 * wmi_tlv_attach() - Attach TLV APIs
18063 *
18064 * Return: None
18065 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053018066void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053018067{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053018068 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053018069#ifdef WMI_INTERFACE_EVENT_LOGGING
18070 wmi_handle->log_info.buf_offset_command = 2;
18071 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053018072#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053018073 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018074 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053018075}