blob: ee78dc5de7c6910c1ef817b052b7a82b98c4e630 [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"
Govind Singh5eb51532016-03-09 11:34:12 +053033
Wu Gaocd3a8512017-03-13 20:17:34 +080034#ifdef CONVERGED_P2P_ENABLE
35#include "wlan_p2p_public_struct.h"
36#endif
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
289 /* FIXME: Find out min, max and regulatory power levels */
290 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
291 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
292
293}
294#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530295/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530296 * send_vdev_start_cmd_tlv() - send vdev start request to fw
297 * @wmi_handle: wmi handle
298 * @req: vdev start params
299 *
300 * Return: QDF status
301 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530302static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530303 struct vdev_start_params *req)
304{
305 wmi_vdev_start_request_cmd_fixed_param *cmd;
306 wmi_buf_t buf;
307 wmi_channel *chan;
308 int32_t len, ret;
309 uint8_t *buf_ptr;
310
311 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
312 buf = wmi_buf_alloc(wmi_handle, len);
313 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530314 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530315 return QDF_STATUS_E_NOMEM;
316 }
317 buf_ptr = (uint8_t *) wmi_buf_data(buf);
318 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
319 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
320 WMITLV_SET_HDR(&cmd->tlv_header,
321 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
322 WMITLV_GET_STRUCT_TLVLEN
323 (wmi_vdev_start_request_cmd_fixed_param));
324 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
325 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
326 cmd->vdev_id = req->vdev_id;
327
328 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530329 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530330
331 cmd->beacon_interval = req->beacon_intval;
332 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530333
334 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530335 cmd->beacon_interval = req->beacon_intval;
336 cmd->dtim_period = req->dtim_period;
337
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530338 /* Copy the SSID */
339 if (req->ssid.length) {
340 if (req->ssid.length < sizeof(cmd->ssid.ssid))
341 cmd->ssid.ssid_len = req->ssid.length;
342 else
343 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
344 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
345 cmd->ssid.ssid_len);
346 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530347
348 if (req->hidden_ssid)
349 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
350
351 if (req->pmf_enabled)
352 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530353 }
354
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530355 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530356 cmd->preferred_rx_streams = req->preferred_rx_streams;
357 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700358 cmd->cac_duration_ms = req->cac_duration_ms;
359 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700360 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530361
362 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
363 sizeof(wmi_channel));
364 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
365 cmd->num_noa_descriptors *
366 sizeof(wmi_p2p_noa_descriptor));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800367 WMI_LOGA("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
369 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700370 "Tx SS %d, Rx SS %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800371 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530372 req->is_dfs, req->beacon_intval, cmd->dtim_period,
373 chan->band_center_freq1, chan->band_center_freq2,
374 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700375 req->preferred_tx_streams, req->preferred_rx_streams,
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700376 req->cac_duration_ms, req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530377
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530378 if (req->is_restart)
379 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
380 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530381 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530382 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
383 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530384 if (ret) {
385 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530386 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530387 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530388 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530389
390 return QDF_STATUS_SUCCESS;
391}
392
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530393/**
394 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
395 * @wmi_handle: wmi handle
396 * @restart_params: vdev restart params
397 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530398 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530399 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530400static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530401 struct hidden_ssid_vdev_restart_params *restart_params)
402{
403 wmi_vdev_start_request_cmd_fixed_param *cmd;
404 wmi_buf_t buf;
405 wmi_channel *chan;
406 int32_t len;
407 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530408 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530409
410 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
411 buf = wmi_buf_alloc(wmi_handle, len);
412 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530413 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530414 return QDF_STATUS_E_NOMEM;
415 }
416 buf_ptr = (uint8_t *) wmi_buf_data(buf);
417 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
418 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
419
420 WMITLV_SET_HDR(&cmd->tlv_header,
421 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
422 WMITLV_GET_STRUCT_TLVLEN
423 (wmi_vdev_start_request_cmd_fixed_param));
424
425 WMITLV_SET_HDR(&chan->tlv_header,
426 WMITLV_TAG_STRUC_wmi_channel,
427 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
428
429 cmd->vdev_id = restart_params->session_id;
430 cmd->ssid.ssid_len = restart_params->ssid_len;
431 qdf_mem_copy(cmd->ssid.ssid,
432 restart_params->ssid,
433 cmd->ssid.ssid_len);
434 cmd->flags = restart_params->flags;
435 cmd->requestor_id = restart_params->requestor_id;
436 cmd->disable_hw_ack = restart_params->disable_hw_ack;
437
438 chan->mhz = restart_params->mhz;
439 chan->band_center_freq1 =
440 restart_params->band_center_freq1;
441 chan->band_center_freq2 =
442 restart_params->band_center_freq2;
443 chan->info = restart_params->info;
444 chan->reg_info_1 = restart_params->reg_info_1;
445 chan->reg_info_2 = restart_params->reg_info_2;
446
447 cmd->num_noa_descriptors = 0;
448 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
449 sizeof(wmi_channel));
450 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
451 cmd->num_noa_descriptors *
452 sizeof(wmi_p2p_noa_descriptor));
453
454 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
455 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530456 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530457 wmi_buf_free(buf);
458 return QDF_STATUS_E_FAILURE;
459 }
460 return QDF_STATUS_SUCCESS;
461}
462
463
464/**
Govind Singh5eb51532016-03-09 11:34:12 +0530465 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
466 * @wmi: wmi handle
467 * @peer_addr: peer mac address
468 * @param: pointer to hold peer flush tid parameter
469 *
470 * Return: 0 for sucess or error code
471 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530472static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530473 uint8_t peer_addr[IEEE80211_ADDR_LEN],
474 struct peer_flush_params *param)
475{
476 wmi_peer_flush_tids_cmd_fixed_param *cmd;
477 wmi_buf_t buf;
478 int32_t len = sizeof(*cmd);
479
480 buf = wmi_buf_alloc(wmi, len);
481 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530482 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530483 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530484 }
485 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
486 WMITLV_SET_HDR(&cmd->tlv_header,
487 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
488 WMITLV_GET_STRUCT_TLVLEN
489 (wmi_peer_flush_tids_cmd_fixed_param));
490 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
491 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
492 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530493 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530494 peer_addr, param->vdev_id,
495 param->peer_tid_bitmap);
496 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530497 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530498 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530499 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530500 }
501
502 return 0;
503}
504
505/**
506 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
507 * @wmi: wmi handle
508 * @peer_addr: peer mac addr
509 * @vdev_id: vdev id
510 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530511 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530512 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530513static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530514 uint8_t peer_addr[IEEE80211_ADDR_LEN],
515 uint8_t vdev_id)
516{
517 wmi_peer_delete_cmd_fixed_param *cmd;
518 wmi_buf_t buf;
519 int32_t len = sizeof(*cmd);
520 buf = wmi_buf_alloc(wmi, len);
521 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530522 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530523 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530524 }
525 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
526 WMITLV_SET_HDR(&cmd->tlv_header,
527 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
528 WMITLV_GET_STRUCT_TLVLEN
529 (wmi_peer_delete_cmd_fixed_param));
530 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
531 cmd->vdev_id = vdev_id;
532
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800533 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530534 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530535 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530536 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530537 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530538 }
Govind Singh5eb51532016-03-09 11:34:12 +0530539
540 return 0;
541}
542
543/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530544 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
545 * to target id.
546 * @targ_paramid: Target parameter id to hold the result.
547 * @peer_param_id: host param id.
548 *
549 * Return: QDF_STATUS_SUCCESS for success
550 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
551 */
552#ifdef CONFIG_MCL
553static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
554 uint32_t *targ_paramid,
555 uint32_t peer_param_id)
556{
557 *targ_paramid = peer_param_id;
558 return QDF_STATUS_SUCCESS;
559}
560#else
561static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
562 uint32_t *targ_paramid,
563 uint32_t peer_param_id)
564{
565 switch (peer_param_id) {
566 case WMI_HOST_PEER_MIMO_PS_STATE:
567 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
568 break;
569 case WMI_HOST_PEER_AMPDU:
570 *targ_paramid = WMI_PEER_AMPDU;
571 break;
572 case WMI_HOST_PEER_AUTHORIZE:
573 *targ_paramid = WMI_PEER_AUTHORIZE;
574 break;
575 case WMI_HOST_PEER_CHWIDTH:
576 *targ_paramid = WMI_PEER_CHWIDTH;
577 break;
578 case WMI_HOST_PEER_NSS:
579 *targ_paramid = WMI_PEER_NSS;
580 break;
581 case WMI_HOST_PEER_USE_4ADDR:
582 *targ_paramid = WMI_PEER_USE_4ADDR;
583 break;
584 case WMI_HOST_PEER_MEMBERSHIP:
585 *targ_paramid = WMI_PEER_MEMBERSHIP;
586 break;
587 case WMI_HOST_PEER_USERPOS:
588 *targ_paramid = WMI_PEER_USERPOS;
589 break;
590 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
591 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
592 break;
593 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
594 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
595 break;
596 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
597 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
598 break;
599 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
600 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
601 break;
602 case WMI_HOST_PEER_PHYMODE:
603 *targ_paramid = WMI_PEER_PHYMODE;
604 break;
605 case WMI_HOST_PEER_USE_FIXED_PWR:
606 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
607 break;
608 case WMI_HOST_PEER_PARAM_FIXED_RATE:
609 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
610 break;
611 case WMI_HOST_PEER_SET_MU_WHITELIST:
612 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
613 break;
614 case WMI_HOST_PEER_SET_MAC_TX_RATE:
615 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
616 break;
617 case WMI_HOST_PEER_SET_MIN_TX_RATE:
618 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
619 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530620 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
621 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
622 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530623 default:
624 return QDF_STATUS_E_NOSUPPORT;
625 }
626
627 return QDF_STATUS_SUCCESS;
628}
629#endif
630/**
Govind Singh5eb51532016-03-09 11:34:12 +0530631 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530632 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530633 * @peer_addr: peer mac address
634 * @param : pointer to hold peer set parameter
635 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530636 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530637 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530638static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530639 uint8_t peer_addr[IEEE80211_ADDR_LEN],
640 struct peer_set_params *param)
641{
642 wmi_peer_set_param_cmd_fixed_param *cmd;
643 wmi_buf_t buf;
644 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530645 uint32_t param_id;
646
647 if (convert_host_peer_id_to_target_id_tlv(&param_id,
648 param->param_id) != QDF_STATUS_SUCCESS)
649 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530650
651 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
652 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530653 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530654 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530655 }
656 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
657 WMITLV_SET_HDR(&cmd->tlv_header,
658 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
659 WMITLV_GET_STRUCT_TLVLEN
660 (wmi_peer_set_param_cmd_fixed_param));
661 cmd->vdev_id = param->vdev_id;
662 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530663 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530664 cmd->param_value = param->param_value;
665 err = wmi_unified_cmd_send(wmi, buf,
666 sizeof(wmi_peer_set_param_cmd_fixed_param),
667 WMI_PEER_SET_PARAM_CMDID);
668 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530669 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530670 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530671 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530672 }
673
674 return 0;
675}
676
677/**
678 * send_vdev_up_cmd_tlv() - send vdev up command in fw
679 * @wmi: wmi handle
680 * @bssid: bssid
681 * @vdev_up_params: pointer to hold vdev up parameter
682 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530683 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530684 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530685static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530686 uint8_t bssid[IEEE80211_ADDR_LEN],
687 struct vdev_up_params *params)
688{
689 wmi_vdev_up_cmd_fixed_param *cmd;
690 wmi_buf_t buf;
691 int32_t len = sizeof(*cmd);
692
Govind Singhb53420c2016-03-09 14:32:57 +0530693 WMI_LOGD("%s: VDEV_UP", __func__);
694 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530695 params->vdev_id, params->assoc_id, bssid);
696 buf = wmi_buf_alloc(wmi, len);
697 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530698 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530699 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530700 }
701 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
702 WMITLV_SET_HDR(&cmd->tlv_header,
703 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
704 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
705 cmd->vdev_id = params->vdev_id;
706 cmd->vdev_assoc_id = params->assoc_id;
707 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
708 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530709 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530710 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530711 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530712 }
713
714 return 0;
715}
716
717/**
718 * send_peer_create_cmd_tlv() - send peer create command to fw
719 * @wmi: wmi handle
720 * @peer_addr: peer mac address
721 * @peer_type: peer type
722 * @vdev_id: vdev id
723 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530724 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530725 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530726static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530727 struct peer_create_params *param)
728{
729 wmi_peer_create_cmd_fixed_param *cmd;
730 wmi_buf_t buf;
731 int32_t len = sizeof(*cmd);
732
733 buf = wmi_buf_alloc(wmi, len);
734 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530735 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530736 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530737 }
738 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
739 WMITLV_SET_HDR(&cmd->tlv_header,
740 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
741 WMITLV_GET_STRUCT_TLVLEN
742 (wmi_peer_create_cmd_fixed_param));
743 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
744 cmd->peer_type = param->peer_type;
745 cmd->vdev_id = param->vdev_id;
746
747 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530748 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530749 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530750 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530751 }
Govind Singhb53420c2016-03-09 14:32:57 +0530752 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530753 param->vdev_id);
754
755 return 0;
756}
757
758/**
Leo Changeee40872016-09-28 13:43:36 -0700759 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
760 * command to fw
761 * @wmi: wmi handle
762 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
763 *
764 * Return: 0 for success or error code
765 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700766static
Leo Changeee40872016-09-28 13:43:36 -0700767QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
768 struct rx_reorder_queue_setup_params *param)
769{
770 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
771 wmi_buf_t buf;
772 int32_t len = sizeof(*cmd);
773
774 buf = wmi_buf_alloc(wmi, len);
775 if (!buf) {
776 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
777 return QDF_STATUS_E_NOMEM;
778 }
779 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
780 WMITLV_SET_HDR(&cmd->tlv_header,
781 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
782 WMITLV_GET_STRUCT_TLVLEN
783 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
784 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
785 cmd->vdev_id = param->vdev_id;
786 cmd->tid = param->tid;
787 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
788 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
789 cmd->queue_no = param->queue_no;
790
791 if (wmi_unified_cmd_send(wmi, buf, len,
792 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
793 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
794 __func__);
795 qdf_nbuf_free(buf);
796 return QDF_STATUS_E_FAILURE;
797 }
798 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
799 param->peer_macaddr, param->vdev_id, param->tid);
800
801 return QDF_STATUS_SUCCESS;
802}
803
804/**
805 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
806 * command to fw
807 * @wmi: wmi handle
808 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
809 *
810 * Return: 0 for success or error code
811 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700812static
Leo Changeee40872016-09-28 13:43:36 -0700813QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
814 struct rx_reorder_queue_remove_params *param)
815{
816 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
817 wmi_buf_t buf;
818 int32_t len = sizeof(*cmd);
819
820 buf = wmi_buf_alloc(wmi, len);
821 if (!buf) {
822 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
823 return QDF_STATUS_E_NOMEM;
824 }
825 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
826 wmi_buf_data(buf);
827 WMITLV_SET_HDR(&cmd->tlv_header,
828 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
829 WMITLV_GET_STRUCT_TLVLEN
830 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
831 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
832 cmd->vdev_id = param->vdev_id;
833 cmd->tid_mask = param->peer_tid_bitmap;
834
835 if (wmi_unified_cmd_send(wmi, buf, len,
836 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
837 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
838 __func__);
839 qdf_nbuf_free(buf);
840 return QDF_STATUS_E_FAILURE;
841 }
842 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
843 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
844
845 return QDF_STATUS_SUCCESS;
846}
847
848/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530849 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
850 * @wmi_handle: wmi handle
851 * @param: pointer holding peer details
852 *
853 * Return: 0 for success or error code
854 */
855static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
856 struct peer_add_wds_entry_params *param)
857{
858 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
859 wmi_buf_t buf;
860 int len = sizeof(*cmd);
861
862 buf = wmi_buf_alloc(wmi_handle, len);
863 if (!buf) {
864 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
865 return QDF_STATUS_E_FAILURE;
866 }
867 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
868 WMITLV_SET_HDR(&cmd->tlv_header,
869 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
870 WMITLV_GET_STRUCT_TLVLEN
871 (wmi_peer_add_wds_entry_cmd_fixed_param));
872 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
873 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
874 cmd->flags = param->flags;
875
876 return wmi_unified_cmd_send(wmi_handle, buf, len,
877 WMI_PEER_ADD_WDS_ENTRY_CMDID);
878}
879
880/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530881 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530882 * @wmi_handle: wmi handle
883 * @param: pointer holding peer details
884 *
885 * Return: 0 for success or error code
886 */
887static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
888 struct peer_del_wds_entry_params *param)
889{
890 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
891 wmi_buf_t buf;
892 int len = sizeof(*cmd);
893
894 buf = wmi_buf_alloc(wmi_handle, len);
895 if (!buf) {
896 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
897 return QDF_STATUS_E_NOMEM;
898 }
899 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
900 WMITLV_SET_HDR(&cmd->tlv_header,
901 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
902 WMITLV_GET_STRUCT_TLVLEN
903 (wmi_peer_remove_wds_entry_cmd_fixed_param));
904 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
905 return wmi_unified_cmd_send(wmi_handle, buf, len,
906 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
907}
908
909/**
910 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
911 * @wmi_handle: wmi handle
912 * @param: pointer holding peer details
913 *
914 * Return: 0 for success or error code
915 */
916static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
917 struct peer_update_wds_entry_params *param)
918{
919 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
920 wmi_buf_t buf;
921 int len = sizeof(*cmd);
922
923 buf = wmi_buf_alloc(wmi_handle, len);
924 if (!buf) {
925 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
926 return QDF_STATUS_E_NOMEM;
927 }
928
929 /* wmi_buf_alloc returns zeroed command buffer */
930 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
931 WMITLV_SET_HDR(&cmd->tlv_header,
932 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
933 WMITLV_GET_STRUCT_TLVLEN
934 (wmi_peer_update_wds_entry_cmd_fixed_param));
935 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
936 if (param->wds_macaddr)
937 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
938 &cmd->wds_macaddr);
939 if (param->peer_macaddr)
940 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
941 &cmd->peer_macaddr);
942 return wmi_unified_cmd_send(wmi_handle, buf, len,
943 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
944}
945
946
947
948/**
Govind Singh5eb51532016-03-09 11:34:12 +0530949 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
950 * @wmi_handle: wmi handle
951 * @value: value
952 * @mac_id: mac id to have radio context
953 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530954 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530955 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530956static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530957 uint32_t value, uint8_t mac_id)
958{
959 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
960 wmi_buf_t buf;
961 int32_t len = sizeof(*cmd);
962
Govind Singhb53420c2016-03-09 14:32:57 +0530963 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530964
965 buf = wmi_buf_alloc(wmi_handle, len);
966 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530967 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530968 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530969 }
970
971 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
972 WMITLV_SET_HDR(&cmd->tlv_header,
973 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
974 WMITLV_GET_STRUCT_TLVLEN
975 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +0530976 cmd->pdev_id = 0;
Govind Singh5eb51532016-03-09 11:34:12 +0530977 cmd->enable = value;
978
979 if (wmi_unified_cmd_send(wmi_handle, buf, len,
980 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530981 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530982 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530983 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530984 }
985
986 return 0;
987}
988
989/**
990 * send_pdev_utf_cmd_tlv() - send utf command to fw
991 * @wmi_handle: wmi handle
992 * @param: pointer to pdev_utf_params
993 * @mac_id: mac id to have radio context
994 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530995 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530996 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530997static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +0530998send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
999 struct pdev_utf_params *param,
1000 uint8_t mac_id)
1001{
1002 wmi_buf_t buf;
1003 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001004 /* if param->len is 0 no data is sent, return error */
1005 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301006 static uint8_t msgref = 1;
1007 uint8_t segNumber = 0, segInfo, numSegments;
1008 uint16_t chunk_len, total_bytes;
1009 uint8_t *bufpos;
1010 struct seg_hdr_info segHdrInfo;
1011
1012 bufpos = param->utf_payload;
1013 total_bytes = param->len;
1014 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1015 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1016 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1017
1018 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1019 numSegments++;
1020
1021 while (param->len) {
1022 if (param->len > MAX_WMI_UTF_LEN)
1023 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1024 else
1025 chunk_len = param->len;
1026
1027 buf = wmi_buf_alloc(wmi_handle,
1028 (chunk_len + sizeof(segHdrInfo) +
1029 WMI_TLV_HDR_SIZE));
1030 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301031 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301032 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301033 }
1034
1035 cmd = (uint8_t *) wmi_buf_data(buf);
1036
1037 segHdrInfo.len = total_bytes;
1038 segHdrInfo.msgref = msgref;
1039 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1040 segHdrInfo.segmentInfo = segInfo;
1041 segHdrInfo.pad = 0;
1042
Govind Singhb53420c2016-03-09 14:32:57 +05301043 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301044 " segHdrInfo.segmentInfo = %d",
1045 __func__, segHdrInfo.len, segHdrInfo.msgref,
1046 segHdrInfo.segmentInfo);
1047
Govind Singhb53420c2016-03-09 14:32:57 +05301048 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301049 "chunk len %d", __func__, total_bytes, segNumber,
1050 numSegments, chunk_len);
1051
1052 segNumber++;
1053
1054 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1055 (chunk_len + sizeof(segHdrInfo)));
1056 cmd += WMI_TLV_HDR_SIZE;
1057 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1058 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1059
1060 ret = wmi_unified_cmd_send(wmi_handle, buf,
1061 (chunk_len + sizeof(segHdrInfo) +
1062 WMI_TLV_HDR_SIZE),
1063 WMI_PDEV_UTF_CMDID);
1064
Govind Singh67922e82016-04-01 16:48:57 +05301065 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301066 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301067 wmi_buf_free(buf);
1068 break;
1069 }
1070
1071 param->len -= chunk_len;
1072 bufpos += chunk_len;
1073 }
1074
1075 msgref++;
1076
1077 return ret;
1078}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301079#ifdef CONFIG_MCL
1080static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1081 uint32_t host_param)
1082{
1083 return host_param;
1084}
1085#else
1086static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1087 uint32_t host_param)
1088{
1089 if (host_param < wmi_pdev_param_max)
1090 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301091
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301092 return WMI_UNAVAILABLE_PARAM;
1093}
1094#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301095/**
1096 * send_pdev_param_cmd_tlv() - set pdev parameters
1097 * @wmi_handle: wmi handle
1098 * @param: pointer to pdev parameter
1099 * @mac_id: radio context
1100 *
1101 * Return: 0 on success, errno on failure
1102 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301103static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301104send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1105 struct pdev_params *param,
1106 uint8_t mac_id)
1107{
Govind Singh67922e82016-04-01 16:48:57 +05301108 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301109 wmi_pdev_set_param_cmd_fixed_param *cmd;
1110 wmi_buf_t buf;
1111 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301112 uint32_t pdev_param;
1113
1114 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1115 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1116 WMI_LOGW("%s: Unavailable param %d\n",
1117 __func__, param->param_id);
1118 return QDF_STATUS_E_INVAL;
1119 }
Govind Singh5eb51532016-03-09 11:34:12 +05301120
1121 buf = wmi_buf_alloc(wmi_handle, len);
1122 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301123 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301124 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301125 }
1126 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1127 WMITLV_SET_HDR(&cmd->tlv_header,
1128 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1129 WMITLV_GET_STRUCT_TLVLEN
1130 (wmi_pdev_set_param_cmd_fixed_param));
Govind Singh8b1466e2016-03-16 16:27:50 +05301131 cmd->pdev_id = 0;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301132 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301133 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301134 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301135 param->param_value);
1136 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1137 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301138 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301139 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301140 wmi_buf_free(buf);
1141 }
1142 return ret;
1143}
1144
1145/**
1146 * send_suspend_cmd_tlv() - WMI suspend function
1147 * @param wmi_handle : handle to WMI.
1148 * @param param : pointer to hold suspend parameter
1149 * @mac_id: radio context
1150 *
1151 * Return 0 on success and -ve on failure.
1152 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301153static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301154 struct suspend_params *param,
1155 uint8_t mac_id)
1156{
1157 wmi_pdev_suspend_cmd_fixed_param *cmd;
1158 wmi_buf_t wmibuf;
1159 uint32_t len = sizeof(*cmd);
1160 int32_t ret;
1161
1162 /*
1163 * send the comand to Target to ignore the
1164 * PCIE reset so as to ensure that Host and target
1165 * states are in sync
1166 */
1167 wmibuf = wmi_buf_alloc(wmi_handle, len);
1168 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301169 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301170
1171 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1172 WMITLV_SET_HDR(&cmd->tlv_header,
1173 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1174 WMITLV_GET_STRUCT_TLVLEN
1175 (wmi_pdev_suspend_cmd_fixed_param));
1176 if (param->disable_target_intr)
1177 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1178 else
1179 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1180 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1181 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301182 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301183 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301184 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301185 }
1186
1187 return ret;
1188}
1189
1190/**
1191 * send_resume_cmd_tlv() - WMI resume function
1192 * @param wmi_handle : handle to WMI.
1193 * @mac_id: radio context
1194 *
1195 * Return: 0 on success and -ve on failure.
1196 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301197static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301198 uint8_t mac_id)
1199{
1200 wmi_buf_t wmibuf;
1201 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301202 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301203
1204 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1205 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301206 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301207 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1208 WMITLV_SET_HDR(&cmd->tlv_header,
1209 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1210 WMITLV_GET_STRUCT_TLVLEN
1211 (wmi_pdev_resume_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07001212 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh5eb51532016-03-09 11:34:12 +05301213 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1214 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301215 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301216 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301217 wmi_buf_free(wmibuf);
1218 }
1219
1220 return ret;
1221}
1222
1223/**
1224 * send_wow_enable_cmd_tlv() - WMI wow enable function
1225 * @param wmi_handle : handle to WMI.
1226 * @param param : pointer to hold wow enable parameter
1227 * @mac_id: radio context
1228 *
1229 * Return: 0 on success and -ve on failure.
1230 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301231static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301232 struct wow_cmd_params *param,
1233 uint8_t mac_id)
1234{
1235 wmi_wow_enable_cmd_fixed_param *cmd;
1236 wmi_buf_t buf;
1237 int32_t len;
1238 int32_t ret;
1239
1240 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1241
1242 buf = wmi_buf_alloc(wmi_handle, len);
1243 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301244 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1245 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301246 }
1247 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1248 WMITLV_SET_HDR(&cmd->tlv_header,
1249 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1250 WMITLV_GET_STRUCT_TLVLEN
1251 (wmi_wow_enable_cmd_fixed_param));
1252 cmd->enable = param->enable;
1253 if (param->can_suspend_link)
1254 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1255 else
1256 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001257 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301258
Govind Singhb53420c2016-03-09 14:32:57 +05301259 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301260 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1261 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1262
1263 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1264 WMI_WOW_ENABLE_CMDID);
1265 if (ret)
1266 wmi_buf_free(buf);
1267
1268 return ret;
1269}
1270
1271/**
1272 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301273 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301274 * @peer_addr: peer mac address
1275 * @param: pointer to ap_ps parameter structure
1276 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301277 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301278 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301279static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301280 uint8_t *peer_addr,
1281 struct ap_ps_params *param)
1282{
1283 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1284 wmi_buf_t buf;
1285 int32_t err;
1286
1287 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1288 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301289 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301290 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301291 }
1292 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1293 WMITLV_SET_HDR(&cmd->tlv_header,
1294 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1295 WMITLV_GET_STRUCT_TLVLEN
1296 (wmi_ap_ps_peer_cmd_fixed_param));
1297 cmd->vdev_id = param->vdev_id;
1298 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1299 cmd->param = param->param;
1300 cmd->value = param->value;
1301 err = wmi_unified_cmd_send(wmi_handle, buf,
1302 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1303 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301304 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301305 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301306 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301307 }
1308
1309 return 0;
1310}
1311
1312/**
1313 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301314 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301315 * @peer_addr: peer mac address
1316 * @param: pointer to sta_ps parameter structure
1317 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301318 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301319 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301320static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301321 struct sta_ps_params *param)
1322{
1323 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1324 wmi_buf_t buf;
1325 int32_t len = sizeof(*cmd);
1326
1327 buf = wmi_buf_alloc(wmi_handle, len);
1328 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301329 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301330 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301331 }
1332
1333 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1334 WMITLV_SET_HDR(&cmd->tlv_header,
1335 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1336 WMITLV_GET_STRUCT_TLVLEN
1337 (wmi_sta_powersave_param_cmd_fixed_param));
1338 cmd->vdev_id = param->vdev_id;
1339 cmd->param = param->param;
1340 cmd->value = param->value;
1341
1342 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1343 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301344 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301345 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301346 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301347 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301348 }
1349
1350 return 0;
1351}
1352
1353/**
1354 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301355 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301356 * @param: ponirt to crash inject paramter structure
1357 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301358 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301359 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301360static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301361 struct crash_inject *param)
1362{
1363 int32_t ret = 0;
1364 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1365 uint16_t len = sizeof(*cmd);
1366 wmi_buf_t buf;
1367
1368 buf = wmi_buf_alloc(wmi_handle, len);
1369 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301370 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301371 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301372 }
1373
1374 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1375 WMITLV_SET_HDR(&cmd->tlv_header,
1376 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1377 WMITLV_GET_STRUCT_TLVLEN
1378 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1379 cmd->type = param->type;
1380 cmd->delay_time_ms = param->delay_time_ms;
1381
1382 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1383 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301384 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301385 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301386 __func__, ret);
1387 wmi_buf_free(buf);
1388 }
1389
1390 return ret;
1391}
1392
1393/**
1394 * send_dbglog_cmd_tlv() - set debug log level
1395 * @param wmi_handle : handle to WMI.
1396 * @param param : pointer to hold dbglog level parameter
1397 *
1398 * Return: 0 on success and -ve on failure.
1399 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301400 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301401send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1402 struct dbglog_params *dbglog_param)
1403{
1404 wmi_buf_t buf;
1405 wmi_debug_log_config_cmd_fixed_param *configmsg;
1406 A_STATUS status = A_OK;
1407 int32_t i;
1408 int32_t len;
1409 int8_t *buf_ptr;
1410 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1411
1412 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1413
1414 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1415 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1416 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1417 buf = wmi_buf_alloc(wmi_handle, len);
1418 if (buf == NULL)
1419 return A_NO_MEMORY;
1420
1421 configmsg =
1422 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1423 buf_ptr = (int8_t *) configmsg;
1424 WMITLV_SET_HDR(&configmsg->tlv_header,
1425 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1426 WMITLV_GET_STRUCT_TLVLEN
1427 (wmi_debug_log_config_cmd_fixed_param));
1428 configmsg->dbg_log_param = dbglog_param->param;
1429 configmsg->value = dbglog_param->val;
1430 /* Filling in the data part of second tlv -- should
1431 * follow first tlv _ WMI_TLV_HDR_SIZE */
1432 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1433 sizeof
1434 (wmi_debug_log_config_cmd_fixed_param)
1435 + WMI_TLV_HDR_SIZE);
1436 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1437 WMITLV_TAG_ARRAY_UINT32,
1438 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1439 if (dbglog_param->module_id_bitmap) {
1440 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1441 module_id_bitmap_array[i] =
1442 dbglog_param->module_id_bitmap[i];
1443 }
1444 }
1445
1446 status = wmi_unified_cmd_send(wmi_handle, buf,
1447 len, WMI_DBGLOG_CFG_CMDID);
1448
1449 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301450 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301451
1452 return status;
1453}
1454
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301455#ifdef CONFIG_MCL
1456static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1457 uint32_t host_param)
1458{
1459 return host_param;
1460}
1461#else
1462static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1463 uint32_t host_param)
1464{
1465 if (host_param < wmi_vdev_param_max)
1466 return wmi_handle->vdev_param[host_param];
1467
1468 return WMI_UNAVAILABLE_PARAM;
1469}
1470#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301471/**
1472 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1473 * @param wmi_handle : handle to WMI.
1474 * @param macaddr : MAC address
1475 * @param param : pointer to hold vdev set parameter
1476 *
1477 * Return: 0 on success and -ve on failure.
1478 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301479static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301480 struct vdev_set_params *param)
1481{
Govind Singh67922e82016-04-01 16:48:57 +05301482 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301483 wmi_vdev_set_param_cmd_fixed_param *cmd;
1484 wmi_buf_t buf;
1485 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301486 uint32_t vdev_param;
1487
1488 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1489 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1490 WMI_LOGW("%s:Vdev param %d not available", __func__,
1491 param->param_id);
1492 return QDF_STATUS_E_INVAL;
1493
1494 }
Govind Singh5eb51532016-03-09 11:34:12 +05301495
1496 buf = wmi_buf_alloc(wmi_handle, len);
1497 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301498 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301499 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301500 }
1501 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1502 WMITLV_SET_HDR(&cmd->tlv_header,
1503 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1504 WMITLV_GET_STRUCT_TLVLEN
1505 (wmi_vdev_set_param_cmd_fixed_param));
1506 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301507 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301508 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301509 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301510 param->if_id, param->param_id, param->param_value);
1511 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1512 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301513 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301514 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301515 wmi_buf_free(buf);
1516 }
1517
1518 return ret;
1519}
1520
1521/**
1522 * send_stats_request_cmd_tlv() - WMI request stats function
1523 * @param wmi_handle : handle to WMI.
1524 * @param macaddr : MAC address
1525 * @param param : pointer to hold stats request parameter
1526 *
1527 * Return: 0 on success and -ve on failure.
1528 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301529static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301530 uint8_t macaddr[IEEE80211_ADDR_LEN],
1531 struct stats_request_params *param)
1532{
Govind Singhd3156eb2016-02-26 17:50:39 +05301533 int32_t ret;
1534 wmi_request_stats_cmd_fixed_param *cmd;
1535 wmi_buf_t buf;
1536 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1537
1538 buf = wmi_buf_alloc(wmi_handle, len);
1539 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301540 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1541 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301542 }
1543
1544 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1545 WMITLV_SET_HDR(&cmd->tlv_header,
1546 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1547 WMITLV_GET_STRUCT_TLVLEN
1548 (wmi_request_stats_cmd_fixed_param));
1549 cmd->stats_id = param->stats_id;
1550 cmd->vdev_id = param->vdev_id;
1551 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1552 WMI_REQUEST_STATS_CMDID);
1553 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301554 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301555 wmi_buf_free(buf);
1556 }
1557
1558 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301559}
1560
Govind Singh87542482016-06-08 19:40:11 +05301561#ifdef CONFIG_WIN
1562/**
1563 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1564 * @param wmi_handle : handle to WMI.
1565 * @param macaddr : MAC address
1566 * @param param : pointer to hold stats request parameter
1567 *
1568 * Return: 0 on success and -ve on failure.
1569 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301570static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301571 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1572{
1573 return 0;
1574}
1575#else
Govind Singh5eb51532016-03-09 11:34:12 +05301576/**
1577 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1578 * @param wmi_handle : handle to WMI.
1579 * @param macaddr : MAC address
1580 * @param param : pointer to hold stats request parameter
1581 *
1582 * Return: 0 on success and -ve on failure.
1583 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301584static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301585 uint8_t macaddr[IEEE80211_ADDR_LEN],
1586 struct packet_enable_params *param)
1587{
1588 return 0;
1589}
Govind Singh87542482016-06-08 19:40:11 +05301590#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301591
Govind Singh87542482016-06-08 19:40:11 +05301592#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301593/**
1594 * send_beacon_send_cmd_tlv() - WMI beacon send function
1595 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301596 * @param param : pointer to hold beacon send cmd parameter
1597 *
1598 * Return: 0 on success and -ve on failure.
1599 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301600static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301601 struct beacon_params *param)
1602{
Govind Singhd3156eb2016-02-26 17:50:39 +05301603 int32_t ret;
1604 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1605 wmi_bcn_prb_info *bcn_prb_info;
1606 wmi_buf_t wmi_buf;
1607 uint8_t *buf_ptr;
1608 uint32_t wmi_buf_len;
1609
1610 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1611 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1612 param->tmpl_len_aligned;
1613 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1614 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301615 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301616 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301617 }
1618 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1619 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1620 WMITLV_SET_HDR(&cmd->tlv_header,
1621 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1622 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1623 cmd->vdev_id = param->vdev_id;
1624 cmd->tim_ie_offset = param->tim_ie_offset;
1625 cmd->buf_len = param->tmpl_len;
1626 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1627
1628 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1629 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1630 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1631 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1632 bcn_prb_info->caps = 0;
1633 bcn_prb_info->erp = 0;
1634 buf_ptr += sizeof(wmi_bcn_prb_info);
1635
1636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1637 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301638 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301639
1640 ret = wmi_unified_cmd_send(wmi_handle,
1641 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1642 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301643 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301644 wmi_buf_free(wmi_buf);
1645 }
Govind Singh5eb51532016-03-09 11:34:12 +05301646 return 0;
1647}
Govind Singh87542482016-06-08 19:40:11 +05301648#else
Sathish Kumarfd347372017-02-13 12:29:09 +05301649static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301650 struct beacon_params *param)
1651{
1652 return 0;
1653}
1654
1655/**
1656 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1657 * @param wmi_handle : handle to WMI.
1658 * @param param : pointer to hold beacon send cmd parameter
1659 *
1660 * Return: 0 on success and -ve on failure.
1661 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301662static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301663 struct beacon_tmpl_params *param)
1664{
1665 int32_t ret;
1666 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1667 wmi_bcn_prb_info *bcn_prb_info;
1668 wmi_buf_t wmi_buf;
1669 uint8_t *buf_ptr;
1670 uint32_t wmi_buf_len;
1671
Sathish Kumar45e991b2017-02-27 10:35:40 +05301672 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301673 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1674 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1675 param->tmpl_len_aligned;
1676 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1677 if (!wmi_buf) {
1678 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1679 return QDF_STATUS_E_NOMEM;
1680 }
1681 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1682 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1683 WMITLV_SET_HDR(&cmd->tlv_header,
1684 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1685 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1686 cmd->vdev_id = param->vdev_id;
1687 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301688 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1689 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301690 cmd->buf_len = param->tmpl_len;
1691 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1692
1693 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1694 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1695 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1696 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1697 bcn_prb_info->caps = 0;
1698 bcn_prb_info->erp = 0;
1699 buf_ptr += sizeof(wmi_bcn_prb_info);
1700
1701 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1702 buf_ptr += WMI_TLV_HDR_SIZE;
1703 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1704
1705 ret = wmi_unified_cmd_send(wmi_handle,
1706 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1707 if (ret) {
1708 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1709 wmi_buf_free(wmi_buf);
1710 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301711
Govind Singh87542482016-06-08 19:40:11 +05301712 return 0;
1713}
1714#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301715
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301716#ifdef CONFIG_MCL
1717static inline void copy_peer_flags_tlv(
1718 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1719 struct peer_assoc_params *param)
1720{
1721 cmd->peer_flags = param->peer_flags;
1722}
1723#else
1724static inline void copy_peer_flags_tlv(
1725 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1726 struct peer_assoc_params *param)
1727{
1728 /*
1729 * The target only needs a subset of the flags maintained in the host.
1730 * Just populate those flags and send it down
1731 */
1732 cmd->peer_flags = 0;
1733
1734 /*
1735 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1736 */
1737 if (param->is_wme_set) {
1738
1739 if (param->qos_flag)
1740 cmd->peer_flags |= WMI_PEER_QOS;
1741 if (param->apsd_flag)
1742 cmd->peer_flags |= WMI_PEER_APSD;
1743 if (param->ht_flag)
1744 cmd->peer_flags |= WMI_PEER_HT;
1745 if (param->bw_40)
1746 cmd->peer_flags |= WMI_PEER_40MHZ;
1747 if (param->bw_80)
1748 cmd->peer_flags |= WMI_PEER_80MHZ;
1749 if (param->bw_160)
1750 cmd->peer_flags |= WMI_PEER_160MHZ;
1751
1752 /* Typically if STBC is enabled for VHT it should be enabled
1753 * for HT as well
1754 **/
1755 if (param->stbc_flag)
1756 cmd->peer_flags |= WMI_PEER_STBC;
1757
1758 /* Typically if LDPC is enabled for VHT it should be enabled
1759 * for HT as well
1760 **/
1761 if (param->ldpc_flag)
1762 cmd->peer_flags |= WMI_PEER_LDPC;
1763
1764 if (param->static_mimops_flag)
1765 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1766 if (param->dynamic_mimops_flag)
1767 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1768 if (param->spatial_mux_flag)
1769 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1770 if (param->vht_flag)
1771 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001772 if (param->he_flag)
1773 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301774 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001775
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301776 /*
1777 * Suppress authorization for all AUTH modes that need 4-way handshake
1778 * (during re-association).
1779 * Authorization will be done for these modes on key installation.
1780 */
1781 if (param->auth_flag)
1782 cmd->peer_flags |= WMI_PEER_AUTH;
1783 if (param->need_ptk_4_way)
1784 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1785 else
1786 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1787 if (param->need_gtk_2_way)
1788 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1789 /* safe mode bypass the 4-way handshake */
1790 if (param->safe_mode_enabled)
1791 cmd->peer_flags &=
1792 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1793 /* Disable AMSDU for station transmit, if user configures it */
1794 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1795 * it
1796 * if (param->amsdu_disable) Add after FW support
1797 **/
1798
1799 /* Target asserts if node is marked HT and all MCS is set to 0.
1800 * Mark the node as non-HT if all the mcs rates are disabled through
1801 * iwpriv
1802 **/
1803 if (param->peer_ht_rates.num_rates == 0)
1804 cmd->peer_flags &= ~WMI_PEER_HT;
1805}
1806#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301807
1808#ifdef CONFIG_MCL
1809static inline void copy_peer_mac_addr_tlv(
1810 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1811 struct peer_assoc_params *param)
1812{
1813 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1814 sizeof(param->peer_macaddr));
1815}
1816#else
1817static inline void copy_peer_mac_addr_tlv(
1818 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1819 struct peer_assoc_params *param)
1820{
1821 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1822}
1823#endif
1824
Govind Singh5eb51532016-03-09 11:34:12 +05301825/**
1826 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1827 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301828 * @param param : pointer to peer assoc parameter
1829 *
1830 * Return: 0 on success and -ve on failure.
1831 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301832static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301833 struct peer_assoc_params *param)
1834{
Govind Singhd3156eb2016-02-26 17:50:39 +05301835 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1836 wmi_vht_rate_set *mcs;
1837 wmi_buf_t buf;
1838 int32_t len;
1839 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301840 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301841 uint32_t peer_legacy_rates_align;
1842 uint32_t peer_ht_rates_align;
1843
1844
1845 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1846 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301847
1848 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301849 (peer_legacy_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301850 WMI_TLV_HDR_SIZE +
Govind Singh3419aea2016-03-28 22:02:42 +05301851 (peer_ht_rates_align * sizeof(uint8_t)) +
Govind Singhd3156eb2016-02-26 17:50:39 +05301852 sizeof(wmi_vht_rate_set);
1853
1854 buf = wmi_buf_alloc(wmi_handle, len);
1855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301856 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301857 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301858 }
1859
1860 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1861 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1862 WMITLV_SET_HDR(&cmd->tlv_header,
1863 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1864 WMITLV_GET_STRUCT_TLVLEN
1865 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301866
Govind Singhd3156eb2016-02-26 17:50:39 +05301867 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301868
Govind Singhd3156eb2016-02-26 17:50:39 +05301869 cmd->peer_new_assoc = param->peer_new_assoc;
1870 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301871
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301872 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301873 copy_peer_mac_addr_tlv(cmd, param);
1874
Govind Singhd3156eb2016-02-26 17:50:39 +05301875 cmd->peer_rate_caps = param->peer_rate_caps;
1876 cmd->peer_caps = param->peer_caps;
1877 cmd->peer_listen_intval = param->peer_listen_intval;
1878 cmd->peer_ht_caps = param->peer_ht_caps;
1879 cmd->peer_max_mpdu = param->peer_max_mpdu;
1880 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301881 cmd->peer_vht_caps = param->peer_vht_caps;
1882 cmd->peer_phymode = param->peer_phymode;
1883
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001884 /* Update 11ax capabilities */
1885 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1886 cmd->peer_he_ops = param->peer_he_ops;
1887 cmd->peer_he_mcs = param->peer_he_mcs;
1888 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1889 sizeof(param->peer_he_cap_phyinfo));
1890 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1891 sizeof(param->peer_ppet));
1892
Govind Singhd3156eb2016-02-26 17:50:39 +05301893 /* Update peer legacy rate information */
1894 buf_ptr += sizeof(*cmd);
1895 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301896 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301897 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301898 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301899 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301900 param->peer_legacy_rates.num_rates);
1901
1902 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001903 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301904 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301905 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301906 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301907 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301908 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301909 param->peer_ht_rates.num_rates);
1910
1911 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001912 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301913 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1914 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1915
1916 cmd->peer_nss = param->peer_nss;
1917 mcs = (wmi_vht_rate_set *) buf_ptr;
1918 if (param->vht_capable) {
1919 mcs->rx_max_rate = param->rx_max_rate;
1920 mcs->rx_mcs_set = param->rx_mcs_set;
1921 mcs->tx_max_rate = param->tx_max_rate;
1922 mcs->tx_mcs_set = param->tx_mcs_set;
1923 }
1924
Govind Singhb53420c2016-03-09 14:32:57 +05301925 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301926 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1927 "nss %d phymode %d peer_mpdu_density %d "
1928 "cmd->peer_vht_caps %x", __func__,
1929 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1930 cmd->peer_rate_caps, cmd->peer_caps,
1931 cmd->peer_listen_intval, cmd->peer_ht_caps,
1932 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1933 cmd->peer_mpdu_density,
1934 cmd->peer_vht_caps);
1935
1936 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1937 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301938 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301939 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301940 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301941 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301942 }
1943
1944 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301945}
1946
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301947/* copy_scan_notify_events() - Helper routine to copy scan notify events
1948 */
1949#ifdef CONFIG_MCL
1950static inline void copy_scan_notify_ev_flags(
1951 wmi_start_scan_cmd_fixed_param * cmd,
1952 struct scan_start_params *params)
1953{
1954 cmd->notify_scan_events = params->notify_scan_events;
1955 cmd->scan_ctrl_flags = params->scan_ctrl_flags;
1956}
1957#else
1958static inline void copy_scan_notify_ev_flags(
1959 wmi_start_scan_cmd_fixed_param * cmd,
1960 struct scan_start_params *params)
1961{
1962 cmd->notify_scan_events = WMI_SCAN_EVENT_STARTED |
1963 WMI_SCAN_EVENT_COMPLETED |
1964 WMI_SCAN_EVENT_BSS_CHANNEL |
1965 WMI_SCAN_EVENT_FOREIGN_CHANNEL |
1966 WMI_SCAN_EVENT_DEQUEUED
1967 ;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301968
1969 cmd->scan_ctrl_flags = (params->passive_flag) ?
1970 WMI_SCAN_FLAG_PASSIVE : 0;
1971
1972 if (params->is_strict_pscan_en)
1973 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301974
1975 if (params->is_phy_error)
1976 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301977
1978 if (params->half_rate)
1979 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
1980
1981 if (params->quarter_rate)
1982 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
1983
1984 if (params->is_phy_error)
1985 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
1986
1987 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
1988 /* add cck rates if required */
1989 if (params->add_cck_rates)
1990 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
1991 /** It enables the Channel stat event indication to host */
1992 if (params->chan_stat_enable)
1993 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
1994 if (params->add_bcast_probe_reqd)
1995 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
1996 /* off channel TX control */
1997 if (params->offchan_tx_mgmt)
1998 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
1999 if (params->offchan_tx_data)
2000 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302001}
2002#endif
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302003
2004
2005/* scan_copy_ie_buffer() - Copy scan ie_data */
2006#ifndef CONFIG_MCL
2007static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
2008 struct scan_start_params *params)
2009{
2010 qdf_mem_copy(buf_ptr, params->ie_data, params->ie_len);
2011}
2012#else
2013static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
2014 struct scan_start_params *params)
2015{
2016 qdf_mem_copy(buf_ptr,
2017 (uint8_t *) params->ie_base +
2018 (params->uie_fieldOffset), params->ie_len);
2019}
2020#endif
2021
Govind Singh5eb51532016-03-09 11:34:12 +05302022/**
2023 * send_scan_start_cmd_tlv() - WMI scan start function
2024 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302025 * @param param : pointer to hold scan start cmd parameter
2026 *
2027 * Return: 0 on success and -ve on failure.
2028 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302029static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302030 struct scan_start_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302031{
Govind Singhd3156eb2016-02-26 17:50:39 +05302032 int32_t ret = 0;
2033 int32_t i;
2034 wmi_buf_t wmi_buf;
2035 wmi_start_scan_cmd_fixed_param *cmd;
2036 uint8_t *buf_ptr;
2037 uint32_t *tmp_ptr;
2038 wmi_ssid *ssid = NULL;
2039 wmi_mac_addr *bssid;
2040 int len = sizeof(*cmd);
2041
2042 /* Length TLV placeholder for array of uint32_t */
2043 len += WMI_TLV_HDR_SIZE;
2044 /* calculate the length of buffer required */
2045 if (params->num_chan)
2046 len += params->num_chan * sizeof(uint32_t);
2047
2048 /* Length TLV placeholder for array of wmi_ssid structures */
2049 len += WMI_TLV_HDR_SIZE;
2050 if (params->num_ssids)
2051 len += params->num_ssids * sizeof(wmi_ssid);
2052
2053 /* Length TLV placeholder for array of wmi_mac_addr structures */
2054 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302055 if (params->num_bssid)
2056 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302057
2058 /* Length TLV placeholder for array of bytes */
2059 len += WMI_TLV_HDR_SIZE;
2060 if (params->ie_len)
2061 len += roundup(params->ie_len, sizeof(uint32_t));
2062
2063 /* Allocate the memory */
2064 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2065 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302066 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302067 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302068 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302069 }
2070 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2071 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2072 WMITLV_SET_HDR(&cmd->tlv_header,
2073 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2074 WMITLV_GET_STRUCT_TLVLEN
2075 (wmi_start_scan_cmd_fixed_param));
2076
2077 cmd->scan_id = params->scan_id;
2078 cmd->scan_req_id = params->scan_req_id;
2079 cmd->vdev_id = params->vdev_id;
2080 cmd->scan_priority = params->scan_priority;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302081 copy_scan_notify_ev_flags(cmd, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05302082 cmd->dwell_time_active = params->dwell_time_active;
2083 cmd->dwell_time_passive = params->dwell_time_passive;
2084 cmd->min_rest_time = params->min_rest_time;
2085 cmd->max_rest_time = params->max_rest_time;
2086 cmd->repeat_probe_time = params->repeat_probe_time;
2087 cmd->probe_spacing_time = params->probe_spacing_time;
2088 cmd->idle_time = params->idle_time;
2089 cmd->max_scan_time = params->max_scan_time;
2090 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302091 cmd->burst_duration = params->burst_duration;
2092 cmd->num_chan = params->num_chan;
2093 cmd->num_bssid = params->num_bssid;
2094 cmd->num_ssids = params->num_ssids;
2095 cmd->ie_len = params->ie_len;
2096 cmd->n_probes = params->n_probes;
2097 buf_ptr += sizeof(*cmd);
2098 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2099 for (i = 0; i < params->num_chan; ++i)
2100 tmp_ptr[i] = params->chan_list[i];
2101
2102 WMITLV_SET_HDR(buf_ptr,
2103 WMITLV_TAG_ARRAY_UINT32,
2104 (params->num_chan * sizeof(uint32_t)));
2105 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302106 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302107 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302108 goto error;
2109 }
2110
2111 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2112 (params->num_ssids * sizeof(wmi_ssid)));
2113
2114 if (params->num_ssids) {
2115 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2116 for (i = 0; i < params->num_ssids; ++i) {
2117 ssid->ssid_len = params->ssid[i].length;
Govind Singhb53420c2016-03-09 14:32:57 +05302118 qdf_mem_copy(ssid->ssid, params->ssid[i].mac_ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302119 params->ssid[i].length);
2120 ssid++;
2121 }
2122 }
2123 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2124
2125 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2126 (params->num_bssid * sizeof(wmi_mac_addr)));
2127 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302128#if CONFIG_MCL
Govind Singhd3156eb2016-02-26 17:50:39 +05302129 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->mac_add_bytes, bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302130#else
2131 if (params->num_bssid) {
2132 for (i = 0; i < params->num_bssid; ++i) {
2133 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->bssid_list[i],
2134 bssid);
2135 bssid++;
2136 }
2137 }
2138#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302139 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_bssid * sizeof(wmi_mac_addr));
2140
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302141 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2142 roundup(params->ie_len, sizeof(uint32_t)));
Govind Singhd3156eb2016-02-26 17:50:39 +05302143 if (params->ie_len) {
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302144 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE, params);
Govind Singhd3156eb2016-02-26 17:50:39 +05302145 }
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302146 buf_ptr += WMI_TLV_HDR_SIZE + roundup(params->ie_len, sizeof(uint32_t));
Govind Singhd3156eb2016-02-26 17:50:39 +05302147
2148 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2149 len, WMI_START_SCAN_CMDID);
2150 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302151 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302152 wmi_buf_free(wmi_buf);
2153 }
2154 return ret;
2155error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302156 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302157 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302158}
2159
2160/**
2161 * send_scan_stop_cmd_tlv() - WMI scan start function
2162 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302163 * @param param : pointer to hold scan start cmd parameter
2164 *
2165 * Return: 0 on success and -ve on failure.
2166 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302167static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05302168 struct scan_stop_params *param)
2169{
Govind Singhd3156eb2016-02-26 17:50:39 +05302170 wmi_stop_scan_cmd_fixed_param *cmd;
2171 int ret;
2172 int len = sizeof(*cmd);
2173 wmi_buf_t wmi_buf;
2174
2175 /* Allocate the memory */
2176 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2177 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302178 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302179 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302180 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302181 goto error;
2182 }
2183
2184 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2185 WMITLV_SET_HDR(&cmd->tlv_header,
2186 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2187 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2188 cmd->vdev_id = param->vdev_id;
2189 cmd->requestor = param->requestor;
2190 cmd->scan_id = param->scan_id;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302191 cmd->pdev_id = param->pdev_id;
Govind Singhd3156eb2016-02-26 17:50:39 +05302192 /* stop the scan with the corresponding scan_id */
2193 cmd->req_type = param->req_type;
2194 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf,
2195 len, WMI_STOP_SCAN_CMDID);
2196 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302197 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302198 wmi_buf_free(wmi_buf);
2199 }
2200
2201error:
2202 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302203}
2204
Govind Singh87542482016-06-08 19:40:11 +05302205#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302206/**
2207 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2208 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302209 * @param param : pointer to hold scan channel list parameter
2210 *
2211 * Return: 0 on success and -ve on failure.
2212 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302213static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302214 struct scan_chan_list_params *chan_list)
2215{
2216 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302217 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302218 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302219 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302220 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302221 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302222 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2223
2224 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2225 buf = wmi_buf_alloc(wmi_handle, len);
2226 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302227 WMI_LOGE("Failed to allocate memory");
2228 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302229 goto end;
2230 }
2231
2232 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2233 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2234 WMITLV_SET_HDR(&cmd->tlv_header,
2235 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2236 WMITLV_GET_STRUCT_TLVLEN
2237 (wmi_scan_chan_list_cmd_fixed_param));
2238
Govind Singhb53420c2016-03-09 14:32:57 +05302239 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302240
2241 cmd->num_scan_chans = chan_list->num_scan_chans;
2242 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2243 WMITLV_TAG_ARRAY_STRUC,
2244 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302245 chan_info = (wmi_channel_param *)
2246 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302247 tchan_info = chan_list->chan_info;
2248
2249 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2250 WMITLV_SET_HDR(&chan_info->tlv_header,
2251 WMITLV_TAG_STRUC_wmi_channel,
2252 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2253 chan_info->mhz = tchan_info->mhz;
2254 chan_info->band_center_freq1 =
2255 tchan_info->band_center_freq1;
2256 chan_info->band_center_freq2 =
2257 tchan_info->band_center_freq2;
2258 chan_info->info = tchan_info->info;
2259 chan_info->reg_info_1 = tchan_info->reg_info_1;
2260 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302261 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302262
2263 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2264 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2265 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2266 tchan_info++;
2267 chan_info++;
2268 }
2269
Govind Singh67922e82016-04-01 16:48:57 +05302270 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singhd3156eb2016-02-26 17:50:39 +05302271 WMI_SCAN_CHAN_LIST_CMDID);
2272
Govind Singh67922e82016-04-01 16:48:57 +05302273 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302274 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302275 wmi_buf_free(buf);
2276 }
Govind Singh67922e82016-04-01 16:48:57 +05302277
Govind Singhd3156eb2016-02-26 17:50:39 +05302278end:
Govind Singhb53420c2016-03-09 14:32:57 +05302279 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302280}
Govind Singh87542482016-06-08 19:40:11 +05302281#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302282static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302283 struct scan_chan_list_params *chan_list)
2284{
2285 wmi_buf_t buf;
2286 QDF_STATUS qdf_status;
2287 wmi_scan_chan_list_cmd_fixed_param *cmd;
2288 int i;
2289 uint8_t *buf_ptr;
2290 wmi_channel *chan_info;
2291 struct channel_param *tchan_info;
2292 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302293
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302294 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302295 buf = wmi_buf_alloc(wmi_handle, len);
2296 if (!buf) {
2297 WMI_LOGE("Failed to allocate memory");
2298 qdf_status = QDF_STATUS_E_NOMEM;
2299 goto end;
2300 }
2301
2302 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2303 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2304 WMITLV_SET_HDR(&cmd->tlv_header,
2305 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2306 WMITLV_GET_STRUCT_TLVLEN
2307 (wmi_scan_chan_list_cmd_fixed_param));
2308
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302309 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302310
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302311 cmd->pdev_id = chan_list->pdev_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302312 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302313 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2314 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302315 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302316 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2317 tchan_info = &(chan_list->ch_param[0]);
2318
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302319 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302320 WMITLV_SET_HDR(&chan_info->tlv_header,
2321 WMITLV_TAG_STRUC_wmi_channel,
2322 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2323 chan_info->mhz = tchan_info->mhz;
2324 chan_info->band_center_freq1 =
2325 tchan_info->cfreq1;
2326 chan_info->band_center_freq2 =
2327 tchan_info->cfreq2;
2328
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302329 if (tchan_info->is_chan_passive)
2330 WMI_SET_CHANNEL_FLAG(chan_info,
2331 WMI_CHAN_FLAG_PASSIVE);
2332
2333 if (tchan_info->allow_vht)
2334 WMI_SET_CHANNEL_FLAG(chan_info,
2335 WMI_CHAN_FLAG_ALLOW_VHT);
2336 else if (tchan_info->allow_ht)
2337 WMI_SET_CHANNEL_FLAG(chan_info,
2338 WMI_CHAN_FLAG_ALLOW_HT);
2339 WMI_SET_CHANNEL_MODE(chan_info,
2340 tchan_info->phy_mode);
2341
2342 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2343 * after FW support
2344 */
2345
2346 /* also fill in power information */
2347 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2348 tchan_info->minpower);
2349 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2350 tchan_info->maxpower);
2351 WMI_SET_CHANNEL_REG_POWER(chan_info,
2352 tchan_info->maxregpower);
2353 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2354 tchan_info->antennamax);
2355 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2356 tchan_info->reg_class_id);
2357
Govind Singh87542482016-06-08 19:40:11 +05302358 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2359
Govind Singh87542482016-06-08 19:40:11 +05302360 tchan_info++;
2361 chan_info++;
2362 }
2363
2364 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
2365 WMI_SCAN_CHAN_LIST_CMDID);
2366
2367 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2368 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2369 wmi_buf_free(buf);
2370 }
2371
2372end:
2373 return qdf_status;
2374}
2375#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302376/**
2377 * send_mgmt_cmd_tlv() - WMI scan start function
2378 * @wmi_handle : handle to WMI.
2379 * @param : pointer to hold mgmt cmd parameter
2380 *
2381 * Return: 0 on success and -ve on failure.
2382 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302383static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302384 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302385{
Govind Singh427ee5a2016-02-26 18:09:36 +05302386 wmi_buf_t buf;
2387 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2388 int32_t cmd_len;
2389 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302390 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302391 uint8_t *bufp;
2392 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2393 mgmt_tx_dl_frm_len;
2394
2395 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2396 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2397
2398 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2399 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302400 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2401 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302402 }
2403
2404 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2405 bufp = (uint8_t *) cmd;
2406 WMITLV_SET_HDR(&cmd->tlv_header,
2407 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2408 WMITLV_GET_STRUCT_TLVLEN
2409 (wmi_mgmt_tx_send_cmd_fixed_param));
2410
2411 cmd->vdev_id = param->vdev_id;
2412
Govind Singh224a7312016-06-21 14:33:26 +05302413 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302414 cmd->chanfreq = param->chanfreq;
2415 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2416 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2417 sizeof(uint32_t)));
2418 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302419 qdf_mem_copy(bufp, param->pdata, bufp_len);
2420 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2421 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302422 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002423#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302424 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2425#endif
2426 cmd->frame_len = param->frm_len;
2427 cmd->buf_len = bufp_len;
2428
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002429 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002430 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002431
Govind Singh427ee5a2016-02-26 18:09:36 +05302432 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2433 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302434 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302435 goto err1;
2436 }
Govind Singhb53420c2016-03-09 14:32:57 +05302437 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302438
2439err1:
2440 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302441 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302442}
2443
2444/**
2445 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2446 * @wmi_handle: wmi handle
2447 * @param_value: parameter value
2448 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302449 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302450 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302451static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302452 uint32_t param_value)
2453{
Govind Singh67922e82016-04-01 16:48:57 +05302454 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302455 wmi_modem_power_state_cmd_param *cmd;
2456 wmi_buf_t buf;
2457 uint16_t len = sizeof(*cmd);
2458
2459 buf = wmi_buf_alloc(wmi_handle, len);
2460 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302461 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302462 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302463 }
2464 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2465 WMITLV_SET_HDR(&cmd->tlv_header,
2466 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2467 WMITLV_GET_STRUCT_TLVLEN
2468 (wmi_modem_power_state_cmd_param));
2469 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302470 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302471 param_value);
2472 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2473 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302474 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302475 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302476 wmi_buf_free(buf);
2477 }
Govind Singh67922e82016-04-01 16:48:57 +05302478
Govind Singh427ee5a2016-02-26 18:09:36 +05302479 return ret;
2480}
2481
2482/**
2483 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2484 * @wmi_handle: wmi handle
2485 * @vdev_id: vdev id
2486 * @val: value
2487 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302488 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302489 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302490static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302491 uint32_t vdev_id, uint8_t val)
2492{
2493 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2494 wmi_buf_t buf;
2495 int32_t len = sizeof(*cmd);
2496
Govind Singhb53420c2016-03-09 14:32:57 +05302497 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302498
2499 buf = wmi_buf_alloc(wmi_handle, len);
2500 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302501 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302502 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302503 }
2504 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2505 WMITLV_SET_HDR(&cmd->tlv_header,
2506 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2507 WMITLV_GET_STRUCT_TLVLEN
2508 (wmi_sta_powersave_mode_cmd_fixed_param));
2509 cmd->vdev_id = vdev_id;
2510 if (val)
2511 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2512 else
2513 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2514
2515 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2516 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302517 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302518 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302519 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302520 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302521 }
Govind Singh5eb51532016-03-09 11:34:12 +05302522 return 0;
2523}
2524
Govind Singh427ee5a2016-02-26 18:09:36 +05302525/**
2526 * send_set_mimops_cmd_tlv() - set MIMO powersave
2527 * @wmi_handle: wmi handle
2528 * @vdev_id: vdev id
2529 * @value: value
2530 *
Govind Singhb53420c2016-03-09 14:32:57 +05302531 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302532 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302533static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302534 uint8_t vdev_id, int value)
2535{
Govind Singh67922e82016-04-01 16:48:57 +05302536 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302537 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2538 wmi_buf_t buf;
2539 uint16_t len = sizeof(*cmd);
2540
2541 buf = wmi_buf_alloc(wmi_handle, len);
2542 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302543 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302544 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302545 }
2546 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2547 WMITLV_SET_HDR(&cmd->tlv_header,
2548 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2549 WMITLV_GET_STRUCT_TLVLEN
2550 (wmi_sta_smps_force_mode_cmd_fixed_param));
2551
2552 cmd->vdev_id = vdev_id;
2553
Houston Hoffmanb5168052016-04-14 02:18:01 -07002554 /* WMI_SMPS_FORCED_MODE values do not directly map
2555 * to SM power save values defined in the specification.
2556 * Make sure to send the right mapping.
2557 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302558 switch (value) {
2559 case 0:
2560 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2561 break;
2562 case 1:
2563 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2564 break;
2565 case 2:
2566 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2567 break;
2568 case 3:
2569 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2570 break;
2571 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302572 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2573 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302574 }
2575
Govind Singhb53420c2016-03-09 14:32:57 +05302576 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302577
2578 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2579 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302580 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302581 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302582 wmi_buf_free(buf);
2583 }
2584
2585 return ret;
2586}
2587
2588/**
2589 * send_set_smps_params_cmd_tlv() - set smps params
2590 * @wmi_handle: wmi handle
2591 * @vdev_id: vdev id
2592 * @value: value
2593 *
Govind Singhb53420c2016-03-09 14:32:57 +05302594 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302595 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302596static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302597 int value)
2598{
Govind Singh67922e82016-04-01 16:48:57 +05302599 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302600 wmi_sta_smps_param_cmd_fixed_param *cmd;
2601 wmi_buf_t buf;
2602 uint16_t len = sizeof(*cmd);
2603
2604 buf = wmi_buf_alloc(wmi_handle, len);
2605 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302606 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302607 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302608 }
2609 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2610 WMITLV_SET_HDR(&cmd->tlv_header,
2611 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2612 WMITLV_GET_STRUCT_TLVLEN
2613 (wmi_sta_smps_param_cmd_fixed_param));
2614
2615 cmd->vdev_id = vdev_id;
2616 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2617 cmd->param =
2618 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2619
Govind Singhb53420c2016-03-09 14:32:57 +05302620 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302621 cmd->param);
2622
2623 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2624 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302625 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302626 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302627 wmi_buf_free(buf);
2628 }
2629
2630 return ret;
2631}
2632
2633/**
2634 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2635 * @wmi_handle: wmi handle
2636 * @noa: p2p power save parameters
2637 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302638 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302639 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302640static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302641 struct p2p_ps_params *noa)
2642{
2643 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2644 wmi_p2p_noa_descriptor *noa_discriptor;
2645 wmi_buf_t buf;
2646 uint8_t *buf_ptr;
2647 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302648 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302649 uint32_t duration;
2650
Govind Singhb53420c2016-03-09 14:32:57 +05302651 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302652 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2653 buf = wmi_buf_alloc(wmi_handle, len);
2654 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302655 WMI_LOGE("Failed to allocate memory");
2656 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302657 goto end;
2658 }
2659
2660 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2661 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2662 WMITLV_SET_HDR(&cmd->tlv_header,
2663 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2664 WMITLV_GET_STRUCT_TLVLEN
2665 (wmi_p2p_set_noa_cmd_fixed_param));
2666 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2667 cmd->vdev_id = noa->session_id;
2668 cmd->enable = (duration) ? true : false;
2669 cmd->num_noa = 1;
2670
2671 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2672 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2673 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2674 sizeof
2675 (wmi_p2p_set_noa_cmd_fixed_param)
2676 + WMI_TLV_HDR_SIZE);
2677 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2678 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2679 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2680 noa_discriptor->type_count = noa->count;
2681 noa_discriptor->duration = duration;
2682 noa_discriptor->interval = noa->interval;
2683 noa_discriptor->start_time = 0;
2684
Govind Singhb53420c2016-03-09 14:32:57 +05302685 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302686 cmd->vdev_id, noa->count, noa_discriptor->duration,
2687 noa->interval);
2688 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2689 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302690 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302691 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302692 wmi_buf_free(buf);
2693 }
2694
2695end:
Govind Singhb53420c2016-03-09 14:32:57 +05302696 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302697 return status;
2698}
2699
2700
2701/**
2702 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2703 * @wmi_handle: wmi handle
2704 * @noa: p2p opp power save parameters
2705 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302706 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302707 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302708static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302709 struct p2p_ps_params *oppps)
2710{
2711 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2712 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302713 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302714
Govind Singhb53420c2016-03-09 14:32:57 +05302715 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302716 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2717 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302718 WMI_LOGE("Failed to allocate memory");
2719 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302720 goto end;
2721 }
2722
2723 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2724 WMITLV_SET_HDR(&cmd->tlv_header,
2725 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2726 WMITLV_GET_STRUCT_TLVLEN
2727 (wmi_p2p_set_oppps_cmd_fixed_param));
2728 cmd->vdev_id = oppps->session_id;
2729 if (oppps->ctwindow)
2730 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2731
2732 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302733 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302734 cmd->vdev_id, oppps->ctwindow);
2735 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2736 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302737 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302738 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302739 wmi_buf_free(buf);
2740 }
2741
2742end:
Govind Singhb53420c2016-03-09 14:32:57 +05302743 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302744 return status;
2745}
2746
Wu Gaocd3a8512017-03-13 20:17:34 +08002747#ifdef CONVERGED_P2P_ENABLE
2748/**
2749 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
2750 * @wmi_handle: wmi handle
2751 * @param: p2p listen offload start parameters
2752 *
2753 * Return: QDF status
2754 */
2755static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
2756 struct p2p_lo_start *param)
2757{
2758 wmi_buf_t buf;
2759 wmi_p2p_lo_start_cmd_fixed_param *cmd;
2760 int32_t len = sizeof(*cmd);
2761 uint8_t *buf_ptr;
2762 QDF_STATUS status;
2763 int device_types_len_aligned;
2764 int probe_resp_len_aligned;
2765
2766 if (!param) {
2767 WMI_LOGE("lo start param is null");
2768 return QDF_STATUS_E_INVAL;
2769 }
2770
2771 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
2772
2773 device_types_len_aligned =
2774 qdf_roundup(param->dev_types_len,
2775 sizeof(A_UINT32));
2776 probe_resp_len_aligned =
2777 qdf_roundup(param->probe_resp_len,
2778 sizeof(A_UINT32));
2779
2780 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
2781 probe_resp_len_aligned;
2782
2783 buf = wmi_buf_alloc(wmi_handle, len);
2784 if (!buf) {
2785 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
2786 __func__);
2787 return QDF_STATUS_E_NOMEM;
2788 }
2789
2790 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
2791 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2792
2793 WMITLV_SET_HDR(&cmd->tlv_header,
2794 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
2795 WMITLV_GET_STRUCT_TLVLEN(
2796 wmi_p2p_lo_start_cmd_fixed_param));
2797
2798 cmd->vdev_id = param->vdev_id;
2799 cmd->ctl_flags = param->ctl_flags;
2800 cmd->channel = param->freq;
2801 cmd->period = param->period;
2802 cmd->interval = param->interval;
2803 cmd->count = param->count;
2804 cmd->device_types_len = param->dev_types_len;
2805 cmd->prob_resp_len = param->probe_resp_len;
2806
2807 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
2808 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2809 device_types_len_aligned);
2810 buf_ptr += WMI_TLV_HDR_SIZE;
2811 qdf_mem_copy(buf_ptr, param->device_types,
2812 param->dev_types_len);
2813
2814 buf_ptr += device_types_len_aligned;
2815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2816 probe_resp_len_aligned);
2817 buf_ptr += WMI_TLV_HDR_SIZE;
2818 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
2819 param->probe_resp_len);
2820
2821 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
2822 cmd->channel, cmd->period, cmd->interval, cmd->count);
2823
2824 status = wmi_unified_cmd_send(wmi_handle,
2825 buf, len,
2826 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
2827 if (status != QDF_STATUS_SUCCESS) {
2828 WMI_LOGE("%s: Failed to send p2p lo start: %d",
2829 __func__, status);
2830 wmi_buf_free(buf);
2831 return status;
2832 }
2833
2834 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
2835
2836 return QDF_STATUS_SUCCESS;
2837}
2838
2839/**
2840 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
2841 * @wmi_handle: wmi handle
2842 * @param: p2p listen offload stop parameters
2843 *
2844 * Return: QDF status
2845 */
2846static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
2847 uint8_t vdev_id)
2848{
2849 wmi_buf_t buf;
2850 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
2851 int32_t len;
2852 QDF_STATUS status;
2853
2854 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
2855
2856 len = sizeof(*cmd);
2857 buf = wmi_buf_alloc(wmi_handle, len);
2858 if (!buf) {
2859 qdf_print("%s: Failed to allocate memory for p2p lo stop",
2860 __func__);
2861 return QDF_STATUS_E_NOMEM;
2862 }
2863 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
2864
2865 WMITLV_SET_HDR(&cmd->tlv_header,
2866 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
2867 WMITLV_GET_STRUCT_TLVLEN(
2868 wmi_p2p_lo_stop_cmd_fixed_param));
2869
2870 cmd->vdev_id = vdev_id;
2871
2872 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
2873
2874 status = wmi_unified_cmd_send(wmi_handle,
2875 buf, len,
2876 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
2877 if (status != QDF_STATUS_SUCCESS) {
2878 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
2879 __func__, status);
2880 wmi_buf_free(buf);
2881 return status;
2882 }
2883
2884 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
2885
2886 return QDF_STATUS_SUCCESS;
2887}
2888#endif /* End of CONVERGED_P2P_ENABLE */
2889
Govind Singh427ee5a2016-02-26 18:09:36 +05302890/**
2891 * send_get_temperature_cmd_tlv() - get pdev temperature req
2892 * @wmi_handle: wmi handle
2893 *
Govind Singhb53420c2016-03-09 14:32:57 +05302894 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302895 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302896static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302897{
2898 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2899 wmi_buf_t wmi_buf;
2900 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
2901 uint8_t *buf_ptr;
2902
2903 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05302904 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
2905 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05302906 }
2907
2908 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2909 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302910 WMI_LOGE(FL("wmi_buf_alloc failed"));
2911 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302912 }
2913
2914 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2915
2916 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
2917 WMITLV_SET_HDR(&cmd->tlv_header,
2918 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
2919 WMITLV_GET_STRUCT_TLVLEN
2920 (wmi_pdev_get_temperature_cmd_fixed_param));
2921
2922 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
2923 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302924 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05302925 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302926 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302927 }
Govind Singh2edc80f2016-03-01 15:30:53 +05302928
Govind Singhb53420c2016-03-09 14:32:57 +05302929 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302930}
2931
2932/**
2933 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
2934 * @wmi_handle: wmi handle
2935 * @vdevid: vdev id
2936 * @peer_addr: peer mac address
2937 * @auto_triggerparam: auto trigger parameters
2938 * @num_ac: number of access category
2939 *
2940 * This function sets the trigger
2941 * uapsd params such as service interval, delay interval
2942 * and suspend interval which will be used by the firmware
2943 * to send trigger frames periodically when there is no
2944 * traffic on the transmit side.
2945 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302946 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302947 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302948static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302949 struct sta_uapsd_trig_params *param)
2950{
2951 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302952 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302953 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
2954 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
2955 uint32_t i;
2956 wmi_buf_t buf;
2957 uint8_t *buf_ptr;
2958
2959 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2960 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302961 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302962 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302963 }
2964
2965 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2966 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
2967 WMITLV_SET_HDR(&cmd->tlv_header,
2968 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
2969 WMITLV_GET_STRUCT_TLVLEN
2970 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
2971 cmd->vdev_id = param->vdevid;
2972 cmd->num_ac = param->num_ac;
2973 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
2974
2975 /* TLV indicating array of structures to follow */
2976 buf_ptr += sizeof(*cmd);
2977 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
2978
2979 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302980 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05302981
2982 /*
2983 * Update tag and length for uapsd auto trigger params (this will take
2984 * care of updating tag and length if it is not pre-filled by caller).
2985 */
2986 for (i = 0; i < param->num_ac; i++) {
2987 WMITLV_SET_HDR((buf_ptr +
2988 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
2989 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
2990 WMITLV_GET_STRUCT_TLVLEN
2991 (wmi_sta_uapsd_auto_trig_param));
2992 }
2993
2994 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2995 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302996 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302997 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302998 wmi_buf_free(buf);
2999 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303000
Govind Singh427ee5a2016-02-26 18:09:36 +05303001 return ret;
3002}
3003
Govind Singh2edc80f2016-03-01 15:30:53 +05303004/**
3005 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3006 * @wmi_handle: pointer to the wmi handle
3007 * @utc: pointer to the UTC time struct
3008 *
3009 * Return: 0 on succes
3010 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303011static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303012 struct ocb_utc_param *utc)
3013{
Govind Singh67922e82016-04-01 16:48:57 +05303014 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303015 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3016 uint8_t *buf_ptr;
3017 uint32_t len, i;
3018 wmi_buf_t buf;
3019
3020 len = sizeof(*cmd);
3021 buf = wmi_buf_alloc(wmi_handle, len);
3022 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303023 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303024 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303025 }
3026
3027 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3028 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3029 WMITLV_SET_HDR(&cmd->tlv_header,
3030 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3031 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3032 cmd->vdev_id = utc->vdev_id;
3033
3034 for (i = 0; i < SIZE_UTC_TIME; i++)
3035 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3036
3037 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3038 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3039
3040 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3041 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303042 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303043 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303044 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303045 }
3046
Govind Singh67922e82016-04-01 16:48:57 +05303047 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303048}
3049
3050/**
3051 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3052 * frames on a channel
3053 * @wmi_handle: pointer to the wmi handle
3054 * @timing_advert: pointer to the timing advertisement struct
3055 *
3056 * Return: 0 on succes
3057 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303058static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303059 struct ocb_timing_advert_param *timing_advert)
3060{
Govind Singh67922e82016-04-01 16:48:57 +05303061 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303062 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3063 uint8_t *buf_ptr;
3064 uint32_t len, len_template;
3065 wmi_buf_t buf;
3066
3067 len = sizeof(*cmd) +
3068 WMI_TLV_HDR_SIZE;
3069
3070 len_template = timing_advert->template_length;
3071 /* Add padding to the template if needed */
3072 if (len_template % 4 != 0)
3073 len_template += 4 - (len_template % 4);
3074 len += len_template;
3075
3076 buf = wmi_buf_alloc(wmi_handle, len);
3077 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303078 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303079 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303080 }
3081
3082 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3083 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3084 WMITLV_SET_HDR(&cmd->tlv_header,
3085 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3086 WMITLV_GET_STRUCT_TLVLEN(
3087 wmi_ocb_start_timing_advert_cmd_fixed_param));
3088 cmd->vdev_id = timing_advert->vdev_id;
3089 cmd->repeat_rate = timing_advert->repeat_rate;
3090 cmd->channel_freq = timing_advert->chan_freq;
3091 cmd->timestamp_offset = timing_advert->timestamp_offset;
3092 cmd->time_value_offset = timing_advert->time_value_offset;
3093 cmd->timing_advert_template_length = timing_advert->template_length;
3094 buf_ptr += sizeof(*cmd);
3095
3096 /* Add the timing advert template */
3097 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3098 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303099 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303100 (uint8_t *)timing_advert->template_value,
3101 timing_advert->template_length);
3102
3103 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3104 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303105 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303106 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303107 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303108 }
3109
Govind Singh67922e82016-04-01 16:48:57 +05303110 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303111}
3112
3113/**
3114 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3115 * on a channel
3116 * @wmi_handle: pointer to the wmi handle
3117 * @timing_advert: pointer to the timing advertisement struct
3118 *
3119 * Return: 0 on succes
3120 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303121static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303122 struct ocb_timing_advert_param *timing_advert)
3123{
Govind Singh67922e82016-04-01 16:48:57 +05303124 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303125 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3126 uint8_t *buf_ptr;
3127 uint32_t len;
3128 wmi_buf_t buf;
3129
3130 len = sizeof(*cmd);
3131 buf = wmi_buf_alloc(wmi_handle, len);
3132 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303133 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303134 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303135 }
3136
3137 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3138 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3139 WMITLV_SET_HDR(&cmd->tlv_header,
3140 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3141 WMITLV_GET_STRUCT_TLVLEN(
3142 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3143 cmd->vdev_id = timing_advert->vdev_id;
3144 cmd->channel_freq = timing_advert->chan_freq;
3145
3146 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3147 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303148 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303149 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303150 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303151 }
3152
Govind Singh67922e82016-04-01 16:48:57 +05303153 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303154}
3155
3156/**
3157 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3158 * @wmi_handle: pointer to the wmi handle
3159 * @request: pointer to the request
3160 *
3161 * Return: 0 on succes
3162 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303163static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303164 uint8_t vdev_id)
3165{
Govind Singhb53420c2016-03-09 14:32:57 +05303166 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303167 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3168 uint8_t *buf_ptr;
3169 wmi_buf_t buf;
3170 int32_t len;
3171
3172 len = sizeof(*cmd);
3173 buf = wmi_buf_alloc(wmi_handle, len);
3174 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303175 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303176 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303177 }
3178 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3179
3180 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303181 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303182 WMITLV_SET_HDR(&cmd->tlv_header,
3183 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3184 WMITLV_GET_STRUCT_TLVLEN(
3185 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3186 cmd->vdev_id = vdev_id;
3187
3188 /* Send the WMI command */
3189 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3190 WMI_OCB_GET_TSF_TIMER_CMDID);
3191 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303192 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303193 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303194 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303195 }
3196
Govind Singh67922e82016-04-01 16:48:57 +05303197 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303198}
3199
3200/**
3201 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3202 * @wmi_handle: pointer to the wmi handle
3203 * @get_stats_param: pointer to the dcc stats
3204 *
3205 * Return: 0 on succes
3206 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303207static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303208 struct dcc_get_stats_param *get_stats_param)
3209{
Govind Singh67922e82016-04-01 16:48:57 +05303210 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303211 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3212 wmi_dcc_channel_stats_request *channel_stats_array;
3213 wmi_buf_t buf;
3214 uint8_t *buf_ptr;
3215 uint32_t len;
3216 uint32_t i;
3217
3218 /* Validate the input */
3219 if (get_stats_param->request_array_len !=
3220 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303221 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303222 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303223 }
3224
3225 /* Allocate memory for the WMI command */
3226 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3227 get_stats_param->request_array_len;
3228
3229 buf = wmi_buf_alloc(wmi_handle, len);
3230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303231 WMI_LOGE(FL("wmi_buf_alloc failed"));
3232 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303233 }
3234
3235 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303236 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303237
3238 /* Populate the WMI command */
3239 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3240 buf_ptr += sizeof(*cmd);
3241
3242 WMITLV_SET_HDR(&cmd->tlv_header,
3243 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3244 WMITLV_GET_STRUCT_TLVLEN(
3245 wmi_dcc_get_stats_cmd_fixed_param));
3246 cmd->vdev_id = get_stats_param->vdev_id;
3247 cmd->num_channels = get_stats_param->channel_count;
3248
3249 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3250 get_stats_param->request_array_len);
3251 buf_ptr += WMI_TLV_HDR_SIZE;
3252
3253 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303254 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303255 get_stats_param->request_array_len);
3256 for (i = 0; i < cmd->num_channels; i++)
3257 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3258 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3259 WMITLV_GET_STRUCT_TLVLEN(
3260 wmi_dcc_channel_stats_request));
3261
3262 /* Send the WMI command */
3263 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3264 WMI_DCC_GET_STATS_CMDID);
3265
Govind Singh67922e82016-04-01 16:48:57 +05303266 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303267 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303268 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303269 }
3270
Govind Singh67922e82016-04-01 16:48:57 +05303271 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303272}
3273
3274/**
3275 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3276 * @wmi_handle: pointer to the wmi handle
3277 * @vdev_id: vdev id
3278 * @dcc_stats_bitmap: dcc status bitmap
3279 *
3280 * Return: 0 on succes
3281 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303282static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303283 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3284{
Govind Singh67922e82016-04-01 16:48:57 +05303285 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303286 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3287 wmi_buf_t buf;
3288 uint8_t *buf_ptr;
3289 uint32_t len;
3290
3291 /* Allocate memory for the WMI command */
3292 len = sizeof(*cmd);
3293
3294 buf = wmi_buf_alloc(wmi_handle, len);
3295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303296 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303297 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303298 }
3299
3300 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303301 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303302
3303 /* Populate the WMI command */
3304 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3305
3306 WMITLV_SET_HDR(&cmd->tlv_header,
3307 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3308 WMITLV_GET_STRUCT_TLVLEN(
3309 wmi_dcc_clear_stats_cmd_fixed_param));
3310 cmd->vdev_id = vdev_id;
3311 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3312
3313 /* Send the WMI command */
3314 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3315 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303316 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303317 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303318 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303319 }
3320
Govind Singh67922e82016-04-01 16:48:57 +05303321 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303322}
3323
3324/**
3325 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3326 * @wmi_handle: pointer to the wmi handle
3327 * @update_ndl_param: pointer to the request parameters
3328 *
3329 * Return: 0 on success
3330 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303331static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303332 struct dcc_update_ndl_param *update_ndl_param)
3333{
Govind Singhb53420c2016-03-09 14:32:57 +05303334 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303335 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3336 wmi_dcc_ndl_chan *ndl_chan_array;
3337 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3338 uint32_t active_state_count;
3339 wmi_buf_t buf;
3340 uint8_t *buf_ptr;
3341 uint32_t len;
3342 uint32_t i;
3343
3344 /* validate the input */
3345 if (update_ndl_param->dcc_ndl_chan_list_len !=
3346 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303347 WMI_LOGE(FL("Invalid parameter"));
3348 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303349 }
3350 active_state_count = 0;
3351 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3352 for (i = 0; i < update_ndl_param->channel_count; i++)
3353 active_state_count +=
3354 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3355 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3356 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303357 WMI_LOGE(FL("Invalid parameter"));
3358 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303359 }
3360
3361 /* Allocate memory for the WMI command */
3362 len = sizeof(*cmd) +
3363 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3364 WMI_TLV_HDR_SIZE +
3365 update_ndl_param->dcc_ndl_active_state_list_len;
3366
3367 buf = wmi_buf_alloc(wmi_handle, len);
3368 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303369 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303370 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303371 }
3372
3373 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303374 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303375
3376 /* Populate the WMI command */
3377 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3378 buf_ptr += sizeof(*cmd);
3379
3380 WMITLV_SET_HDR(&cmd->tlv_header,
3381 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3382 WMITLV_GET_STRUCT_TLVLEN(
3383 wmi_dcc_update_ndl_cmd_fixed_param));
3384 cmd->vdev_id = update_ndl_param->vdev_id;
3385 cmd->num_channel = update_ndl_param->channel_count;
3386
3387 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3388 update_ndl_param->dcc_ndl_chan_list_len);
3389 buf_ptr += WMI_TLV_HDR_SIZE;
3390
3391 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303392 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303393 update_ndl_param->dcc_ndl_chan_list_len);
3394 for (i = 0; i < cmd->num_channel; i++)
3395 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3396 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3397 WMITLV_GET_STRUCT_TLVLEN(
3398 wmi_dcc_ndl_chan));
3399 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3400
3401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3402 update_ndl_param->dcc_ndl_active_state_list_len);
3403 buf_ptr += WMI_TLV_HDR_SIZE;
3404
3405 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303406 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303407 update_ndl_param->dcc_ndl_active_state_list,
3408 update_ndl_param->dcc_ndl_active_state_list_len);
3409 for (i = 0; i < active_state_count; i++) {
3410 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3411 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3412 WMITLV_GET_STRUCT_TLVLEN(
3413 wmi_dcc_ndl_active_state_config));
3414 }
3415 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3416
3417 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303418 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303419 WMI_DCC_UPDATE_NDL_CMDID);
3420 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303421 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303422 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303423 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303424 }
3425
Govind Singh67922e82016-04-01 16:48:57 +05303426 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303427}
3428
3429/**
3430 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3431 * @wmi_handle: pointer to the wmi handle
3432 * @config: the OCB configuration
3433 *
3434 * Return: 0 on success
3435 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303436static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303437 struct ocb_config_param *config, uint32_t *ch_mhz)
3438{
Govind Singh67922e82016-04-01 16:48:57 +05303439 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303440 wmi_ocb_set_config_cmd_fixed_param *cmd;
3441 wmi_channel *chan;
3442 wmi_ocb_channel *ocb_chan;
3443 wmi_qos_parameter *qos_param;
3444 wmi_dcc_ndl_chan *ndl_chan;
3445 wmi_dcc_ndl_active_state_config *ndl_active_config;
3446 wmi_ocb_schedule_element *sched_elem;
3447 uint8_t *buf_ptr;
3448 wmi_buf_t buf;
3449 int32_t len;
3450 int32_t i, j, active_state_count;
3451
3452 /*
3453 * Validate the dcc_ndl_chan_list_len and count the number of active
3454 * states. Validate dcc_ndl_active_state_list_len.
3455 */
3456 active_state_count = 0;
3457 if (config->dcc_ndl_chan_list_len) {
3458 if (!config->dcc_ndl_chan_list ||
3459 config->dcc_ndl_chan_list_len !=
3460 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303461 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303462 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303463 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303464 }
3465
3466 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3467 i < config->channel_count; ++i, ++ndl_chan)
3468 active_state_count +=
3469 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3470
3471 if (active_state_count) {
3472 if (!config->dcc_ndl_active_state_list ||
3473 config->dcc_ndl_active_state_list_len !=
3474 active_state_count *
3475 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303476 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303477 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303478 }
3479 }
3480 }
3481
3482 len = sizeof(*cmd) +
3483 WMI_TLV_HDR_SIZE + config->channel_count *
3484 sizeof(wmi_channel) +
3485 WMI_TLV_HDR_SIZE + config->channel_count *
3486 sizeof(wmi_ocb_channel) +
3487 WMI_TLV_HDR_SIZE + config->channel_count *
3488 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3489 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3490 WMI_TLV_HDR_SIZE + active_state_count *
3491 sizeof(wmi_dcc_ndl_active_state_config) +
3492 WMI_TLV_HDR_SIZE + config->schedule_size *
3493 sizeof(wmi_ocb_schedule_element);
3494 buf = wmi_buf_alloc(wmi_handle, len);
3495 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303496 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303497 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303498 }
3499
3500 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3501 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3502 WMITLV_SET_HDR(&cmd->tlv_header,
3503 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3504 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3505 cmd->vdev_id = config->session_id;
3506 cmd->channel_count = config->channel_count;
3507 cmd->schedule_size = config->schedule_size;
3508 cmd->flags = config->flags;
3509 buf_ptr += sizeof(*cmd);
3510
3511 /* Add the wmi_channel info */
3512 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3513 config->channel_count*sizeof(wmi_channel));
3514 buf_ptr += WMI_TLV_HDR_SIZE;
3515 for (i = 0; i < config->channel_count; i++) {
3516 chan = (wmi_channel *)buf_ptr;
3517 WMITLV_SET_HDR(&chan->tlv_header,
3518 WMITLV_TAG_STRUC_wmi_channel,
3519 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3520 chan->mhz = config->channels[i].chan_freq;
3521 chan->band_center_freq1 = config->channels[i].chan_freq;
3522 chan->band_center_freq2 = 0;
3523 chan->info = 0;
3524
3525 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3526 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3527 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3528 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3529 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3530 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3531 config->channels[i].antenna_max);
3532
3533 if (config->channels[i].bandwidth < 10)
3534 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3535 else if (config->channels[i].bandwidth < 20)
3536 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3537 buf_ptr += sizeof(*chan);
3538 }
3539
3540 /* Add the wmi_ocb_channel info */
3541 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3542 config->channel_count*sizeof(wmi_ocb_channel));
3543 buf_ptr += WMI_TLV_HDR_SIZE;
3544 for (i = 0; i < config->channel_count; i++) {
3545 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3546 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3547 WMITLV_TAG_STRUC_wmi_ocb_channel,
3548 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3549 ocb_chan->bandwidth = config->channels[i].bandwidth;
3550 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3551 config->channels[i].mac_address.bytes,
3552 &ocb_chan->mac_address);
3553 buf_ptr += sizeof(*ocb_chan);
3554 }
3555
3556 /* Add the wmi_qos_parameter info */
3557 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3558 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3559 buf_ptr += WMI_TLV_HDR_SIZE;
3560 /* WMI_MAX_NUM_AC parameters for each channel */
3561 for (i = 0; i < config->channel_count; i++) {
3562 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3563 qos_param = (wmi_qos_parameter *)buf_ptr;
3564 WMITLV_SET_HDR(&qos_param->tlv_header,
3565 WMITLV_TAG_STRUC_wmi_qos_parameter,
3566 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3567 qos_param->aifsn =
3568 config->channels[i].qos_params[j].aifsn;
3569 qos_param->cwmin =
3570 config->channels[i].qos_params[j].cwmin;
3571 qos_param->cwmax =
3572 config->channels[i].qos_params[j].cwmax;
3573 buf_ptr += sizeof(*qos_param);
3574 }
3575 }
3576
3577 /* Add the wmi_dcc_ndl_chan (per channel) */
3578 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3579 config->dcc_ndl_chan_list_len);
3580 buf_ptr += WMI_TLV_HDR_SIZE;
3581 if (config->dcc_ndl_chan_list_len) {
3582 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303583 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303584 config->dcc_ndl_chan_list_len);
3585 for (i = 0; i < config->channel_count; i++)
3586 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3587 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3588 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3589 buf_ptr += config->dcc_ndl_chan_list_len;
3590 }
3591
3592 /* Add the wmi_dcc_ndl_active_state_config */
3593 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3594 sizeof(wmi_dcc_ndl_active_state_config));
3595 buf_ptr += WMI_TLV_HDR_SIZE;
3596 if (active_state_count) {
3597 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303598 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303599 config->dcc_ndl_active_state_list,
3600 active_state_count * sizeof(*ndl_active_config));
3601 for (i = 0; i < active_state_count; ++i)
3602 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3603 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3604 WMITLV_GET_STRUCT_TLVLEN(
3605 wmi_dcc_ndl_active_state_config));
3606 buf_ptr += active_state_count *
3607 sizeof(*ndl_active_config);
3608 }
3609
3610 /* Add the wmi_ocb_schedule_element info */
3611 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3612 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3613 buf_ptr += WMI_TLV_HDR_SIZE;
3614 for (i = 0; i < config->schedule_size; i++) {
3615 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3616 WMITLV_SET_HDR(&sched_elem->tlv_header,
3617 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3618 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3619 sched_elem->channel_freq = config->schedule[i].chan_freq;
3620 sched_elem->total_duration = config->schedule[i].total_duration;
3621 sched_elem->guard_interval = config->schedule[i].guard_interval;
3622 buf_ptr += sizeof(*sched_elem);
3623 }
3624
3625
3626 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3627 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303628 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303629 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303630 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303631 }
3632
Govind Singh67922e82016-04-01 16:48:57 +05303633 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303634}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303635
3636/**
3637 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3638 * @wmi_handle: wmi handle
3639 * @mcc_adaptive_scheduler: enable/disable
3640 *
3641 * This function enable/disable mcc adaptive scheduler in fw.
3642 *
Govind Singhb53420c2016-03-09 14:32:57 +05303643 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303644 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303645static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003646 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3647 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303648{
Govind Singh67922e82016-04-01 16:48:57 +05303649 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303650 wmi_buf_t buf = 0;
3651 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3652 uint16_t len =
3653 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3654
3655 buf = wmi_buf_alloc(wmi_handle, len);
3656 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303657 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3658 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303659 }
3660 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3661 wmi_buf_data(buf);
3662
3663 WMITLV_SET_HDR(&cmd->tlv_header,
3664 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3665 WMITLV_GET_STRUCT_TLVLEN
3666 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3667 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003668 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303669
3670 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3671 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303672 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303673 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303674 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303675 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303676 }
Govind Singh67922e82016-04-01 16:48:57 +05303677
3678 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303679}
3680
3681/**
3682 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3683 * @wmi: wmi handle
3684 * @mcc_channel: mcc channel
3685 * @mcc_channel_time_latency: MCC channel time latency.
3686 *
3687 * Currently used to set time latency for an MCC vdev/adapter using operating
3688 * channel of it and channel number. The info is provided run time using
3689 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3690 *
3691 * Return: CDF status
3692 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303693static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303694 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3695{
Govind Singh67922e82016-04-01 16:48:57 +05303696 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303697 wmi_buf_t buf = 0;
3698 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3699 uint16_t len = 0;
3700 uint8_t *buf_ptr = NULL;
3701 wmi_resmgr_chan_latency chan_latency;
3702 /* Note: we only support MCC time latency for a single channel */
3703 uint32_t num_channels = 1;
3704 uint32_t chan1_freq = mcc_channel_freq;
3705 uint32_t latency_chan1 = mcc_channel_time_latency;
3706
3707
3708 /* If 0ms latency is provided, then FW will set to a default.
3709 * Otherwise, latency must be at least 30ms.
3710 */
3711 if ((latency_chan1 > 0) &&
3712 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303713 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303714 "Minimum is 30ms (or 0 to use default value by "
3715 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303716 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303717 }
3718
3719 /* Set WMI CMD for channel time latency here */
3720 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3721 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3722 num_channels * sizeof(wmi_resmgr_chan_latency);
3723 buf = wmi_buf_alloc(wmi_handle, len);
3724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303725 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3726 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303727 }
3728 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3729 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3730 wmi_buf_data(buf);
3731 WMITLV_SET_HDR(&cmdTL->tlv_header,
3732 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3733 WMITLV_GET_STRUCT_TLVLEN
3734 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3735 cmdTL->num_chans = num_channels;
3736 /* Update channel time latency information for home channel(s) */
3737 buf_ptr += sizeof(*cmdTL);
3738 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3739 num_channels * sizeof(wmi_resmgr_chan_latency));
3740 buf_ptr += WMI_TLV_HDR_SIZE;
3741 chan_latency.chan_mhz = chan1_freq;
3742 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303743 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303744 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3745 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303746 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303747 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303748 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303749 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303750 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303751 }
Govind Singh67922e82016-04-01 16:48:57 +05303752
3753 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303754}
3755
3756/**
3757 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3758 * @wmi: wmi handle
3759 * @adapter_1_chan_number: adapter 1 channel number
3760 * @adapter_1_quota: adapter 1 quota
3761 * @adapter_2_chan_number: adapter 2 channel number
3762 *
3763 * Return: CDF status
3764 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303765static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303766 uint32_t adapter_1_chan_freq,
3767 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3768{
Govind Singh67922e82016-04-01 16:48:57 +05303769 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303770 wmi_buf_t buf = 0;
3771 uint16_t len = 0;
3772 uint8_t *buf_ptr = NULL;
3773 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3774 wmi_resmgr_chan_time_quota chan_quota;
3775 uint32_t quota_chan1 = adapter_1_quota;
3776 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3777 uint32_t quota_chan2 = 100 - quota_chan1;
3778 /* Note: setting time quota for MCC requires info for 2 channels */
3779 uint32_t num_channels = 2;
3780 uint32_t chan1_freq = adapter_1_chan_freq;
3781 uint32_t chan2_freq = adapter_2_chan_freq;
3782
Govind Singhb53420c2016-03-09 14:32:57 +05303783 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303784 "freq2:%dMHz, Quota2:%dms", __func__,
3785 chan1_freq, quota_chan1, chan2_freq,
3786 quota_chan2);
3787
3788 /*
3789 * Perform sanity check on time quota values provided.
3790 */
3791 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3792 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303793 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303794 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303795 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303796 }
3797 /* Set WMI CMD for channel time quota here */
3798 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3799 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3800 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3801 buf = wmi_buf_alloc(wmi_handle, len);
3802 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303803 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3804 QDF_ASSERT(0);
3805 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303806 }
3807 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3808 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3809 wmi_buf_data(buf);
3810 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3811 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3812 WMITLV_GET_STRUCT_TLVLEN
3813 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3814 cmdTQ->num_chans = num_channels;
3815
3816 /* Update channel time quota information for home channel(s) */
3817 buf_ptr += sizeof(*cmdTQ);
3818 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3819 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3820 buf_ptr += WMI_TLV_HDR_SIZE;
3821 chan_quota.chan_mhz = chan1_freq;
3822 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303823 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303824 /* Construct channel and quota record for the 2nd MCC mode. */
3825 buf_ptr += sizeof(chan_quota);
3826 chan_quota.chan_mhz = chan2_freq;
3827 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303828 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303829
3830 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3831 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303832 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303833 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303834 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303835 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303836 }
Govind Singh67922e82016-04-01 16:48:57 +05303837
3838 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303839}
3840
3841/**
3842 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3843 * @wmi_handle: Pointer to wmi handle
3844 * @thermal_info: Thermal command information
3845 *
3846 * This function sends the thermal management command
3847 * to the firmware
3848 *
Govind Singhb53420c2016-03-09 14:32:57 +05303849 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303850 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303851static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303852 struct thermal_cmd_params *thermal_info)
3853{
3854 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3855 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303856 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303857 uint32_t len = 0;
3858
3859 len = sizeof(*cmd);
3860
3861 buf = wmi_buf_alloc(wmi_handle, len);
3862 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303863 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3864 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303865 }
3866
3867 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3868
3869 WMITLV_SET_HDR(&cmd->tlv_header,
3870 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3871 WMITLV_GET_STRUCT_TLVLEN
3872 (wmi_thermal_mgmt_cmd_fixed_param));
3873
3874 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3875 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3876 cmd->enable = thermal_info->thermal_enable;
3877
Govind Singhb53420c2016-03-09 14:32:57 +05303878 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303879 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3880
3881 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3882 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303883 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303884 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303885 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303886 }
3887
Govind Singh67922e82016-04-01 16:48:57 +05303888 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303889}
3890
3891
3892/**
3893 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303894 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303895 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3896 *
3897 * This function sends down the LRO configuration parameters to
3898 * the firmware to enable LRO, sets the TCP flags and sets the
3899 * seed values for the toeplitz hash generation
3900 *
Govind Singhb53420c2016-03-09 14:32:57 +05303901 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303902 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303903static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303904 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
3905{
3906 wmi_lro_info_cmd_fixed_param *cmd;
3907 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05303908 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303909
3910
3911 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
3912 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303913 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3914 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303915 }
3916
3917 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
3918
3919 WMITLV_SET_HDR(&cmd->tlv_header,
3920 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
3921 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
3922
3923 cmd->lro_enable = wmi_lro_cmd->lro_enable;
3924 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
3925 wmi_lro_cmd->tcp_flag);
3926 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
3927 wmi_lro_cmd->tcp_flag_mask);
3928 cmd->toeplitz_hash_ipv4_0_3 =
3929 wmi_lro_cmd->toeplitz_hash_ipv4[0];
3930 cmd->toeplitz_hash_ipv4_4_7 =
3931 wmi_lro_cmd->toeplitz_hash_ipv4[1];
3932 cmd->toeplitz_hash_ipv4_8_11 =
3933 wmi_lro_cmd->toeplitz_hash_ipv4[2];
3934 cmd->toeplitz_hash_ipv4_12_15 =
3935 wmi_lro_cmd->toeplitz_hash_ipv4[3];
3936 cmd->toeplitz_hash_ipv4_16 =
3937 wmi_lro_cmd->toeplitz_hash_ipv4[4];
3938
3939 cmd->toeplitz_hash_ipv6_0_3 =
3940 wmi_lro_cmd->toeplitz_hash_ipv6[0];
3941 cmd->toeplitz_hash_ipv6_4_7 =
3942 wmi_lro_cmd->toeplitz_hash_ipv6[1];
3943 cmd->toeplitz_hash_ipv6_8_11 =
3944 wmi_lro_cmd->toeplitz_hash_ipv6[2];
3945 cmd->toeplitz_hash_ipv6_12_15 =
3946 wmi_lro_cmd->toeplitz_hash_ipv6[3];
3947 cmd->toeplitz_hash_ipv6_16_19 =
3948 wmi_lro_cmd->toeplitz_hash_ipv6[4];
3949 cmd->toeplitz_hash_ipv6_20_23 =
3950 wmi_lro_cmd->toeplitz_hash_ipv6[5];
3951 cmd->toeplitz_hash_ipv6_24_27 =
3952 wmi_lro_cmd->toeplitz_hash_ipv6[6];
3953 cmd->toeplitz_hash_ipv6_28_31 =
3954 wmi_lro_cmd->toeplitz_hash_ipv6[7];
3955 cmd->toeplitz_hash_ipv6_32_35 =
3956 wmi_lro_cmd->toeplitz_hash_ipv6[8];
3957 cmd->toeplitz_hash_ipv6_36_39 =
3958 wmi_lro_cmd->toeplitz_hash_ipv6[9];
3959 cmd->toeplitz_hash_ipv6_40 =
3960 wmi_lro_cmd->toeplitz_hash_ipv6[10];
3961
Govind Singhb53420c2016-03-09 14:32:57 +05303962 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303963 cmd->lro_enable, cmd->tcp_flag_u32);
3964
3965 status = wmi_unified_cmd_send(wmi_handle, buf,
3966 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303967 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303968 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303969 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303970 }
3971
Govind Singh67922e82016-04-01 16:48:57 +05303972 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303973}
3974
Govind Singh4eacd2b2016-03-07 14:24:22 +05303975/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303976 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
3977 * @wmi_handle: Pointer to wmi handle
3978 * @rate_report_params: Pointer to peer rate report parameters
3979 *
3980 *
3981 * Return: QDF_STATUS_SUCCESS for success otherwise failure
3982 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303983static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05303984 struct wmi_peer_rate_report_params *rate_report_params)
3985{
3986 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
3987 wmi_buf_t buf = NULL;
3988 QDF_STATUS status = 0;
3989 uint32_t len = 0;
3990 uint32_t i, j;
3991
3992 len = sizeof(*cmd);
3993
3994 buf = wmi_buf_alloc(wmi_handle, len);
3995 if (!buf) {
3996 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
3997 return QDF_STATUS_E_FAILURE;
3998 }
3999
4000 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4001 wmi_buf_data(buf);
4002
4003 WMITLV_SET_HDR(
4004 &cmd->tlv_header,
4005 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4006 WMITLV_GET_STRUCT_TLVLEN(
4007 wmi_peer_set_rate_report_condition_fixed_param));
4008
4009 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4010 cmd->report_backoff_time = rate_report_params->backoff_time;
4011 cmd->report_timer_period = rate_report_params->timer_period;
4012 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4013 cmd->cond_per_phy[i].val_cond_flags =
4014 rate_report_params->report_per_phy[i].cond_flags;
4015 cmd->cond_per_phy[i].rate_delta.min_delta =
4016 rate_report_params->report_per_phy[i].delta.delta_min;
4017 cmd->cond_per_phy[i].rate_delta.percentage =
4018 rate_report_params->report_per_phy[i].delta.percent;
4019 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4020 cmd->cond_per_phy[i].rate_threshold[j] =
4021 rate_report_params->report_per_phy[i].
4022 report_rate_threshold[j];
4023 }
4024 }
4025
4026 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4027 cmd->enable_rate_report,
4028 cmd->report_backoff_time, cmd->report_timer_period);
4029
4030 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4031 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4032 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304033 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304034 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4035 __func__);
4036 }
4037 return status;
4038}
4039
4040/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304041 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4042 * @wmi_handle: wmi handle
4043 * @param: bcn ll cmd parameter
4044 *
Govind Singhb53420c2016-03-09 14:32:57 +05304045 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304046 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304047static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304048 wmi_bcn_send_from_host_cmd_fixed_param *param)
4049{
4050 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4051 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304052 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304053
4054 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4055 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304056 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4057 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304058 }
4059
4060 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4061 WMITLV_SET_HDR(&cmd->tlv_header,
4062 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4063 WMITLV_GET_STRUCT_TLVLEN
4064 (wmi_bcn_send_from_host_cmd_fixed_param));
4065 cmd->vdev_id = param->vdev_id;
4066 cmd->data_len = param->data_len;
4067 cmd->frame_ctrl = param->frame_ctrl;
4068 cmd->frag_ptr = param->frag_ptr;
4069 cmd->dtim_flag = param->dtim_flag;
4070
4071 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4072 WMI_PDEV_SEND_BCN_CMDID);
4073
Govind Singh67922e82016-04-01 16:48:57 +05304074 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304075 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304076 wmi_buf_free(wmi_buf);
4077 }
4078
4079 return ret;
4080}
4081
4082/**
4083 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4084 * @wmi_handle: wmi handle
4085 * @vdev_id: vdev id
4086 * @max_retries: max retries
4087 * @retry_interval: retry interval
4088 * This function sets sta query related parameters in fw.
4089 *
Govind Singhb53420c2016-03-09 14:32:57 +05304090 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304091 */
4092
Sathish Kumarfd347372017-02-13 12:29:09 +05304093static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304094 uint8_t vdev_id, uint32_t max_retries,
4095 uint32_t retry_interval)
4096{
4097 wmi_buf_t buf;
4098 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4099 int len;
4100
4101 len = sizeof(*cmd);
4102 buf = wmi_buf_alloc(wmi_handle, len);
4103 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304104 WMI_LOGE(FL("wmi_buf_alloc failed"));
4105 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304106 }
4107
4108 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4109 WMITLV_SET_HDR(&cmd->tlv_header,
4110 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4111 WMITLV_GET_STRUCT_TLVLEN
4112 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4113
4114
4115 cmd->vdev_id = vdev_id;
4116 cmd->sa_query_max_retry_count = max_retries;
4117 cmd->sa_query_retry_interval = retry_interval;
4118
Govind Singhb53420c2016-03-09 14:32:57 +05304119 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304120 vdev_id, retry_interval, max_retries);
4121
4122 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4123 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304124 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304125 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304126 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304127 }
4128
Govind Singhb53420c2016-03-09 14:32:57 +05304129 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304130 return 0;
4131}
4132
4133/**
4134 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4135 * @wmi_handle: wmi handle
4136 * @params: sta keep alive parameter
4137 *
4138 * This function sets keep alive related parameters in fw.
4139 *
4140 * Return: CDF status
4141 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304142static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304143 struct sta_params *params)
4144{
4145 wmi_buf_t buf;
4146 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4147 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4148 uint8_t *buf_ptr;
4149 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304150 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304151
Govind Singhb53420c2016-03-09 14:32:57 +05304152 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304153
Govind Singh4eacd2b2016-03-07 14:24:22 +05304154 len = sizeof(*cmd) + sizeof(*arp_rsp);
4155 buf = wmi_buf_alloc(wmi_handle, len);
4156 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304157 WMI_LOGE("wmi_buf_alloc failed");
4158 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304159 }
4160
4161 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4162 buf_ptr = (uint8_t *) cmd;
4163 WMITLV_SET_HDR(&cmd->tlv_header,
4164 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4165 WMITLV_GET_STRUCT_TLVLEN
4166 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4167 cmd->interval = params->timeperiod;
4168 cmd->enable = (params->timeperiod) ? 1 : 0;
4169 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304170 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304171 params->timeperiod, params->method);
4172 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4173 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4174 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4175 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4176
4177 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4178 if ((NULL == params->hostv4addr) ||
4179 (NULL == params->destv4addr) ||
4180 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304181 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304182 "destv4addr:%p destmac:%p ", __func__,
4183 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304184 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304185 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304186 }
4187 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304188 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304189 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304190 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304191 WMI_IPV4_ADDR_LEN);
4192 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4193 } else {
4194 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4195 }
4196
Govind Singh67922e82016-04-01 16:48:57 +05304197 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4198 WMI_STA_KEEPALIVE_CMDID);
4199 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304200 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304201 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304202 }
4203
Govind Singhb53420c2016-03-09 14:32:57 +05304204 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304205 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304206}
4207
4208/**
4209 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4210 * @wmi_handle: wmi handle
4211 * @if_id: vdev id
4212 * @gtx_info: GTX config params
4213 *
4214 * This function set GTX related params in firmware.
4215 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304216 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304217 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304218static 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 +05304219 struct wmi_gtx_config *gtx_info)
4220{
4221 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4222 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304223 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304224 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304225
Govind Singh4eacd2b2016-03-07 14:24:22 +05304226 buf = wmi_buf_alloc(wmi_handle, len);
4227 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304228 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304229 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304230 }
4231 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4232 WMITLV_SET_HDR(&cmd->tlv_header,
4233 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4234 WMITLV_GET_STRUCT_TLVLEN
4235 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4236 cmd->vdev_id = if_id;
4237
4238 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4239 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4240 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4241 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4242 cmd->gtxPERMargin = gtx_info->gtx_margin;
4243 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4244 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4245 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4246
Govind Singhb53420c2016-03-09 14:32:57 +05304247 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304248 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4249 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4250 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4251 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4252
Abhishek Singh716c46c2016-05-04 16:24:07 +05304253 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304254 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304255 if (QDF_IS_STATUS_ERROR(ret)) {
4256 WMI_LOGE("Failed to set GTX PARAMS");
4257 wmi_buf_free(buf);
4258 }
4259 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304260}
4261
4262/**
4263 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4264 * @wmi_handle: wmi handle
4265 * @edca_params: edca parameters
4266 *
4267 * This function updates EDCA parameters to the target
4268 *
4269 * Return: CDF Status
4270 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304271static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304272 uint8_t vdev_id,
4273 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4274{
4275 uint8_t *buf_ptr;
4276 wmi_buf_t buf;
4277 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4278 wmi_wmm_vparams *wmm_param, *twmm_param;
4279 int len = sizeof(*cmd);
4280 int ac;
4281
4282 buf = wmi_buf_alloc(wmi_handle, len);
4283
4284 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304285 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4286 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304287 }
4288
4289 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4290 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4291 WMITLV_SET_HDR(&cmd->tlv_header,
4292 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4293 WMITLV_GET_STRUCT_TLVLEN
4294 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4295 cmd->vdev_id = vdev_id;
4296
4297 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4298 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4299 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4300 WMITLV_SET_HDR(&wmm_param->tlv_header,
4301 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4302 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4303 wmm_param->cwmin = twmm_param->cwmin;
4304 wmm_param->cwmax = twmm_param->cwmax;
4305 wmm_param->aifs = twmm_param->aifs;
4306 wmm_param->txoplimit = twmm_param->txoplimit;
4307 wmm_param->acm = twmm_param->acm;
4308 wmm_param->no_ack = twmm_param->no_ack;
4309 }
4310
4311 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4312 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4313 goto fail;
4314
Govind Singhb53420c2016-03-09 14:32:57 +05304315 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304316
4317fail:
4318 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304319 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4320 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304321}
4322
4323/**
4324 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4325 * @wmi_handle: wmi handle
4326 * @vdev_id: vdev id
4327 * @probe_rsp_info: probe response info
4328 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304329 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304330 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304331static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304332 uint8_t vdev_id,
4333 struct wmi_probe_resp_params *probe_rsp_info,
4334 uint8_t *frm)
4335{
4336 wmi_prb_tmpl_cmd_fixed_param *cmd;
4337 wmi_bcn_prb_info *bcn_prb_info;
4338 wmi_buf_t wmi_buf;
4339 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4340 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304341 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304342
Govind Singhb53420c2016-03-09 14:32:57 +05304343 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304344
4345 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4346 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4347
4348 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4349 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4350 tmpl_len_aligned;
4351
4352 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304353 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304354 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304355 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304356 }
4357
4358 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4359 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304360 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304361 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304362 }
4363
4364 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4365
4366 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4367 WMITLV_SET_HDR(&cmd->tlv_header,
4368 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4369 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4370 cmd->vdev_id = vdev_id;
4371 cmd->buf_len = tmpl_len;
4372 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4373
4374 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4375 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4376 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4377 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4378 bcn_prb_info->caps = 0;
4379 bcn_prb_info->erp = 0;
4380 buf_ptr += sizeof(wmi_bcn_prb_info);
4381
4382 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4383 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304384 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304385
4386 ret = wmi_unified_cmd_send(wmi_handle,
4387 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304388 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304389 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304390 wmi_buf_free(wmi_buf);
4391 }
4392
4393 return ret;
4394}
4395
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304396#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304397#define WPI_IV_LEN 16
4398
4399/**
4400 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4401 *
4402 * @dest_tx: destination address of tsc key counter
4403 * @src_tx: source address of tsc key counter
4404 * @dest_rx: destination address of rsc key counter
4405 * @src_rx: source address of rsc key counter
4406 *
4407 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4408 *
4409 * Return: None
4410 *
4411 */
4412static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4413 uint8_t *dest_rx, uint8_t *src_rx)
4414{
4415 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4416 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4417}
4418#else
4419static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4420 uint8_t *dest_rx, uint8_t *src_rx)
4421{
4422 return;
4423}
4424#endif
4425
4426/**
4427 * send_setup_install_key_cmd_tlv() - set key parameters
4428 * @wmi_handle: wmi handle
4429 * @key_params: key parameters
4430 *
4431 * This function fills structure from information
4432 * passed in key_params.
4433 *
4434 * Return: QDF_STATUS_SUCCESS - success
4435 * QDF_STATUS_E_FAILURE - failure
4436 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4437 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304438static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304439 struct set_key_params *key_params)
4440{
4441 wmi_vdev_install_key_cmd_fixed_param *cmd;
4442 wmi_buf_t buf;
4443 uint8_t *buf_ptr;
4444 uint32_t len;
4445 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304446 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304447
4448 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4449 WMI_TLV_HDR_SIZE;
4450
4451 buf = wmi_buf_alloc(wmi_handle, len);
4452 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304453 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304454 return QDF_STATUS_E_NOMEM;
4455 }
4456
4457 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4458 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4459 WMITLV_SET_HDR(&cmd->tlv_header,
4460 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4461 WMITLV_GET_STRUCT_TLVLEN
4462 (wmi_vdev_install_key_cmd_fixed_param));
4463 cmd->vdev_id = key_params->vdev_id;
4464 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304465
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304466
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304467 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4468 cmd->key_flags |= key_params->key_flags;
4469 cmd->key_cipher = key_params->key_cipher;
4470 if ((key_params->key_txmic_len) &&
4471 (key_params->key_rxmic_len)) {
4472 cmd->key_txmic_len = key_params->key_txmic_len;
4473 cmd->key_rxmic_len = key_params->key_rxmic_len;
4474 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304475#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304476 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4477 key_params->tx_iv,
4478 cmd->wpi_key_rsc_counter,
4479 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304480#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304481 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4482 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4483 roundup(key_params->key_len, sizeof(uint32_t)));
4484 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4485 qdf_mem_copy((void *)key_data,
4486 (const void *)key_params->key_data, key_params->key_len);
4487 cmd->key_len = key_params->key_len;
4488
4489 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4490 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304491 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304492 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304493
Govind Singh67922e82016-04-01 16:48:57 +05304494 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304495}
4496
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304497/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004498 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4499 * @wmi_handle: wmi handle
4500 * @params: sar limit params
4501 *
4502 * Return: QDF_STATUS_SUCCESS for success or error code
4503 */
4504static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4505 struct sar_limit_cmd_params *sar_limit_params)
4506{
4507 wmi_buf_t buf;
4508 QDF_STATUS qdf_status;
4509 wmi_sar_limits_cmd_fixed_param *cmd;
4510 int i;
4511 uint8_t *buf_ptr;
4512 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4513 struct sar_limit_cmd_row *sar_rows_list;
4514 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4515
4516 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4517 buf = wmi_buf_alloc(wmi_handle, len);
4518 if (!buf) {
4519 WMI_LOGE("Failed to allocate memory");
4520 qdf_status = QDF_STATUS_E_NOMEM;
4521 goto end;
4522 }
4523
4524 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4525 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4526 WMITLV_SET_HDR(&cmd->tlv_header,
4527 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4528 WMITLV_GET_STRUCT_TLVLEN
4529 (wmi_sar_limits_cmd_fixed_param));
4530 cmd->sar_enable = sar_limit_params->sar_enable;
4531 cmd->commit_limits = sar_limit_params->commit_limits;
4532 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4533
4534 WMI_LOGD("no of sar rows = %d, len = %d",
4535 sar_limit_params->num_limit_rows, len);
4536 buf_ptr += sizeof(*cmd);
4537 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4538 sizeof(wmi_sar_limit_cmd_row) *
4539 sar_limit_params->num_limit_rows);
4540 if (cmd->num_limit_rows == 0)
4541 goto send_sar_limits;
4542
4543 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4544 (buf_ptr + WMI_TLV_HDR_SIZE);
4545 sar_rows_list = sar_limit_params->sar_limit_row_list;
4546
4547 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4548 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4549 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4550 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4551 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4552 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4553 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4554 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4555 wmi_sar_rows_list->validity_bitmap =
4556 sar_rows_list->validity_bitmap;
4557 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4558 i, wmi_sar_rows_list->band_id,
4559 wmi_sar_rows_list->chain_id,
4560 wmi_sar_rows_list->mod_id,
4561 wmi_sar_rows_list->limit_value,
4562 wmi_sar_rows_list->validity_bitmap);
4563 sar_rows_list++;
4564 wmi_sar_rows_list++;
4565 }
4566send_sar_limits:
4567 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4568 WMI_SAR_LIMITS_CMDID);
4569
4570 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4571 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4572 wmi_buf_free(buf);
4573 }
4574
4575end:
4576 return qdf_status;
4577}
4578
4579/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304580 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4581 * @wmi_handle: wmi handle
4582 * @params: encrypt/decrypt params
4583 *
4584 * Return: QDF_STATUS_SUCCESS for success or error code
4585 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004586static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304587QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4588 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4589{
4590 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4591 wmi_buf_t wmi_buf;
4592 uint8_t *buf_ptr;
4593 QDF_STATUS ret;
4594 uint32_t len;
4595
4596 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4597
4598 len = sizeof(*cmd) +
4599 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4600 WMI_TLV_HDR_SIZE;
4601 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4602 if (!wmi_buf) {
4603 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4604 __func__);
4605 return QDF_STATUS_E_NOMEM;
4606 }
4607
4608 buf_ptr = wmi_buf_data(wmi_buf);
4609 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4610
4611 WMITLV_SET_HDR(&cmd->tlv_header,
4612 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4613 WMITLV_GET_STRUCT_TLVLEN(
4614 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4615
4616 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4617 cmd->key_flag = encrypt_decrypt_params->key_flag;
4618 cmd->key_idx = encrypt_decrypt_params->key_idx;
4619 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4620 cmd->key_len = encrypt_decrypt_params->key_len;
4621 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4622 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4623
4624 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4625 encrypt_decrypt_params->key_len);
4626
4627 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4628 MAX_MAC_HEADER_LEN);
4629
4630 cmd->data_len = encrypt_decrypt_params->data_len;
4631
4632 if (cmd->data_len) {
4633 buf_ptr += sizeof(*cmd);
4634 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4635 roundup(encrypt_decrypt_params->data_len,
4636 sizeof(A_UINT32)));
4637 buf_ptr += WMI_TLV_HDR_SIZE;
4638 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4639 encrypt_decrypt_params->data_len);
4640 }
4641
4642 /* This conversion is to facilitate data to FW in little endian */
4643 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4644 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4645 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4646 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4647 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4648 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4649
4650 ret = wmi_unified_cmd_send(wmi_handle,
4651 wmi_buf, len,
4652 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4653 if (QDF_IS_STATUS_ERROR(ret)) {
4654 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4655 wmi_buf_free(wmi_buf);
4656 }
4657
4658 return ret;
4659}
4660
4661
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304662
Govind Singh4eacd2b2016-03-07 14:24:22 +05304663/**
4664 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4665 * @wmi_handle: wmi handle
4666 * @vdev_id: vdev id
4667 * @p2p_ie: p2p IE
4668 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304669 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304670 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304671static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304672 A_UINT32 vdev_id, uint8_t *p2p_ie)
4673{
Govind Singh67922e82016-04-01 16:48:57 +05304674 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304675 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4676 wmi_buf_t wmi_buf;
4677 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4678 uint8_t *buf_ptr;
4679
4680 ie_len = (uint32_t) (p2p_ie[1] + 2);
4681
4682 /* More than one P2P IE may be included in a single frame.
4683 If multiple P2P IEs are present, the complete P2P attribute
4684 data consists of the concatenation of the P2P Attribute
4685 fields of the P2P IEs. The P2P Attributes field of each
4686 P2P IE may be any length up to the maximum (251 octets).
4687 In this case host sends one P2P IE to firmware so the length
4688 should not exceed more than 251 bytes
4689 */
4690 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304691 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304692 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304693 }
4694
4695 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4696
4697 wmi_buf_len =
4698 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4699 WMI_TLV_HDR_SIZE;
4700
4701 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4702 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304703 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304704 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304705 }
4706
4707 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4708
4709 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4710 WMITLV_SET_HDR(&cmd->tlv_header,
4711 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4712 WMITLV_GET_STRUCT_TLVLEN
4713 (wmi_p2p_go_set_beacon_ie_fixed_param));
4714 cmd->vdev_id = vdev_id;
4715 cmd->ie_buf_len = ie_len;
4716
4717 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4719 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304720 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304721
Govind Singhb53420c2016-03-09 14:32:57 +05304722 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304723
4724 ret = wmi_unified_cmd_send(wmi_handle,
4725 wmi_buf, wmi_buf_len,
4726 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304727 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304728 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304729 wmi_buf_free(wmi_buf);
4730 }
4731
Govind Singhb53420c2016-03-09 14:32:57 +05304732 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304733 return ret;
4734}
4735
4736/**
4737 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4738 * @wmi_handle: wmi handle
4739 * @req: gateway parameter update request structure
4740 *
4741 * This function reads the incoming @req and fill in the destination
4742 * WMI structure and sends down the gateway configs down to the firmware
4743 *
Govind Singhb53420c2016-03-09 14:32:57 +05304744 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304745 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304746static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304747 struct gateway_update_req_param *req)
4748{
4749 wmi_roam_subnet_change_config_fixed_param *cmd;
4750 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304751 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304752 int len = sizeof(*cmd);
4753
4754 buf = wmi_buf_alloc(wmi_handle, len);
4755 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304756 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4757 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304758 }
4759
4760 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4761 WMITLV_SET_HDR(&cmd->tlv_header,
4762 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4763 WMITLV_GET_STRUCT_TLVLEN(
4764 wmi_roam_subnet_change_config_fixed_param));
4765
4766 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304767 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4768 QDF_IPV4_ADDR_SIZE);
4769 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4770 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304771 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4772 &cmd->inet_gw_mac_addr);
4773 cmd->max_retries = req->max_retries;
4774 cmd->timeout = req->timeout;
4775 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4776 cmd->flag = 0;
4777 if (req->ipv4_addr_type)
4778 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4779
4780 if (req->ipv6_addr_type)
4781 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4782
4783 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4784 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304785 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304786 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304787 ret);
4788 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304789 }
4790
Govind Singh67922e82016-04-01 16:48:57 +05304791 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304792}
4793
4794/**
4795 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4796 * @wmi_handle: wmi handle
4797 * @req: rssi monitoring request structure
4798 *
4799 * This function reads the incoming @req and fill in the destination
4800 * WMI structure and send down the rssi monitoring configs down to the firmware
4801 *
4802 * Return: 0 on success; error number otherwise
4803 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304804static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304805 struct rssi_monitor_param *req)
4806{
4807 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4808 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304809 QDF_STATUS ret;
4810 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304811
4812 buf = wmi_buf_alloc(wmi_handle, len);
4813 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304814 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4815 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304816 }
4817
4818 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4819 WMITLV_SET_HDR(&cmd->tlv_header,
4820 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4821 WMITLV_GET_STRUCT_TLVLEN(
4822 wmi_rssi_breach_monitor_config_fixed_param));
4823
4824 cmd->vdev_id = req->session_id;
4825 cmd->request_id = req->request_id;
4826 cmd->lo_rssi_reenable_hysteresis = 0;
4827 cmd->hi_rssi_reenable_histeresis = 0;
4828 cmd->min_report_interval = 0;
4829 cmd->max_num_report = 1;
4830 if (req->control) {
4831 /* enable one threshold for each min/max */
4832 cmd->enabled_bitmap = 0x09;
4833 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4834 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4835 } else {
4836 cmd->enabled_bitmap = 0;
4837 cmd->low_rssi_breach_threshold[0] = 0;
4838 cmd->hi_rssi_breach_threshold[0] = 0;
4839 }
4840
4841 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4842 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304843 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304844 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304845 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304846 }
4847
Govind Singhb53420c2016-03-09 14:32:57 +05304848 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304849 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304850}
4851
4852/**
4853 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4854 * @wmi_handle: wmi handle
4855 * @psetoui: OUI parameters
4856 *
4857 * set scan probe OUI parameters in firmware
4858 *
4859 * Return: CDF status
4860 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304861static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304862 struct scan_mac_oui *psetoui)
4863{
4864 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4865 wmi_buf_t wmi_buf;
4866 uint32_t len;
4867 uint8_t *buf_ptr;
4868 uint32_t *oui_buf;
4869
4870 len = sizeof(*cmd);
4871 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4872 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304873 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4874 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304875 }
4876 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4877 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4878 WMITLV_SET_HDR(&cmd->tlv_header,
4879 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4880 WMITLV_GET_STRUCT_TLVLEN
4881 (wmi_scan_prob_req_oui_cmd_fixed_param));
4882
4883 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304884 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304885 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4886 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304887 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304888 cmd->prob_req_oui);
4889
4890 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4891 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304892 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304893 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304894 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304895 }
Govind Singhb53420c2016-03-09 14:32:57 +05304896 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304897}
4898
4899/**
4900 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
4901 * @wmi_handle: wmi handle
4902 * @req: passpoint network request structure
4903 *
4904 * This function sends down WMI command with network id set to wildcard id.
4905 * firmware shall clear all the config entries
4906 *
Govind Singhb53420c2016-03-09 14:32:57 +05304907 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304908 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304909static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304910 struct wifi_passpoint_req_param *req)
4911{
4912 wmi_passpoint_config_cmd_fixed_param *cmd;
4913 wmi_buf_t buf;
4914 uint32_t len;
4915 int ret;
4916
4917 len = sizeof(*cmd);
4918 buf = wmi_buf_alloc(wmi_handle, len);
4919 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304920 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4921 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304922 }
4923
4924 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
4925
4926 WMITLV_SET_HDR(&cmd->tlv_header,
4927 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4928 WMITLV_GET_STRUCT_TLVLEN(
4929 wmi_passpoint_config_cmd_fixed_param));
4930 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
4931
4932 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4933 WMI_PASSPOINT_LIST_CONFIG_CMDID);
4934 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05304935 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304936 __func__);
4937 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304938 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304939 }
4940
Govind Singhb53420c2016-03-09 14:32:57 +05304941 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304942}
4943
4944/**
4945 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
4946 * @wmi_handle: wmi handle
4947 * @req: passpoint network request structure
4948 *
4949 * This function reads the incoming @req and fill in the destination
4950 * WMI structure and send down the passpoint configs down to the firmware
4951 *
Govind Singhb53420c2016-03-09 14:32:57 +05304952 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05304953 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304954static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304955 struct wifi_passpoint_req_param *req)
4956{
4957 wmi_passpoint_config_cmd_fixed_param *cmd;
4958 u_int8_t i, j, *bytes;
4959 wmi_buf_t buf;
4960 uint32_t len;
4961 int ret;
4962
4963 len = sizeof(*cmd);
4964 for (i = 0; i < req->num_networks; i++) {
4965 buf = wmi_buf_alloc(wmi_handle, len);
4966 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304967 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
4968 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304969 }
4970
4971 cmd = (wmi_passpoint_config_cmd_fixed_param *)
4972 wmi_buf_data(buf);
4973
4974 WMITLV_SET_HDR(&cmd->tlv_header,
4975 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
4976 WMITLV_GET_STRUCT_TLVLEN(
4977 wmi_passpoint_config_cmd_fixed_param));
4978 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05304979 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
4980 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304981 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05304982 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304983 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
4984 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05304985 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304986 j, bytes[0], bytes[1], bytes[2], bytes[3],
4987 bytes[4], bytes[5], bytes[6], bytes[7]);
4988
Govind Singhb53420c2016-03-09 14:32:57 +05304989 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05304990 &req->networks[i].roaming_consortium_ids[j],
4991 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
4992 }
Govind Singhb53420c2016-03-09 14:32:57 +05304993 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304994 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304995 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304996 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
4997
4998 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4999 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5000 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305001 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305002 __func__);
5003 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305004 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305005 }
5006 }
5007
Govind Singhb53420c2016-03-09 14:32:57 +05305008 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305009}
5010
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305011/**
5012 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5013 * @wmi_handle: wmi handle
5014 * @scan_cmd_fp: start scan command ptr
5015 * @roam_req: roam request param
5016 *
5017 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5018 * of WMI_ROAM_SCAN_MODE.
5019 *
5020 * Return: QDF status
5021 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305022static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305023 wmi_start_scan_cmd_fixed_param *
5024 scan_cmd_fp,
5025 struct roam_offload_scan_params *roam_req)
5026{
5027 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305028 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305029 int len;
5030 uint8_t *buf_ptr;
5031 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305032
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305033#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5034 int auth_mode = roam_req->auth_mode;
5035 wmi_roam_offload_tlv_param *roam_offload_params;
5036 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5037 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5038 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305039 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305040#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5041 /* Need to create a buf with roam_scan command at
5042 * front and piggyback with scan command */
5043 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5044#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5045 (2 * WMI_TLV_HDR_SIZE) +
5046#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5047 sizeof(wmi_start_scan_cmd_fixed_param);
5048#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5049 if (roam_req->is_roam_req_valid &&
5050 roam_req->roam_offload_enabled) {
5051 len += sizeof(wmi_roam_offload_tlv_param);
5052 len += WMI_TLV_HDR_SIZE;
5053 if ((auth_mode != WMI_AUTH_NONE) &&
5054 ((auth_mode != WMI_AUTH_OPEN) ||
5055 (auth_mode == WMI_AUTH_OPEN &&
5056 roam_req->mdid.mdie_present) ||
5057 roam_req->is_ese_assoc)) {
5058 len += WMI_TLV_HDR_SIZE;
5059 if (roam_req->is_ese_assoc)
5060 len +=
5061 sizeof(wmi_roam_ese_offload_tlv_param);
5062 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5063 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5064 (auth_mode == WMI_AUTH_OPEN &&
5065 roam_req->mdid.mdie_present))
5066 len +=
5067 sizeof(wmi_roam_11r_offload_tlv_param);
5068 else
5069 len +=
5070 sizeof(wmi_roam_11i_offload_tlv_param);
5071 } else {
5072 len += WMI_TLV_HDR_SIZE;
5073 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305074
5075 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5076 + roundup(roam_req->assoc_ie_length,
5077 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305078 } else {
5079 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305080 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305081 __func__, roam_req->roam_offload_enabled);
5082 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305083 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305084 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305085 }
5086 if (roam_req->is_roam_req_valid &&
5087 roam_req->roam_offload_enabled) {
5088 roam_req->mode = roam_req->mode |
5089 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5090 }
5091#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5092
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305093 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5094 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5095 len = sizeof(wmi_roam_scan_mode_fixed_param);
5096
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305097 buf = wmi_buf_alloc(wmi_handle, len);
5098 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305099 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305100 return QDF_STATUS_E_NOMEM;
5101 }
5102
5103 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305104
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305105 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5106 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5107 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5108 WMITLV_GET_STRUCT_TLVLEN
5109 (wmi_roam_scan_mode_fixed_param));
5110
5111 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5112 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305113 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5114 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5115 goto send_roam_scan_mode_cmd;
5116
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305117 /* Fill in scan parameters suitable for roaming scan */
5118 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305119
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305120 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5121 sizeof(wmi_start_scan_cmd_fixed_param));
5122 /* Ensure there is no additional IEs */
5123 scan_cmd_fp->ie_len = 0;
5124 WMITLV_SET_HDR(buf_ptr,
5125 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5126 WMITLV_GET_STRUCT_TLVLEN
5127 (wmi_start_scan_cmd_fixed_param));
5128#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5129 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5130 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5131 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5132 sizeof(wmi_roam_offload_tlv_param));
5133 buf_ptr += WMI_TLV_HDR_SIZE;
5134 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5135 WMITLV_SET_HDR(buf_ptr,
5136 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5137 WMITLV_GET_STRUCT_TLVLEN
5138 (wmi_roam_offload_tlv_param));
5139 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5140 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5141 roam_offload_params->select_5g_margin =
5142 roam_req->select_5ghz_margin;
5143 roam_offload_params->reassoc_failure_timeout =
5144 roam_req->reassoc_failure_timeout;
5145
5146 /* Fill the capabilities */
5147 roam_offload_params->capability =
5148 roam_req->roam_offload_params.capability;
5149 roam_offload_params->ht_caps_info =
5150 roam_req->roam_offload_params.ht_caps_info;
5151 roam_offload_params->ampdu_param =
5152 roam_req->roam_offload_params.ampdu_param;
5153 roam_offload_params->ht_ext_cap =
5154 roam_req->roam_offload_params.ht_ext_cap;
5155 roam_offload_params->ht_txbf =
5156 roam_req->roam_offload_params.ht_txbf;
5157 roam_offload_params->asel_cap =
5158 roam_req->roam_offload_params.asel_cap;
5159 roam_offload_params->qos_caps =
5160 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005161 roam_offload_params->qos_enabled =
5162 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305163 roam_offload_params->wmm_caps =
5164 roam_req->roam_offload_params.wmm_caps;
5165 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5166 (uint8_t *)roam_req->roam_offload_params.mcsset,
5167 ROAM_OFFLOAD_NUM_MCS_SET);
5168
5169 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5170 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5171 * they are filled in the same order.Depending on the
5172 * authentication type, the other mode TLV's are nullified
5173 * and only headers are filled.*/
5174 if ((auth_mode != WMI_AUTH_NONE) &&
5175 ((auth_mode != WMI_AUTH_OPEN) ||
5176 (auth_mode == WMI_AUTH_OPEN
5177 && roam_req->mdid.mdie_present) ||
5178 roam_req->is_ese_assoc)) {
5179 if (roam_req->is_ese_assoc) {
5180 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5181 WMITLV_GET_STRUCT_TLVLEN(0));
5182 buf_ptr += WMI_TLV_HDR_SIZE;
5183 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5184 WMITLV_GET_STRUCT_TLVLEN(0));
5185 buf_ptr += WMI_TLV_HDR_SIZE;
5186 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5187 sizeof(wmi_roam_ese_offload_tlv_param));
5188 buf_ptr += WMI_TLV_HDR_SIZE;
5189 roam_offload_ese =
5190 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5191 qdf_mem_copy(roam_offload_ese->krk,
5192 roam_req->krk,
5193 sizeof(roam_req->krk));
5194 qdf_mem_copy(roam_offload_ese->btk,
5195 roam_req->btk,
5196 sizeof(roam_req->btk));
5197 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5198 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5199 WMITLV_GET_STRUCT_TLVLEN
5200 (wmi_roam_ese_offload_tlv_param));
5201 buf_ptr +=
5202 sizeof(wmi_roam_ese_offload_tlv_param);
5203 } else if (auth_mode == WMI_AUTH_FT_RSNA
5204 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5205 || (auth_mode == WMI_AUTH_OPEN
5206 && roam_req->mdid.mdie_present)) {
5207 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5208 0);
5209 buf_ptr += WMI_TLV_HDR_SIZE;
5210 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5211 sizeof(wmi_roam_11r_offload_tlv_param));
5212 buf_ptr += WMI_TLV_HDR_SIZE;
5213 roam_offload_11r =
5214 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5215 roam_offload_11r->r0kh_id_len =
5216 roam_req->rokh_id_length;
5217 qdf_mem_copy(roam_offload_11r->r0kh_id,
5218 roam_req->rokh_id,
5219 roam_offload_11r->r0kh_id_len);
5220 qdf_mem_copy(roam_offload_11r->psk_msk,
5221 roam_req->psk_pmk,
5222 sizeof(roam_req->psk_pmk));
5223 roam_offload_11r->psk_msk_len =
5224 roam_req->pmk_len;
5225 roam_offload_11r->mdie_present =
5226 roam_req->mdid.mdie_present;
5227 roam_offload_11r->mdid =
5228 roam_req->mdid.mobility_domain;
5229 if (auth_mode == WMI_AUTH_OPEN) {
5230 /* If FT-Open ensure pmk length
5231 and r0khid len are zero */
5232 roam_offload_11r->r0kh_id_len = 0;
5233 roam_offload_11r->psk_msk_len = 0;
5234 }
5235 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5236 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5237 WMITLV_GET_STRUCT_TLVLEN
5238 (wmi_roam_11r_offload_tlv_param));
5239 buf_ptr +=
5240 sizeof(wmi_roam_11r_offload_tlv_param);
5241 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5242 WMITLV_GET_STRUCT_TLVLEN(0));
5243 buf_ptr += WMI_TLV_HDR_SIZE;
5244 } else {
5245 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5246 sizeof(wmi_roam_11i_offload_tlv_param));
5247 buf_ptr += WMI_TLV_HDR_SIZE;
5248 roam_offload_11i =
5249 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005250 if (roam_req->roam_key_mgmt_offload_enabled &&
5251 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305252 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5253 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305254 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305255 } else {
5256 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5257 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305258 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305259 }
5260
5261 qdf_mem_copy(roam_offload_11i->pmk,
5262 roam_req->psk_pmk,
5263 sizeof(roam_req->psk_pmk));
5264 roam_offload_11i->pmk_len = roam_req->pmk_len;
5265 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5266 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5267 WMITLV_GET_STRUCT_TLVLEN
5268 (wmi_roam_11i_offload_tlv_param));
5269 buf_ptr +=
5270 sizeof(wmi_roam_11i_offload_tlv_param);
5271 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5272 0);
5273 buf_ptr += WMI_TLV_HDR_SIZE;
5274 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5275 0);
5276 buf_ptr += WMI_TLV_HDR_SIZE;
5277 }
5278 } else {
5279 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5280 WMITLV_GET_STRUCT_TLVLEN(0));
5281 buf_ptr += WMI_TLV_HDR_SIZE;
5282 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5283 WMITLV_GET_STRUCT_TLVLEN(0));
5284 buf_ptr += WMI_TLV_HDR_SIZE;
5285 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5286 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305287 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305288 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305289
5290 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5291 sizeof(*assoc_ies));
5292 buf_ptr += WMI_TLV_HDR_SIZE;
5293
5294 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5295 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5296 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5297 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5298 assoc_ies->buf_len = roam_req->assoc_ie_length;
5299
5300 buf_ptr += sizeof(*assoc_ies);
5301
5302 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5303 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5304 buf_ptr += WMI_TLV_HDR_SIZE;
5305
5306 if (assoc_ies->buf_len != 0) {
5307 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5308 assoc_ies->buf_len);
5309 }
5310
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305311 } else {
5312 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5313 WMITLV_GET_STRUCT_TLVLEN(0));
5314 buf_ptr += WMI_TLV_HDR_SIZE;
5315 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5316 WMITLV_GET_STRUCT_TLVLEN(0));
5317 buf_ptr += WMI_TLV_HDR_SIZE;
5318 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5319 WMITLV_GET_STRUCT_TLVLEN(0));
5320 buf_ptr += WMI_TLV_HDR_SIZE;
5321 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5322 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305323 buf_ptr += WMI_TLV_HDR_SIZE;
5324 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5325 WMITLV_GET_STRUCT_TLVLEN(0));
5326 buf_ptr += WMI_TLV_HDR_SIZE;
5327 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5328 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305329 }
5330#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305331
5332send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305333 status = wmi_unified_cmd_send(wmi_handle, buf,
5334 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305335 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305336 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305337 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5338 status);
5339 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305340 }
5341
Govind Singh67922e82016-04-01 16:48:57 +05305342 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305343}
5344
5345
5346/**
5347 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5348 * rssi threashold
5349 * @wmi_handle: wmi handle
5350 * @roam_req: Roaming request buffer
5351 *
5352 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5353 *
5354 * Return: QDF status
5355 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305356static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305357 struct roam_offload_scan_rssi_params *roam_req)
5358{
5359 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305360 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305361 int len;
5362 uint8_t *buf_ptr;
5363 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5364 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5365 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305366 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305367
5368 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5369 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5370 len += sizeof(wmi_roam_scan_extended_threshold_param);
5371 len += WMI_TLV_HDR_SIZE;
5372 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305373 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5374 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305375 buf = wmi_buf_alloc(wmi_handle, len);
5376 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305377 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305378 return QDF_STATUS_E_NOMEM;
5379 }
5380
5381 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5382 rssi_threshold_fp =
5383 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5384 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5385 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5386 WMITLV_GET_STRUCT_TLVLEN
5387 (wmi_roam_scan_rssi_threshold_fixed_param));
5388 /* fill in threshold values */
5389 rssi_threshold_fp->vdev_id = roam_req->session_id;
5390 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5391 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5392 rssi_threshold_fp->hirssi_scan_max_count =
5393 roam_req->hi_rssi_scan_max_count;
5394 rssi_threshold_fp->hirssi_scan_delta =
5395 roam_req->hi_rssi_scan_rssi_delta;
5396 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5397
5398 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5399 WMITLV_SET_HDR(buf_ptr,
5400 WMITLV_TAG_ARRAY_STRUC,
5401 sizeof(wmi_roam_scan_extended_threshold_param));
5402 buf_ptr += WMI_TLV_HDR_SIZE;
5403 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5404
5405 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5406 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5407 ext_thresholds->boost_threshold_5g =
5408 roam_req->boost_threshold_5g;
5409
5410 ext_thresholds->boost_algorithm_5g =
5411 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5412 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5413 ext_thresholds->penalty_algorithm_5g =
5414 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5415 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5416 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5417 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5418 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5419
5420 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5421 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5422 WMITLV_GET_STRUCT_TLVLEN
5423 (wmi_roam_scan_extended_threshold_param));
5424 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5425 WMITLV_SET_HDR(buf_ptr,
5426 WMITLV_TAG_ARRAY_STRUC,
5427 sizeof(wmi_roam_earlystop_rssi_thres_param));
5428 buf_ptr += WMI_TLV_HDR_SIZE;
5429 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5430 early_stop_thresholds->roam_earlystop_thres_min =
5431 roam_req->roam_earlystop_thres_min;
5432 early_stop_thresholds->roam_earlystop_thres_max =
5433 roam_req->roam_earlystop_thres_max;
5434 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5435 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5436 WMITLV_GET_STRUCT_TLVLEN
5437 (wmi_roam_earlystop_rssi_thres_param));
5438
Gupta, Kapil7e652922016-04-12 15:02:00 +05305439 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5441 sizeof(wmi_roam_dense_thres_param));
5442 buf_ptr += WMI_TLV_HDR_SIZE;
5443 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5444 dense_thresholds->roam_dense_rssi_thres_offset =
5445 roam_req->dense_rssi_thresh_offset;
5446 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5447 dense_thresholds->roam_dense_traffic_thres =
5448 roam_req->traffic_threshold;
5449 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5450 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5451 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5452 WMITLV_GET_STRUCT_TLVLEN
5453 (wmi_roam_dense_thres_param));
5454
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305455 status = wmi_unified_cmd_send(wmi_handle, buf,
5456 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305457 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305458 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305459 status);
5460 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305461 }
5462
Govind Singh67922e82016-04-01 16:48:57 +05305463 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305464}
5465
5466/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305467 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5468 * configuration params
5469 * @wma_handle: wma handler
5470 * @dwelltime_params: pointer to dwelltime_params
5471 *
5472 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5473 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005474static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305475QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5476 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5477{
5478 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5479 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5480 wmi_buf_t buf;
5481 uint8_t *buf_ptr;
5482 int32_t err;
5483 int len;
5484
5485 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5486 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5487 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5488 buf = wmi_buf_alloc(wmi_handle, len);
5489 if (!buf) {
5490 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5491 __func__);
5492 return QDF_STATUS_E_NOMEM;
5493 }
5494 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5495 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5496 WMITLV_SET_HDR(&dwell_param->tlv_header,
5497 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5498 WMITLV_GET_STRUCT_TLVLEN
5499 (wmi_scan_adaptive_dwell_config_fixed_param));
5500
5501 dwell_param->enable = dwelltime_params->is_enabled;
5502 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5503 WMITLV_SET_HDR(buf_ptr,
5504 WMITLV_TAG_ARRAY_STRUC,
5505 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5506 buf_ptr += WMI_TLV_HDR_SIZE;
5507
5508 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5509 WMITLV_SET_HDR(&cmd->tlv_header,
5510 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5511 WMITLV_GET_STRUCT_TLVLEN(
5512 wmi_scan_adaptive_dwell_parameters_tlv));
5513
5514 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5515 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5516 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5517 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5518 err = wmi_unified_cmd_send(wmi_handle, buf,
5519 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5520 if (err) {
5521 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5522 wmi_buf_free(buf);
5523 return QDF_STATUS_E_FAILURE;
5524 }
5525
5526 return QDF_STATUS_SUCCESS;
5527}
5528
5529
5530/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305531 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5532 * @wmi_handle: wmi handle
5533 * @roam_req: Request which contains the filters
5534 *
5535 * There are filters such as whitelist, blacklist and preferred
5536 * list that need to be applied to the scan results to form the
5537 * probable candidates for roaming.
5538 *
5539 * Return: Return success upon succesfully passing the
5540 * parameters to the firmware, otherwise failure.
5541 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305542static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305543 struct roam_scan_filter_params *roam_req)
5544{
5545 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305546 QDF_STATUS status;
5547 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305548 uint32_t len;
5549 uint8_t *buf_ptr;
5550 wmi_roam_filter_fixed_param *roam_filter;
5551 uint8_t *bssid_src_ptr = NULL;
5552 wmi_mac_addr *bssid_dst_ptr = NULL;
5553 wmi_ssid *ssid_ptr = NULL;
5554 uint32_t *bssid_preferred_factor_ptr = NULL;
5555
5556 len = sizeof(wmi_roam_filter_fixed_param);
5557 len += WMI_TLV_HDR_SIZE;
5558 len += roam_req->len;
5559
5560 buf = wmi_buf_alloc(wmi_handle, len);
5561 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305562 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305563 return QDF_STATUS_E_NOMEM;
5564 }
5565
5566 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5567 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5568 WMITLV_SET_HDR(&roam_filter->tlv_header,
5569 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5570 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5571 /* fill in fixed values */
5572 roam_filter->vdev_id = roam_req->session_id;
5573 roam_filter->flags = 0;
5574 roam_filter->op_bitmap = roam_req->op_bitmap;
5575 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5576 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5577 roam_filter->num_bssid_preferred_list =
5578 roam_req->num_bssid_preferred_list;
5579 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5580
5581 WMITLV_SET_HDR((buf_ptr),
5582 WMITLV_TAG_ARRAY_FIXED_STRUC,
5583 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5584 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5585 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5586 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5587 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5588 bssid_src_ptr += ATH_MAC_LEN;
5589 bssid_dst_ptr++;
5590 }
5591 buf_ptr += WMI_TLV_HDR_SIZE +
5592 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5593 WMITLV_SET_HDR((buf_ptr),
5594 WMITLV_TAG_ARRAY_FIXED_STRUC,
5595 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5596 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5597 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5598 qdf_mem_copy(&ssid_ptr->ssid,
5599 &roam_req->ssid_allowed_list[i].mac_ssid,
5600 roam_req->ssid_allowed_list[i].length);
5601 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5602 ssid_ptr++;
5603 }
5604 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5605 sizeof(wmi_ssid));
5606 WMITLV_SET_HDR((buf_ptr),
5607 WMITLV_TAG_ARRAY_FIXED_STRUC,
5608 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5609 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5610 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5611 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5612 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5613 (wmi_mac_addr *)bssid_dst_ptr);
5614 bssid_src_ptr += ATH_MAC_LEN;
5615 bssid_dst_ptr++;
5616 }
5617 buf_ptr += WMI_TLV_HDR_SIZE +
5618 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5619 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5620 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5621 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5622 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5623 *bssid_preferred_factor_ptr =
5624 roam_req->bssid_favored_factor[i];
5625 bssid_preferred_factor_ptr++;
5626 }
5627 buf_ptr += WMI_TLV_HDR_SIZE +
5628 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5629
5630 status = wmi_unified_cmd_send(wmi_handle, buf,
5631 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305632 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305633 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305634 status);
5635 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305636 }
Govind Singh67922e82016-04-01 16:48:57 +05305637
5638 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305639}
5640
Govind Singh4eacd2b2016-03-07 14:24:22 +05305641/** send_set_epno_network_list_cmd_tlv() - set epno network list
5642 * @wmi_handle: wmi handle
5643 * @req: epno config params request structure
5644 *
5645 * This function reads the incoming epno config request structure
5646 * and constructs the WMI message to the firmware.
5647 *
5648 * Returns: 0 on success, error number otherwise
5649 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305650static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305651 struct wifi_enhanched_pno_params *req)
5652{
5653 wmi_nlo_config_cmd_fixed_param *cmd;
5654 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305655 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305656 u_int8_t i, *buf_ptr;
5657 wmi_buf_t buf;
5658 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305659 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305660
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305661 /* Fixed Params */
5662 len = sizeof(*cmd);
5663 if (req->num_networks) {
5664 /* TLV place holder for array of structures
5665 * then each nlo_configured_parameters(nlo_list) TLV.
5666 */
5667 len += WMI_TLV_HDR_SIZE;
5668 len += (sizeof(nlo_configured_parameters)
5669 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5670 /* TLV for array of uint32 channel_list */
5671 len += WMI_TLV_HDR_SIZE;
5672 /* TLV for nlo_channel_prediction_cfg */
5673 len += WMI_TLV_HDR_SIZE;
5674 /* TLV for candidate score params */
5675 len += sizeof(enlo_candidate_score_params);
5676 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305677
5678 buf = wmi_buf_alloc(wmi_handle, len);
5679 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305680 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5681 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305682 }
5683
5684 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5685
5686 buf_ptr = (u_int8_t *) cmd;
5687 WMITLV_SET_HDR(&cmd->tlv_header,
5688 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5689 WMITLV_GET_STRUCT_TLVLEN(
5690 wmi_nlo_config_cmd_fixed_param));
5691 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305692
5693 /* set flag to reset if num of networks are 0 */
5694 cmd->flags = (req->num_networks == 0 ?
5695 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305696
5697 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5698
Govind Singhb53420c2016-03-09 14:32:57 +05305699 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305700 WMI_LOGD("SSID count: %d flags: %d",
5701 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305702
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305703 /* Fill nlo_config only when num_networks are non zero */
5704 if (cmd->no_of_ssids) {
5705 /* Fill networks */
5706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5707 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5708 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305709
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305710 nlo_list = (nlo_configured_parameters *) buf_ptr;
5711 for (i = 0; i < cmd->no_of_ssids; i++) {
5712 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5713 WMITLV_TAG_ARRAY_BYTE,
5714 WMITLV_GET_STRUCT_TLVLEN(
5715 nlo_configured_parameters));
5716 /* Copy ssid and it's length */
5717 nlo_list[i].ssid.valid = true;
5718 nlo_list[i].ssid.ssid.ssid_len =
5719 req->networks[i].ssid.length;
5720 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5721 req->networks[i].ssid.mac_ssid,
5722 nlo_list[i].ssid.ssid.ssid_len);
5723 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5724 nlo_list[i].ssid.ssid.ssid_len,
5725 (char *) nlo_list[i].ssid.ssid.ssid,
5726 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305727
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305728 /* Copy pno flags */
5729 nlo_list[i].bcast_nw_type.valid = true;
5730 nlo_list[i].bcast_nw_type.bcast_nw_type =
5731 req->networks[i].flags;
5732 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305733 nlo_list[i].bcast_nw_type.bcast_nw_type);
5734
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305735 /* Copy auth bit field */
5736 nlo_list[i].auth_type.valid = true;
5737 nlo_list[i].auth_type.auth_type =
5738 req->networks[i].auth_bit_field;
5739 WMI_LOGD("Auth bit field (%u)",
5740 nlo_list[i].auth_type.auth_type);
5741 }
5742
5743 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5744 /* Fill the channel list */
5745 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5746 buf_ptr += WMI_TLV_HDR_SIZE;
5747
5748 /* Fill prediction_param */
5749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5750 buf_ptr += WMI_TLV_HDR_SIZE;
5751
5752 /* Fill epno candidate score params */
5753 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5754 WMITLV_SET_HDR(buf_ptr,
5755 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5756 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5757 cand_score_params->min5GHz_rssi =
5758 req->min_5ghz_rssi;
5759 cand_score_params->min24GHz_rssi =
5760 req->min_24ghz_rssi;
5761 cand_score_params->initial_score_max =
5762 req->initial_score_max;
5763 cand_score_params->current_connection_bonus =
5764 req->current_connection_bonus;
5765 cand_score_params->same_network_bonus =
5766 req->same_network_bonus;
5767 cand_score_params->secure_bonus =
5768 req->secure_bonus;
5769 cand_score_params->band5GHz_bonus =
5770 req->band_5ghz_bonus;
5771 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305772 }
5773
Govind Singh4eacd2b2016-03-07 14:24:22 +05305774 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305775 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305776 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305777 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305778 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305779 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305780 }
5781
Govind Singhb53420c2016-03-09 14:32:57 +05305782 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305783 req->session_id);
5784
Govind Singh67922e82016-04-01 16:48:57 +05305785 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305786}
5787
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305788
Govind Singh4eacd2b2016-03-07 14:24:22 +05305789/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5790 * @wmi_handle: wmi handle
5791 * @ipa_offload: ipa offload control parameter
5792 *
5793 * Returns: 0 on success, error number otherwise
5794 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305795static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305796 struct ipa_offload_control_params *ipa_offload)
5797{
5798 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5799 wmi_buf_t wmi_buf;
5800 uint32_t len;
5801 u_int8_t *buf_ptr;
5802
5803 len = sizeof(*cmd);
5804 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5805 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305806 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5807 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305808 }
5809
Govind Singhb53420c2016-03-09 14:32:57 +05305810 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305811 ipa_offload->offload_type, ipa_offload->enable);
5812
5813 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5814
5815 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5816 WMITLV_SET_HDR(&cmd->tlv_header,
5817 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5818 WMITLV_GET_STRUCT_TLVLEN(
5819 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5820
5821 cmd->offload_type = ipa_offload->offload_type;
5822 cmd->vdev_id = ipa_offload->vdev_id;
5823 cmd->enable = ipa_offload->enable;
5824
5825 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5826 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305827 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305828 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305829 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305830 }
5831
Govind Singhb53420c2016-03-09 14:32:57 +05305832 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305833}
5834
5835/**
5836 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5837 * @wmi_handle: wmi handle
5838 * @pgetcapab: get capabilities params
5839 *
5840 * This function send request to fw to get extscan capabilities.
5841 *
5842 * Return: CDF status
5843 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305844static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305845 struct extscan_capabilities_params *pgetcapab)
5846{
5847 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5848 wmi_buf_t wmi_buf;
5849 uint32_t len;
5850 uint8_t *buf_ptr;
5851
5852 len = sizeof(*cmd);
5853 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5854 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305855 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5856 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305857 }
5858 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5859
5860 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5861 WMITLV_SET_HDR(&cmd->tlv_header,
5862 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5863 WMITLV_GET_STRUCT_TLVLEN
5864 (wmi_extscan_get_capabilities_cmd_fixed_param));
5865
5866 cmd->request_id = pgetcapab->request_id;
5867
5868 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5869 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305870 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305871 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305872 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305873 }
Govind Singhb53420c2016-03-09 14:32:57 +05305874 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305875}
5876
5877/**
5878 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5879 * @wmi_handle: wmi handle
5880 * @pcached_results: cached results parameters
5881 *
5882 * This function send request to fw to get cached results.
5883 *
5884 * Return: CDF status
5885 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305886static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305887 struct extscan_cached_result_params *pcached_results)
5888{
5889 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5890 wmi_buf_t wmi_buf;
5891 uint32_t len;
5892 uint8_t *buf_ptr;
5893
5894 len = sizeof(*cmd);
5895 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5896 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305897 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5898 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305899 }
5900 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5901
5902 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
5903 WMITLV_SET_HDR(&cmd->tlv_header,
5904 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
5905 WMITLV_GET_STRUCT_TLVLEN
5906 (wmi_extscan_get_cached_results_cmd_fixed_param));
5907
5908 cmd->request_id = pcached_results->request_id;
5909 cmd->vdev_id = pcached_results->session_id;
5910 cmd->control_flags = pcached_results->flush;
5911
5912 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5913 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305914 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305915 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305916 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305917 }
Govind Singhb53420c2016-03-09 14:32:57 +05305918 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305919}
5920
5921/**
5922 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
5923 * @wmi_handle: wmi handle
5924 * @reset_req: Reset change request params
5925 *
5926 * This function sends stop change monitor request to fw.
5927 *
5928 * Return: CDF status
5929 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305930static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305931 struct extscan_capabilities_reset_params *reset_req)
5932{
5933 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5934 wmi_buf_t wmi_buf;
5935 uint32_t len;
5936 uint8_t *buf_ptr;
5937 int change_list = 0;
5938
5939 len = sizeof(*cmd);
5940
5941 /* reset significant change tlv is set to 0 */
5942 len += WMI_TLV_HDR_SIZE;
5943 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
5944 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5945 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305946 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5947 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305948 }
5949 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5950
5951 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
5952 buf_ptr;
5953 WMITLV_SET_HDR(&cmd->tlv_header,
5954 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
5955 WMITLV_GET_STRUCT_TLVLEN
5956 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
5957
5958 cmd->request_id = reset_req->request_id;
5959 cmd->vdev_id = reset_req->session_id;
5960 cmd->mode = 0;
5961
5962 buf_ptr += sizeof(*cmd);
5963 WMITLV_SET_HDR(buf_ptr,
5964 WMITLV_TAG_ARRAY_STRUC,
5965 change_list *
5966 sizeof(wmi_extscan_wlan_change_bssid_param));
5967 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
5968 sizeof
5969 (wmi_extscan_wlan_change_bssid_param));
5970
5971 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5972 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305973 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305974 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305975 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305976 }
Govind Singhb53420c2016-03-09 14:32:57 +05305977 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305978}
5979
5980/**
5981 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
5982 * @wmi_handle: wmi handle
5983 * @psigchange: change monitor request params
5984 * @buf: wmi buffer
5985 * @buf_len: buffer length
5986 *
5987 * This function fills elements of change monitor request buffer.
5988 *
5989 * Return: CDF status
5990 */
Govind Singhb53420c2016-03-09 14:32:57 +05305991static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305992 struct extscan_set_sig_changereq_params
5993 *psigchange, wmi_buf_t *buf, int *buf_len)
5994{
5995 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
5996 wmi_extscan_wlan_change_bssid_param *dest_chglist;
5997 uint8_t *buf_ptr;
5998 int j;
5999 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006000 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306001 struct ap_threshold_params *src_ap = psigchange->ap;
6002
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006003 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306004 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6005 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306006 }
6007 len += WMI_TLV_HDR_SIZE;
6008 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6009
6010 *buf = wmi_buf_alloc(wmi_handle, len);
6011 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306012 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306013 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306014 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306015 }
6016 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6017 cmd =
6018 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6019 buf_ptr;
6020 WMITLV_SET_HDR(&cmd->tlv_header,
6021 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6022 WMITLV_GET_STRUCT_TLVLEN
6023 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6024
6025 cmd->request_id = psigchange->request_id;
6026 cmd->vdev_id = psigchange->session_id;
6027 cmd->total_entries = numap;
6028 cmd->mode = 1;
6029 cmd->num_entries_in_page = numap;
6030 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6031 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6032 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6033 cmd->max_out_of_range_count = psigchange->min_breaching;
6034
6035 buf_ptr += sizeof(*cmd);
6036 WMITLV_SET_HDR(buf_ptr,
6037 WMITLV_TAG_ARRAY_STRUC,
6038 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6039 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6040 (buf_ptr + WMI_TLV_HDR_SIZE);
6041
6042 for (j = 0; j < numap; j++) {
6043 WMITLV_SET_HDR(dest_chglist,
6044 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6045 WMITLV_GET_STRUCT_TLVLEN
6046 (wmi_extscan_wlan_change_bssid_param));
6047
6048 dest_chglist->lower_rssi_limit = src_ap->low;
6049 dest_chglist->upper_rssi_limit = src_ap->high;
6050 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6051 &dest_chglist->bssid);
6052
Govind Singhb53420c2016-03-09 14:32:57 +05306053 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306054 dest_chglist->lower_rssi_limit);
6055 dest_chglist++;
6056 src_ap++;
6057 }
6058 buf_ptr += WMI_TLV_HDR_SIZE +
6059 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6060 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306061 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306062}
6063
6064/**
6065 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6066 * @wmi_handle: wmi handle
6067 * @psigchange: change monitor request params
6068 *
6069 * This function sends start change monitor request to fw.
6070 *
6071 * Return: CDF status
6072 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306073static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306074 struct extscan_set_sig_changereq_params *
6075 psigchange)
6076{
Govind Singhb53420c2016-03-09 14:32:57 +05306077 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306078 wmi_buf_t buf;
6079 int len;
6080
6081
Govind Singhb53420c2016-03-09 14:32:57 +05306082 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306083 psigchange, &buf,
6084 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306085 if (qdf_status != QDF_STATUS_SUCCESS) {
6086 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306087 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306088 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306089 }
6090 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306091 WMI_LOGE("%s: Failed to get buffer", __func__);
6092 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306093 }
6094 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6095 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306096 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306097 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306098 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306099 }
Govind Singhb53420c2016-03-09 14:32:57 +05306100 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306101}
6102
6103/**
6104 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6105 * @wmi_handle: wmi handle
6106 * @photlist_reset: hotlist reset params
6107 *
6108 * This function configures hotlist monitor to stop in fw.
6109 *
6110 * Return: CDF status
6111 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306112static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306113 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6114{
6115 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6116 wmi_buf_t wmi_buf;
6117 uint32_t len;
6118 uint8_t *buf_ptr;
6119 int hotlist_entries = 0;
6120
6121 len = sizeof(*cmd);
6122
6123 /* reset bssid hotlist with tlv set to 0 */
6124 len += WMI_TLV_HDR_SIZE;
6125 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6126
6127 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6128 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306129 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6130 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306131 }
6132
6133 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6134 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6135 buf_ptr;
6136 WMITLV_SET_HDR(&cmd->tlv_header,
6137 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6138 WMITLV_GET_STRUCT_TLVLEN
6139 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6140
6141 cmd->request_id = photlist_reset->request_id;
6142 cmd->vdev_id = photlist_reset->session_id;
6143 cmd->mode = 0;
6144
6145 buf_ptr += sizeof(*cmd);
6146 WMITLV_SET_HDR(buf_ptr,
6147 WMITLV_TAG_ARRAY_STRUC,
6148 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6149 buf_ptr += WMI_TLV_HDR_SIZE +
6150 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6151
6152 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6153 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306154 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306155 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306156 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306157 }
Govind Singhb53420c2016-03-09 14:32:57 +05306158 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306159}
6160
6161/**
6162 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6163 * @wmi_handle: wmi handle
6164 * @pstopcmd: stop scan command request params
6165 *
6166 * This function sends stop extscan request to fw.
6167 *
6168 * Return: CDF Status.
6169 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306170static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306171 struct extscan_stop_req_params *pstopcmd)
6172{
6173 wmi_extscan_stop_cmd_fixed_param *cmd;
6174 wmi_buf_t wmi_buf;
6175 uint32_t len;
6176 uint8_t *buf_ptr;
6177
6178 len = sizeof(*cmd);
6179 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6180 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306181 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6182 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306183 }
6184 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6185 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6186 WMITLV_SET_HDR(&cmd->tlv_header,
6187 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6188 WMITLV_GET_STRUCT_TLVLEN
6189 (wmi_extscan_stop_cmd_fixed_param));
6190
6191 cmd->request_id = pstopcmd->request_id;
6192 cmd->vdev_id = pstopcmd->session_id;
6193
6194 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6195 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306196 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306197 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306198 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306199 }
6200
Govind Singhb53420c2016-03-09 14:32:57 +05306201 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306202}
6203
6204/**
6205 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6206 * @wmi_handle: wmi handle
6207 * @pstart: scan command request params
6208 * @buf: event buffer
6209 * @buf_len: length of buffer
6210 *
6211 * This function fills individual elements of extscan request and
6212 * TLV for buckets, channel list.
6213 *
6214 * Return: CDF Status.
6215 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006216static
Govind Singhb53420c2016-03-09 14:32:57 +05306217QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306218 struct wifi_scan_cmd_req_params *pstart,
6219 wmi_buf_t *buf, int *buf_len)
6220{
6221 wmi_extscan_start_cmd_fixed_param *cmd;
6222 wmi_extscan_bucket *dest_blist;
6223 wmi_extscan_bucket_channel *dest_clist;
6224 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6225 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6226 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6227
6228 uint8_t *buf_ptr;
6229 int i, k, count = 0;
6230 int len = sizeof(*cmd);
6231 int nbuckets = pstart->numBuckets;
6232 int nchannels = 0;
6233
6234 /* These TLV's are are NULL by default */
6235 uint32_t ie_len_with_pad = 0;
6236 int num_ssid = 0;
6237 int num_bssid = 0;
6238 int ie_len = 0;
6239
6240 uint32_t base_period = pstart->basePeriod;
6241
6242 /* TLV placeholder for ssid_list (NULL) */
6243 len += WMI_TLV_HDR_SIZE;
6244 len += num_ssid * sizeof(wmi_ssid);
6245
6246 /* TLV placeholder for bssid_list (NULL) */
6247 len += WMI_TLV_HDR_SIZE;
6248 len += num_bssid * sizeof(wmi_mac_addr);
6249
6250 /* TLV placeholder for ie_data (NULL) */
6251 len += WMI_TLV_HDR_SIZE;
6252 len += ie_len * sizeof(uint32_t);
6253
6254 /* TLV placeholder for bucket */
6255 len += WMI_TLV_HDR_SIZE;
6256 len += nbuckets * sizeof(wmi_extscan_bucket);
6257
6258 /* TLV channel placeholder */
6259 len += WMI_TLV_HDR_SIZE;
6260 for (i = 0; i < nbuckets; i++) {
6261 nchannels += src_bucket->numChannels;
6262 src_bucket++;
6263 }
6264
Govind Singhb53420c2016-03-09 14:32:57 +05306265 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306266 __func__, nbuckets, nchannels);
6267 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6268 /* Allocate the memory */
6269 *buf = wmi_buf_alloc(wmi_handle, len);
6270 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306271 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306272 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306273 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306274 }
6275 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6276 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6277 WMITLV_SET_HDR(&cmd->tlv_header,
6278 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6279 WMITLV_GET_STRUCT_TLVLEN
6280 (wmi_extscan_start_cmd_fixed_param));
6281
6282 cmd->request_id = pstart->requestId;
6283 cmd->vdev_id = pstart->sessionId;
6284 cmd->base_period = pstart->basePeriod;
6285 cmd->num_buckets = nbuckets;
6286 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306287 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306288 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306289 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306290 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306291#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306292 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6293 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306294 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6295 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6296#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306297 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6298
6299 /* The max dwell time is retrieved from the first channel
6300 * of the first bucket and kept common for all channels.
6301 */
6302 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6303 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6304 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6305 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6306 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6307 cmd->max_table_usage = pstart->report_threshold_percent;
6308 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6309
6310 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306311 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306312 cmd->probe_delay = 0;
6313 cmd->probe_spacing_time = 0;
6314 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306315 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6316 WMI_SCAN_ADD_CCK_RATES |
6317 WMI_SCAN_ADD_OFDM_RATES |
6318 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6319 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306320 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6321 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306322 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306323 cmd->num_ssids = 0;
6324 cmd->num_bssid = 0;
6325 cmd->ie_len = 0;
6326 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6327 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6328
6329 buf_ptr += sizeof(*cmd);
6330 WMITLV_SET_HDR(buf_ptr,
6331 WMITLV_TAG_ARRAY_FIXED_STRUC,
6332 num_ssid * sizeof(wmi_ssid));
6333 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6334
6335 WMITLV_SET_HDR(buf_ptr,
6336 WMITLV_TAG_ARRAY_FIXED_STRUC,
6337 num_bssid * sizeof(wmi_mac_addr));
6338 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6339
6340 ie_len_with_pad = 0;
6341 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6342 ie_len_with_pad);
6343 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6344
6345 WMITLV_SET_HDR(buf_ptr,
6346 WMITLV_TAG_ARRAY_STRUC,
6347 nbuckets * sizeof(wmi_extscan_bucket));
6348 dest_blist = (wmi_extscan_bucket *)
6349 (buf_ptr + WMI_TLV_HDR_SIZE);
6350 src_bucket = pstart->buckets;
6351
6352 /* Retrieve scanning information from each bucket and
6353 * channels and send it to the target
6354 */
6355 for (i = 0; i < nbuckets; i++) {
6356 WMITLV_SET_HDR(dest_blist,
6357 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6358 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6359
6360 dest_blist->bucket_id = src_bucket->bucket;
6361 dest_blist->base_period_multiplier =
6362 src_bucket->period / base_period;
6363 dest_blist->min_period = src_bucket->period;
6364 dest_blist->max_period = src_bucket->max_period;
6365 dest_blist->exp_backoff = src_bucket->exponent;
6366 dest_blist->exp_max_step_count = src_bucket->step_count;
6367 dest_blist->channel_band = src_bucket->band;
6368 dest_blist->num_channels = src_bucket->numChannels;
6369 dest_blist->notify_extscan_events = 0;
6370
6371 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6372 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006373 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6374 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306375
6376 if (src_bucket->reportEvents &
6377 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6378 dest_blist->forwarding_flags =
6379 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6380 dest_blist->notify_extscan_events |=
6381 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6382 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6383 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6384 } else {
6385 dest_blist->forwarding_flags =
6386 WMI_EXTSCAN_NO_FORWARDING;
6387 }
6388
6389 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6390 dest_blist->configuration_flags = 0;
6391 else
6392 dest_blist->configuration_flags =
6393 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6394
Govind Singhb53420c2016-03-09 14:32:57 +05306395 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306396 __func__, dest_blist->notify_extscan_events,
6397 dest_blist->configuration_flags,
6398 dest_blist->forwarding_flags);
6399
6400 dest_blist->min_dwell_time_active =
6401 src_bucket->min_dwell_time_active;
6402 dest_blist->max_dwell_time_active =
6403 src_bucket->max_dwell_time_active;
6404 dest_blist->min_dwell_time_passive =
6405 src_bucket->min_dwell_time_passive;
6406 dest_blist->max_dwell_time_passive =
6407 src_bucket->max_dwell_time_passive;
6408 src_channel = src_bucket->channels;
6409
6410 /* save the channel info to later populate
6411 * the channel TLV
6412 */
6413 for (k = 0; k < src_bucket->numChannels; k++) {
6414 save_channel[count++].channel = src_channel->channel;
6415 src_channel++;
6416 }
6417 dest_blist++;
6418 src_bucket++;
6419 }
6420 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6421 WMITLV_SET_HDR(buf_ptr,
6422 WMITLV_TAG_ARRAY_STRUC,
6423 nchannels * sizeof(wmi_extscan_bucket_channel));
6424 dest_clist = (wmi_extscan_bucket_channel *)
6425 (buf_ptr + WMI_TLV_HDR_SIZE);
6426
6427 /* Active or passive scan is based on the bucket dwell time
6428 * and channel specific active,passive scans are not
6429 * supported yet
6430 */
6431 for (i = 0; i < nchannels; i++) {
6432 WMITLV_SET_HDR(dest_clist,
6433 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6434 WMITLV_GET_STRUCT_TLVLEN
6435 (wmi_extscan_bucket_channel));
6436 dest_clist->channel = save_channel[i].channel;
6437 dest_clist++;
6438 }
6439 buf_ptr += WMI_TLV_HDR_SIZE +
6440 (nchannels * sizeof(wmi_extscan_bucket_channel));
6441 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306442 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306443}
6444
6445/**
6446 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6447 * @wmi_handle: wmi handle
6448 * @pstart: scan command request params
6449 *
6450 * This function sends start extscan request to fw.
6451 *
6452 * Return: CDF Status.
6453 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306454static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306455 struct wifi_scan_cmd_req_params *pstart)
6456{
Govind Singhb53420c2016-03-09 14:32:57 +05306457 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306458 wmi_buf_t buf;
6459 int len;
6460
6461 /* Fill individual elements of extscan request and
6462 * TLV for buckets, channel list.
6463 */
Govind Singhb53420c2016-03-09 14:32:57 +05306464 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306465 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306466 if (qdf_status != QDF_STATUS_SUCCESS) {
6467 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6468 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306469 }
6470 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306471 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306472 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306473 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306474 }
6475 if (wmi_unified_cmd_send(wmi_handle, buf,
6476 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306477 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306478 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306479 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306480 }
6481
Govind Singhb53420c2016-03-09 14:32:57 +05306482 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306483}
6484
6485/**
6486 * send_plm_stop_cmd_tlv() - plm stop request
6487 * @wmi_handle: wmi handle
6488 * @plm: plm request parameters
6489 *
6490 * This function request FW to stop PLM.
6491 *
6492 * Return: CDF status
6493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306494static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306495 const struct plm_req_params *plm)
6496{
6497 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6498 int32_t len;
6499 wmi_buf_t buf;
6500 uint8_t *buf_ptr;
6501 int ret;
6502
6503 len = sizeof(*cmd);
6504 buf = wmi_buf_alloc(wmi_handle, len);
6505 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306506 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6507 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306508 }
6509
6510 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6511
6512 buf_ptr = (uint8_t *) cmd;
6513
6514 WMITLV_SET_HDR(&cmd->tlv_header,
6515 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6516 WMITLV_GET_STRUCT_TLVLEN
6517 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6518
6519 cmd->vdev_id = plm->session_id;
6520
6521 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306522 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306523
6524 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6525 WMI_VDEV_PLMREQ_STOP_CMDID);
6526 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306527 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306528 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306529 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306530 }
6531
Govind Singhb53420c2016-03-09 14:32:57 +05306532 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306533}
6534
6535/**
6536 * send_plm_start_cmd_tlv() - plm start request
6537 * @wmi_handle: wmi handle
6538 * @plm: plm request parameters
6539 *
6540 * This function request FW to start PLM.
6541 *
6542 * Return: CDF status
6543 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306544static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306545 const struct plm_req_params *plm,
6546 uint32_t *gchannel_list)
6547{
6548 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6549 uint32_t *channel_list;
6550 int32_t len;
6551 wmi_buf_t buf;
6552 uint8_t *buf_ptr;
6553 uint8_t count;
6554 int ret;
6555
6556 /* TLV place holder for channel_list */
6557 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6558 len += sizeof(uint32_t) * plm->plm_num_ch;
6559
6560 buf = wmi_buf_alloc(wmi_handle, len);
6561 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306562 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6563 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306564 }
6565 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6566
6567 buf_ptr = (uint8_t *) cmd;
6568
6569 WMITLV_SET_HDR(&cmd->tlv_header,
6570 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6571 WMITLV_GET_STRUCT_TLVLEN
6572 (wmi_vdev_plmreq_start_cmd_fixed_param));
6573
6574 cmd->vdev_id = plm->session_id;
6575
6576 cmd->meas_token = plm->meas_token;
6577 cmd->dialog_token = plm->diag_token;
6578 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306579 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306580 cmd->off_duration = plm->meas_duration;
6581 cmd->burst_cycle = plm->burst_len;
6582 cmd->tx_power = plm->desired_tx_pwr;
6583 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6584 cmd->num_chans = plm->plm_num_ch;
6585
6586 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6587
Govind Singhb53420c2016-03-09 14:32:57 +05306588 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6589 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6590 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6591 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6592 WMI_LOGD("off_duration: %d", cmd->off_duration);
6593 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6594 WMI_LOGD("tx_power: %d", cmd->tx_power);
6595 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306596
6597 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6598 (cmd->num_chans * sizeof(uint32_t)));
6599
6600 buf_ptr += WMI_TLV_HDR_SIZE;
6601 if (cmd->num_chans) {
6602 channel_list = (uint32_t *) buf_ptr;
6603 for (count = 0; count < cmd->num_chans; count++) {
6604 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306605 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306606 channel_list[count] =
6607 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306608 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306609 }
6610 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6611 }
6612
6613 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6614 WMI_VDEV_PLMREQ_START_CMDID);
6615 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306616 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306617 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306618 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306619 }
6620
Govind Singhb53420c2016-03-09 14:32:57 +05306621 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306622}
6623
6624/**
6625 * send_pno_stop_cmd_tlv() - PNO stop request
6626 * @wmi_handle: wmi handle
6627 * @vdev_id: vdev id
6628 *
6629 * This function request FW to stop ongoing PNO operation.
6630 *
6631 * Return: CDF status
6632 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306633static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306634{
6635 wmi_nlo_config_cmd_fixed_param *cmd;
6636 int32_t len = sizeof(*cmd);
6637 wmi_buf_t buf;
6638 uint8_t *buf_ptr;
6639 int ret;
6640
6641 /*
6642 * TLV place holder for array of structures nlo_configured_parameters
6643 * TLV place holder for array of uint32_t channel_list
6644 * TLV place holder for chnl prediction cfg
6645 */
6646 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6647 buf = wmi_buf_alloc(wmi_handle, len);
6648 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306649 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6650 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306651 }
6652
6653 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6654 buf_ptr = (uint8_t *) cmd;
6655
6656 WMITLV_SET_HDR(&cmd->tlv_header,
6657 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6658 WMITLV_GET_STRUCT_TLVLEN
6659 (wmi_nlo_config_cmd_fixed_param));
6660
6661 cmd->vdev_id = vdev_id;
6662 cmd->flags = WMI_NLO_CONFIG_STOP;
6663 buf_ptr += sizeof(*cmd);
6664
6665 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6666 buf_ptr += WMI_TLV_HDR_SIZE;
6667
6668 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6669 buf_ptr += WMI_TLV_HDR_SIZE;
6670
6671 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6672 buf_ptr += WMI_TLV_HDR_SIZE;
6673
6674
6675 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6676 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6677 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306678 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306679 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306680 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306681 }
6682
Govind Singhb53420c2016-03-09 14:32:57 +05306683 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306684}
6685
6686/**
Govind Singhccb0c272016-04-01 16:30:08 +05306687 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6688 * @buf_ptr: Buffer passed by upper layers
6689 * @pno: Buffer to be sent to the firmware
6690 *
6691 * Copy the PNO Channel prediction configuration parameters
6692 * passed by the upper layers to a WMI format TLV and send it
6693 * down to the firmware.
6694 *
6695 * Return: None
6696 */
6697static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6698 struct pno_scan_req_params *pno)
6699{
6700 nlo_channel_prediction_cfg *channel_prediction_cfg =
6701 (nlo_channel_prediction_cfg *) buf_ptr;
6702 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6703 WMITLV_TAG_ARRAY_BYTE,
6704 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306705#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306706 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6707 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6708 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6709 channel_prediction_cfg->full_scan_period_ms =
6710 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306711#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306712 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6713 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6714 channel_prediction_cfg->enable,
6715 channel_prediction_cfg->top_k_num,
6716 channel_prediction_cfg->stationary_threshold,
6717 channel_prediction_cfg->full_scan_period_ms);
6718}
6719
6720/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306721 * send_pno_start_cmd_tlv() - PNO start request
6722 * @wmi_handle: wmi handle
6723 * @pno: PNO request
6724 *
6725 * This function request FW to start PNO request.
6726 * Request: CDF status
6727 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306728static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306729 struct pno_scan_req_params *pno,
6730 uint32_t *gchannel_freq_list)
6731{
6732 wmi_nlo_config_cmd_fixed_param *cmd;
6733 nlo_configured_parameters *nlo_list;
6734 uint32_t *channel_list;
6735 int32_t len;
6736 wmi_buf_t buf;
6737 uint8_t *buf_ptr;
6738 uint8_t i;
6739 int ret;
6740
6741 /*
6742 * TLV place holder for array nlo_configured_parameters(nlo_list)
6743 * TLV place holder for array of uint32_t channel_list
6744 * TLV place holder for chnnl prediction cfg
6745 */
6746 len = sizeof(*cmd) +
6747 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6748
Govind Singhb53420c2016-03-09 14:32:57 +05306749 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306750 WMI_NLO_MAX_CHAN);
6751 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306752 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306753 len += sizeof(nlo_channel_prediction_cfg);
6754
6755 buf = wmi_buf_alloc(wmi_handle, len);
6756 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306757 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6758 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306759 }
6760
6761 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6762
6763 buf_ptr = (uint8_t *) cmd;
6764 WMITLV_SET_HDR(&cmd->tlv_header,
6765 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6766 WMITLV_GET_STRUCT_TLVLEN
6767 (wmi_nlo_config_cmd_fixed_param));
6768 cmd->vdev_id = pno->sessionId;
6769 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6770
Govind Singh87542482016-06-08 19:40:11 +05306771#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306772 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6773 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306774#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306775 /* Current FW does not support min-max range for dwell time */
6776 cmd->active_dwell_time = pno->active_max_time;
6777 cmd->passive_dwell_time = pno->passive_max_time;
6778
6779 /* Copy scan interval */
6780 cmd->fast_scan_period = pno->fast_scan_period;
6781 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08006782 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306783 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306784 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306785 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306786 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306787
6788 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6789
Govind Singhb53420c2016-03-09 14:32:57 +05306790 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6791 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306792 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6793 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6794 buf_ptr += WMI_TLV_HDR_SIZE;
6795
6796 nlo_list = (nlo_configured_parameters *) buf_ptr;
6797 for (i = 0; i < cmd->no_of_ssids; i++) {
6798 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6799 WMITLV_TAG_ARRAY_BYTE,
6800 WMITLV_GET_STRUCT_TLVLEN
6801 (nlo_configured_parameters));
6802 /* Copy ssid and it's length */
6803 nlo_list[i].ssid.valid = true;
6804 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306805 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306806 pno->aNetworks[i].ssid.mac_ssid,
6807 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306808 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306809 nlo_list[i].ssid.ssid.ssid_len,
6810 (char *)nlo_list[i].ssid.ssid.ssid,
6811 nlo_list[i].ssid.ssid.ssid_len);
6812
6813 /* Copy rssi threshold */
6814 if (pno->aNetworks[i].rssiThreshold &&
6815 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6816 nlo_list[i].rssi_cond.valid = true;
6817 nlo_list[i].rssi_cond.rssi =
6818 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306819 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306820 nlo_list[i].rssi_cond.rssi);
6821 }
6822 nlo_list[i].bcast_nw_type.valid = true;
6823 nlo_list[i].bcast_nw_type.bcast_nw_type =
6824 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306825 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306826 nlo_list[i].bcast_nw_type.bcast_nw_type);
6827 }
6828 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6829
6830 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306831 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306832 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306833 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306834 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6835 (cmd->num_of_channels * sizeof(uint32_t)));
6836 buf_ptr += WMI_TLV_HDR_SIZE;
6837
6838 channel_list = (uint32_t *) buf_ptr;
6839 for (i = 0; i < cmd->num_of_channels; i++) {
6840 channel_list[i] = pno->aNetworks[0].aChannels[i];
6841
6842 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6843 channel_list[i] = gchannel_freq_list[i];
6844
Govind Singhb53420c2016-03-09 14:32:57 +05306845 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306846 }
6847 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6848 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6849 sizeof(nlo_channel_prediction_cfg));
6850 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306851 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306852 buf_ptr += WMI_TLV_HDR_SIZE;
6853 /** TODO: Discrete firmware doesn't have command/option to configure
6854 * App IE which comes from wpa_supplicant as of part PNO start request.
6855 */
6856 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6857 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6858 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306859 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306860 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306861 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306862 }
6863
Govind Singhb53420c2016-03-09 14:32:57 +05306864 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306865}
6866
6867/* send_set_ric_req_cmd_tlv() - set ric request element
6868 * @wmi_handle: wmi handle
6869 * @msg: message
6870 * @is_add_ts: is addts required
6871 *
6872 * This function sets ric request element for 11r roaming.
6873 *
6874 * Return: CDF status
6875 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306876static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306877 void *msg, uint8_t is_add_ts)
6878{
6879 wmi_ric_request_fixed_param *cmd;
6880 wmi_ric_tspec *tspec_param;
6881 wmi_buf_t buf;
6882 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306883 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306884 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6885 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6886
6887 buf = wmi_buf_alloc(wmi_handle, len);
6888 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306889 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6890 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306891 }
6892
6893 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6894
6895 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6896 WMITLV_SET_HDR(&cmd->tlv_header,
6897 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6898 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6899 if (is_add_ts)
6900 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
6901 else
6902 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
6903 cmd->num_ric_request = 1;
6904 cmd->is_add_ric = is_add_ts;
6905
6906 buf_ptr += sizeof(wmi_ric_request_fixed_param);
6907 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
6908
6909 buf_ptr += WMI_TLV_HDR_SIZE;
6910 tspec_param = (wmi_ric_tspec *) buf_ptr;
6911 WMITLV_SET_HDR(&tspec_param->tlv_header,
6912 WMITLV_TAG_STRUC_wmi_ric_tspec,
6913 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
6914
6915 if (is_add_ts)
6916 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05306917#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05306918 else
6919 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05306920#endif
6921 if (ptspecIE) {
6922 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05306923#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05306924 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
6925 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306926#else
Govind Singh87542482016-06-08 19:40:11 +05306927 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
6928 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306929#endif /* ANI_LITTLE_BIT_ENDIAN */
6930
Govind Singh87542482016-06-08 19:40:11 +05306931 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
6932 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
6933 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
6934 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
6935 tspec_param->inactivity_interval = ptspecIE->inactInterval;
6936 tspec_param->suspension_interval = ptspecIE->suspendInterval;
6937 tspec_param->svc_start_time = ptspecIE->svcStartTime;
6938 tspec_param->min_data_rate = ptspecIE->minDataRate;
6939 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
6940 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
6941 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
6942 tspec_param->delay_bound = ptspecIE->delayBound;
6943 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
6944 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
6945 tspec_param->medium_time = 0;
6946 }
Govind Singhb53420c2016-03-09 14:32:57 +05306947 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306948
6949 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6950 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306951 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306952 __func__);
6953 if (is_add_ts)
6954 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05306955 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05306956 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306957 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306958 }
6959
Govind Singhb53420c2016-03-09 14:32:57 +05306960 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306961}
6962
6963/**
6964 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
6965 * @wmi_handle: wmi handle
6966 * @clear_req: ll stats clear request command params
6967 *
Govind Singhb53420c2016-03-09 14:32:57 +05306968 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05306969 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306970static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306971 const struct ll_stats_clear_params *clear_req,
6972 uint8_t addr[IEEE80211_ADDR_LEN])
6973{
6974 wmi_clear_link_stats_cmd_fixed_param *cmd;
6975 int32_t len;
6976 wmi_buf_t buf;
6977 uint8_t *buf_ptr;
6978 int ret;
6979
6980 len = sizeof(*cmd);
6981 buf = wmi_buf_alloc(wmi_handle, len);
6982
6983 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306984 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6985 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306986 }
6987
6988 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306989 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306990 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
6991
6992 WMITLV_SET_HDR(&cmd->tlv_header,
6993 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
6994 WMITLV_GET_STRUCT_TLVLEN
6995 (wmi_clear_link_stats_cmd_fixed_param));
6996
6997 cmd->stop_stats_collection_req = clear_req->stop_req;
6998 cmd->vdev_id = clear_req->sta_id;
6999 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7000
7001 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7002 &cmd->peer_macaddr);
7003
Govind Singhb53420c2016-03-09 14:32:57 +05307004 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7005 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7006 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7007 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7008 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307009 cmd->peer_macaddr); */
7010
7011 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7012 WMI_CLEAR_LINK_STATS_CMDID);
7013 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307014 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307015 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307016 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307017 }
7018
Govind Singhb53420c2016-03-09 14:32:57 +05307019 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7020 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307021}
7022
7023/**
7024 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7025 * @wmi_handle: wmi handle
7026 * @setReq: ll stats set request command params
7027 *
Govind Singhb53420c2016-03-09 14:32:57 +05307028 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307029 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307030static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307031 const struct ll_stats_set_params *set_req)
7032{
7033 wmi_start_link_stats_cmd_fixed_param *cmd;
7034 int32_t len;
7035 wmi_buf_t buf;
7036 uint8_t *buf_ptr;
7037 int ret;
7038
7039 len = sizeof(*cmd);
7040 buf = wmi_buf_alloc(wmi_handle, len);
7041
7042 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307043 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7044 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307045 }
7046
7047 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307048 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307049 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7050
7051 WMITLV_SET_HDR(&cmd->tlv_header,
7052 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7053 WMITLV_GET_STRUCT_TLVLEN
7054 (wmi_start_link_stats_cmd_fixed_param));
7055
7056 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7057 cmd->aggressive_statistics_gathering =
7058 set_req->aggressive_statistics_gathering;
7059
Govind Singhb53420c2016-03-09 14:32:57 +05307060 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7061 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7062 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307063
7064 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7065 WMI_START_LINK_STATS_CMDID);
7066 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307067 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307068 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307069 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307070 }
7071
Govind Singhb53420c2016-03-09 14:32:57 +05307072 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307073}
7074
7075/**
7076 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7077 * @wmi_handle:wmi handle
7078 * @get_req:ll stats get request command params
7079 * @addr: mac address
7080 *
Govind Singhb53420c2016-03-09 14:32:57 +05307081 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307082 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307083static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307084 const struct ll_stats_get_params *get_req,
7085 uint8_t addr[IEEE80211_ADDR_LEN])
7086{
7087 wmi_request_link_stats_cmd_fixed_param *cmd;
7088 int32_t len;
7089 wmi_buf_t buf;
7090 uint8_t *buf_ptr;
7091 int ret;
7092
7093 len = sizeof(*cmd);
7094 buf = wmi_buf_alloc(wmi_handle, len);
7095
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307096 if (!buf) {
7097 WMI_LOGE("%s: buf allocation failed", __func__);
7098 return QDF_STATUS_E_NOMEM;
7099 }
7100
Govind Singh4eacd2b2016-03-07 14:24:22 +05307101 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307102 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307103 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7104
7105 WMITLV_SET_HDR(&cmd->tlv_header,
7106 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7107 WMITLV_GET_STRUCT_TLVLEN
7108 (wmi_request_link_stats_cmd_fixed_param));
7109
7110 cmd->request_id = get_req->req_id;
7111 cmd->stats_type = get_req->param_id_mask;
7112 cmd->vdev_id = get_req->sta_id;
7113
7114 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7115 &cmd->peer_macaddr);
7116
Govind Singhb53420c2016-03-09 14:32:57 +05307117 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
7118 WMI_LOGD("Request ID : %d", cmd->request_id);
7119 WMI_LOGD("Stats Type : %d", cmd->stats_type);
7120 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7121 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307122
7123 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7124 WMI_REQUEST_LINK_STATS_CMDID);
7125 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307126 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307127 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307128 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307129 }
7130
Govind Singhb53420c2016-03-09 14:32:57 +05307131 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307132}
7133
7134/**
7135 * send_get_stats_cmd_tlv() - get stats request
7136 * @wmi_handle: wmi handle
7137 * @get_stats_param: stats params
7138 * @addr: mac address
7139 *
7140 * Return: CDF status
7141 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307142static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307143 struct pe_stats_req *get_stats_param,
7144 uint8_t addr[IEEE80211_ADDR_LEN])
7145{
7146 wmi_buf_t buf;
7147 wmi_request_stats_cmd_fixed_param *cmd;
7148 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7149
7150 buf = wmi_buf_alloc(wmi_handle, len);
7151 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307152 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7153 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307154 }
7155
7156
7157 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7158 WMITLV_SET_HDR(&cmd->tlv_header,
7159 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7160 WMITLV_GET_STRUCT_TLVLEN
7161 (wmi_request_stats_cmd_fixed_param));
7162 cmd->stats_id =
7163 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05307164 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307165 cmd->vdev_id = get_stats_param->session_id;
7166 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307167 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307168 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7169 WMI_REQUEST_STATS_CMDID)) {
7170
Govind Singhb53420c2016-03-09 14:32:57 +05307171 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307172 __func__);
7173 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307174 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307175 }
7176
Govind Singhb53420c2016-03-09 14:32:57 +05307177 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307178
7179}
7180
Govind Singh20c5dac2016-03-07 15:33:31 +05307181/**
7182 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7183 * @wmi_handle: wmi handle
7184 * @rssi_req: get RSSI request
7185 *
7186 * Return: CDF status
7187 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307188static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307189{
7190 wmi_buf_t buf;
7191 wmi_request_stats_cmd_fixed_param *cmd;
7192 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7193
7194 buf = wmi_buf_alloc(wmi_handle, len);
7195 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307196 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7197 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307198 }
7199
7200 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7201 WMITLV_SET_HDR(&cmd->tlv_header,
7202 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7203 WMITLV_GET_STRUCT_TLVLEN
7204 (wmi_request_stats_cmd_fixed_param));
7205 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7206 if (wmi_unified_cmd_send
7207 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307208 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307209 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307210 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307211 }
7212
Govind Singhb53420c2016-03-09 14:32:57 +05307213 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307214}
7215
7216/**
7217 * send_snr_cmd_tlv() - get RSSI from fw
7218 * @wmi_handle: wmi handle
7219 * @vdev_id: vdev id
7220 *
7221 * Return: CDF status
7222 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307223static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307224{
7225 wmi_buf_t buf;
7226 wmi_request_stats_cmd_fixed_param *cmd;
7227 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7228
7229 buf = wmi_buf_alloc(wmi_handle, len);
7230 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307231 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7232 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307233 }
7234
7235 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7236 cmd->vdev_id = vdev_id;
7237
7238 WMITLV_SET_HDR(&cmd->tlv_header,
7239 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7240 WMITLV_GET_STRUCT_TLVLEN
7241 (wmi_request_stats_cmd_fixed_param));
7242 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7243 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7244 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307245 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307246 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307247 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307248 }
7249
Govind Singhb53420c2016-03-09 14:32:57 +05307250 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307251}
7252
7253/**
7254 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7255 * @wmi_handle: wmi handle
7256 * @link_status: get link params
7257 *
7258 * Return: CDF status
7259 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307260static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307261 struct link_status_params *link_status)
7262{
7263 wmi_buf_t buf;
7264 wmi_request_stats_cmd_fixed_param *cmd;
7265 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7266
7267 buf = wmi_buf_alloc(wmi_handle, len);
7268 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307269 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7270 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307271 }
7272
7273 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7274 WMITLV_SET_HDR(&cmd->tlv_header,
7275 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7276 WMITLV_GET_STRUCT_TLVLEN
7277 (wmi_request_stats_cmd_fixed_param));
7278 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7279 cmd->vdev_id = link_status->session_id;
7280 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7281 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307282 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307283 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307284 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307285 }
7286
Govind Singhb53420c2016-03-09 14:32:57 +05307287 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307288}
7289
Govind Singh20c5dac2016-03-07 15:33:31 +05307290/**
7291 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7292 * @wmi_handle: wmi handle
7293 * @ta_dhcp_ind: DHCP indication parameter
7294 *
7295 * Return: CDF Status
7296 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307297static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307298 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7299{
Govind Singh67922e82016-04-01 16:48:57 +05307300 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307301 wmi_buf_t buf = NULL;
7302 uint8_t *buf_ptr;
7303 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7304 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7305
7306
7307 buf = wmi_buf_alloc(wmi_handle, len);
7308 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307309 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7310 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307311 }
7312
7313 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7314 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7315 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7316 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7317 WMITLV_GET_STRUCT_TLVLEN
7318 (wmi_peer_set_param_cmd_fixed_param));
7319
7320 /* fill in values */
7321 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7322 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7323 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307324 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307325 &ta_dhcp_ind->peer_macaddr,
7326 sizeof(ta_dhcp_ind->peer_macaddr));
7327
7328 status = wmi_unified_cmd_send(wmi_handle, buf,
7329 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307330 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307331 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307332 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307333 wmi_buf_free(buf);
7334 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307335
Govind Singh67922e82016-04-01 16:48:57 +05307336 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307337}
7338
7339/**
7340 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7341 * @wmi_handle: wmi handle
7342 * @pLinkSpeed: link speed info
7343 *
7344 * Return: CDF status
7345 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307346static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307347 wmi_mac_addr peer_macaddr)
7348{
7349 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7350 wmi_buf_t wmi_buf;
7351 uint32_t len;
7352 uint8_t *buf_ptr;
7353
7354 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7355 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7356 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307357 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7358 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307359 }
7360 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7361
7362 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7363 WMITLV_SET_HDR(&cmd->tlv_header,
7364 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7365 WMITLV_GET_STRUCT_TLVLEN
7366 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7367
7368 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307369 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307370 &peer_macaddr,
7371 sizeof(peer_macaddr));
7372
7373
7374 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7375 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307376 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307377 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307378 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307379 }
Govind Singhb53420c2016-03-09 14:32:57 +05307380 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307381}
7382
7383/**
7384 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7385 * @wmi_handle: wmi handler
7386 * @egap_params: pointer to egap_params
7387 *
7388 * Return: 0 for success, otherwise appropriate error code
7389 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307390static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307391 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7392{
7393 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7394 wmi_buf_t buf;
7395 int32_t err;
7396
7397 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7398 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307399 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7400 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307401 }
7402 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7403 WMITLV_SET_HDR(&cmd->tlv_header,
7404 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7405 WMITLV_GET_STRUCT_TLVLEN(
7406 wmi_ap_ps_egap_param_cmd_fixed_param));
7407
7408 cmd->enable = egap_params->enable;
7409 cmd->inactivity_time = egap_params->inactivity_time;
7410 cmd->wait_time = egap_params->wait_time;
7411 cmd->flags = egap_params->flags;
7412 err = wmi_unified_cmd_send(wmi_handle, buf,
7413 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7414 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307415 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307416 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307417 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307418 }
7419
Govind Singhb53420c2016-03-09 14:32:57 +05307420 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307421}
7422
7423/**
7424 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7425 * @wmi_handl: wmi handle
7426 * @cmd: Profiling command index
7427 * @value1: parameter1 value
7428 * @value2: parameter2 value
7429 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307430 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307431 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307432static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307433 uint32_t cmd, uint32_t value1, uint32_t value2)
7434{
7435 wmi_buf_t buf;
7436 int32_t len = 0;
7437 int ret;
7438 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7439 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7440 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7441 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7442
7443 switch (cmd) {
7444 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7445 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7446 buf = wmi_buf_alloc(wmi_handle, len);
7447 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307448 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307449 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307450 }
7451 prof_trig_cmd =
7452 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7453 wmi_buf_data(buf);
7454 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7455 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7456 WMITLV_GET_STRUCT_TLVLEN
7457 (wmi_wlan_profile_trigger_cmd_fixed_param));
7458 prof_trig_cmd->enable = value1;
7459 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7460 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7461 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307462 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307463 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307464 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307465 return ret;
7466 }
7467 break;
7468
7469 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7470 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7471 buf = wmi_buf_alloc(wmi_handle, len);
7472 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307473 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307474 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307475 }
7476 profile_getdata_cmd =
7477 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7478 wmi_buf_data(buf);
7479 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7480 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7481 WMITLV_GET_STRUCT_TLVLEN
7482 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7483 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7484 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7485 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307486 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307487 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307488 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307489 return ret;
7490 }
7491 break;
7492
7493 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7494 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7495 buf = wmi_buf_alloc(wmi_handle, len);
7496 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307497 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307498 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307499 }
7500 hist_intvl_cmd =
7501 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7502 wmi_buf_data(buf);
7503 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7504 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7505 WMITLV_GET_STRUCT_TLVLEN
7506 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7507 hist_intvl_cmd->profile_id = value1;
7508 hist_intvl_cmd->value = value2;
7509 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7510 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7511 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307512 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307513 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307514 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307515 return ret;
7516 }
7517 break;
7518
7519 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7520 len =
7521 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7522 buf = wmi_buf_alloc(wmi_handle, len);
7523 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307524 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307525 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307526 }
7527 profile_enable_cmd =
7528 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7529 wmi_buf_data(buf);
7530 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7531 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7532 WMITLV_GET_STRUCT_TLVLEN
7533 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7534 profile_enable_cmd->profile_id = value1;
7535 profile_enable_cmd->enable = value2;
7536 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7537 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7538 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307539 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307540 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307541 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307542 return ret;
7543 }
7544 break;
7545
7546 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307547 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307548 break;
7549 }
7550
7551 return 0;
7552}
7553
Govind Singh20c5dac2016-03-07 15:33:31 +05307554/**
7555 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7556 * @wmi_handle: wmi handle
7557 * @vdev_id: vdev id
7558 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307559 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307560 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307561static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307562{
7563 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7564 wmi_buf_t buf;
7565 int32_t len = sizeof(*cmd);
7566
Govind Singhb53420c2016-03-09 14:32:57 +05307567 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307568 buf = wmi_buf_alloc(wmi_handle, len);
7569 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307570 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307571 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307572 }
7573 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7574 wmi_buf_data(buf);
7575 WMITLV_SET_HDR(&cmd->tlv_header,
7576 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7577 WMITLV_GET_STRUCT_TLVLEN
7578 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7579 cmd->vdev_id = vdev_id;
7580 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7581 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7582 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307583 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307584 __func__);
7585 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307586 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307587 }
7588
7589 return 0;
7590}
7591
7592/**
7593 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7594 * @wmi_handle: wmi handle
7595 * @vdev_id: vdev id
7596 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307597 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307598 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307599static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307600 uint8_t vdev_id)
7601{
7602 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7603 wmi_buf_t buf;
7604 int32_t len = sizeof(*cmd);
7605
Govind Singhb53420c2016-03-09 14:32:57 +05307606 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307607 buf = wmi_buf_alloc(wmi_handle, len);
7608 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307609 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307610 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307611 }
7612 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7613 WMITLV_SET_HDR(&cmd->tlv_header,
7614 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7615 WMITLV_GET_STRUCT_TLVLEN
7616 (wmi_csa_offload_enable_cmd_fixed_param));
7617 cmd->vdev_id = vdev_id;
7618 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7619 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7620 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307621 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307622 __func__);
7623 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307624 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307625 }
7626
7627 return 0;
7628}
7629
7630/**
7631 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7632 * @wmi_handle: wmi handle
7633 * @startOemDataReq: start request params
7634 *
7635 * Return: CDF status
7636 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307637static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007638 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307639 uint8_t *data)
7640{
7641 wmi_buf_t buf;
7642 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307643 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307644
7645 buf = wmi_buf_alloc(wmi_handle,
7646 (data_len + WMI_TLV_HDR_SIZE));
7647 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307648 WMI_LOGE(FL("wmi_buf_alloc failed"));
7649 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307650 }
7651
7652 cmd = (uint8_t *) wmi_buf_data(buf);
7653
7654 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7655 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307656 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307657 data_len);
7658
Govind Singhb53420c2016-03-09 14:32:57 +05307659 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307660 data_len);
7661
7662 ret = wmi_unified_cmd_send(wmi_handle, buf,
7663 (data_len +
7664 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7665
Govind Singh67922e82016-04-01 16:48:57 +05307666 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307667 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307668 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307669 }
7670
Govind Singh67922e82016-04-01 16:48:57 +05307671 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307672}
7673
7674/**
7675 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7676 * @wmi_handle: wmi handle
7677 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7678 *
7679 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7680 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7681 * to firmware based on phyerr filtering
7682 * offload status.
7683 *
7684 * Return: 1 success, 0 failure
7685 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307686static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307687send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7688 bool dfs_phyerr_filter_offload)
7689{
7690 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7691 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7692 wmi_buf_t buf;
7693 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307694 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307695
7696
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007697 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307698 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307699 __func__);
7700 len = sizeof(*disable_phyerr_offload_cmd);
7701 buf = wmi_buf_alloc(wmi_handle, len);
7702 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307703 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307704 return 0;
7705 }
7706 disable_phyerr_offload_cmd =
7707 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7708 wmi_buf_data(buf);
7709
7710 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7711 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7712 WMITLV_GET_STRUCT_TLVLEN
7713 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7714
7715 /*
7716 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7717 * to the firmware to disable the phyerror
7718 * filtering offload.
7719 */
7720 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7721 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307722 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307723 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307724 __func__, ret);
7725 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307726 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307727 }
Govind Singhb53420c2016-03-09 14:32:57 +05307728 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307729 __func__);
7730 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307731 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307732 __func__);
7733
7734 len = sizeof(*enable_phyerr_offload_cmd);
7735 buf = wmi_buf_alloc(wmi_handle, len);
7736 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307737 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7738 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307739 }
7740
7741 enable_phyerr_offload_cmd =
7742 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7743 wmi_buf_data(buf);
7744
7745 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7746 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7747 WMITLV_GET_STRUCT_TLVLEN
7748 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7749
7750 /*
7751 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7752 * to the firmware to enable the phyerror
7753 * filtering offload.
7754 */
7755 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7756 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7757
Govind Singh67922e82016-04-01 16:48:57 +05307758 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307759 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307760 __func__, ret);
7761 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307762 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307763 }
Govind Singhb53420c2016-03-09 14:32:57 +05307764 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307765 __func__);
7766 }
7767
Govind Singhb53420c2016-03-09 14:32:57 +05307768 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307769}
7770
7771#if !defined(REMOVE_PKT_LOG)
7772/**
7773 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7774 * @wmi_handle: wmi handle
7775 * @pktlog_event: pktlog event
7776 * @cmd_id: pktlog cmd id
7777 *
7778 * Return: CDF status
7779 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307780static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307781 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307782 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307783{
7784 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7785 WMI_CMD_ID CMD_ID;
7786 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7787 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7788 int len = 0;
7789 wmi_buf_t buf;
7790
7791 PKTLOG_EVENT = pktlog_event;
7792 CMD_ID = cmd_id;
7793
7794 switch (CMD_ID) {
7795 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7796 len = sizeof(*cmd);
7797 buf = wmi_buf_alloc(wmi_handle, len);
7798 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307799 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7800 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307801 }
7802 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7803 wmi_buf_data(buf);
7804 WMITLV_SET_HDR(&cmd->tlv_header,
7805 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7806 WMITLV_GET_STRUCT_TLVLEN
7807 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7808 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307809 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7810 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007811 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307812 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7813 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307814 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307815 goto wmi_send_failed;
7816 }
7817 break;
7818 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7819 len = sizeof(*disable_cmd);
7820 buf = wmi_buf_alloc(wmi_handle, len);
7821 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307822 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7823 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307824 }
7825 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7826 wmi_buf_data(buf);
7827 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7828 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7829 WMITLV_GET_STRUCT_TLVLEN
7830 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007831 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307832 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7833 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307834 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307835 goto wmi_send_failed;
7836 }
7837 break;
7838 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307839 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307840 break;
7841 }
7842
Govind Singhb53420c2016-03-09 14:32:57 +05307843 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307844
7845wmi_send_failed:
7846 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307847 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307848}
7849#endif /* REMOVE_PKT_LOG */
7850
7851/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307852 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7853 * @wmi_handle: wmi handle
7854 * @ptrn_id: pattern id
7855 * @vdev_id: vdev id
7856 *
7857 * Return: CDF status
7858 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05307859static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
7860 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307861{
7862 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7863 wmi_buf_t buf;
7864 int32_t len;
7865 int ret;
7866
7867 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7868
7869
7870 buf = wmi_buf_alloc(wmi_handle, len);
7871 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307872 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7873 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307874 }
7875
7876 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7877
7878 WMITLV_SET_HDR(&cmd->tlv_header,
7879 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7880 WMITLV_GET_STRUCT_TLVLEN(
7881 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7882 cmd->vdev_id = vdev_id;
7883 cmd->pattern_id = ptrn_id;
7884 cmd->pattern_type = WOW_BITMAP_PATTERN;
7885
Govind Singhb53420c2016-03-09 14:32:57 +05307886 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307887 cmd->pattern_id, vdev_id);
7888
7889 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7890 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7891 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307892 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307893 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307894 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307895 }
7896
Govind Singhb53420c2016-03-09 14:32:57 +05307897 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307898}
7899
7900/**
7901 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
7902 * @wmi_handle: wmi handle
7903 *
7904 * Sends host wakeup indication to FW. On receiving this indication,
7905 * FW will come out of WOW.
7906 *
7907 * Return: CDF status
7908 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307909static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307910{
7911 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
7912 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05307913 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307914 int32_t len;
7915 int ret;
7916
7917 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
7918
7919 buf = wmi_buf_alloc(wmi_handle, len);
7920 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307921 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7922 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307923 }
7924
7925 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
7926 wmi_buf_data(buf);
7927 WMITLV_SET_HDR(&cmd->tlv_header,
7928 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
7929 WMITLV_GET_STRUCT_TLVLEN
7930 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
7931
7932
7933 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7934 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
7935 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307936 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307937 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307938 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307939 }
7940
Govind Singhb53420c2016-03-09 14:32:57 +05307941 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307942}
7943
7944/**
7945 * send_del_ts_cmd_tlv() - send DELTS request to fw
7946 * @wmi_handle: wmi handle
7947 * @msg: delts params
7948 *
7949 * Return: CDF status
7950 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307951static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05307952 uint8_t ac)
7953{
7954 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
7955 wmi_buf_t buf;
7956 int32_t len = sizeof(*cmd);
7957
7958 buf = wmi_buf_alloc(wmi_handle, len);
7959 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307960 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7961 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307962 }
7963 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
7964 WMITLV_SET_HDR(&cmd->tlv_header,
7965 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
7966 WMITLV_GET_STRUCT_TLVLEN
7967 (wmi_vdev_wmm_delts_cmd_fixed_param));
7968 cmd->vdev_id = vdev_id;
7969 cmd->ac = ac;
7970
Govind Singhb53420c2016-03-09 14:32:57 +05307971 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307972 cmd->vdev_id, cmd->ac, __func__, __LINE__);
7973 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7974 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307975 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307976 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307977 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307978 }
7979
Govind Singhb53420c2016-03-09 14:32:57 +05307980 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307981}
7982
7983/**
7984 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
7985 * @wmi_handle: handle to wmi
7986 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
7987 *
Govind Singhb53420c2016-03-09 14:32:57 +05307988 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05307989 * ADD_TS requestes to firmware in loop for all the ACs with
7990 * active flow.
7991 *
7992 * Return: CDF status
7993 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307994static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307995 struct aggr_add_ts_param *aggr_qos_rsp_msg)
7996{
7997 int i = 0;
7998 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
7999 wmi_buf_t buf;
8000 int32_t len = sizeof(*cmd);
8001
8002 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8003 /* if flow in this AC is active */
8004 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8005 /*
8006 * as per implementation of wma_add_ts_req() we
8007 * are not waiting any response from firmware so
8008 * apart from sending ADDTS to firmware just send
8009 * success to upper layers
8010 */
Govind Singhb53420c2016-03-09 14:32:57 +05308011 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308012
8013 buf = wmi_buf_alloc(wmi_handle, len);
8014 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308015 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8016 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308017 }
8018 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8019 wmi_buf_data(buf);
8020 WMITLV_SET_HDR(&cmd->tlv_header,
8021 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8022 WMITLV_GET_STRUCT_TLVLEN
8023 (wmi_vdev_wmm_addts_cmd_fixed_param));
8024 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8025 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308026 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308027 traffic.userPrio);
8028 cmd->medium_time_us =
8029 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8030 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308031 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308032 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8033 cmd->medium_time_us, cmd->downgrade_type);
8034 if (wmi_unified_cmd_send
8035 (wmi_handle, buf, len,
8036 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308037 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308038 __func__);
8039 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308040 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308041 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308042 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308043 }
8044 }
8045 }
8046
Govind Singhb53420c2016-03-09 14:32:57 +05308047 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308048}
8049
8050/**
8051 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8052 * @wmi_handle: wmi handle
8053 * @msg: ADDTS params
8054 *
8055 * Return: CDF status
8056 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308057static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308058 struct add_ts_param *msg)
8059{
8060 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8061 wmi_buf_t buf;
8062 int32_t len = sizeof(*cmd);
8063
Govind Singhb53420c2016-03-09 14:32:57 +05308064 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308065
8066 buf = wmi_buf_alloc(wmi_handle, len);
8067 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308068 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8069 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308070 }
8071 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8072 WMITLV_SET_HDR(&cmd->tlv_header,
8073 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8074 WMITLV_GET_STRUCT_TLVLEN
8075 (wmi_vdev_wmm_addts_cmd_fixed_param));
8076 cmd->vdev_id = msg->sme_session_id;
8077 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8078 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8079 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308080 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308081 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8082 cmd->downgrade_type, __func__, __LINE__);
8083 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8084 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308085 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8086 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308087 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308088 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308089 }
8090
Govind Singhb53420c2016-03-09 14:32:57 +05308091 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308092}
8093
8094/**
8095 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8096 * @wmi_handle: wmi handle
8097 * @vdev_id: vdev id
8098 * @enable: Flag to enable/disable packet filter
8099 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308100 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308102static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308103 uint8_t vdev_id, bool enable)
8104{
8105 int32_t len;
8106 int ret = 0;
8107 wmi_buf_t buf;
8108 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8109
8110 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8111
8112 buf = wmi_buf_alloc(wmi_handle, len);
8113 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308114 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308115 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308116 }
8117
8118 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8119 WMITLV_SET_HDR(&cmd->tlv_header,
8120 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8121 WMITLV_GET_STRUCT_TLVLEN(
8122 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8123
8124 cmd->vdev_id = vdev_id;
8125 if (enable)
8126 cmd->enable = PACKET_FILTER_SET_ENABLE;
8127 else
8128 cmd->enable = PACKET_FILTER_SET_DISABLE;
8129
Govind Singhb53420c2016-03-09 14:32:57 +05308130 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308131 __func__, cmd->enable, vdev_id);
8132
8133 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8134 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308135 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308136 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308137 wmi_buf_free(buf);
8138 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308139
8140 return ret;
8141}
8142
8143/**
8144 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8145 * @wmi_handle: wmi handle
8146 * @vdev_id: vdev id
8147 * @rcv_filter_param: Packet filter parameters
8148 * @filter_id: Filter id
8149 * @enable: Flag to add/delete packet filter configuration
8150 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308151 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308152 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308153static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308154 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8155 uint8_t filter_id, bool enable)
8156{
8157 int len, i;
8158 int err = 0;
8159 wmi_buf_t buf;
8160 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8161
8162
8163 /* allocate the memory */
8164 len = sizeof(*cmd);
8165 buf = wmi_buf_alloc(wmi_handle, len);
8166 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308167 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308168 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308169 }
8170
8171 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8172 WMITLV_SET_HDR(&cmd->tlv_header,
8173 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8174 WMITLV_GET_STRUCT_TLVLEN
8175 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8176
8177 cmd->vdev_id = vdev_id;
8178 cmd->filter_id = filter_id;
8179 if (enable)
8180 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8181 else
8182 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8183
8184 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308185 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308186 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8187 rcv_filter_param->numFieldParams);
8188 cmd->filter_type = rcv_filter_param->filterType;
8189 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8190
8191 for (i = 0; i < cmd->num_params; i++) {
8192 cmd->paramsData[i].proto_type =
8193 rcv_filter_param->paramsData[i].protocolLayer;
8194 cmd->paramsData[i].cmp_type =
8195 rcv_filter_param->paramsData[i].cmpFlag;
8196 cmd->paramsData[i].data_length =
8197 rcv_filter_param->paramsData[i].dataLength;
8198 cmd->paramsData[i].data_offset =
8199 rcv_filter_param->paramsData[i].dataOffset;
8200 memcpy(&cmd->paramsData[i].compareData,
8201 rcv_filter_param->paramsData[i].compareData,
8202 sizeof(cmd->paramsData[i].compareData));
8203 memcpy(&cmd->paramsData[i].dataMask,
8204 rcv_filter_param->paramsData[i].dataMask,
8205 sizeof(cmd->paramsData[i].dataMask));
8206 }
8207 }
8208
Govind Singhb53420c2016-03-09 14:32:57 +05308209 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308210 cmd->filter_action, cmd->filter_id, cmd->num_params);
8211 /* send the command along with data */
8212 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8213 WMI_PACKET_FILTER_CONFIG_CMDID);
8214 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308215 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308216 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308217 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308218 }
8219
8220
8221 return 0;
8222}
8223
8224/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308225 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8226 * @wmi_handle: wmi handle
8227 * @pAddPeriodicTxPtrnParams: tx ptrn params
8228 *
8229 * Retrun: CDF status
8230 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308231static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308232 struct periodic_tx_pattern *
8233 pAddPeriodicTxPtrnParams,
8234 uint8_t vdev_id)
8235{
8236 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8237 wmi_buf_t wmi_buf;
8238 uint32_t len;
8239 uint8_t *buf_ptr;
8240 uint32_t ptrn_len, ptrn_len_aligned;
8241 int j;
8242
8243 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8244 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8245 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8246 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8247
8248 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8249 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308250 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8251 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308252 }
8253
8254 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8255
8256 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8257 WMITLV_SET_HDR(&cmd->tlv_header,
8258 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8259 WMITLV_GET_STRUCT_TLVLEN
8260 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8261
8262 /* Pass the pattern id to delete for the corresponding vdev id */
8263 cmd->vdev_id = vdev_id;
8264 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8265 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8266 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8267
8268 /* Pattern info */
8269 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8270 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8271 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308272 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308273 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308274 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308275
Govind Singhb53420c2016-03-09 14:32:57 +05308276 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308277 __func__, cmd->pattern_id, cmd->vdev_id);
8278
8279 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8280 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308281 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308282 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308283 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308284 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308285 }
Govind Singhb53420c2016-03-09 14:32:57 +05308286 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308287}
8288
8289/**
8290 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8291 * @wmi_handle: wmi handle
8292 * @vdev_id: vdev id
8293 * @pattern_id: pattern id
8294 *
8295 * Retrun: CDF status
8296 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308297static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308298 uint8_t vdev_id,
8299 uint8_t pattern_id)
8300{
8301 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8302 wmi_buf_t wmi_buf;
8303 uint32_t len =
8304 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8305
8306 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8307 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308308 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8309 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308310 }
8311
8312 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8313 wmi_buf_data(wmi_buf);
8314 WMITLV_SET_HDR(&cmd->tlv_header,
8315 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8316 WMITLV_GET_STRUCT_TLVLEN
8317 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8318
8319 /* Pass the pattern id to delete for the corresponding vdev id */
8320 cmd->vdev_id = vdev_id;
8321 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308322 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308323 __func__, cmd->pattern_id, cmd->vdev_id);
8324
8325 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8326 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308327 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308328 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308329 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308330 }
Govind Singhb53420c2016-03-09 14:32:57 +05308331 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308332}
8333
8334/**
8335 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8336 * @wmi_handle: wmi handle
8337 * @preq: stats ext params
8338 *
8339 * Return: CDF status
8340 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308341static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308342 struct stats_ext_params *preq)
8343{
Govind Singh67922e82016-04-01 16:48:57 +05308344 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308345 wmi_req_stats_ext_cmd_fixed_param *cmd;
8346 wmi_buf_t buf;
8347 uint16_t len;
8348 uint8_t *buf_ptr;
8349
8350 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8351
8352 buf = wmi_buf_alloc(wmi_handle, len);
8353 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308354 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308355 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308356 }
8357
8358 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8359 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8360
8361 WMITLV_SET_HDR(&cmd->tlv_header,
8362 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8363 WMITLV_GET_STRUCT_TLVLEN
8364 (wmi_req_stats_ext_cmd_fixed_param));
8365 cmd->vdev_id = preq->vdev_id;
8366 cmd->data_len = preq->request_data_len;
8367
Govind Singhb53420c2016-03-09 14:32:57 +05308368 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308369 __func__, preq->request_data_len, preq->vdev_id);
8370
8371 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8372 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8373
8374 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308375 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308376
8377 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8378 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308379 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308380 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308381 ret);
8382 wmi_buf_free(buf);
8383 }
8384
8385 return ret;
8386}
8387
8388/**
8389 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8390 * @wmi_handle: wmi handle
8391 * @params: ext wow params
8392 *
8393 * Return:0 for success or error code
8394 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308395static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308396 struct ext_wow_params *params)
8397{
8398 wmi_extwow_enable_cmd_fixed_param *cmd;
8399 wmi_buf_t buf;
8400 int32_t len;
8401 int ret;
8402
8403 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8404 buf = wmi_buf_alloc(wmi_handle, len);
8405 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308406 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8407 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308408 }
8409
8410 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8411
8412 WMITLV_SET_HDR(&cmd->tlv_header,
8413 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8414 WMITLV_GET_STRUCT_TLVLEN
8415 (wmi_extwow_enable_cmd_fixed_param));
8416
8417 cmd->vdev_id = params->vdev_id;
8418 cmd->type = params->type;
8419 cmd->wakeup_pin_num = params->wakeup_pin_num;
8420
Govind Singhb53420c2016-03-09 14:32:57 +05308421 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308422 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8423
8424 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8425 WMI_EXTWOW_ENABLE_CMDID);
8426 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308427 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308428 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308429 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308430 }
8431
Govind Singhb53420c2016-03-09 14:32:57 +05308432 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308433
8434}
8435
8436/**
8437 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8438 * @wmi_handle: wmi handle
8439 * @app_type1_params: app type1 params
8440 *
8441 * Return: CDF status
8442 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308443static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308444 struct app_type1_params *app_type1_params)
8445{
8446 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8447 wmi_buf_t buf;
8448 int32_t len;
8449 int ret;
8450
8451 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8452 buf = wmi_buf_alloc(wmi_handle, len);
8453 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308454 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8455 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308456 }
8457
8458 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8459 wmi_buf_data(buf);
8460
8461 WMITLV_SET_HDR(&cmd->tlv_header,
8462 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8463 WMITLV_GET_STRUCT_TLVLEN
8464 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8465
8466 cmd->vdev_id = app_type1_params->vdev_id;
8467 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8468 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308469 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308470 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308471 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308472 cmd->passwd_len = app_type1_params->pass_length;
8473
Govind Singhb53420c2016-03-09 14:32:57 +05308474 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308475 "identification_id %.8s id_length %u "
8476 "password %.16s pass_length %u",
8477 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8478 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8479
8480 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8481 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8482 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308483 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308484 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308485 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308486 }
8487
Govind Singhb53420c2016-03-09 14:32:57 +05308488 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308489}
8490
8491/**
8492 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8493 * @wmi_handle: wmi handle
8494 * @appType2Params: app type2 params
8495 *
8496 * Return: CDF status
8497 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308498static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308499 struct app_type2_params *appType2Params)
8500{
8501 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8502 wmi_buf_t buf;
8503 int32_t len;
8504 int ret;
8505
8506 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8507 buf = wmi_buf_alloc(wmi_handle, len);
8508 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308509 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8510 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308511 }
8512
8513 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8514 wmi_buf_data(buf);
8515
8516 WMITLV_SET_HDR(&cmd->tlv_header,
8517 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8518 WMITLV_GET_STRUCT_TLVLEN
8519 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8520
8521 cmd->vdev_id = appType2Params->vdev_id;
8522
Govind Singhb53420c2016-03-09 14:32:57 +05308523 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308524 cmd->rc4_key_len = appType2Params->rc4_key_len;
8525
8526 cmd->ip_id = appType2Params->ip_id;
8527 cmd->ip_device_ip = appType2Params->ip_device_ip;
8528 cmd->ip_server_ip = appType2Params->ip_server_ip;
8529
8530 cmd->tcp_src_port = appType2Params->tcp_src_port;
8531 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8532 cmd->tcp_seq = appType2Params->tcp_seq;
8533 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8534
8535 cmd->keepalive_init = appType2Params->keepalive_init;
8536 cmd->keepalive_min = appType2Params->keepalive_min;
8537 cmd->keepalive_max = appType2Params->keepalive_max;
8538 cmd->keepalive_inc = appType2Params->keepalive_inc;
8539
8540 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8541 &cmd->gateway_mac);
8542 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8543 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8544
Govind Singhb53420c2016-03-09 14:32:57 +05308545 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308546 "rc4_key %.16s rc4_key_len %u "
8547 "ip_id %x ip_device_ip %x ip_server_ip %x "
8548 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8549 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8550 "keepalive_max %u keepalive_inc %u "
8551 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8552 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8553 cmd->rc4_key, cmd->rc4_key_len,
8554 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8555 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8556 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8557 cmd->keepalive_max, cmd->keepalive_inc,
8558 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8559
8560 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8561 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8562 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308563 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308564 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308565 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308566 }
8567
Govind Singhb53420c2016-03-09 14:32:57 +05308568 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308569
8570}
8571
8572/**
8573 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8574 * @wmi_handle: wmi handle
8575 * @timer_val: auto shutdown timer value
8576 *
8577 * Return: CDF status
8578 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308579static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308580 uint32_t timer_val)
8581{
Govind Singh67922e82016-04-01 16:48:57 +05308582 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308583 wmi_buf_t buf = NULL;
8584 uint8_t *buf_ptr;
8585 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8586 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8587
Govind Singhb53420c2016-03-09 14:32:57 +05308588 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308589 __func__, timer_val);
8590
8591 buf = wmi_buf_alloc(wmi_handle, len);
8592 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308593 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8594 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308595 }
8596
8597 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8598 wmi_auto_sh_cmd =
8599 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8600 wmi_auto_sh_cmd->timer_value = timer_val;
8601
8602 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8603 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8604 WMITLV_GET_STRUCT_TLVLEN
8605 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8606
8607 status = wmi_unified_cmd_send(wmi_handle, buf,
8608 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308609 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308610 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308611 __func__, status);
8612 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308613 }
8614
Govind Singh67922e82016-04-01 16:48:57 +05308615 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308616}
8617
8618/**
8619 * send_nan_req_cmd_tlv() - to send nan request to target
8620 * @wmi_handle: wmi handle
8621 * @nan_req: request data which will be non-null
8622 *
8623 * Return: CDF status
8624 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308625static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308626 struct nan_req_params *nan_req)
8627{
Govind Singh67922e82016-04-01 16:48:57 +05308628 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308629 wmi_nan_cmd_param *cmd;
8630 wmi_buf_t buf;
8631 uint16_t len = sizeof(*cmd);
8632 uint16_t nan_data_len, nan_data_len_aligned;
8633 uint8_t *buf_ptr;
8634
8635 /*
8636 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8637 * +------------+----------+-----------------------+--------------+
8638 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8639 * +------------+----------+-----------------------+--------------+
8640 */
8641 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308642 WMI_LOGE("%s:nan req is not valid", __func__);
8643 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308644 }
8645 nan_data_len = nan_req->request_data_len;
8646 nan_data_len_aligned = roundup(nan_req->request_data_len,
8647 sizeof(uint32_t));
8648 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8649 buf = wmi_buf_alloc(wmi_handle, len);
8650 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308651 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8652 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308653 }
8654 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8655 cmd = (wmi_nan_cmd_param *) buf_ptr;
8656 WMITLV_SET_HDR(&cmd->tlv_header,
8657 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8658 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8659 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308660 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308661 __func__, nan_req->request_data_len);
8662 buf_ptr += sizeof(wmi_nan_cmd_param);
8663 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8664 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308665 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308666
8667 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8668 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308669 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308670 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308671 __func__, ret);
8672 wmi_buf_free(buf);
8673 }
8674
8675 return ret;
8676}
8677
8678/**
8679 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8680 * @wmi_handle: wmi handle
8681 * @pDhcpSrvOffloadInfo: DHCP server offload info
8682 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308683 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308684 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308685static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308686 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8687{
8688 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8689 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308690 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308691
8692 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8693 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308694 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308695 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308696 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308697 }
8698
8699 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308700 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308701
8702 WMITLV_SET_HDR(&cmd->tlv_header,
8703 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8704 WMITLV_GET_STRUCT_TLVLEN
8705 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8706 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8707 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8708 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8709 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8710 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308711 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 sizeof(*cmd),
8713 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308714 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308715 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308716 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308717 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308718 }
Govind Singhb53420c2016-03-09 14:32:57 +05308719 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308720 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308721
8722 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308723}
8724
8725/**
8726 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8727 * @wmi_handle: wmi handle
8728 * @flashing: flashing request
8729 *
8730 * Return: CDF status
8731 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308732static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308733 struct flashing_req_params *flashing)
8734{
8735 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308736 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308737 wmi_buf_t buf;
8738 uint8_t *buf_ptr;
8739 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8740
8741 buf = wmi_buf_alloc(wmi_handle, len);
8742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308743 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308744 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308745 }
8746 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8747 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8748 WMITLV_SET_HDR(&cmd->tlv_header,
8749 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8750 WMITLV_GET_STRUCT_TLVLEN
8751 (wmi_set_led_flashing_cmd_fixed_param));
8752 cmd->pattern_id = flashing->pattern_id;
8753 cmd->led_x0 = flashing->led_x0;
8754 cmd->led_x1 = flashing->led_x1;
8755
8756 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8757 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308758 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308759 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308760 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308761 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308762 }
Govind Singh67922e82016-04-01 16:48:57 +05308763
8764 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308765}
8766
8767/**
8768 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8769 * @wmi_handle: wmi handle
8770 * @ch_avoid_update_req: channel avoid update params
8771 *
8772 * Return: CDF status
8773 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308774static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308775{
Govind Singh67922e82016-04-01 16:48:57 +05308776 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308777 wmi_buf_t buf = NULL;
8778 uint8_t *buf_ptr;
8779 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8780 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8781
8782
8783 buf = wmi_buf_alloc(wmi_handle, len);
8784 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308785 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8786 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308787 }
8788
8789 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8790 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8791 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8792 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8793 WMITLV_GET_STRUCT_TLVLEN
8794 (wmi_chan_avoid_update_cmd_param));
8795
8796 status = wmi_unified_cmd_send(wmi_handle, buf,
8797 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308798 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308799 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308800 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8801 " returned Error %d", status);
8802 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308803 }
8804
Govind Singh67922e82016-04-01 16:48:57 +05308805 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308806}
8807
8808/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05308809 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
8810 * @wmi_handle: wmi handle
8811 * @param: pointer to pdev regdomain params
8812 *
8813 * Return: 0 for success or error code
8814 */
8815static QDF_STATUS
8816send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
8817 struct pdev_set_regdomain_params *param)
8818{
8819 wmi_buf_t buf;
8820 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8821 int32_t len = sizeof(*cmd);
8822
8823
8824 buf = wmi_buf_alloc(wmi_handle, len);
8825 if (!buf) {
8826 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8827 return QDF_STATUS_E_NOMEM;
8828 }
8829 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8830 WMITLV_SET_HDR(&cmd->tlv_header,
8831 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8832 WMITLV_GET_STRUCT_TLVLEN
8833 (wmi_pdev_set_regdomain_cmd_fixed_param));
8834
8835 cmd->reg_domain = param->currentRDinuse;
8836 cmd->reg_domain_2G = param->currentRD2G;
8837 cmd->reg_domain_5G = param->currentRD5G;
8838 cmd->conformance_test_limit_2G = param->ctl_2G;
8839 cmd->conformance_test_limit_5G = param->ctl_5G;
8840 cmd->dfs_domain = param->dfsDomain;
8841 cmd->pdev_id = param->pdev_id;
8842
8843 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8844 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
8845 WMI_LOGE("%s: Failed to send pdev set regdomain command",
8846 __func__);
8847 wmi_buf_free(buf);
8848 return QDF_STATUS_E_FAILURE;
8849 }
8850
8851 return QDF_STATUS_SUCCESS;
8852}
8853
8854/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308855 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
8856 * @wmi_handle: wmi handle
8857 * @reg_dmn: reg domain
8858 * @regdmn2G: 2G reg domain
8859 * @regdmn5G: 5G reg domain
8860 * @ctl2G: 2G test limit
8861 * @ctl5G: 5G test limit
8862 *
8863 * Return: none
8864 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308865static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308866 uint32_t reg_dmn, uint16_t regdmn2G,
8867 uint16_t regdmn5G, int8_t ctl2G,
8868 int8_t ctl5G)
8869{
8870 wmi_buf_t buf;
8871 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8872 int32_t len = sizeof(*cmd);
8873
8874
8875 buf = wmi_buf_alloc(wmi_handle, len);
8876 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308877 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8878 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308879 }
8880 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8881 WMITLV_SET_HDR(&cmd->tlv_header,
8882 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8883 WMITLV_GET_STRUCT_TLVLEN
8884 (wmi_pdev_set_regdomain_cmd_fixed_param));
8885 cmd->reg_domain = reg_dmn;
8886 cmd->reg_domain_2G = regdmn2G;
8887 cmd->reg_domain_5G = regdmn5G;
8888 cmd->conformance_test_limit_2G = ctl2G;
8889 cmd->conformance_test_limit_5G = ctl5G;
8890
8891 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8892 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308893 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308894 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308895 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308896 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308897 }
8898
Govind Singhb53420c2016-03-09 14:32:57 +05308899 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308900}
8901
8902
8903/**
8904 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
8905 * @wmi_handle: wmi handle
8906 * @chan_switch_params: Pointer to tdls channel switch parameter structure
8907 *
8908 * This function sets tdls off channel mode
8909 *
8910 * Return: 0 on success; Negative errno otherwise
8911 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308912static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308913 struct tdls_channel_switch_params *chan_switch_params)
8914{
8915 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
8916 wmi_buf_t wmi_buf;
8917 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
8918
8919 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8920 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308921 WMI_LOGE(FL("wmi_buf_alloc failed"));
8922 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308923 }
8924 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
8925 wmi_buf_data(wmi_buf);
8926 WMITLV_SET_HDR(&cmd->tlv_header,
8927 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
8928 WMITLV_GET_STRUCT_TLVLEN(
8929 wmi_tdls_set_offchan_mode_cmd_fixed_param));
8930
8931 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
8932 &cmd->peer_macaddr);
8933 cmd->vdev_id = chan_switch_params->vdev_id;
8934 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
8935 cmd->is_peer_responder = chan_switch_params->is_responder;
8936 cmd->offchan_num = chan_switch_params->tdls_off_ch;
8937 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
8938 cmd->offchan_oper_class = chan_switch_params->oper_class;
8939
Govind Singhb53420c2016-03-09 14:32:57 +05308940 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05308941 cmd->peer_macaddr.mac_addr31to0,
8942 cmd->peer_macaddr.mac_addr47to32);
8943
Govind Singhb53420c2016-03-09 14:32:57 +05308944 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05308945 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
8946 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
8947 ),
8948 cmd->vdev_id,
8949 cmd->offchan_mode,
8950 cmd->offchan_num,
8951 cmd->offchan_bw_bitmap,
8952 cmd->is_peer_responder,
8953 cmd->offchan_oper_class);
8954
8955 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8956 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308957 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05308958 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308959 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308960 }
8961
8962
Govind Singhb53420c2016-03-09 14:32:57 +05308963 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308964}
8965
8966/**
8967 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
8968 * @wmi_handle: wmi handle
8969 * @pwmaTdlsparams: TDLS params
8970 *
8971 * Return: 0 for sucess or error code
8972 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308973static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308974 void *tdls_param, uint8_t tdls_state)
8975{
8976 wmi_tdls_set_state_cmd_fixed_param *cmd;
8977 wmi_buf_t wmi_buf;
8978
8979 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
8980 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
8981
8982 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8983 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308984 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
8985 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308986 }
8987 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
8988 WMITLV_SET_HDR(&cmd->tlv_header,
8989 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
8990 WMITLV_GET_STRUCT_TLVLEN
8991 (wmi_tdls_set_state_cmd_fixed_param));
8992 cmd->vdev_id = wmi_tdls->vdev_id;
8993 cmd->state = tdls_state;
8994 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
8995 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
8996 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
8997 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
8998 cmd->rssi_delta = wmi_tdls->rssi_delta;
8999 cmd->tdls_options = wmi_tdls->tdls_options;
9000 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9001 cmd->tdls_peer_traffic_response_timeout_ms =
9002 wmi_tdls->peer_traffic_response_timeout;
9003 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9004 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9005 cmd->tdls_puapsd_rx_frame_threshold =
9006 wmi_tdls->puapsd_rx_frame_threshold;
9007 cmd->teardown_notification_ms =
9008 wmi_tdls->teardown_notification_ms;
9009 cmd->tdls_peer_kickout_threshold =
9010 wmi_tdls->tdls_peer_kickout_threshold;
9011
Govind Singhb53420c2016-03-09 14:32:57 +05309012 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309013 "notification_interval_ms: %d, "
9014 "tx_discovery_threshold: %d, "
9015 "tx_teardown_threshold: %d, "
9016 "rssi_teardown_threshold: %d, "
9017 "rssi_delta: %d, "
9018 "tdls_options: 0x%x, "
9019 "tdls_peer_traffic_ind_window: %d, "
9020 "tdls_peer_traffic_response_timeout: %d, "
9021 "tdls_puapsd_mask: 0x%x, "
9022 "tdls_puapsd_inactivity_time: %d, "
9023 "tdls_puapsd_rx_frame_threshold: %d, "
9024 "teardown_notification_ms: %d, "
9025 "tdls_peer_kickout_threshold: %d",
9026 __func__, tdls_state, cmd->state,
9027 cmd->notification_interval_ms,
9028 cmd->tx_discovery_threshold,
9029 cmd->tx_teardown_threshold,
9030 cmd->rssi_teardown_threshold,
9031 cmd->rssi_delta,
9032 cmd->tdls_options,
9033 cmd->tdls_peer_traffic_ind_window,
9034 cmd->tdls_peer_traffic_response_timeout_ms,
9035 cmd->tdls_puapsd_mask,
9036 cmd->tdls_puapsd_inactivity_time_ms,
9037 cmd->tdls_puapsd_rx_frame_threshold,
9038 cmd->teardown_notification_ms,
9039 cmd->tdls_peer_kickout_threshold);
9040
9041 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9042 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309043 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309044 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309045 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309046 }
Govind Singhb53420c2016-03-09 14:32:57 +05309047 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309048
Govind Singhb53420c2016-03-09 14:32:57 +05309049 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309050}
9051
9052/**
9053 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9054 * @wmi_handle: wmi handle
9055 * @peerStateParams: TDLS peer state params
9056 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309057 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309058 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309059static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309060 struct tdls_peer_state_params *peerStateParams,
9061 uint32_t *ch_mhz)
9062{
9063 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9064 wmi_tdls_peer_capabilities *peer_cap;
9065 wmi_channel *chan_info;
9066 wmi_buf_t wmi_buf;
9067 uint8_t *buf_ptr;
9068 uint32_t i;
9069 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9070 sizeof(wmi_tdls_peer_capabilities);
9071
9072
9073 len += WMI_TLV_HDR_SIZE +
9074 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9075
9076 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9077 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309078 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9079 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309080 }
9081
9082 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9083 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9084 WMITLV_SET_HDR(&cmd->tlv_header,
9085 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9086 WMITLV_GET_STRUCT_TLVLEN
9087 (wmi_tdls_peer_update_cmd_fixed_param));
9088
9089 cmd->vdev_id = peerStateParams->vdevId;
9090 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9091 &cmd->peer_macaddr);
9092
9093
9094 cmd->peer_state = peerStateParams->peerState;
9095
Govind Singhb53420c2016-03-09 14:32:57 +05309096 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309097 "peer_macaddr.mac_addr31to0: 0x%x, "
9098 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9099 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9100 cmd->peer_macaddr.mac_addr31to0,
9101 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9102
9103 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9104 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9105 WMITLV_SET_HDR(&peer_cap->tlv_header,
9106 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9107 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9108
9109 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9110 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9111 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9112 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9113 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9114 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9115 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9116 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9117
9118 /* Ack and More Data Ack are sent as 0, so no need to set
9119 * but fill SP
9120 */
9121 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9122 peerStateParams->peerCap.peerMaxSp);
9123
9124 peer_cap->buff_sta_support =
9125 peerStateParams->peerCap.peerBuffStaSupport;
9126 peer_cap->off_chan_support =
9127 peerStateParams->peerCap.peerOffChanSupport;
9128 peer_cap->peer_curr_operclass =
9129 peerStateParams->peerCap.peerCurrOperClass;
9130 /* self curr operclass is not being used and so pass op class for
9131 * preferred off chan in it.
9132 */
9133 peer_cap->self_curr_operclass =
9134 peerStateParams->peerCap.opClassForPrefOffChan;
9135 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9136 peer_cap->peer_operclass_len =
9137 peerStateParams->peerCap.peerOperClassLen;
9138
Govind Singhb53420c2016-03-09 14:32:57 +05309139 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309140 __func__, peer_cap->peer_operclass_len);
9141 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9142 peer_cap->peer_operclass[i] =
9143 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309144 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309145 __func__, i, peer_cap->peer_operclass[i]);
9146 }
9147
9148 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9149 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9150 peer_cap->pref_offchan_bw =
9151 peerStateParams->peerCap.prefOffChanBandwidth;
9152
Govind Singhb53420c2016-03-09 14:32:57 +05309153 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309154 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9155 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9156 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9157 " %d, pref_offchan_bw: %d",
9158 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9159 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9160 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9161 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9162 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9163
9164 /* next fill variable size array of peer chan info */
9165 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9166 WMITLV_SET_HDR(buf_ptr,
9167 WMITLV_TAG_ARRAY_STRUC,
9168 sizeof(wmi_channel) *
9169 peerStateParams->peerCap.peerChanLen);
9170 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9171
9172 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9173 WMITLV_SET_HDR(&chan_info->tlv_header,
9174 WMITLV_TAG_STRUC_wmi_channel,
9175 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9176 chan_info->mhz = ch_mhz[i];
9177 chan_info->band_center_freq1 = chan_info->mhz;
9178 chan_info->band_center_freq2 = 0;
9179
Govind Singhb53420c2016-03-09 14:32:57 +05309180 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309181
9182 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9183 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309184 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309185 peerStateParams->peerCap.peerChan[i].chanId,
9186 peerStateParams->peerCap.peerChan[i].dfsSet);
9187 }
9188
9189 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9190 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9191 else
9192 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9193
9194 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9195 peerStateParams->peerCap.
9196 peerChan[i].pwr);
9197
9198 WMI_SET_CHANNEL_REG_POWER(chan_info,
9199 peerStateParams->peerCap.peerChan[i].
9200 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309201 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309202 peerStateParams->peerCap.peerChan[i].pwr);
9203
9204 chan_info++;
9205 }
9206
9207 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9208 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309209 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309210 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309211 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309212 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309213 }
9214
9215
Govind Singhb53420c2016-03-09 14:32:57 +05309216 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309217}
9218
9219/*
9220 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9221 * firmware
9222 * @wmi_handle: Pointer to wmi handle
9223 * @mem_dump_req: Pointer for mem_dump_req
9224 *
9225 * This function sends memory dump request to firmware
9226 *
Govind Singhb53420c2016-03-09 14:32:57 +05309227 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309228 *
9229 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309230static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309231 struct fw_dump_req_param *mem_dump_req)
9232{
9233 wmi_get_fw_mem_dump_fixed_param *cmd;
9234 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309235 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309236 int32_t len;
9237 wmi_buf_t buf;
9238 u_int8_t *buf_ptr;
9239 int ret, loop;
9240
9241 /*
9242 * len = sizeof(fixed param) that includes tlv header +
9243 * tlv header for array of struc +
9244 * sizeof (each struct)
9245 */
9246 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9247 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9248 buf = wmi_buf_alloc(wmi_handle, len);
9249
9250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309251 WMI_LOGE(FL("Failed allocate wmi buffer"));
9252 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309253 }
9254
9255 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309256 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309257 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9258
9259 WMITLV_SET_HDR(&cmd->tlv_header,
9260 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9261 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9262
9263 cmd->request_id = mem_dump_req->request_id;
9264 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9265
9266 /* TLV indicating array of structures to follow */
9267 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9268 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9269 sizeof(wmi_fw_mem_dump) *
9270 cmd->num_fw_mem_dump_segs);
9271
9272 buf_ptr += WMI_TLV_HDR_SIZE;
9273 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9274
Govind Singhb53420c2016-03-09 14:32:57 +05309275 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309276 mem_dump_req->request_id, mem_dump_req->num_seg);
9277 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309278 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309279 ((uint8_t *)(mem_dump_req->segment) +
9280 loop * sizeof(*seg_req));
9281 WMITLV_SET_HDR(&dump_params->tlv_header,
9282 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9283 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9284 dump_params->seg_id = seg_req->seg_id;
9285 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9286 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9287 dump_params->seg_length = seg_req->seg_length;
9288 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9289 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309290 WMI_LOGI(FL("seg_number:%d"), loop);
9291 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309292 dump_params->seg_id, dump_params->seg_start_addr_lo,
9293 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309294 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309295 dump_params->seg_length, dump_params->dest_addr_lo,
9296 dump_params->dest_addr_hi);
9297 dump_params++;
9298 }
9299
9300 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9301 WMI_GET_FW_MEM_DUMP_CMDID);
9302 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309303 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309304 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309305 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309306 }
9307
Govind Singhb53420c2016-03-09 14:32:57 +05309308 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9309 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309310}
9311
9312/*
9313 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9314 * @wmi_handle: Pointer to WMi handle
9315 * @ie_data: Pointer for ie data
9316 *
9317 * This function sends IE information to firmware
9318 *
Govind Singhb53420c2016-03-09 14:32:57 +05309319 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309320 *
9321 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309322static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309323 struct vdev_ie_info_param *ie_info)
9324{
9325 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9326 wmi_buf_t buf;
9327 uint8_t *buf_ptr;
9328 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309329 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309330
9331
9332 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9333 /* Allocate memory for the WMI command */
9334 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9335
9336 buf = wmi_buf_alloc(wmi_handle, len);
9337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309338 WMI_LOGE(FL("wmi_buf_alloc failed"));
9339 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309340 }
9341
9342 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309343 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309344
9345 /* Populate the WMI command */
9346 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9347
9348 WMITLV_SET_HDR(&cmd->tlv_header,
9349 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9350 WMITLV_GET_STRUCT_TLVLEN(
9351 wmi_vdev_set_ie_cmd_fixed_param));
9352 cmd->vdev_id = ie_info->vdev_id;
9353 cmd->ie_id = ie_info->ie_id;
9354 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009355 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309356
Govind Singhb53420c2016-03-09 14:32:57 +05309357 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309358 ie_info->length, ie_info->vdev_id);
9359
9360 buf_ptr += sizeof(*cmd);
9361 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9362 buf_ptr += WMI_TLV_HDR_SIZE;
9363
Govind Singhb53420c2016-03-09 14:32:57 +05309364 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309365
9366 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9367 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309368 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309369 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309370 wmi_buf_free(buf);
9371 }
9372
9373 return ret;
9374}
9375
Sathish Kumar497bef42017-03-01 14:02:36 +05309376/**
9377 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9378 *
9379 * @param wmi_handle : handle to WMI.
9380 * @param param : pointer to antenna param
9381 *
9382 * This function sends smart antenna enable command to FW
9383 *
9384 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9385 */
9386static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9387 struct smart_ant_enable_params *param)
9388{
9389 /* Send WMI COMMAND to Enable */
9390 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9391 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9392 wmi_buf_t buf;
9393 uint8_t *buf_ptr;
9394 int len = 0;
9395 QDF_STATUS ret;
9396 int loop = 0;
9397
9398 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9399 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9400 buf = wmi_buf_alloc(wmi_handle, len);
9401
9402 if (!buf) {
9403 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9404 return QDF_STATUS_E_NOMEM;
9405 }
9406
9407 buf_ptr = wmi_buf_data(buf);
9408 qdf_mem_zero(buf_ptr, len);
9409 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9410
9411 WMITLV_SET_HDR(&cmd->tlv_header,
9412 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9413 WMITLV_GET_STRUCT_TLVLEN(
9414 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9415
9416 cmd->pdev_id = param->pdev_id;
9417 cmd->enable = param->enable;
9418 cmd->mode = param->mode;
9419 cmd->rx_antenna = param->rx_antenna;
9420 cmd->tx_default_antenna = param->rx_antenna;
9421
9422 /* TLV indicating array of structures to follow */
9423 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9424 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9425 WMI_HAL_MAX_SANTENNA *
9426 sizeof(wmi_pdev_smart_ant_gpio_handle));
9427
9428 buf_ptr += WMI_TLV_HDR_SIZE;
9429 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9430
9431 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9432 WMITLV_SET_HDR(&gpio_param->tlv_header,
9433 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9434 WMITLV_GET_STRUCT_TLVLEN(
9435 wmi_pdev_smart_ant_gpio_handle));
9436 if (param->mode == SMART_ANT_MODE_SERIAL) {
9437 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9438 gpio_param->gpio_pin = param->gpio_pin[loop];
9439 gpio_param->gpio_func = param->gpio_func[loop];
9440 } else {
9441 gpio_param->gpio_pin = 0;
9442 gpio_param->gpio_func = 0;
9443 }
9444 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9445 gpio_param->gpio_pin = param->gpio_pin[loop];
9446 gpio_param->gpio_func = param->gpio_func[loop];
9447 }
9448 /* Setting it to 0 for now */
9449 gpio_param->pdev_id = param->pdev_id;
9450 gpio_param++;
9451 }
9452
9453 ret = wmi_unified_cmd_send(wmi_handle,
9454 buf,
9455 len,
9456 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9457
9458 if (ret != 0) {
9459 WMI_LOGE(" %s :WMI Failed\n", __func__);
9460 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9461 cmd->enable,
9462 cmd->mode,
9463 cmd->rx_antenna,
9464 param->gpio_pin[0], param->gpio_pin[1],
9465 param->gpio_pin[2], param->gpio_pin[3],
9466 param->gpio_func[0], param->gpio_func[1],
9467 param->gpio_func[2], param->gpio_func[3],
9468 ret);
9469 wmi_buf_free(buf);
9470 }
9471
9472 return ret;
9473}
9474
9475/**
9476 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9477 *
9478 * @param wmi_handle : handle to WMI.
9479 * @param param : pointer to rx antenna param
9480 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9481 */
9482static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9483 struct smart_ant_rx_ant_params *param)
9484{
9485 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9486 wmi_buf_t buf;
9487 uint8_t *buf_ptr;
9488 uint32_t len;
9489 QDF_STATUS ret;
9490
9491 len = sizeof(*cmd);
9492 buf = wmi_buf_alloc(wmi_handle, len);
9493 WMI_LOGD("%s:\n", __func__);
9494 if (!buf) {
9495 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9496 return QDF_STATUS_E_NOMEM;
9497 }
9498
9499 buf_ptr = wmi_buf_data(buf);
9500 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9501 WMITLV_SET_HDR(&cmd->tlv_header,
9502 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9503 WMITLV_GET_STRUCT_TLVLEN(
9504 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9505 cmd->rx_antenna = param->antenna;
9506 cmd->pdev_id = param->pdev_id;
9507
9508 ret = wmi_unified_cmd_send(wmi_handle,
9509 buf,
9510 len,
9511 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9512
9513 if (ret != 0) {
9514 WMI_LOGE(" %s :WMI Failed\n", __func__);
9515 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9516 __func__,
9517 cmd->rx_antenna,
9518 ret);
9519 wmi_buf_free(buf);
9520 }
9521
9522 return ret;
9523}
9524
9525/**
9526 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9527 * @wmi_handle: wmi handle
9528 * @param: pointer to hold ctl table param
9529 *
9530 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9531 */
9532static QDF_STATUS
9533send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9534 struct ctl_table_params *param)
9535{
9536 uint16_t len, ctl_tlv_len;
9537 uint8_t *buf_ptr;
9538 wmi_buf_t buf;
9539 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9540 uint32_t *ctl_array;
9541
9542 if (!param->ctl_array)
9543 return QDF_STATUS_E_FAILURE;
9544
9545 if (param->ctl_cmd_len !=
9546 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9547 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9548 qdf_print("CTL array len not correct\n");
9549 return QDF_STATUS_E_FAILURE;
9550 }
9551
9552 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9553 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9554 len = sizeof(*cmd) + ctl_tlv_len;
9555
9556 buf = wmi_buf_alloc(wmi_handle, len);
9557 if (!buf) {
9558 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9559 return QDF_STATUS_E_FAILURE;
9560 }
9561
9562 buf_ptr = wmi_buf_data(buf);
9563 qdf_mem_zero(buf_ptr, len);
9564
9565 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9566
9567 WMITLV_SET_HDR(&cmd->tlv_header,
9568 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9569 WMITLV_GET_STRUCT_TLVLEN(
9570 wmi_pdev_set_ctl_table_cmd_fixed_param));
9571 cmd->ctl_len = param->ctl_cmd_len;
9572 cmd->pdev_id = param->pdev_id;
9573
9574 buf_ptr += sizeof(*cmd);
9575 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9576 (cmd->ctl_len));
9577 buf_ptr += WMI_TLV_HDR_SIZE;
9578 ctl_array = (uint32_t *)buf_ptr;
9579
9580 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9581 sizeof(param->ctl_band));
9582 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9583 param->ctl_cmd_len -
9584 sizeof(param->ctl_band));
9585
9586 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9587 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9588 WMI_LOGE("%s:Failed to send command\n", __func__);
9589 wmi_buf_free(buf);
9590 return QDF_STATUS_E_FAILURE;
9591 }
9592
9593 return QDF_STATUS_SUCCESS;
9594}
9595
9596/**
9597 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9598 * @wmi_handle: wmi handle
9599 * @param: pointer to hold mimogain table param
9600 *
9601 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9602 */
9603static QDF_STATUS
9604send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9605 struct mimogain_table_params *param)
9606{
9607 uint16_t len, table_tlv_len;
9608 wmi_buf_t buf;
9609 uint8_t *buf_ptr;
9610 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
9611 uint32_t *gain_table;
9612
9613 if (!param->array_gain)
9614 return QDF_STATUS_E_FAILURE;
9615
9616 /* len must be multiple of a single array gain table */
9617 if (param->tbl_len %
9618 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
9619 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
9620 WMI_LOGE("Array gain table len not correct\n");
9621 return QDF_STATUS_E_FAILURE;
9622 }
9623
9624 table_tlv_len = WMI_TLV_HDR_SIZE +
9625 roundup(param->tbl_len, sizeof(uint32_t));
9626 len = sizeof(*cmd) + table_tlv_len;
9627
9628 buf = wmi_buf_alloc(wmi_handle, len);
9629 if (!buf) {
9630 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9631 return QDF_STATUS_E_FAILURE;
9632 }
9633
9634 buf_ptr = wmi_buf_data(buf);
9635 qdf_mem_zero(buf_ptr, len);
9636
9637 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
9638
9639 WMITLV_SET_HDR(&cmd->tlv_header,
9640 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
9641 WMITLV_GET_STRUCT_TLVLEN(
9642 wmi_pdev_set_mimogain_table_cmd_fixed_param));
9643
9644 cmd->pdev_id = param->pdev_id;
9645 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
9646 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
9647 param->multichain_gain_bypass);
9648
9649 buf_ptr += sizeof(*cmd);
9650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9651 (param->tbl_len));
9652 buf_ptr += WMI_TLV_HDR_SIZE;
9653 gain_table = (uint32_t *)buf_ptr;
9654
9655 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
9656 param->array_gain,
9657 param->tbl_len);
9658
9659 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9660 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
9661 return QDF_STATUS_E_FAILURE;
9662 }
9663
9664 return QDF_STATUS_SUCCESS;
9665}
9666
9667/**
9668 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
9669 * info to fw
9670 * @wmi_handle: wmi handle
9671 * @param: pointer to hold packet power info param
9672 *
9673 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9674 */
9675static QDF_STATUS
9676send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
9677 struct packet_power_info_params *param)
9678{
9679 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
9680 wmi_buf_t wmibuf;
9681 uint8_t *buf_ptr;
9682 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
9683
9684 wmibuf = wmi_buf_alloc(wmi_handle, len);
9685 if (wmibuf == NULL)
9686 return QDF_STATUS_E_NOMEM;
9687
9688 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
9689
9690 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
9691 WMITLV_SET_HDR(&cmd->tlv_header,
9692 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
9693 WMITLV_GET_STRUCT_TLVLEN(
9694 wmi_pdev_get_tpc_cmd_fixed_param));
9695 cmd->pdev_id = param->pdev_id;
9696 cmd->rate_flags = param->rate_flags;
9697 cmd->nss = param->nss;
9698 cmd->preamble = param->preamble;
9699 cmd->hw_rate = param->hw_rate;
9700 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
9701 __func__,
9702 __LINE__,
9703 WMI_PDEV_GET_TPC_CMDID,
9704 *((u_int32_t *)cmd));
9705 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
9706 WMI_PDEV_GET_TPC_CMDID)) {
9707 WMI_LOGE(FL("Failed to get tpc command\n"));
9708 wmi_buf_free(wmibuf);
9709 return QDF_STATUS_E_FAILURE;
9710 }
9711
9712 return QDF_STATUS_SUCCESS;
9713}
9714
9715/**
9716 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
9717 * @wmi_handle: wmi handle
9718 * @param: pointer to hold config ratemask params
9719 *
9720 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9721 */
9722static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
9723 struct config_ratemask_params *param)
9724{
9725 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
9726 wmi_buf_t buf;
9727 int32_t len = sizeof(*cmd);
9728
9729 buf = wmi_buf_alloc(wmi_handle, len);
9730 if (!buf) {
9731 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9732 return QDF_STATUS_E_FAILURE;
9733 }
9734 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
9735 WMITLV_SET_HDR(&cmd->tlv_header,
9736 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
9737 WMITLV_GET_STRUCT_TLVLEN(
9738 wmi_vdev_config_ratemask_cmd_fixed_param));
9739 cmd->vdev_id = param->vdev_id;
9740 cmd->type = param->type;
9741 cmd->mask_lower32 = param->lower32;
9742 cmd->mask_higher32 = param->higher32;
9743 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
9744 param->vdev_id, param->type, param->lower32, param->higher32);
9745
9746 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9747 WMI_VDEV_RATEMASK_CMDID)) {
9748 WMI_LOGE("Seting vdev ratemask failed\n");
9749 wmi_buf_free(buf);
9750 return QDF_STATUS_E_FAILURE;
9751 }
9752
9753 return QDF_STATUS_SUCCESS;
9754}
9755
9756/**
9757 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
9758 * @wmi_handle: wmi handle
9759 * @param: pointer to hold vap dscp tid map param
9760 *
9761 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9762 */
9763static QDF_STATUS
9764send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
9765 struct vap_dscp_tid_map_params *param)
9766{
9767 wmi_buf_t buf;
9768 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
9769 int32_t len = sizeof(*cmd);
9770
9771 buf = wmi_buf_alloc(wmi_handle, len);
9772 if (!buf) {
9773 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9774 return QDF_STATUS_E_FAILURE;
9775 }
9776
9777 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
9778 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
9779 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
9780
9781 cmd->vdev_id = param->vdev_id;
9782 cmd->enable_override = 0;
9783
9784 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
9785 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9786 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
9787 WMI_LOGE("Failed to set dscp cmd\n");
9788 wmi_buf_free(buf);
9789 return QDF_STATUS_E_FAILURE;
9790 }
9791
9792 return QDF_STATUS_SUCCESS;
9793}
9794
9795/**
9796 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
9797 * @wmi_handle: wmi handle
9798 * @macaddr: vdev mac address
9799 * @param: pointer to hold neigbour rx param
9800 *
9801 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9802 */
9803static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
9804 uint8_t macaddr[IEEE80211_ADDR_LEN],
9805 struct set_neighbour_rx_params *param)
9806{
9807 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
9808 wmi_buf_t buf;
9809 int32_t len = sizeof(*cmd);
9810
9811 buf = wmi_buf_alloc(wmi_handle, len);
9812 if (!buf) {
9813 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9814 return QDF_STATUS_E_FAILURE;
9815 }
9816 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
9817 WMITLV_SET_HDR(&cmd->tlv_header,
9818 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
9819 WMITLV_GET_STRUCT_TLVLEN(
9820 wmi_vdev_filter_nrp_config_cmd_fixed_param));
9821 cmd->vdev_id = param->vdev_id;
9822 cmd->bssid_idx = param->idx;
9823 cmd->action = param->action;
9824 cmd->type = param->type;
9825 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
9826 cmd->flag = 0;
9827
9828 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9829 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
9830 WMI_LOGE("Failed to set neighbour rx param\n");
9831 wmi_buf_free(buf);
9832 return QDF_STATUS_E_FAILURE;
9833 }
9834
9835 return QDF_STATUS_SUCCESS;
9836}
9837
9838/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05309839 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +05309840 * @param wmi_handle : handle to WMI.
9841 * @param macaddr : vdev mac address
9842 * @param param : pointer to tx antenna param
9843 *
9844 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9845 */
9846static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9847 uint8_t macaddr[IEEE80211_ADDR_LEN],
9848 struct smart_ant_tx_ant_params *param)
9849{
9850 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
9851 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
9852 wmi_buf_t buf;
9853 int32_t len = 0;
9854 int i;
9855 uint8_t *buf_ptr;
9856 QDF_STATUS ret;
9857
9858 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9859 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
9860 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
9861 buf = wmi_buf_alloc(wmi_handle, len);
9862
9863 if (!buf) {
9864 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9865 return QDF_STATUS_E_NOMEM;
9866 }
9867
9868 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9869 qdf_mem_zero(buf_ptr, len);
9870 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
9871
9872 WMITLV_SET_HDR(&cmd->tlv_header,
9873 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
9874 WMITLV_GET_STRUCT_TLVLEN(
9875 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
9876
9877 cmd->vdev_id = param->vdev_id;
9878 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
9879
9880 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
9881 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9882 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
9883 buf_ptr += WMI_TLV_HDR_SIZE;
9884 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
9885
9886 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
9887 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
9888 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
9889 WMITLV_GET_STRUCT_TLVLEN(
9890 wmi_peer_smart_ant_set_tx_antenna_series));
9891 ant_tx_series->antenna_series = param->antenna_array[i];
9892 ant_tx_series++;
9893 }
9894
9895 ret = wmi_unified_cmd_send(wmi_handle,
9896 buf,
9897 len,
9898 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
9899
9900 if (ret != 0) {
9901 WMI_LOGE(" %s :WMI Failed\n", __func__);
9902 wmi_buf_free(buf);
9903 }
9904
9905 return ret;
9906}
9907
Sathish Kumar02c3b542017-02-22 17:24:45 +05309908/**
9909 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
9910 * @wmi_handle: wmi handle
9911 * @param: pointer to hold ant switch tbl param
9912 *
9913 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9914 */
9915static QDF_STATUS
9916send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
9917 struct ant_switch_tbl_params *param)
9918{
9919 uint8_t len;
9920 wmi_buf_t buf;
9921 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
9922 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
9923 uint8_t *buf_ptr;
9924
9925 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9926 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
9927 buf = wmi_buf_alloc(wmi_handle, len);
9928
9929 if (!buf) {
9930 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9931 return QDF_STATUS_E_NOMEM;
9932 }
9933
9934 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9935 qdf_mem_zero(buf_ptr, len);
9936 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
9937
9938 WMITLV_SET_HDR(&cmd->tlv_header,
9939 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
9940 WMITLV_GET_STRUCT_TLVLEN(
9941 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
9942
9943 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
9944 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
9945 cmd->mac_id = param->pdev_id; /* Setting it to 0 for now */
9946
9947 /* TLV indicating array of structures to follow */
9948 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
9949 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9950 sizeof(wmi_pdev_set_ant_ctrl_chain));
9951 buf_ptr += WMI_TLV_HDR_SIZE;
9952 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
9953
9954 ctrl_chain->pdev_id = param->pdev_id;
9955 ctrl_chain->antCtrlChain = param->antCtrlChain;
9956
9957 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9958 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
9959 wmi_buf_free(buf);
9960 return QDF_STATUS_E_FAILURE;
9961 }
9962
9963 return QDF_STATUS_SUCCESS;
9964}
9965
9966/**
9967 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
9968 * training information function
9969 * @param wmi_handle : handle to WMI.
9970 * @macaddr : vdev mac address
9971 * @param param : pointer to tx antenna param
9972 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9973 */
9974static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
9975 wmi_unified_t wmi_handle,
9976 uint8_t macaddr[IEEE80211_ADDR_LEN],
9977 struct smart_ant_training_info_params *param)
9978{
9979 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
9980 wmi_peer_smart_ant_set_train_antenna_param *train_param;
9981 wmi_buf_t buf;
9982 uint8_t *buf_ptr;
9983 int32_t len = 0;
9984 QDF_STATUS ret;
9985 int loop;
9986
9987 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9988 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
9989 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
9990 buf = wmi_buf_alloc(wmi_handle, len);
9991
9992 if (!buf) {
9993 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9994 return QDF_STATUS_E_NOMEM;
9995 }
9996
9997 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9998 qdf_mem_zero(buf_ptr, len);
9999 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10000
10001 WMITLV_SET_HDR(&cmd->tlv_header,
10002 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10003 WMITLV_GET_STRUCT_TLVLEN(
10004 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10005
10006 cmd->vdev_id = param->vdev_id;
10007 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10008 cmd->num_pkts = param->numpkts;
10009
10010 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10011 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10012 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10013 WMI_SMART_ANT_MAX_RATE_SERIES);
10014
10015 buf_ptr += WMI_TLV_HDR_SIZE;
10016 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10017
10018 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10019 WMITLV_SET_HDR(&train_param->tlv_header,
10020 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10021 WMITLV_GET_STRUCT_TLVLEN(
10022 wmi_peer_smart_ant_set_train_antenna_param));
10023 train_param->train_rate_series = param->rate_array[loop];
10024 train_param->train_antenna_series = param->antenna_array[loop];
10025 train_param->rc_flags = 0;
10026 WMI_LOGI(FL("Series number:%d\n"), loop);
10027 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10028 train_param->train_rate_series,
10029 train_param->train_antenna_series);
10030 train_param++;
10031 }
10032
10033 ret = wmi_unified_cmd_send(wmi_handle,
10034 buf,
10035 len,
10036 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10037
10038 if (ret != 0) {
10039 WMI_LOGE(" %s :WMI Failed\n", __func__);
10040 wmi_buf_free(buf);
10041 return QDF_STATUS_E_FAILURE;
10042 }
10043
10044 return ret;
10045}
10046
10047/**
10048 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10049 * configuration function
10050 * @param wmi_handle : handle to WMI.
10051 * @macaddr : vdev mad address
10052 * @param param : pointer to tx antenna param
10053 *
10054 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10055 */
10056static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10057 wmi_unified_t wmi_handle,
10058 uint8_t macaddr[IEEE80211_ADDR_LEN],
10059 struct smart_ant_node_config_params *param)
10060{
10061 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10062 wmi_buf_t buf;
10063 uint8_t *buf_ptr;
10064 int32_t len = 0, args_tlv_len;
10065 int ret;
10066 int i = 0;
10067 A_UINT32 *node_config_args;
10068
10069 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10070 len = sizeof(*cmd) + args_tlv_len;
10071
10072 if ((param->args_count == 0)) {
10073 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10074 __func__, param->args_count);
10075 return QDF_STATUS_E_FAILURE;
10076 }
10077
10078 buf = wmi_buf_alloc(wmi_handle, len);
10079 if (!buf) {
10080 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10081 return QDF_STATUS_E_NOMEM;
10082 }
10083
10084 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10085 wmi_buf_data(buf);
10086 buf_ptr = (uint8_t *)cmd;
10087 WMITLV_SET_HDR(&cmd->tlv_header,
10088 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10089 WMITLV_GET_STRUCT_TLVLEN(
10090 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10091 cmd->vdev_id = param->vdev_id;
10092 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10093 cmd->cmd_id = param->cmd_id;
10094 cmd->args_count = param->args_count;
10095 buf_ptr += sizeof(
10096 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10097 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10098 (cmd->args_count * sizeof(A_UINT32)));
10099 buf_ptr += WMI_TLV_HDR_SIZE;
10100 node_config_args = (A_UINT32 *)buf_ptr;
10101
10102 for (i = 0; i < param->args_count; i++) {
10103 node_config_args[i] = param->args_arr[i];
10104 WMI_LOGI("%d", param->args_arr[i]);
10105 }
10106
10107 ret = wmi_unified_cmd_send(wmi_handle,
10108 buf,
10109 len,
10110 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10111
10112 if (ret != 0) {
10113 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10114 __func__, param->cmd_id, macaddr[0],
10115 macaddr[1], macaddr[2], macaddr[3],
10116 macaddr[4], macaddr[5], ret);
10117 wmi_buf_free(buf);
10118 }
10119
10120 return ret;
10121}
10122
10123/**
10124 * send_set_atf_cmd_tlv() - send set atf command to fw
10125 * @wmi_handle: wmi handle
10126 * @param: pointer to set atf param
10127 *
10128 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10129 */
10130static QDF_STATUS
10131send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10132 struct set_atf_params *param)
10133{
10134 wmi_atf_peer_info *peer_info;
10135 wmi_peer_atf_request_fixed_param *cmd;
10136 wmi_buf_t buf;
10137 uint8_t *buf_ptr;
10138 int i;
10139 int32_t len = 0;
10140 QDF_STATUS retval;
10141
10142 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10143 len += param->num_peers * sizeof(wmi_atf_peer_info);
10144 buf = wmi_buf_alloc(wmi_handle, len);
10145 if (!buf) {
10146 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10147 return QDF_STATUS_E_FAILURE;
10148 }
10149 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10150 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10151 WMITLV_SET_HDR(&cmd->tlv_header,
10152 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10153 WMITLV_GET_STRUCT_TLVLEN(
10154 wmi_peer_atf_request_fixed_param));
10155 cmd->num_peers = param->num_peers;
10156
10157 buf_ptr += sizeof(*cmd);
10158 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10159 sizeof(wmi_atf_peer_info) *
10160 cmd->num_peers);
10161 buf_ptr += WMI_TLV_HDR_SIZE;
10162 peer_info = (wmi_atf_peer_info *)buf_ptr;
10163
10164 for (i = 0; i < cmd->num_peers; i++) {
10165 WMITLV_SET_HDR(&peer_info->tlv_header,
10166 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10167 WMITLV_GET_STRUCT_TLVLEN(
10168 wmi_atf_peer_info));
10169 peer_info->atf_units = param->peer_info[i].percentage_peer;
10170 /*
10171 * TLV definition for peer atf request fixed param combines
10172 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10173 * stats and atf extension stats as two different
10174 * implementations.
10175 * Need to discuss with FW on this.
10176 *
10177 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10178 * peer_info->atf_units_reserved =
10179 * param->peer_ext_info[i].atf_index_reserved;
10180 */
10181 peer_info++;
10182 }
10183
10184 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10185 WMI_PEER_ATF_REQUEST_CMDID);
10186
10187 if (retval != QDF_STATUS_SUCCESS) {
10188 WMI_LOGE("%s : WMI Failed\n", __func__);
10189 wmi_buf_free(buf);
10190 }
10191
10192 return retval;
10193}
10194
10195/**
10196 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10197 * @wmi_handle: wmi handle
10198 * @param: pointer to hold fwtest param
10199 *
10200 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10201 */
10202static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10203 struct set_fwtest_params *param)
10204{
10205 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10206 wmi_buf_t buf;
10207 int32_t len = sizeof(*cmd);
10208
10209 buf = wmi_buf_alloc(wmi_handle, len);
10210
10211 if (!buf) {
10212 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10213 return QDF_STATUS_E_FAILURE;
10214 }
10215
10216 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10217 WMITLV_SET_HDR(&cmd->tlv_header,
10218 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10219 WMITLV_GET_STRUCT_TLVLEN(
10220 wmi_fwtest_set_param_cmd_fixed_param));
10221 cmd->param_id = param->arg;
10222 cmd->param_value = param->value;
10223
10224 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10225 WMI_LOGE("Setting FW test param failed\n");
10226 wmi_buf_free(buf);
10227 return QDF_STATUS_E_FAILURE;
10228 }
10229
10230 return QDF_STATUS_SUCCESS;
10231}
10232
10233/**
10234 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10235 * @wmi_handle: wmi handle
10236 * @param: pointer to qboost params
10237 * @macaddr: vdev mac address
10238 *
10239 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10240 */
10241static QDF_STATUS
10242send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10243 uint8_t macaddr[IEEE80211_ADDR_LEN],
10244 struct set_qboost_params *param)
10245{
10246 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10247 wmi_buf_t buf;
10248 int32_t len;
10249 QDF_STATUS ret;
10250
10251 len = sizeof(*cmd);
10252
10253 buf = wmi_buf_alloc(wmi_handle, len);
10254 if (!buf) {
10255 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10256 return QDF_STATUS_E_FAILURE;
10257 }
10258
10259 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10260 WMITLV_SET_HDR(&cmd->tlv_header,
10261 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10262 WMITLV_GET_STRUCT_TLVLEN(
10263 WMI_QBOOST_CFG_CMD_fixed_param));
10264 cmd->vdev_id = param->vdev_id;
10265 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10266 cmd->qb_enable = param->value;
10267
10268 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10269 WMI_QBOOST_CFG_CMDID);
10270
10271 if (ret != 0) {
10272 WMI_LOGE("Setting qboost cmd failed\n");
10273 wmi_buf_free(buf);
10274 }
10275
10276 return ret;
10277}
10278
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010279/**
10280 * send_gpio_config_cmd_tlv() - send gpio config to fw
10281 * @wmi_handle: wmi handle
10282 * @param: pointer to hold gpio config param
10283 *
10284 * Return: 0 for success or error code
10285 */
10286static QDF_STATUS
10287send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10288 struct gpio_config_params *param)
10289{
10290 wmi_gpio_config_cmd_fixed_param *cmd;
10291 wmi_buf_t buf;
10292 int32_t len;
10293 QDF_STATUS ret;
10294
10295 len = sizeof(*cmd);
10296
10297 /* Sanity Checks */
10298 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10299 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10300 return QDF_STATUS_E_FAILURE;
10301 }
10302
10303 buf = wmi_buf_alloc(wmi_handle, len);
10304 if (!buf) {
10305 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10306 return QDF_STATUS_E_FAILURE;
10307 }
10308
10309 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10310 WMITLV_SET_HDR(&cmd->tlv_header,
10311 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10312 WMITLV_GET_STRUCT_TLVLEN(
10313 wmi_gpio_config_cmd_fixed_param));
10314 cmd->gpio_num = param->gpio_num;
10315 cmd->input = param->input;
10316 cmd->pull_type = param->pull_type;
10317 cmd->intr_mode = param->intr_mode;
10318
10319 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10320 WMI_GPIO_CONFIG_CMDID);
10321
10322 if (ret != 0) {
10323 WMI_LOGE("Sending GPIO config cmd failed\n");
10324 wmi_buf_free(buf);
10325 }
10326
10327 return ret;
10328}
10329
10330/**
10331 * send_gpio_output_cmd_tlv() - send gpio output to fw
10332 * @wmi_handle: wmi handle
10333 * @param: pointer to hold gpio output param
10334 *
10335 * Return: 0 for success or error code
10336 */
10337static QDF_STATUS
10338send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10339 struct gpio_output_params *param)
10340{
10341 wmi_gpio_output_cmd_fixed_param *cmd;
10342 wmi_buf_t buf;
10343 int32_t len;
10344 QDF_STATUS ret;
10345
10346 len = sizeof(*cmd);
10347
10348 buf = wmi_buf_alloc(wmi_handle, len);
10349 if (!buf) {
10350 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10351 return QDF_STATUS_E_FAILURE;
10352 }
10353
10354 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10355 WMITLV_SET_HDR(&cmd->tlv_header,
10356 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10357 WMITLV_GET_STRUCT_TLVLEN(
10358 wmi_gpio_output_cmd_fixed_param));
10359 cmd->gpio_num = param->gpio_num;
10360 cmd->set = param->set;
10361
10362 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10363 WMI_GPIO_OUTPUT_CMDID);
10364
10365 if (ret != 0) {
10366 WMI_LOGE("Sending GPIO output cmd failed\n");
10367 wmi_buf_free(buf);
10368 }
10369
10370 return ret;
10371
10372}
10373
10374/**
10375 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10376 *
10377 * @param wmi_handle : handle to WMI.
10378 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10379 */
10380static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10381{
10382 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10383 wmi_buf_t buf;
10384 QDF_STATUS ret;
10385 int32_t len;
10386
10387 len = sizeof(*cmd);
10388
10389 buf = wmi_buf_alloc(wmi_handle, len);
10390 if (!buf) {
10391 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10392 return QDF_STATUS_E_FAILURE;
10393 }
10394
10395 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10396 WMITLV_SET_HDR(&cmd->tlv_header,
10397 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10398 WMITLV_GET_STRUCT_TLVLEN(
10399 wmi_pdev_dfs_disable_cmd_fixed_param));
10400 /* Filling it with WMI_PDEV_ID_SOC for now */
10401 cmd->pdev_id = WMI_PDEV_ID_SOC;
10402
10403 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10404 WMI_PDEV_DFS_DISABLE_CMDID);
10405
10406 if (ret != 0) {
10407 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10408 wmi_buf_free(buf);
10409 }
10410
10411 return ret;
10412}
10413
10414/**
10415 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10416 *
10417 * @param wmi_handle : handle to WMI.
10418 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10419 */
10420static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10421{
10422 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10423 wmi_buf_t buf;
10424 QDF_STATUS ret;
10425 int32_t len;
10426
10427 len = sizeof(*cmd);
10428
10429 buf = wmi_buf_alloc(wmi_handle, len);
10430 if (!buf) {
10431 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10432 return QDF_STATUS_E_FAILURE;
10433 }
10434
10435 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10436 WMITLV_SET_HDR(&cmd->tlv_header,
10437 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10438 WMITLV_GET_STRUCT_TLVLEN(
10439 wmi_pdev_dfs_enable_cmd_fixed_param));
10440 /* Reserved for future use */
10441 cmd->reserved0 = 0;
10442
10443 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10444 WMI_PDEV_DFS_ENABLE_CMDID);
10445
10446 if (ret != 0) {
10447 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10448 wmi_buf_free(buf);
10449 }
10450
10451 return ret;
10452}
10453
10454/**
10455 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10456 * @wmi_handle: wmi handle
10457 *
10458 * Return: 0 for success or error code
10459 */
10460static QDF_STATUS
10461send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10462{
10463 wmi_buf_t buf;
10464 QDF_STATUS ret;
10465
10466 buf = wmi_buf_alloc(wmi_handle, 0);
10467 if (buf == NULL)
10468 return QDF_STATUS_E_NOMEM;
10469
10470 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10471 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10472 if (ret != 0) {
10473 WMI_LOGE("Sending get nfcal power cmd failed\n");
10474 wmi_buf_free(buf);
10475 }
10476
10477 return ret;
10478}
10479
10480/**
10481 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10482 * @wmi_handle: wmi handle
10483 * @param: pointer to ht ie param
10484 *
10485 * Return: 0 for success or error code
10486 */
10487static QDF_STATUS
10488send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10489 struct ht_ie_params *param)
10490{
10491 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10492 wmi_buf_t buf;
10493 QDF_STATUS ret;
10494 int32_t len;
10495 uint8_t *buf_ptr;
10496
10497 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10498 roundup(param->ie_len, sizeof(uint32_t));
10499
10500 buf = wmi_buf_alloc(wmi_handle, len);
10501 if (!buf) {
10502 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10503 return QDF_STATUS_E_FAILURE;
10504 }
10505
10506 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10507 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10508 WMITLV_SET_HDR(&cmd->tlv_header,
10509 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10510 WMITLV_GET_STRUCT_TLVLEN(
10511 wmi_pdev_set_ht_ie_cmd_fixed_param));
10512 cmd->reserved0 = 0;
10513 cmd->ie_len = param->ie_len;
10514 cmd->tx_streams = param->tx_streams;
10515 cmd->rx_streams = param->rx_streams;
10516
10517 buf_ptr += sizeof(*cmd);
10518 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10519 buf_ptr += WMI_TLV_HDR_SIZE;
10520 if (param->ie_len)
10521 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10522 cmd->ie_len);
10523
10524 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10525 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10526
10527 if (ret != 0) {
10528 WMI_LOGE("Sending set ht ie cmd failed\n");
10529 wmi_buf_free(buf);
10530 }
10531
10532 return ret;
10533}
10534
10535/**
10536 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10537 * @wmi_handle: wmi handle
10538 * @param: pointer to vht ie param
10539 *
10540 * Return: 0 for success or error code
10541 */
10542static QDF_STATUS
10543send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10544 struct vht_ie_params *param)
10545{
10546 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10547 wmi_buf_t buf;
10548 QDF_STATUS ret;
10549 int32_t len;
10550 uint8_t *buf_ptr;
10551
10552 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10553 roundup(param->ie_len, sizeof(uint32_t));
10554
10555 buf = wmi_buf_alloc(wmi_handle, len);
10556 if (!buf) {
10557 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10558 return QDF_STATUS_E_FAILURE;
10559 }
10560
10561 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10562 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10563 WMITLV_SET_HDR(&cmd->tlv_header,
10564 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10565 WMITLV_GET_STRUCT_TLVLEN(
10566 wmi_pdev_set_vht_ie_cmd_fixed_param));
10567 cmd->reserved0 = 0;
10568 cmd->ie_len = param->ie_len;
10569 cmd->tx_streams = param->tx_streams;
10570 cmd->rx_streams = param->rx_streams;
10571
10572 buf_ptr += sizeof(*cmd);
10573 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10574 buf_ptr += WMI_TLV_HDR_SIZE;
10575 if (param->ie_len)
10576 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10577 cmd->ie_len);
10578
10579 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10580 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
10581
10582 if (ret != 0) {
10583 WMI_LOGE("Sending set vht ie cmd failed\n");
10584 wmi_buf_free(buf);
10585 }
10586
10587 return ret;
10588}
10589
Jeff Johnson9366d7a2016-10-07 13:03:02 -070010590static
Govind Singh9ddd5162016-03-07 16:30:32 +053010591void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053010592 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053010593{
Govind Singhe7f2f342016-05-23 12:12:52 +053010594 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053010595 resource_cfg->num_peers = tgt_res_cfg->num_peers;
10596 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
10597 resource_cfg->num_offload_reorder_buffs =
10598 tgt_res_cfg->num_offload_reorder_buffs;
10599 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
10600 resource_cfg->num_tids = tgt_res_cfg->num_tids;
10601 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
10602 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
10603 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
10604 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
10605 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
10606 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
10607 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
10608 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
10609 resource_cfg->scan_max_pending_req =
10610 tgt_res_cfg->scan_max_pending_req;
10611 resource_cfg->bmiss_offload_max_vdev =
10612 tgt_res_cfg->bmiss_offload_max_vdev;
10613 resource_cfg->roam_offload_max_vdev =
10614 tgt_res_cfg->roam_offload_max_vdev;
10615 resource_cfg->roam_offload_max_ap_profiles =
10616 tgt_res_cfg->roam_offload_max_ap_profiles;
10617 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
10618 resource_cfg->num_mcast_table_elems =
10619 tgt_res_cfg->num_mcast_table_elems;
10620 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
10621 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
10622 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
10623 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
10624 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
10625 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
10626 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
10627 resource_cfg->vow_config = tgt_res_cfg->vow_config;
10628 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
10629 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
10630 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
10631 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
10632 resource_cfg->num_tdls_conn_table_entries =
10633 tgt_res_cfg->num_tdls_conn_table_entries;
10634 resource_cfg->beacon_tx_offload_max_vdev =
10635 tgt_res_cfg->beacon_tx_offload_max_vdev;
10636 resource_cfg->num_multicast_filter_entries =
10637 tgt_res_cfg->num_multicast_filter_entries;
10638 resource_cfg->num_wow_filters =
10639 tgt_res_cfg->num_wow_filters;
10640 resource_cfg->num_keep_alive_pattern =
10641 tgt_res_cfg->num_keep_alive_pattern;
10642 resource_cfg->keep_alive_pattern_size =
10643 tgt_res_cfg->keep_alive_pattern_size;
10644 resource_cfg->max_tdls_concurrent_sleep_sta =
10645 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
10646 resource_cfg->max_tdls_concurrent_buffer_sta =
10647 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
10648 resource_cfg->wmi_send_separate =
10649 tgt_res_cfg->wmi_send_separate;
10650 resource_cfg->num_ocb_vdevs =
10651 tgt_res_cfg->num_ocb_vdevs;
10652 resource_cfg->num_ocb_channels =
10653 tgt_res_cfg->num_ocb_channels;
10654 resource_cfg->num_ocb_schedules =
10655 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053010656 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
10657 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
10658 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Govind Singh9ddd5162016-03-07 16:30:32 +053010659}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053010660#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010661/**
10662 * send_init_cmd_tlv() - wmi init command
10663 * @wmi_handle: pointer to wmi handle
10664 * @res_cfg: resource config
10665 * @num_mem_chunks: no of mem chunck
10666 * @mem_chunk: pointer to mem chunck structure
10667 *
10668 * This function sends IE information to firmware
10669 *
Govind Singhb53420c2016-03-09 14:32:57 +053010670 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010671 *
10672 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010673static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010674 wmi_resource_config *tgt_res_cfg,
10675 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
10676 bool action)
10677{
10678 wmi_buf_t buf;
10679 wmi_init_cmd_fixed_param *cmd;
10680 wmi_abi_version my_vers;
10681 int num_whitelist;
10682 uint8_t *buf_ptr;
10683 wmi_resource_config *resource_cfg;
10684 wlan_host_memory_chunk *host_mem_chunks;
10685 uint32_t mem_chunk_len = 0;
10686 uint16_t idx;
10687 int len;
10688 int ret;
10689
10690 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
10691 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
10692 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
10693 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010694 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
10695 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010696 }
10697
10698 buf_ptr = (uint8_t *) wmi_buf_data(buf);
10699 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
10700 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
10701
10702 host_mem_chunks = (wlan_host_memory_chunk *)
10703 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
10704 + WMI_TLV_HDR_SIZE);
10705
10706 WMITLV_SET_HDR(&cmd->tlv_header,
10707 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
10708 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
10709
Govind Singhb53420c2016-03-09 14:32:57 +053010710 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053010711 WMITLV_SET_HDR(&resource_cfg->tlv_header,
10712 WMITLV_TAG_STRUC_wmi_resource_config,
10713 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
10714
10715 for (idx = 0; idx < num_mem_chunks; ++idx) {
10716 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
10717 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
10718 WMITLV_GET_STRUCT_TLVLEN
10719 (wlan_host_memory_chunk));
10720 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
10721 host_mem_chunks[idx].size = mem_chunks[idx].len;
10722 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053010723 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053010724 idx, host_mem_chunks[idx].size,
10725 host_mem_chunks[idx].ptr);
10726 }
10727 cmd->num_host_mem_chunks = num_mem_chunks;
10728 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
10729 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
10730 WMITLV_TAG_ARRAY_STRUC,
10731 (sizeof(wlan_host_memory_chunk) *
10732 num_mem_chunks));
10733
10734 num_whitelist = sizeof(version_whitelist) /
10735 sizeof(wmi_whitelist_version_info);
10736 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
10737 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
10738 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
10739 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
10740 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
10741 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053010742#ifdef CONFIG_MCL
10743 /* This needs to be enabled for WIN Lithium after removing dependency
10744 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053010745 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
10746 &my_vers,
10747 &wmi_handle->fw_abi_version,
10748 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053010749#endif
Govind Singhb53420c2016-03-09 14:32:57 +053010750 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053010751 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
10752 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
10753 cmd->host_abi_vers.abi_version_ns_0,
10754 cmd->host_abi_vers.abi_version_ns_1,
10755 cmd->host_abi_vers.abi_version_ns_2,
10756 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053010757#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010758 /* Save version sent from host -
10759 * Will be used to check ready event
10760 */
Govind Singhb53420c2016-03-09 14:32:57 +053010761 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010762 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010763#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010764 if (action) {
10765 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10766 WMI_INIT_CMDID);
10767 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053010768 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053010769 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010770 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010771 }
10772 } else {
10773 wmi_handle->saved_wmi_init_cmd.buf = buf;
10774 wmi_handle->saved_wmi_init_cmd.buf_len = len;
10775 }
10776
Govind Singhb53420c2016-03-09 14:32:57 +053010777 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010778
10779}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053010780#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010781/**
10782 * send_saved_init_cmd_tlv() - wmi init command
10783 * @wmi_handle: pointer to wmi handle
10784 *
10785 * This function sends IE information to firmware
10786 *
Govind Singhb53420c2016-03-09 14:32:57 +053010787 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010788 *
10789 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010790static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053010791{
10792 int status;
10793
10794 if (!wmi_handle->saved_wmi_init_cmd.buf ||
10795 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053010796 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
10797 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010798 }
10799 status = wmi_unified_cmd_send(wmi_handle,
10800 wmi_handle->saved_wmi_init_cmd.buf,
10801 wmi_handle->saved_wmi_init_cmd.buf_len,
10802 WMI_INIT_CMDID);
10803 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053010804 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053010805 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010806 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010807 }
10808 wmi_handle->saved_wmi_init_cmd.buf = NULL;
10809 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
10810
Govind Singhb53420c2016-03-09 14:32:57 +053010811 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010812}
10813
Sathish Kumarfd347372017-02-13 12:29:09 +053010814static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053010815{
10816 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
10817 wmi_service_ready_event_fixed_param *ev;
10818
10819
10820 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
10821
10822 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
10823 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053010824 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010825
Govind Singh87542482016-06-08 19:40:11 +053010826#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010827 /*Save fw version from service ready message */
10828 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053010829 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010830 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010831#endif
Govind Singhb53420c2016-03-09 14:32:57 +053010832 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010833}
10834
10835/**
10836 * wmi_unified_save_fw_version_cmd() - save fw version
10837 * @wmi_handle: pointer to wmi handle
10838 * @res_cfg: resource config
10839 * @num_mem_chunks: no of mem chunck
10840 * @mem_chunk: pointer to mem chunck structure
10841 *
10842 * This function sends IE information to firmware
10843 *
Govind Singhb53420c2016-03-09 14:32:57 +053010844 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053010845 *
10846 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010847static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053010848 void *evt_buf)
10849{
10850 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
10851 wmi_ready_event_fixed_param *ev = NULL;
10852
10853 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
10854 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053010855#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053010856 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
10857 &ev->fw_abi_vers)) {
10858 /*
10859 * Error: Our host version and the given firmware version
10860 * are incompatible.
10861 **/
Govind Singhb53420c2016-03-09 14:32:57 +053010862 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053010863 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
10864 __func__,
10865 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
10866 abi_version_0),
10867 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
10868 abi_version_0),
10869 wmi_handle->final_abi_vers.abi_version_ns_0,
10870 wmi_handle->final_abi_vers.abi_version_ns_1,
10871 wmi_handle->final_abi_vers.abi_version_ns_2,
10872 wmi_handle->final_abi_vers.abi_version_ns_3,
10873 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
10874 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
10875 ev->fw_abi_vers.abi_version_ns_0,
10876 ev->fw_abi_vers.abi_version_ns_1,
10877 ev->fw_abi_vers.abi_version_ns_2,
10878 ev->fw_abi_vers.abi_version_ns_3);
10879
Govind Singhb53420c2016-03-09 14:32:57 +053010880 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053010881 }
Govind Singhb53420c2016-03-09 14:32:57 +053010882 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010883 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053010884 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053010885 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053010886#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053010887
Govind Singhb53420c2016-03-09 14:32:57 +053010888 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053010889}
Govind Singha4836fd2016-03-07 16:45:38 +053010890
10891/**
10892 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
10893 * @wmi_handle: wmi handle
10894 * @custom_addr: base mac address
10895 *
Govind Singhe7f2f342016-05-23 12:12:52 +053010896 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053010897 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010898static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010899 uint8_t *custom_addr)
10900{
10901 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
10902 wmi_buf_t buf;
10903 int err;
10904
10905 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
10906 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010907 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053010908 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010909 }
10910
10911 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053010912 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053010913
10914 WMITLV_SET_HDR(&cmd->tlv_header,
10915 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
10916 WMITLV_GET_STRUCT_TLVLEN
10917 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
10918 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070010919 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053010920 err = wmi_unified_cmd_send(wmi_handle, buf,
10921 sizeof(*cmd),
10922 WMI_PDEV_SET_BASE_MACADDR_CMDID);
10923 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053010924 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053010925 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053010926 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053010927 }
10928
10929 return 0;
10930}
10931
10932/**
10933 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
10934 * @handle: wmi handle
10935 * @event: Event received from FW
10936 * @len: Length of the event
10937 *
10938 * Enables the low frequency events and disables the high frequency
10939 * events. Bit 17 indicates if the event if low/high frequency.
10940 * 1 - high frequency, 0 - low frequency
10941 *
10942 * Return: 0 on successfully enabling/disabling the events
10943 */
Sathish Kumarfd347372017-02-13 12:29:09 +053010944static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053010945 uint8_t *event,
10946 uint32_t len)
10947{
10948 uint32_t num_of_diag_events_logs;
10949 wmi_diag_event_log_config_fixed_param *cmd;
10950 wmi_buf_t buf;
10951 uint8_t *buf_ptr;
10952 uint32_t *cmd_args, *evt_args;
10953 uint32_t buf_len, i;
10954
10955 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
10956 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
10957
Govind Singhb53420c2016-03-09 14:32:57 +053010958 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053010959
10960 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
10961 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010962 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053010963 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010964 }
10965 wmi_event = param_buf->fixed_param;
10966 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
10967 evt_args = param_buf->diag_events_logs_list;
10968 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053010969 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010970 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053010971 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053010972 }
10973
Govind Singhb53420c2016-03-09 14:32:57 +053010974 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053010975 __func__, num_of_diag_events_logs);
10976
10977 /* Free any previous allocation */
10978 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053010979 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010980
10981 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053010982 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053010983 sizeof(uint32_t));
10984 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053010985 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053010986 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053010987 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053010988 }
10989 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
10990
10991 /* Prepare the send buffer */
10992 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10993 (num_of_diag_events_logs * sizeof(uint32_t));
10994
10995 buf = wmi_buf_alloc(wmi_handle, buf_len);
10996 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053010997 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
10998 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053010999 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011000 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011001 }
11002
11003 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11004 buf_ptr = (uint8_t *) cmd;
11005
11006 WMITLV_SET_HDR(&cmd->tlv_header,
11007 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11008 WMITLV_GET_STRUCT_TLVLEN(
11009 wmi_diag_event_log_config_fixed_param));
11010
11011 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
11012
11013 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11014
11015 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11016 (num_of_diag_events_logs * sizeof(uint32_t)));
11017
11018 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11019
11020 /* Populate the events */
11021 for (i = 0; i < num_of_diag_events_logs; i++) {
11022 /* Low freq (0) - Enable (1) the event
11023 * High freq (1) - Disable (0) the event
11024 */
11025 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
11026 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
11027 /* Set the event ID */
11028 WMI_DIAG_ID_SET(cmd_args[i],
11029 WMI_DIAG_ID_GET(evt_args[i]));
11030 /* Set the type */
11031 WMI_DIAG_TYPE_SET(cmd_args[i],
11032 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053011033 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053011034 wmi_handle->events_logs_list[i] = evt_args[i];
11035 }
11036
11037 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
11038 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011039 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011040 __func__);
11041 wmi_buf_free(buf);
11042 /* Not clearing events_logs_list, though wmi cmd failed.
11043 * Host can still have this list
11044 */
Govind Singh67922e82016-04-01 16:48:57 +053011045 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011046 }
11047
11048 return 0;
11049}
11050
11051/**
11052 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
11053 * @wmi_handle: wmi handle
11054 * @start_log: Start logging related parameters
11055 *
11056 * Send the command to the FW based on which specific logging of diag
11057 * event/log id can be started/stopped
11058 *
11059 * Return: None
11060 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011061static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011062 struct wmi_wifi_start_log *start_log)
11063{
11064 wmi_diag_event_log_config_fixed_param *cmd;
11065 wmi_buf_t buf;
11066 uint8_t *buf_ptr;
11067 uint32_t len, count, log_level, i;
11068 uint32_t *cmd_args;
11069 uint32_t total_len;
11070 count = 0;
11071
11072 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011073 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053011074 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011075 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011076 }
11077 /* total_len stores the number of events where BITS 17 and 18 are set.
11078 * i.e., events of high frequency (17) and for extended debugging (18)
11079 */
11080 total_len = 0;
11081 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11082 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
11083 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
11084 total_len++;
11085 }
11086
11087 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11088 (total_len * sizeof(uint32_t));
11089
11090 buf = wmi_buf_alloc(wmi_handle, len);
11091 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011092 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011093 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011094 }
11095 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11096 buf_ptr = (uint8_t *) cmd;
11097
11098 WMITLV_SET_HDR(&cmd->tlv_header,
11099 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11100 WMITLV_GET_STRUCT_TLVLEN(
11101 wmi_diag_event_log_config_fixed_param));
11102
11103 cmd->num_of_diag_events_logs = total_len;
11104
11105 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11106
11107 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11108 (total_len * sizeof(uint32_t)));
11109
11110 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11111
Govind Singh224a7312016-06-21 14:33:26 +053011112 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053011113 log_level = 1;
11114 else
11115 log_level = 0;
11116
Govind Singhb53420c2016-03-09 14:32:57 +053011117 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053011118 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11119 uint32_t val = wmi_handle->events_logs_list[i];
11120 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
11121 (WMI_DIAG_EXT_FEATURE_GET(val))) {
11122
11123 WMI_DIAG_ID_SET(cmd_args[count],
11124 WMI_DIAG_ID_GET(val));
11125 WMI_DIAG_TYPE_SET(cmd_args[count],
11126 WMI_DIAG_TYPE_GET(val));
11127 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
11128 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053011129 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053011130 count++;
11131 }
11132 }
11133
11134 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11135 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011136 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011137 __func__);
11138 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011139 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011140 }
11141
Govind Singhb53420c2016-03-09 14:32:57 +053011142 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011143}
11144
11145/**
11146 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
11147 * @wmi_handle: WMI handle
11148 *
11149 * This function is used to send the flush command to the FW,
11150 * that will flush the fw logs that are residue in the FW
11151 *
11152 * Return: None
11153 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011154static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053011155{
11156 wmi_debug_mesg_flush_fixed_param *cmd;
11157 wmi_buf_t buf;
11158 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053011159 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011160
11161 buf = wmi_buf_alloc(wmi_handle, len);
11162 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011163 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011164 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011165 }
11166
11167 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
11168 WMITLV_SET_HDR(&cmd->tlv_header,
11169 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
11170 WMITLV_GET_STRUCT_TLVLEN(
11171 wmi_debug_mesg_flush_fixed_param));
11172 cmd->reserved0 = 0;
11173
11174 ret = wmi_unified_cmd_send(wmi_handle,
11175 buf,
11176 len,
11177 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011178 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011179 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053011180 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011181 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011182 }
Govind Singhb53420c2016-03-09 14:32:57 +053011183 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053011184
Govind Singh67922e82016-04-01 16:48:57 +053011185 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011186}
11187
11188/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011189 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011190 * @wmi_handle: wmi handle
11191 * @msg: PCL structure containing the PCL and the number of channels
11192 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011193 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053011194 * firmware. The DBS Manager is the consumer of this information in the WLAN
11195 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
11196 * to migrate to a new channel without host driver involvement. An example of
11197 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
11198 * manage the channel selection without firmware involvement.
11199 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011200 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
11201 * channel list. The weights corresponds to the channels sent in
11202 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
11203 * weightage compared to the non PCL channels.
11204 *
Govind Singha4836fd2016-03-07 16:45:38 +053011205 * Return: Success if the cmd is sent successfully to the firmware
11206 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011207static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011208 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053011209{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011210 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011211 wmi_buf_t buf;
11212 uint8_t *buf_ptr;
11213 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011214 uint32_t chan_len;
11215
11216 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053011217
11218 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011219 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053011220
11221 buf = wmi_buf_alloc(wmi_handle, len);
11222 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011223 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11224 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011225 }
11226
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011227 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011228 buf_ptr = (uint8_t *) cmd;
11229 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011230 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
11231 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053011232
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011233 cmd->pdev_id = WMI_PDEV_ID_SOC;
11234 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053011235 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011236
11237 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053011238 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011239 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053011240 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011241 for (i = 0; i < chan_len ; i++) {
11242 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053011243 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011244 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011245 }
11246 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011247 WMI_PDEV_SET_PCL_CMDID)) {
11248 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011249 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011250 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011251 }
Govind Singhb53420c2016-03-09 14:32:57 +053011252 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011253}
11254
11255/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011256 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011257 * @wmi_handle: wmi handle
11258 * @msg: Structure containing the following parameters
11259 *
11260 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
11261 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
11262 *
11263 * Provides notification to the WLAN firmware that host driver is requesting a
11264 * HardWare (HW) Mode change. This command is needed to support iHelium in the
11265 * configurations that include the Dual Band Simultaneous (DBS) feature.
11266 *
11267 * Return: Success if the cmd is sent successfully to the firmware
11268 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011269static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011270 uint32_t hw_mode_index)
11271{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011272 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011273 wmi_buf_t buf;
11274 uint32_t len;
11275
11276 len = sizeof(*cmd);
11277
11278 buf = wmi_buf_alloc(wmi_handle, len);
11279 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011280 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11281 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011282 }
11283
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011284 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011285 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011286 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
11287 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
11288
11289 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011290 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053011291 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053011292
11293 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011294 WMI_PDEV_SET_HW_MODE_CMDID)) {
11295 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011296 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011297 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011298 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011299 }
11300
Govind Singhb53420c2016-03-09 14:32:57 +053011301 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011302}
11303
11304/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011305 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011306 * @wmi_handle: wmi handle
11307 * @msg: Dual MAC config parameters
11308 *
11309 * Configures WLAN firmware with the dual MAC features
11310 *
Govind Singhb53420c2016-03-09 14:32:57 +053011311 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053011312 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011313static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011314QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011315 struct wmi_dual_mac_config *msg)
11316{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011317 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011318 wmi_buf_t buf;
11319 uint32_t len;
11320
11321 len = sizeof(*cmd);
11322
11323 buf = wmi_buf_alloc(wmi_handle, len);
11324 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011325 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11326 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011327 }
11328
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011329 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011330 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011331 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053011332 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011333 wmi_pdev_set_mac_config_cmd_fixed_param));
11334
11335 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011336 cmd->concurrent_scan_config_bits = msg->scan_config;
11337 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053011338 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053011339 __func__, msg->scan_config, msg->fw_mode_config);
11340
11341 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011342 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
11343 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011344 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011345 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011346 }
Govind Singhb53420c2016-03-09 14:32:57 +053011347 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011348}
11349
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011350#ifdef BIG_ENDIAN_HOST
11351/**
11352* fips_conv_data_be() - LE to BE conversion of FIPS ev data
11353* @param data_len - data length
11354* @param data - pointer to data
11355*
11356* Return: QDF_STATUS - success or error status
11357*/
11358static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
11359 struct fips_params *param)
11360{
11361 unsigned char *key_unaligned, *data_unaligned;
11362 int c;
11363 u_int8_t *key_aligned = NULL;
11364 u_int8_t *data_aligned = NULL;
11365
11366 /* Assigning unaligned space to copy the key */
11367 key_unaligned = qdf_mem_malloc(
11368 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
11369 data_unaligned = qdf_mem_malloc(
11370 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
11371
11372 /* Checking if kmalloc is succesful to allocate space */
11373 if (key_unaligned == NULL)
11374 return QDF_STATUS_SUCCESS;
11375 /* Checking if space is aligned */
11376 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
11377 /* align to 4 */
11378 key_aligned =
11379 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
11380 FIPS_ALIGN);
11381 } else {
11382 key_aligned = (u_int8_t *)key_unaligned;
11383 }
11384
11385 /* memset and copy content from key to key aligned */
11386 OS_MEMSET(key_aligned, 0, param->key_len);
11387 OS_MEMCPY(key_aligned, param->key, param->key_len);
11388
11389 /* print a hexdump for host debug */
11390 print_hex_dump(KERN_DEBUG,
11391 "\t Aligned and Copied Key:@@@@ ",
11392 DUMP_PREFIX_NONE,
11393 16, 1, key_aligned, param->key_len, true);
11394
11395 /* Checking if kmalloc is succesful to allocate space */
11396 if (data_unaligned == NULL)
11397 return QDF_STATUS_SUCCESS;
11398 /* Checking of space is aligned */
11399 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
11400 /* align to 4 */
11401 data_aligned =
11402 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
11403 FIPS_ALIGN);
11404 } else {
11405 data_aligned = (u_int8_t *)data_unaligned;
11406 }
11407
11408 /* memset and copy content from data to data aligned */
11409 OS_MEMSET(data_aligned, 0, param->data_len);
11410 OS_MEMCPY(data_aligned, param->data, param->data_len);
11411
11412 /* print a hexdump for host debug */
11413 print_hex_dump(KERN_DEBUG,
11414 "\t Properly Aligned and Copied Data:@@@@ ",
11415 DUMP_PREFIX_NONE,
11416 16, 1, data_aligned, param->data_len, true);
11417
11418 /* converting to little Endian both key_aligned and
11419 * data_aligned*/
11420 for (c = 0; c < param->key_len/4; c++) {
11421 *((u_int32_t *)key_aligned+c) =
11422 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
11423 }
11424 for (c = 0; c < param->data_len/4; c++) {
11425 *((u_int32_t *)data_aligned+c) =
11426 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
11427 }
11428
11429 /* update endian data to key and data vectors */
11430 OS_MEMCPY(param->key, key_aligned, param->key_len);
11431 OS_MEMCPY(param->data, data_aligned, param->data_len);
11432
11433 /* clean up allocated spaces */
11434 qdf_mem_free(key_unaligned);
11435 key_unaligned = NULL;
11436 key_aligned = NULL;
11437
11438 qdf_mem_free(data_unaligned);
11439 data_unaligned = NULL;
11440 data_aligned = NULL;
11441
11442 return QDF_STATUS_SUCCESS;
11443}
11444#else
11445/**
11446* fips_align_data_be() - DUMMY for LE platform
11447*
11448* Return: QDF_STATUS - success
11449*/
11450static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
11451 struct fips_params *param)
11452{
11453 return QDF_STATUS_SUCCESS;
11454}
11455#endif
11456
11457
11458/**
11459 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
11460 * @wmi_handle: wmi handle
11461 * @param: pointer to hold pdev fips param
11462 *
11463 * Return: 0 for success or error code
11464 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011465static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011466send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
11467 struct fips_params *param)
11468{
11469 wmi_pdev_fips_cmd_fixed_param *cmd;
11470 wmi_buf_t buf;
11471 uint8_t *buf_ptr;
11472 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
11473 QDF_STATUS retval = QDF_STATUS_SUCCESS;
11474
11475 /* Length TLV placeholder for array of bytes */
11476 len += WMI_TLV_HDR_SIZE;
11477 if (param->data_len)
11478 len += (param->data_len*sizeof(uint8_t));
11479
11480 /*
11481 * Data length must be multiples of 16 bytes - checked against 0xF -
11482 * and must be less than WMI_SVC_MSG_SIZE - static size of
11483 * wmi_pdev_fips_cmd structure
11484 */
11485
11486 /* do sanity on the input */
11487 if (!(((param->data_len & 0xF) == 0) &&
11488 ((param->data_len > 0) &&
11489 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
11490 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
11491 return QDF_STATUS_E_INVAL;
11492 }
11493
11494 buf = wmi_buf_alloc(wmi_handle, len);
11495 if (!buf) {
11496 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
11497 return QDF_STATUS_E_FAILURE;
11498 }
11499
11500 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11501 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
11502 WMITLV_SET_HDR(&cmd->tlv_header,
11503 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
11504 WMITLV_GET_STRUCT_TLVLEN
11505 (wmi_pdev_fips_cmd_fixed_param));
11506
11507 cmd->pdev_id = param->pdev_id;
11508 if (param->key != NULL && param->data != NULL) {
11509 cmd->key_len = param->key_len;
11510 cmd->data_len = param->data_len;
11511 cmd->fips_cmd = !!(param->op);
11512
11513 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
11514 return QDF_STATUS_E_FAILURE;
11515
11516 qdf_mem_copy(cmd->key, param->key, param->key_len);
11517
11518 if (param->mode == FIPS_ENGINE_AES_CTR ||
11519 param->mode == FIPS_ENGINE_AES_MIC) {
11520 cmd->mode = param->mode;
11521 } else {
11522 cmd->mode = FIPS_ENGINE_AES_CTR;
11523 }
11524 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
11525 cmd->key_len, cmd->data_len);
11526
11527 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
11528 cmd->key, cmd->key_len, true);
11529 buf_ptr += sizeof(*cmd);
11530
11531 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
11532
11533 buf_ptr += WMI_TLV_HDR_SIZE;
11534 if (param->data_len)
11535 qdf_mem_copy(buf_ptr,
11536 (uint8_t *) param->data, param->data_len);
11537
11538 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
11539 16, 1, buf_ptr, cmd->data_len, true);
11540
11541 buf_ptr += param->data_len;
11542
11543 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
11544 WMI_PDEV_FIPS_CMDID);
11545 qdf_print("%s return value %d\n", __func__, retval);
11546 } else {
11547 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
11548 wmi_buf_free(buf);
11549 retval = -QDF_STATUS_E_BADMSG;
11550 }
11551
11552 return retval;
11553}
11554
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011555#ifdef WLAN_PMO_ENABLE
11556/**
11557 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
11558 * @wmi_handle: wmi handle
11559 * @vdev_id: vdev id
11560 * @bitmap: Event bitmap
11561 * @enable: enable/disable
11562 *
11563 * Return: CDF status
11564 */
11565static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
11566 uint32_t vdev_id,
11567 uint32_t bitmap,
11568 bool enable)
11569{
11570 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
11571 uint16_t len;
11572 wmi_buf_t buf;
11573 int ret;
11574
11575 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
11576 buf = wmi_buf_alloc(wmi_handle, len);
11577 if (!buf) {
11578 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11579 return QDF_STATUS_E_NOMEM;
11580 }
11581 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
11582 WMITLV_SET_HDR(&cmd->tlv_header,
11583 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
11584 WMITLV_GET_STRUCT_TLVLEN
11585 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
11586 cmd->vdev_id = vdev_id;
11587 cmd->is_add = enable;
11588 cmd->event_bitmap = bitmap;
11589
11590 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11591 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
11592 if (ret) {
11593 WMI_LOGE("Failed to config wow wakeup event");
11594 wmi_buf_free(buf);
11595 return QDF_STATUS_E_FAILURE;
11596 }
11597
11598 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
11599 enable ? "enabled" : "disabled");
11600
11601 return QDF_STATUS_SUCCESS;
11602}
11603
11604/**
11605 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
11606 * @wmi_handle: wmi handle
11607 * @vdev_id: vdev id
11608 * @ptrn_id: pattern id
11609 * @ptrn: pattern
11610 * @ptrn_len: pattern length
11611 * @ptrn_offset: pattern offset
11612 * @mask: mask
11613 * @mask_len: mask length
11614 * @user: true for user configured pattern and false for default pattern
11615 * @default_patterns: default patterns
11616 *
11617 * Return: CDF status
11618 */
11619static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
11620 uint8_t vdev_id, uint8_t ptrn_id,
11621 const uint8_t *ptrn, uint8_t ptrn_len,
11622 uint8_t ptrn_offset, const uint8_t *mask,
11623 uint8_t mask_len, bool user,
11624 uint8_t default_patterns)
11625{
11626 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
11627 WOW_BITMAP_PATTERN_T *bitmap_pattern;
11628 wmi_buf_t buf;
11629 uint8_t *buf_ptr;
11630 int32_t len;
11631 int ret;
11632
11633 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
11634 WMI_TLV_HDR_SIZE +
11635 1 * sizeof(WOW_BITMAP_PATTERN_T) +
11636 WMI_TLV_HDR_SIZE +
11637 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
11638 WMI_TLV_HDR_SIZE +
11639 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
11640 WMI_TLV_HDR_SIZE +
11641 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
11642 WMI_TLV_HDR_SIZE +
11643 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
11644
11645 buf = wmi_buf_alloc(wmi_handle, len);
11646 if (!buf) {
11647 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
11648 return QDF_STATUS_E_NOMEM;
11649 }
11650
11651 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
11652 buf_ptr = (uint8_t *) cmd;
11653
11654 WMITLV_SET_HDR(&cmd->tlv_header,
11655 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
11656 WMITLV_GET_STRUCT_TLVLEN
11657 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
11658 cmd->vdev_id = vdev_id;
11659 cmd->pattern_id = ptrn_id;
11660
11661 cmd->pattern_type = WOW_BITMAP_PATTERN;
11662 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
11663
11664 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11665 sizeof(WOW_BITMAP_PATTERN_T));
11666 buf_ptr += WMI_TLV_HDR_SIZE;
11667 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
11668
11669 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
11670 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
11671 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
11672
11673 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
11674 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
11675
11676 bitmap_pattern->pattern_offset = ptrn_offset;
11677 bitmap_pattern->pattern_len = ptrn_len;
11678
11679 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
11680 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
11681
11682 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
11683 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
11684
11685 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
11686 bitmap_pattern->pattern_id = ptrn_id;
11687
11688 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
11689 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
11690 bitmap_pattern->pattern_offset, user);
11691 WMI_LOGI("Pattern : ");
11692 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
11693 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
11694
11695 WMI_LOGI("Mask : ");
11696 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
11697 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
11698
11699 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
11700
11701 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
11702 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11703 buf_ptr += WMI_TLV_HDR_SIZE;
11704
11705 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
11706 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11707 buf_ptr += WMI_TLV_HDR_SIZE;
11708
11709 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
11710 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
11711 buf_ptr += WMI_TLV_HDR_SIZE;
11712
11713 /* Fill TLV for pattern_info_timeout but no data. */
11714 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
11715 buf_ptr += WMI_TLV_HDR_SIZE;
11716
11717 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
11718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
11719 buf_ptr += WMI_TLV_HDR_SIZE;
11720 *(A_UINT32 *) buf_ptr = 0;
11721
11722 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11723 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
11724 if (ret) {
11725 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
11726 wmi_buf_free(buf);
11727 return QDF_STATUS_E_FAILURE;
11728 }
11729
11730 return QDF_STATUS_SUCCESS;
11731}
11732
Govind Singha4836fd2016-03-07 16:45:38 +053011733/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011734 * fill_arp_offload_params_tlv() - Fill ARP offload data
11735 * @wmi_handle: wmi handle
11736 * @offload_req: offload request
11737 * @buf_ptr: buffer pointer
11738 *
11739 * To fill ARP offload data to firmware
11740 * when target goes to wow mode.
11741 *
11742 * Return: None
11743 */
11744static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011745 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011746{
11747
11748 int i;
11749 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011750 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011751
11752 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11753 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
11754 *buf_ptr += WMI_TLV_HDR_SIZE;
11755 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
11756 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
11757 WMITLV_SET_HDR(&arp_tuple->tlv_header,
11758 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
11759 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
11760
11761 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011762 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011763 /* Copy the target ip addr and flags */
11764 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
11765 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011766 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011767 WMI_IPV4_ADDR_LEN);
11768 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011769 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011770 }
11771 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
11772 }
11773}
11774
11775#ifdef WLAN_NS_OFFLOAD
11776/**
11777 * fill_ns_offload_params_tlv() - Fill NS offload data
11778 * @wmi|_handle: wmi handle
11779 * @offload_req: offload request
11780 * @buf_ptr: buffer pointer
11781 *
11782 * To fill NS offload data to firmware
11783 * when target goes to wow mode.
11784 *
11785 * Return: None
11786 */
11787static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011788 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011789{
11790
11791 int i;
11792 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011793
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011794 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11795 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11796 *buf_ptr += WMI_TLV_HDR_SIZE;
11797 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
11798 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11799 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11800 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11801 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
11802
11803 /*
11804 * Fill data only for NS offload in the first ARP tuple for LA
11805 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011806 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011807 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11808 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011809 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011810 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011811 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011812 sizeof(WMI_IPV6_ADDR));
11813 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011814 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011815 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011816 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011817 ns_tuple->flags |=
11818 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11819 }
11820 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011821 i, &ns_req->self_ipv6_addr[i],
11822 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011823
11824 /* target MAC is optional, check if it is valid,
11825 * if this is not valid, the target will use the known
11826 * local MAC address rather than the tuple
11827 */
11828 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011829 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011830 &ns_tuple->target_mac);
11831 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11832 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11833 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11834 }
11835 }
11836 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11837 }
11838}
11839
11840
11841/**
11842 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
11843 * @wmi: wmi handle
11844 * @offload_req: offload request
11845 * @buf_ptr: buffer pointer
11846 *
11847 * To fill extended NS offload extended data to firmware
11848 * when target goes to wow mode.
11849 *
11850 * Return: None
11851 */
11852static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011853 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011854{
11855 int i;
11856 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
11857 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011858
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011859 count = ns_req->num_ns_offload_count;
11860 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011861 WMI_MAX_NS_OFFLOADS;
11862
11863 /* Populate extended NS offload tuples */
11864 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11865 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
11866 *buf_ptr += WMI_TLV_HDR_SIZE;
11867 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
11868 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
11869 WMITLV_SET_HDR(&ns_tuple->tlv_header,
11870 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
11871 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
11872
11873 /*
11874 * Fill data only for NS offload in the first ARP tuple for LA
11875 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011876 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011877 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
11878 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011879 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011880 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011881 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011882 sizeof(WMI_IPV6_ADDR));
11883 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011884 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011885 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011886 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011887 ns_tuple->flags |=
11888 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
11889 }
11890 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011891 i, &ns_req->self_ipv6_addr[i],
11892 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011893
11894 /* target MAC is optional, check if it is valid,
11895 * if this is not valid, the target will use the
11896 * known local MAC address rather than the tuple
11897 */
11898 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011899 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011900 &ns_tuple->target_mac);
11901 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
11902 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
11903 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
11904 }
11905 }
11906 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
11907 }
11908}
11909#else
11910static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011911 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011912{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011913}
11914
11915static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011916 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011917{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011918}
11919#endif
11920
11921/**
Govind Singha4836fd2016-03-07 16:45:38 +053011922 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
11923 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011924 * @arp_offload_req: arp offload request
11925 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053011926 * @arp_only: flag
11927 *
11928 * To configure ARP NS off load data to firmware
11929 * when target goes to wow mode.
11930 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011931 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053011932 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011933static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053011934 struct pmo_arp_offload_params *arp_offload_req,
11935 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053011936 uint8_t vdev_id)
11937{
Govind Singha4836fd2016-03-07 16:45:38 +053011938 int32_t res;
11939 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011940 A_UINT8 *buf_ptr;
11941 wmi_buf_t buf;
11942 int32_t len;
11943 uint32_t count = 0, num_ns_ext_tuples = 0;
11944
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011945 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053011946
Govind Singha4836fd2016-03-07 16:45:38 +053011947 /*
11948 * TLV place holder size for array of NS tuples
11949 * TLV place holder size for array of ARP tuples
11950 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011951 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
11952 WMI_TLV_HDR_SIZE +
11953 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
11954 WMI_TLV_HDR_SIZE +
11955 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011956
11957 /*
11958 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
11959 * extra length for extended NS offload tuples which follows ARP offload
11960 * tuples. Host needs to fill this structure in following format:
11961 * 2 NS ofload tuples
11962 * 2 ARP offload tuples
11963 * N numbers of extended NS offload tuples if HDD has given more than
11964 * 2 NS offload addresses
11965 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011966 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053011967 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011968 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
11969 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053011970 }
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__);
Govind Singhb53420c2016-03-09 14:32:57 +053011975 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011976 }
11977
11978 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
11979 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
11980 WMITLV_SET_HDR(&cmd->tlv_header,
11981 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
11982 WMITLV_GET_STRUCT_TLVLEN
11983 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
11984 cmd->flags = 0;
11985 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011986 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053011987
Govind Singhb53420c2016-03-09 14:32:57 +053011988 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053011989
Govind Singha4836fd2016-03-07 16:45:38 +053011990 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053011991 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
11992 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
11993 if (num_ns_ext_tuples)
11994 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053011995
11996 res = wmi_unified_cmd_send(wmi_handle, buf, len,
11997 WMI_SET_ARP_NS_OFFLOAD_CMDID);
11998 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053011999 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053012000 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012001 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012002 }
12003
Govind Singhb53420c2016-03-09 14:32:57 +053012004 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012005}
12006
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012007/**
12008 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
12009 * @wmi_handle: wmi handle
12010 * @vdev_id: vdev id
12011 * @action: true for enable else false
12012 *
12013 * To enable enhance multicast offload to firmware
12014 * when target goes to wow mode.
12015 *
12016 * Return: QDF Status
12017 */
12018
12019static
12020QDF_STATUS send_enable_enhance_multicast_offload_tlv(
12021 wmi_unified_t wmi_handle,
12022 uint8_t vdev_id, bool action)
12023{
12024 QDF_STATUS status;
12025 wmi_buf_t buf;
12026 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
12027
12028 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12029 if (!buf) {
12030 WMI_LOGE("Failed to allocate buffer to send set key cmd");
12031 return QDF_STATUS_E_NOMEM;
12032 }
12033
12034 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
12035 wmi_buf_data(buf);
12036
12037 WMITLV_SET_HDR(&cmd->tlv_header,
12038 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
12039 WMITLV_GET_STRUCT_TLVLEN(
12040 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
12041
12042 cmd->vdev_id = vdev_id;
12043 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
12044 ENHANCED_MCAST_FILTER_ENABLED);
12045 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
12046 __func__, action, vdev_id);
12047 status = wmi_unified_cmd_send(wmi_handle, buf,
12048 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
12049 if (status != QDF_STATUS_SUCCESS) {
12050 qdf_nbuf_free(buf);
12051 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
12052 __func__);
12053 }
12054
12055 return status;
12056}
12057
12058/**
12059 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
12060 * @wmi_handle: wmi handle
12061 * @param evt_buf: pointer to event buffer
12062 * @param hdr: Pointer to hold header
12063 * @param bufp: Pointer to hold pointer to rx param buffer
12064 *
12065 * Return: QDF_STATUS_SUCCESS for success or error code
12066 */
12067static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
12068 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
12069{
12070 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
12071 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
12072
12073 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
12074 if (!param_buf) {
12075 WMI_LOGE("gtk param_buf is NULL");
12076 return QDF_STATUS_E_INVAL;
12077 }
12078
12079 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
12080 WMI_LOGE("Invalid length for GTK status");
12081 return QDF_STATUS_E_INVAL;
12082 }
12083
12084 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
12085 param_buf->fixed_param;
12086 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
12087 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
12088 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
12089 qdf_mem_copy(&gtk_rsp_param->replay_counter,
12090 &fixed_param->replay_counter,
12091 GTK_REPLAY_COUNTER_BYTES);
12092
12093 return QDF_STATUS_SUCCESS;
12094
12095}
12096
12097#ifdef FEATURE_WLAN_RA_FILTERING
12098/**
12099 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
12100 * @wmi_handle: wmi handle
12101 * @vdev_id: vdev id
12102 *
12103 * Return: CDF status
12104 */
12105static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
12106 uint8_t vdev_id, uint8_t default_pattern,
12107 uint16_t rate_limit_interval)
12108{
12109
12110 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12111 wmi_buf_t buf;
12112 uint8_t *buf_ptr;
12113 int32_t len;
12114 int ret;
12115
12116 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12117 WMI_TLV_HDR_SIZE +
12118 0 * sizeof(WOW_BITMAP_PATTERN_T) +
12119 WMI_TLV_HDR_SIZE +
12120 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12121 WMI_TLV_HDR_SIZE +
12122 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12123 WMI_TLV_HDR_SIZE +
12124 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12125 WMI_TLV_HDR_SIZE +
12126 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12127
12128 buf = wmi_buf_alloc(wmi_handle, len);
12129 if (!buf) {
12130 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12131 return QDF_STATUS_E_NOMEM;
12132 }
12133
12134 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12135 buf_ptr = (uint8_t *) cmd;
12136
12137 WMITLV_SET_HDR(&cmd->tlv_header,
12138 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12139 WMITLV_GET_STRUCT_TLVLEN
12140 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12141 cmd->vdev_id = vdev_id;
12142 cmd->pattern_id = default_pattern,
12143 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
12144 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12145
12146 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
12147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12148 buf_ptr += WMI_TLV_HDR_SIZE;
12149
12150 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12151 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12152 buf_ptr += WMI_TLV_HDR_SIZE;
12153
12154 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12155 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12156 buf_ptr += WMI_TLV_HDR_SIZE;
12157
12158 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12159 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12160 buf_ptr += WMI_TLV_HDR_SIZE;
12161
12162 /* Fill TLV for pattern_info_timeout but no data. */
12163 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12164 buf_ptr += WMI_TLV_HDR_SIZE;
12165
12166 /* Fill TLV for ra_ratelimit_interval. */
12167 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
12168 buf_ptr += WMI_TLV_HDR_SIZE;
12169
12170 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
12171
12172 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
12173 rate_limit_interval, vdev_id);
12174
12175 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12176 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12177 if (ret) {
12178 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
12179 wmi_buf_free(buf);
12180 return QDF_STATUS_E_FAILURE;
12181 }
12182
12183 return QDF_STATUS_SUCCESS;
12184
12185}
12186#endif /* FEATURE_WLAN_RA_FILTERING */
12187
12188/**
12189 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
12190 * @wmi_handle: wmi handle
12191 * @vdev_id: vdev id
12192 * @multicastAddr: mcast address
12193 * @clearList: clear list flag
12194 *
12195 * Return: QDF_STATUS_SUCCESS for success or error code
12196 */
12197static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
12198 uint8_t vdev_id,
12199 struct qdf_mac_addr multicast_addr,
12200 bool clearList)
12201{
12202 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
12203 wmi_buf_t buf;
12204 int err;
12205
12206 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12207 if (!buf) {
12208 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
12209 return QDF_STATUS_E_NOMEM;
12210 }
12211
12212 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
12213 qdf_mem_zero(cmd, sizeof(*cmd));
12214
12215 WMITLV_SET_HDR(&cmd->tlv_header,
12216 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
12217 WMITLV_GET_STRUCT_TLVLEN
12218 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
12219 cmd->action =
12220 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
12221 cmd->vdev_id = vdev_id;
12222 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
12223
12224 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
12225 cmd->action, vdev_id, clearList, multicast_addr.bytes);
12226
12227 err = wmi_unified_cmd_send(wmi_handle, buf,
12228 sizeof(*cmd),
12229 WMI_SET_MCASTBCAST_FILTER_CMDID);
12230 if (err) {
12231 WMI_LOGE("Failed to send set_param cmd");
12232 wmi_buf_free(buf);
12233 return QDF_STATUS_E_FAILURE;
12234 }
12235
12236 return QDF_STATUS_SUCCESS;
12237}
12238
12239/**
12240 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
12241 * @wmi_handle: wmi handle
12242 * @vdev_id: vdev id
12243 * @params: GTK offload parameters
12244 *
12245 * Return: CDF status
12246 */
12247static
12248QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
12249 struct pmo_gtk_req *params,
12250 bool enable_offload,
12251 uint32_t gtk_offload_opcode)
12252{
12253 int len;
12254 wmi_buf_t buf;
12255 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12256 QDF_STATUS status = QDF_STATUS_SUCCESS;
12257
12258 WMI_LOGD("%s Enter", __func__);
12259
12260 len = sizeof(*cmd);
12261
12262 /* alloc wmi buffer */
12263 buf = wmi_buf_alloc(wmi_handle, len);
12264 if (!buf) {
12265 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12266 status = QDF_STATUS_E_NOMEM;
12267 goto out;
12268 }
12269
12270 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12271 WMITLV_SET_HDR(&cmd->tlv_header,
12272 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12273 WMITLV_GET_STRUCT_TLVLEN
12274 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12275
12276 cmd->vdev_id = vdev_id;
12277
12278 /* Request target to enable GTK offload */
12279 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
12280 cmd->flags = gtk_offload_opcode;
12281
12282 /* Copy the keys and replay counter */
12283 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
12284 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
12285 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
12286 GTK_REPLAY_COUNTER_BYTES);
12287 } else {
12288 cmd->flags = gtk_offload_opcode;
12289 }
12290
12291 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
12292
12293 /* send the wmi command */
12294 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12295 WMI_GTK_OFFLOAD_CMDID)) {
12296 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
12297 wmi_buf_free(buf);
12298 status = QDF_STATUS_E_FAILURE;
12299 }
12300
12301out:
12302 WMI_LOGD("%s Exit", __func__);
12303 return status;
12304}
12305
12306/**
12307 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
12308 * @wmi_handle: wmi handle
12309 * @params: GTK offload params
12310 *
12311 * Return: CDF status
12312 */
12313static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
12314 wmi_unified_t wmi_handle,
12315 uint8_t vdev_id,
12316 uint64_t offload_req_opcode)
12317{
12318 int len;
12319 wmi_buf_t buf;
12320 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12321 QDF_STATUS status = QDF_STATUS_SUCCESS;
12322
12323 len = sizeof(*cmd);
12324
12325 /* alloc wmi buffer */
12326 buf = wmi_buf_alloc(wmi_handle, len);
12327 if (!buf) {
12328 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12329 status = QDF_STATUS_E_NOMEM;
12330 goto out;
12331 }
12332
12333 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12334 WMITLV_SET_HDR(&cmd->tlv_header,
12335 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12336 WMITLV_GET_STRUCT_TLVLEN
12337 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12338
12339 /* Request for GTK offload status */
12340 cmd->flags = offload_req_opcode;
12341 cmd->vdev_id = vdev_id;
12342
12343 /* send the wmi command */
12344 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12345 WMI_GTK_OFFLOAD_CMDID)) {
12346 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
12347 wmi_buf_free(buf);
12348 status = QDF_STATUS_E_FAILURE;
12349 }
12350
12351out:
12352 return status;
12353}
12354
12355/**
12356 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
12357 * @wmi_handle: wmi handler
12358 * @action_params: pointer to action_params
12359 *
12360 * Return: 0 for success, otherwise appropriate error code
12361 */
12362static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
12363 struct pmo_action_wakeup_set_params *action_params)
12364{
12365 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
12366 wmi_buf_t buf;
12367 int i;
12368 int32_t err;
12369
12370 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12371 if (!buf) {
12372 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
12373 return QDF_STATUS_E_NOMEM;
12374 }
12375 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
12376 WMITLV_SET_HDR(&cmd->tlv_header,
12377 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
12378 WMITLV_GET_STRUCT_TLVLEN(
12379 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
12380
12381 cmd->vdev_id = action_params->vdev_id;
12382 cmd->operation = action_params->operation;
12383
12384 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
12385 cmd->action_category_map[i] =
12386 action_params->action_category_map[i];
12387
12388 err = wmi_unified_cmd_send(wmi_handle, buf,
12389 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
12390 if (err) {
12391 WMI_LOGE("Failed to send ap_ps_egap cmd");
12392 wmi_buf_free(buf);
12393 return QDF_STATUS_E_FAILURE;
12394 }
12395
12396 return QDF_STATUS_SUCCESS;
12397}
12398
12399#ifdef FEATURE_WLAN_LPHB
12400
12401/**
12402 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
12403 * @wmi_handle: wmi handle
12404 * @lphb_conf_req: configuration info
12405 *
12406 * Return: CDF status
12407 */
12408static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
12409 wmi_hb_set_enable_cmd_fixed_param *params)
12410{
12411 QDF_STATUS status;
12412 wmi_buf_t buf = NULL;
12413 uint8_t *buf_ptr;
12414 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
12415 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
12416
12417
12418 buf = wmi_buf_alloc(wmi_handle, len);
12419 if (!buf) {
12420 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12421 return QDF_STATUS_E_NOMEM;
12422 }
12423
12424 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12425 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
12426 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
12427 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
12428 WMITLV_GET_STRUCT_TLVLEN
12429 (wmi_hb_set_enable_cmd_fixed_param));
12430
12431 /* fill in values */
12432 hb_enable_fp->vdev_id = params->session;
12433 hb_enable_fp->enable = params->enable;
12434 hb_enable_fp->item = params->item;
12435 hb_enable_fp->session = params->session;
12436
12437 status = wmi_unified_cmd_send(wmi_handle, buf,
12438 len, WMI_HB_SET_ENABLE_CMDID);
12439 if (QDF_IS_STATUS_ERROR(status)) {
12440 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
12441 status);
12442 wmi_buf_free(buf);
12443 }
12444
12445 return status;
12446}
12447
12448/**
12449 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
12450 * @wmi_handle: wmi handle
12451 * @lphb_conf_req: lphb config request
12452 *
12453 * Return: CDF status
12454 */
12455static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
12456 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
12457{
12458 QDF_STATUS status;
12459 wmi_buf_t buf = NULL;
12460 uint8_t *buf_ptr;
12461 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
12462 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
12463
12464 buf = wmi_buf_alloc(wmi_handle, len);
12465 if (!buf) {
12466 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12467 return QDF_STATUS_E_NOMEM;
12468 }
12469
12470 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12471 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
12472 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
12473 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
12474 WMITLV_GET_STRUCT_TLVLEN
12475 (wmi_hb_set_tcp_params_cmd_fixed_param));
12476
12477 /* fill in values */
12478 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
12479 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
12480 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
12481 hb_tcp_params_fp->seq = lphb_conf_req->seq;
12482 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
12483 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
12484 hb_tcp_params_fp->interval = lphb_conf_req->interval;
12485 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
12486 hb_tcp_params_fp->session = lphb_conf_req->session;
12487 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
12488 &lphb_conf_req->gateway_mac,
12489 sizeof(hb_tcp_params_fp->gateway_mac));
12490
12491 status = wmi_unified_cmd_send(wmi_handle, buf,
12492 len, WMI_HB_SET_TCP_PARAMS_CMDID);
12493 if (QDF_IS_STATUS_ERROR(status)) {
12494 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
12495 status);
12496 wmi_buf_free(buf);
12497 }
12498
12499 return status;
12500}
12501
12502/**
12503 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
12504 * @wmi_handle: wmi handle
12505 * @lphb_conf_req: lphb config request
12506 *
12507 * Return: CDF status
12508 */
12509static
12510QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
12511 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
12512{
12513 QDF_STATUS status;
12514 wmi_buf_t buf = NULL;
12515 uint8_t *buf_ptr;
12516 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
12517 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
12518
12519 buf = wmi_buf_alloc(wmi_handle, len);
12520 if (!buf) {
12521 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12522 return QDF_STATUS_E_NOMEM;
12523 }
12524
12525 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12526 hb_tcp_filter_fp =
12527 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
12528 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
12529 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
12530 WMITLV_GET_STRUCT_TLVLEN
12531 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
12532
12533 /* fill in values */
12534 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
12535 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
12536 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
12537 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
12538 memcpy((void *)&hb_tcp_filter_fp->filter,
12539 (void *)&g_hb_tcp_filter_fp->filter,
12540 WMI_WLAN_HB_MAX_FILTER_SIZE);
12541
12542 status = wmi_unified_cmd_send(wmi_handle, buf,
12543 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
12544 if (QDF_IS_STATUS_ERROR(status)) {
12545 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
12546 status);
12547 wmi_buf_free(buf);
12548 }
12549
12550 return status;
12551}
12552
12553/**
12554 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
12555 * @wmi_handle: wmi handle
12556 * @lphb_conf_req: lphb config request
12557 *
12558 * Return: CDF status
12559 */
12560static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
12561 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
12562{
12563 QDF_STATUS status;
12564 wmi_buf_t buf = NULL;
12565 uint8_t *buf_ptr;
12566 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
12567 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
12568
12569 buf = wmi_buf_alloc(wmi_handle, len);
12570 if (!buf) {
12571 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12572 return QDF_STATUS_E_NOMEM;
12573 }
12574
12575 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12576 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
12577 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
12578 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
12579 WMITLV_GET_STRUCT_TLVLEN
12580 (wmi_hb_set_udp_params_cmd_fixed_param));
12581
12582 /* fill in values */
12583 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
12584 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
12585 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
12586 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
12587 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
12588 hb_udp_params_fp->interval = lphb_conf_req->interval;
12589 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
12590 hb_udp_params_fp->session = lphb_conf_req->session;
12591 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
12592 &lphb_conf_req->gateway_mac,
12593 sizeof(lphb_conf_req->gateway_mac));
12594
12595 status = wmi_unified_cmd_send(wmi_handle, buf,
12596 len, WMI_HB_SET_UDP_PARAMS_CMDID);
12597 if (QDF_IS_STATUS_ERROR(status)) {
12598 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
12599 status);
12600 wmi_buf_free(buf);
12601 }
12602
12603 return status;
12604}
12605
12606/**
12607 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
12608 * @wmi_handle: wmi handle
12609 * @lphb_conf_req: lphb config request
12610 *
12611 * Return: CDF status
12612 */
12613static
12614QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
12615 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
12616{
12617 QDF_STATUS status;
12618 wmi_buf_t buf = NULL;
12619 uint8_t *buf_ptr;
12620 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
12621 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
12622
12623 buf = wmi_buf_alloc(wmi_handle, len);
12624 if (!buf) {
12625 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
12626 return QDF_STATUS_E_NOMEM;
12627 }
12628
12629 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12630 hb_udp_filter_fp =
12631 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
12632 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
12633 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
12634 WMITLV_GET_STRUCT_TLVLEN
12635 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
12636
12637 /* fill in values */
12638 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
12639 hb_udp_filter_fp->length = lphb_conf_req->length;
12640 hb_udp_filter_fp->offset = lphb_conf_req->offset;
12641 hb_udp_filter_fp->session = lphb_conf_req->session;
12642 memcpy((void *)&hb_udp_filter_fp->filter,
12643 (void *)&lphb_conf_req->filter,
12644 WMI_WLAN_HB_MAX_FILTER_SIZE);
12645
12646 status = wmi_unified_cmd_send(wmi_handle, buf,
12647 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
12648 if (QDF_IS_STATUS_ERROR(status)) {
12649 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
12650 status);
12651 wmi_buf_free(buf);
12652 }
12653
12654 return status;
12655}
12656#endif /* FEATURE_WLAN_LPHB */
12657#endif /* End of WLAN_PMO_ENABLE */
12658
Sathish Kumarfd347372017-02-13 12:29:09 +053012659static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053012660 uint8_t vdev_id, bool enable)
12661{
12662 int32_t res;
12663 wmi_hw_data_filter_cmd_fixed_param *cmd;
12664 A_UINT8 *buf_ptr;
12665 wmi_buf_t buf;
12666 int32_t len;
12667
12668 /*
12669 * TLV place holder size for array of ARP tuples
12670 */
12671 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
12672
12673 buf = wmi_buf_alloc(wmi_handle, len);
12674 if (!buf) {
12675 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12676 return QDF_STATUS_E_NOMEM;
12677 }
12678
12679 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
12680 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
12681 WMITLV_SET_HDR(&cmd->tlv_header,
12682 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
12683 WMITLV_GET_STRUCT_TLVLEN
12684 (wmi_hw_data_filter_cmd_fixed_param));
12685 cmd->vdev_id = vdev_id;
12686 cmd->enable = enable;
12687 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
12688
12689 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
12690
12691 res = wmi_unified_cmd_send(wmi_handle, buf, len,
12692 WMI_HW_DATA_FILTER_CMDID);
12693 if (res) {
12694 WMI_LOGE("Failed to enable ARP NDP/NSffload");
12695 wmi_buf_free(buf);
12696 return QDF_STATUS_E_FAILURE;
12697 }
12698
12699 return QDF_STATUS_SUCCESS;
12700}
12701
Govind Singha4836fd2016-03-07 16:45:38 +053012702/**
12703 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
12704 * @wmi_handle: wmi handle
12705 * @request: SSID hotlist set request
12706 *
Govind Singhb53420c2016-03-09 14:32:57 +053012707 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053012708 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012709static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053012710send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
12711 struct ssid_hotlist_request_params *request)
12712{
12713 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
12714 wmi_buf_t wmi_buf;
12715 uint32_t len;
12716 uint32_t array_size;
12717 uint8_t *buf_ptr;
12718
12719 /* length of fixed portion */
12720 len = sizeof(*cmd);
12721
12722 /* length of variable portion */
12723 array_size =
12724 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
12725 len += WMI_TLV_HDR_SIZE + array_size;
12726
12727 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12728 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012729 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12730 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012731 }
12732
12733 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
12734 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
12735 buf_ptr;
12736 WMITLV_SET_HDR
12737 (&cmd->tlv_header,
12738 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
12739 WMITLV_GET_STRUCT_TLVLEN
12740 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
12741
12742 cmd->request_id = request->request_id;
12743 cmd->requestor_id = 0;
12744 cmd->vdev_id = request->session_id;
12745 cmd->table_id = 0;
12746 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
12747 cmd->total_entries = request->ssid_count;
12748 cmd->num_entries_in_page = request->ssid_count;
12749 cmd->first_entry_index = 0;
12750
12751 buf_ptr += sizeof(*cmd);
12752 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
12753
12754 if (request->ssid_count) {
12755 wmi_extscan_hotlist_ssid_entry *entry;
12756 int i;
12757
12758 buf_ptr += WMI_TLV_HDR_SIZE;
12759 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
12760 for (i = 0; i < request->ssid_count; i++) {
12761 WMITLV_SET_HDR
12762 (entry,
12763 WMITLV_TAG_ARRAY_STRUC,
12764 WMITLV_GET_STRUCT_TLVLEN
12765 (wmi_extscan_hotlist_ssid_entry));
12766 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053012767 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053012768 request->ssids[i].ssid.mac_ssid,
12769 request->ssids[i].ssid.length);
12770 entry->band = request->ssids[i].band;
12771 entry->min_rssi = request->ssids[i].rssi_low;
12772 entry->max_rssi = request->ssids[i].rssi_high;
12773 entry++;
12774 }
12775 cmd->mode = WMI_EXTSCAN_MODE_START;
12776 } else {
12777 cmd->mode = WMI_EXTSCAN_MODE_STOP;
12778 }
12779
12780 if (wmi_unified_cmd_send
12781 (wmi_handle, wmi_buf, len,
12782 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012783 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053012784 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012785 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012786 }
12787
Govind Singhb53420c2016-03-09 14:32:57 +053012788 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012789}
12790
12791/**
12792 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
12793 * @wmi_handle: wmi handle
12794 * @vdev_id: vdev id
12795 *
12796 * This function sends roam synch complete event to fw.
12797 *
12798 * Return: CDF STATUS
12799 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012800static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012801 uint8_t vdev_id)
12802{
12803 wmi_roam_synch_complete_fixed_param *cmd;
12804 wmi_buf_t wmi_buf;
12805 uint8_t *buf_ptr;
12806 uint16_t len;
12807 len = sizeof(wmi_roam_synch_complete_fixed_param);
12808
12809 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12810 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012811 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12812 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012813 }
12814 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
12815 buf_ptr = (uint8_t *) cmd;
12816 WMITLV_SET_HDR(&cmd->tlv_header,
12817 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
12818 WMITLV_GET_STRUCT_TLVLEN
12819 (wmi_roam_synch_complete_fixed_param));
12820 cmd->vdev_id = vdev_id;
12821 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12822 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012823 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053012824 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012825 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012826 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012827 }
12828
Govind Singhb53420c2016-03-09 14:32:57 +053012829 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012830}
12831
12832/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053012833 * send_fw_test_cmd_tlv() - send fw test command to fw.
12834 * @wmi_handle: wmi handle
12835 * @wmi_fwtest: fw test command
12836 *
12837 * This function sends fw test command to fw.
12838 *
12839 * Return: CDF STATUS
12840 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012841static
Anurag Chouhan459e0152016-07-22 20:19:54 +053012842QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
12843 struct set_fwtest_params *wmi_fwtest)
12844{
12845 wmi_fwtest_set_param_cmd_fixed_param *cmd;
12846 wmi_buf_t wmi_buf;
12847 uint16_t len;
12848
12849 len = sizeof(*cmd);
12850
12851 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12852 if (!wmi_buf) {
12853 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12854 return QDF_STATUS_E_NOMEM;
12855 }
12856
12857 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12858 WMITLV_SET_HDR(&cmd->tlv_header,
12859 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
12860 WMITLV_GET_STRUCT_TLVLEN(
12861 wmi_fwtest_set_param_cmd_fixed_param));
12862 cmd->param_id = wmi_fwtest->arg;
12863 cmd->param_value = wmi_fwtest->value;
12864
12865 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12866 WMI_FWTEST_CMDID)) {
12867 WMI_LOGP("%s: failed to send fw test command", __func__);
12868 qdf_nbuf_free(wmi_buf);
12869 return QDF_STATUS_E_FAILURE;
12870 }
12871
12872 return QDF_STATUS_SUCCESS;
12873}
12874
12875/**
Govind Singha4836fd2016-03-07 16:45:38 +053012876 * send_unit_test_cmd_tlv() - send unit test command to fw.
12877 * @wmi_handle: wmi handle
12878 * @wmi_utest: unit test command
12879 *
12880 * This function send unit test command to fw.
12881 *
12882 * Return: CDF STATUS
12883 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012884static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012885 struct wmi_unit_test_cmd *wmi_utest)
12886{
12887 wmi_unit_test_cmd_fixed_param *cmd;
12888 wmi_buf_t wmi_buf;
12889 uint8_t *buf_ptr;
12890 int i;
12891 uint16_t len, args_tlv_len;
12892 A_UINT32 *unit_test_cmd_args;
12893
12894 args_tlv_len =
12895 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
12896 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
12897
12898 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12899 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012900 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12901 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012902 }
12903
12904 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
12905 buf_ptr = (uint8_t *) cmd;
12906 WMITLV_SET_HDR(&cmd->tlv_header,
12907 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
12908 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
12909 cmd->vdev_id = wmi_utest->vdev_id;
12910 cmd->module_id = wmi_utest->module_id;
12911 cmd->num_args = wmi_utest->num_args;
12912 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
12913 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12914 (wmi_utest->num_args * sizeof(uint32_t)));
12915 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053012916 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053012917 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
12918 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053012919 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012920 }
12921 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
12922 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053012923 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012924 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012925 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012926 }
12927
Govind Singhb53420c2016-03-09 14:32:57 +053012928 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012929}
12930
12931/**
12932 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
12933 * @wmi_handle: wma handle
12934 * @roaminvoke: roam invoke command
12935 *
12936 * Send roam invoke command to fw for fastreassoc.
12937 *
12938 * Return: CDF STATUS
12939 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012940static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012941 struct wmi_roam_invoke_cmd *roaminvoke,
12942 uint32_t ch_hz)
12943{
12944 wmi_roam_invoke_cmd_fixed_param *cmd;
12945 wmi_buf_t wmi_buf;
12946 u_int8_t *buf_ptr;
12947 u_int16_t len, args_tlv_len;
12948 A_UINT32 *channel_list;
12949 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080012950 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053012951
12952 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080012953 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
12954 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
12955 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012956 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
12957 wmi_buf = wmi_buf_alloc(wmi_handle, len);
12958 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012959 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
12960 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012961 }
12962
12963 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
12964 buf_ptr = (u_int8_t *) cmd;
12965 WMITLV_SET_HDR(&cmd->tlv_header,
12966 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
12967 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
12968 cmd->vdev_id = roaminvoke->vdev_id;
12969 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080012970
12971 if (roaminvoke->frame_len)
12972 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
12973 else
12974 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
12975
Govind Singha4836fd2016-03-07 16:45:38 +053012976 cmd->roam_ap_sel_mode = 0;
12977 cmd->roam_delay = 0;
12978 cmd->num_chan = 1;
12979 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080012980 /* packing 1 beacon/probe_rsp frame with WMI cmd */
12981 cmd->num_buf = 1;
12982
Govind Singha4836fd2016-03-07 16:45:38 +053012983 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
12984 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
12985 (sizeof(u_int32_t)));
12986 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
12987 *channel_list = ch_hz;
12988 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
12989 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12990 (sizeof(wmi_mac_addr)));
12991 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
12992 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080012993
12994 /* move to next tlv i.e. bcn_prb_buf_list */
12995 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
12996
12997 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
12998 sizeof(wmi_tlv_buf_len_param));
12999
13000 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
13001 buf_len_tlv->buf_len = roaminvoke->frame_len;
13002
13003 /* move to next tlv i.e. bcn_prb_frm */
13004 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
13005 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
13006 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
13007
13008 /* copy frame after the header */
13009 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
13010 roaminvoke->frame_buf,
13011 roaminvoke->frame_len);
13012
13013 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
13014 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
13015 buf_ptr + WMI_TLV_HDR_SIZE,
13016 roaminvoke->frame_len);
13017
Govind Singha4836fd2016-03-07 16:45:38 +053013018 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13019 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013020 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013021 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013022 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013023 }
13024
Govind Singhb53420c2016-03-09 14:32:57 +053013025 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013026}
13027
13028/**
13029 * send_roam_scan_offload_cmd_tlv() - set roam offload command
13030 * @wmi_handle: wmi handle
13031 * @command: command
13032 * @vdev_id: vdev id
13033 *
13034 * This function set roam offload command to fw.
13035 *
13036 * Return: CDF status
13037 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013038static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013039 uint32_t command, uint32_t vdev_id)
13040{
Govind Singh67922e82016-04-01 16:48:57 +053013041 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013042 wmi_roam_scan_cmd_fixed_param *cmd_fp;
13043 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013044 int len;
13045 uint8_t *buf_ptr;
13046
13047 len = sizeof(wmi_roam_scan_cmd_fixed_param);
13048 buf = wmi_buf_alloc(wmi_handle, len);
13049 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013050 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13051 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013052 }
13053
13054 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13055
13056 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
13057 WMITLV_SET_HDR(&cmd_fp->tlv_header,
13058 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
13059 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
13060 cmd_fp->vdev_id = vdev_id;
13061 cmd_fp->command_arg = command;
13062
13063 status = wmi_unified_cmd_send(wmi_handle, buf,
13064 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053013065 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013066 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013067 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013068 goto error;
13069 }
13070
Govind Singhb53420c2016-03-09 14:32:57 +053013071 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
13072 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013073
13074error:
13075 wmi_buf_free(buf);
13076
Govind Singh67922e82016-04-01 16:48:57 +053013077 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013078}
13079
13080/**
13081 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
13082 * @wmi_handle: wmi handle
13083 * @ap_profile_p: ap profile
13084 * @vdev_id: vdev id
13085 *
13086 * Send WMI_ROAM_AP_PROFILE to firmware
13087 *
13088 * Return: CDF status
13089 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013090static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013091 wmi_ap_profile *ap_profile_p,
13092 uint32_t vdev_id)
13093{
Govind Singha4836fd2016-03-07 16:45:38 +053013094 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013095 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013096 int len;
13097 uint8_t *buf_ptr;
13098 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
13099
13100 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
13101
13102 buf = wmi_buf_alloc(wmi_handle, len);
13103 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013104 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13105 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013106 }
13107
13108 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13109 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
13110 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
13111 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
13112 WMITLV_GET_STRUCT_TLVLEN
13113 (wmi_roam_ap_profile_fixed_param));
13114 /* fill in threshold values */
13115 roam_ap_profile_fp->vdev_id = vdev_id;
13116 roam_ap_profile_fp->id = 0;
13117 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
13118
Govind Singhb53420c2016-03-09 14:32:57 +053013119 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053013120 WMITLV_SET_HDR(buf_ptr,
13121 WMITLV_TAG_STRUC_wmi_ap_profile,
13122 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
13123 status = wmi_unified_cmd_send(wmi_handle, buf,
13124 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053013125 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013126 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013127 status);
Govind Singh67922e82016-04-01 16:48:57 +053013128 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013129 }
13130
Govind Singhb53420c2016-03-09 14:32:57 +053013131 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053013132
Govind Singh67922e82016-04-01 16:48:57 +053013133 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013134}
13135
13136/**
13137 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
13138 * @wmi_handle: wmi handle
13139 * @scan_period: scan period
13140 * @scan_age: scan age
13141 * @vdev_id: vdev id
13142 *
13143 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
13144 *
13145 * Return: CDF status
13146 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013147static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013148 uint32_t scan_period,
13149 uint32_t scan_age,
13150 uint32_t vdev_id)
13151{
Govind Singh67922e82016-04-01 16:48:57 +053013152 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013153 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013154 int len;
13155 uint8_t *buf_ptr;
13156 wmi_roam_scan_period_fixed_param *scan_period_fp;
13157
13158 /* Send scan period values */
13159 len = sizeof(wmi_roam_scan_period_fixed_param);
13160 buf = wmi_buf_alloc(wmi_handle, len);
13161 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013162 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13163 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013164 }
13165
13166 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13167 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
13168 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
13169 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
13170 WMITLV_GET_STRUCT_TLVLEN
13171 (wmi_roam_scan_period_fixed_param));
13172 /* fill in scan period values */
13173 scan_period_fp->vdev_id = vdev_id;
13174 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
13175 scan_period_fp->roam_scan_age = scan_age;
13176
13177 status = wmi_unified_cmd_send(wmi_handle, buf,
13178 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053013179 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013180 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013181 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013182 goto error;
13183 }
13184
Govind Singhb53420c2016-03-09 14:32:57 +053013185 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013186 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053013187 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013188error:
13189 wmi_buf_free(buf);
13190
Govind Singh67922e82016-04-01 16:48:57 +053013191 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013192}
13193
13194/**
13195 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
13196 * @wmi_handle: wmi handle
13197 * @chan_count: channel count
13198 * @chan_list: channel list
13199 * @list_type: list type
13200 * @vdev_id: vdev id
13201 *
13202 * Set roam offload channel list.
13203 *
13204 * Return: CDF status
13205 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013206static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013207 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070013208 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053013209 uint8_t list_type, uint32_t vdev_id)
13210{
Govind Singha4836fd2016-03-07 16:45:38 +053013211 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013212 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013213 int len, list_tlv_len;
13214 int i;
13215 uint8_t *buf_ptr;
13216 wmi_roam_chan_list_fixed_param *chan_list_fp;
13217 A_UINT32 *roam_chan_list_array;
13218
13219 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053013220 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053013221 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053013222 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053013223 }
13224 /* Channel list is a table of 2 TLV's */
13225 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
13226 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
13227 buf = wmi_buf_alloc(wmi_handle, len);
13228 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013229 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13230 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013231 }
13232
13233 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13234 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
13235 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
13236 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
13237 WMITLV_GET_STRUCT_TLVLEN
13238 (wmi_roam_chan_list_fixed_param));
13239 chan_list_fp->vdev_id = vdev_id;
13240 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053013241 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053013242 /* external app is controlling channel list */
13243 chan_list_fp->chan_list_type =
13244 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
13245 } else {
13246 /* umac supplied occupied channel list in LFR */
13247 chan_list_fp->chan_list_type =
13248 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
13249 }
13250
13251 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
13252 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13253 (chan_list_fp->num_chan * sizeof(uint32_t)));
13254 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013255 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053013256 for (i = 0; ((i < chan_list_fp->num_chan) &&
13257 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
13258 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013259 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013260 }
13261
13262 status = wmi_unified_cmd_send(wmi_handle, buf,
13263 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053013264 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013265 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013266 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013267 goto error;
13268 }
13269
Govind Singhb53420c2016-03-09 14:32:57 +053013270 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
13271 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013272error:
13273 wmi_buf_free(buf);
13274
Govind Singh67922e82016-04-01 16:48:57 +053013275 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013276}
13277
13278/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013279 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
13280 * @wmi_handle: wmi handle
13281 * @req_buf: per roam config buffer
13282 *
13283 * Return: QDF status
13284 */
13285static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
13286 struct wmi_per_roam_config_req *req_buf)
13287{
13288 wmi_buf_t buf = NULL;
13289 QDF_STATUS status;
13290 int len;
13291 uint8_t *buf_ptr;
13292 wmi_roam_per_config_fixed_param *wmi_per_config;
13293
13294 len = sizeof(wmi_roam_per_config_fixed_param);
13295 buf = wmi_buf_alloc(wmi_handle, len);
13296 if (!buf) {
13297 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13298 return QDF_STATUS_E_NOMEM;
13299 }
13300
13301 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13302 wmi_per_config =
13303 (wmi_roam_per_config_fixed_param *) buf_ptr;
13304 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
13305 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
13306 WMITLV_GET_STRUCT_TLVLEN
13307 (wmi_roam_per_config_fixed_param));
13308
13309 /* fill in per roam config values */
13310 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013311
13312 wmi_per_config->enable = req_buf->per_config.enable;
13313 wmi_per_config->high_rate_thresh =
13314 (req_buf->per_config.tx_high_rate_thresh << 16) |
13315 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
13316 wmi_per_config->low_rate_thresh =
13317 (req_buf->per_config.tx_low_rate_thresh << 16) |
13318 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
13319 wmi_per_config->pkt_err_rate_thresh_pct =
13320 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
13321 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
13322 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053013323 wmi_per_config->pkt_err_rate_mon_time =
13324 (req_buf->per_config.tx_per_mon_time << 16) |
13325 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013326
13327 /* Send per roam config parameters */
13328 status = wmi_unified_cmd_send(wmi_handle, buf,
13329 len, WMI_ROAM_PER_CONFIG_CMDID);
13330 if (QDF_IS_STATUS_ERROR(status)) {
13331 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
13332 status);
13333 wmi_buf_free(buf);
13334 return status;
13335 }
13336
13337 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
13338 req_buf->per_config.enable, req_buf->vdev_id);
13339 return QDF_STATUS_SUCCESS;
13340}
13341
13342/**
Govind Singha4836fd2016-03-07 16:45:38 +053013343 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
13344 * @wmi_handle: wmi handle
13345 * @rssi_change_thresh: RSSI Change threshold
13346 * @bcn_rssi_weight: beacon RSSI weight
13347 * @vdev_id: vdev id
13348 *
13349 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
13350 *
13351 * Return: CDF status
13352 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013353static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013354 uint32_t vdev_id,
13355 int32_t rssi_change_thresh,
13356 uint32_t bcn_rssi_weight,
13357 uint32_t hirssi_delay_btw_scans)
13358{
Govind Singha4836fd2016-03-07 16:45:38 +053013359 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013360 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013361 int len;
13362 uint8_t *buf_ptr;
13363 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
13364
13365 /* Send rssi change parameters */
13366 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
13367 buf = wmi_buf_alloc(wmi_handle, len);
13368 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013369 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13370 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013371 }
13372
13373 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13374 rssi_change_fp =
13375 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
13376 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
13377 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
13378 WMITLV_GET_STRUCT_TLVLEN
13379 (wmi_roam_scan_rssi_change_threshold_fixed_param));
13380 /* fill in rssi change threshold (hysteresis) values */
13381 rssi_change_fp->vdev_id = vdev_id;
13382 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
13383 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
13384 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
13385
13386 status = wmi_unified_cmd_send(wmi_handle, buf,
13387 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053013388 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013389 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013390 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013391 goto error;
13392 }
13393
Govind Singhb53420c2016-03-09 14:32:57 +053013394 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053013395 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053013396 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
13397 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013398error:
13399 wmi_buf_free(buf);
13400
Govind Singh67922e82016-04-01 16:48:57 +053013401 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013402}
13403
13404/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
13405 * @wmi_handle: wmi handle.
13406 * @cmd: size of command structure.
13407 * @per_entry_size: per entry size.
13408 *
13409 * This utility function calculates how many hotlist entries can
13410 * fit in one page.
13411 *
13412 * Return: number of entries
13413 */
13414static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
13415 size_t cmd_size,
13416 size_t per_entry_size)
13417{
13418 uint32_t avail_space = 0;
13419 int num_entries = 0;
13420 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
13421
13422 /* Calculate number of hotlist entries that can
13423 * be passed in wma message request.
13424 */
13425 avail_space = max_msg_len - cmd_size;
13426 num_entries = avail_space / per_entry_size;
13427 return num_entries;
13428}
13429
13430/**
13431 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
13432 * @wmi_handle: wmi handle
13433 * @photlist: hotlist command params
13434 * @buf_len: buffer length
13435 *
13436 * This function fills individual elements for hotlist request and
13437 * TLV for bssid entries
13438 *
13439 * Return: CDF Status.
13440 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013441static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013442 struct ext_scan_setbssi_hotlist_params *
13443 photlist, int *buf_len)
13444{
13445 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
13446 wmi_extscan_hotlist_entry *dest_hotlist;
13447 struct ap_threshold_params *src_ap = photlist->ap;
13448 wmi_buf_t buf;
13449 uint8_t *buf_ptr;
13450
13451 int j, index = 0;
13452 int cmd_len = 0;
13453 int num_entries;
13454 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080013455 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053013456 int len = sizeof(*cmd);
13457
13458 len += WMI_TLV_HDR_SIZE;
13459 cmd_len = len;
13460
13461 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
13462 cmd_len,
13463 sizeof(*dest_hotlist));
13464 /* setbssid hotlist expects the bssid list
13465 * to be non zero value
13466 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080013467 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080013468 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053013469 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053013470 }
13471
13472 /* Split the hot list entry pages and send multiple command
13473 * requests if the buffer reaches the maximum request size
13474 */
13475 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053013476 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053013477 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
13478 buf = wmi_buf_alloc(wmi_handle, len);
13479 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013480 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
13481 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013482 }
13483 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13484 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
13485 buf_ptr;
13486 WMITLV_SET_HDR(&cmd->tlv_header,
13487 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
13488 WMITLV_GET_STRUCT_TLVLEN
13489 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
13490
13491 /* Multiple requests are sent until the num_entries_in_page
13492 * matches the total_entries
13493 */
13494 cmd->request_id = photlist->requestId;
13495 cmd->vdev_id = photlist->sessionId;
13496 cmd->total_entries = numap;
13497 cmd->mode = 1;
13498 cmd->num_entries_in_page = min_entries;
13499 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
13500 cmd->first_entry_index = index;
13501
Govind Singhb53420c2016-03-09 14:32:57 +053013502 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013503 __func__, cmd->vdev_id, cmd->total_entries,
13504 cmd->num_entries_in_page,
13505 cmd->lost_ap_scan_count);
13506
13507 buf_ptr += sizeof(*cmd);
13508 WMITLV_SET_HDR(buf_ptr,
13509 WMITLV_TAG_ARRAY_STRUC,
13510 min_entries * sizeof(wmi_extscan_hotlist_entry));
13511 dest_hotlist = (wmi_extscan_hotlist_entry *)
13512 (buf_ptr + WMI_TLV_HDR_SIZE);
13513
13514 /* Populate bssid, channel info and rssi
13515 * for the bssid's that are sent as hotlists.
13516 */
13517 for (j = 0; j < min_entries; j++) {
13518 WMITLV_SET_HDR(dest_hotlist,
13519 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
13520 WMITLV_GET_STRUCT_TLVLEN
13521 (wmi_extscan_hotlist_entry));
13522
13523 dest_hotlist->min_rssi = src_ap->low;
13524 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
13525 &dest_hotlist->bssid);
13526
Govind Singhb53420c2016-03-09 14:32:57 +053013527 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013528 __func__, dest_hotlist->channel,
13529 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053013530 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053013531 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
13532 __func__, dest_hotlist->bssid.mac_addr31to0,
13533 dest_hotlist->bssid.mac_addr47to32);
13534 dest_hotlist++;
13535 src_ap++;
13536 }
13537 buf_ptr += WMI_TLV_HDR_SIZE +
13538 (min_entries * sizeof(wmi_extscan_hotlist_entry));
13539
13540 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13541 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013542 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013543 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013544 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013545 }
13546 index = index + min_entries;
13547 num_entries = numap - min_entries;
13548 len = cmd_len;
13549 }
Govind Singhb53420c2016-03-09 14:32:57 +053013550 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013551}
13552
Govind Singhbca3b1b2016-05-02 17:59:24 +053013553/**
Dustin Brown4423f632017-01-13 15:24:07 -080013554 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
13555 * @wmi_handle: the WMI handle
13556 * @vdev_id: the Id of the vdev to apply the configuration to
13557 * @ucast_mode: the active BPF mode to configure for unicast packets
13558 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
13559 * packets
13560 *
13561 * Return: QDF status
13562 */
13563static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
13564 uint8_t vdev_id,
13565 enum wmi_host_active_bpf_mode ucast_mode,
13566 enum wmi_host_active_bpf_mode mcast_bcast_mode)
13567{
13568 const WMITLV_TAG_ID tag_id =
13569 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
13570 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
13571 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
13572 QDF_STATUS status;
13573 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
13574 wmi_buf_t buf;
13575
13576 WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
13577 vdev_id, ucast_mode, mcast_bcast_mode);
13578
13579 /* allocate command buffer */
13580 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13581 if (!buf) {
13582 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13583 return QDF_STATUS_E_NOMEM;
13584 }
13585
13586 /* set TLV header */
13587 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
13588 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
13589
13590 /* populate data */
13591 cmd->vdev_id = vdev_id;
13592 cmd->uc_mode = ucast_mode;
13593 cmd->mcbc_mode = mcast_bcast_mode;
13594
13595 /* send to FW */
13596 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
13597 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
13598 if (QDF_IS_STATUS_ERROR(status)) {
13599 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
13600 status);
13601 wmi_buf_free(buf);
13602 return status;
13603 }
13604
13605 WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
13606
13607 return QDF_STATUS_SUCCESS;
13608}
13609
13610/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053013611 * send_power_dbg_cmd_tlv() - send power debug commands
13612 * @wmi_handle: wmi handle
13613 * @param: wmi power debug parameter
13614 *
13615 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
13616 *
13617 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13618 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013619static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
13620 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053013621{
13622 wmi_buf_t buf = NULL;
13623 QDF_STATUS status;
13624 int len, args_tlv_len;
13625 uint8_t *buf_ptr;
13626 uint8_t i;
13627 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
13628 uint32_t *cmd_args;
13629
13630 /* Prepare and send power debug cmd parameters */
13631 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
13632 len = sizeof(*cmd) + args_tlv_len;
13633 buf = wmi_buf_alloc(wmi_handle, len);
13634 if (!buf) {
13635 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13636 return QDF_STATUS_E_NOMEM;
13637 }
13638
13639 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13640 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
13641 WMITLV_SET_HDR(&cmd->tlv_header,
13642 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
13643 WMITLV_GET_STRUCT_TLVLEN
13644 (wmi_pdev_wal_power_debug_cmd_fixed_param));
13645
13646 cmd->pdev_id = param->pdev_id;
13647 cmd->module_id = param->module_id;
13648 cmd->num_args = param->num_args;
13649 buf_ptr += sizeof(*cmd);
13650 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13651 (param->num_args * sizeof(uint32_t)));
13652 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
13653 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
13654 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
13655 cmd_args[i] = param->args[i];
13656 WMI_LOGI("%d,", param->args[i]);
13657 }
13658
13659 status = wmi_unified_cmd_send(wmi_handle, buf,
13660 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
13661 if (QDF_IS_STATUS_ERROR(status)) {
13662 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
13663 status);
13664 goto error;
13665 }
13666
13667 return QDF_STATUS_SUCCESS;
13668error:
13669 wmi_buf_free(buf);
13670
13671 return status;
13672}
13673
Kiran Venkatappa26117052016-12-23 19:58:54 +053013674/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
13675 * @buf_ptr: pointer to current position in init command buffer
13676 * @len: pointer to length. This will be updated with current lenght of cmd
13677 * @param: point host parameters for init command
13678 *
13679 * Return: Updated pointer of buf_ptr.
13680 */
13681static inline uint8_t *copy_hw_mode_in_init_cmd(uint8_t *buf_ptr,
13682 int *len, struct wmi_init_cmd_param *param)
13683{
13684 uint16_t idx;
13685
13686 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
13687 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
13688 wmi_pdev_band_to_mac *band_to_mac;
13689
13690 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
13691 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
13692 sizeof(wmi_resource_config) +
13693 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
13694 sizeof(wlan_host_memory_chunk)));
13695
13696 WMITLV_SET_HDR(&hw_mode->tlv_header,
13697 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
13698 (WMITLV_GET_STRUCT_TLVLEN
13699 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
13700
13701 hw_mode->hw_mode_index = param->hw_mode_id;
13702 hw_mode->num_band_to_mac = param->num_band_to_mac;
13703
13704 buf_ptr = (uint8_t *) (hw_mode + 1);
13705 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
13706 WMI_TLV_HDR_SIZE);
13707 for (idx = 0; idx < param->num_band_to_mac; idx++) {
13708 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
13709 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
13710 WMITLV_GET_STRUCT_TLVLEN
13711 (wmi_pdev_band_to_mac));
13712 band_to_mac[idx].pdev_id =
13713 param->band_to_mac[idx].pdev_id;
13714 band_to_mac[idx].start_freq =
13715 param->band_to_mac[idx].start_freq;
13716 band_to_mac[idx].end_freq =
13717 param->band_to_mac[idx].end_freq;
13718 }
13719 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13720 (param->num_band_to_mac *
13721 sizeof(wmi_pdev_band_to_mac)) +
13722 WMI_TLV_HDR_SIZE;
13723
13724 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
13725 (param->num_band_to_mac *
13726 sizeof(wmi_pdev_band_to_mac)));
13727 }
13728
13729 return buf_ptr;
13730}
13731
Govind Singhe7f2f342016-05-23 12:12:52 +053013732/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053013733 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
13734 * @wmi_handle: wmi handle
13735 * @param: wmi multiple vdev restart req param
13736 *
13737 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
13738 *
13739 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13740 */
13741static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
13742 wmi_unified_t wmi_handle,
13743 struct multiple_vdev_restart_params *param)
13744{
13745 wmi_buf_t buf;
13746 QDF_STATUS qdf_status;
13747 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
13748 int i;
13749 uint8_t *buf_ptr;
13750 uint32_t *vdev_ids;
13751 wmi_channel *chan_info;
13752 struct channel_param *tchan_info;
13753 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
13754
13755 len += sizeof(wmi_channel);
13756 if (param->num_vdevs)
13757 len += sizeof(uint32_t) * param->num_vdevs;
13758
13759 buf = wmi_buf_alloc(wmi_handle, len);
13760 if (!buf) {
13761 WMI_LOGE("Failed to allocate memory\n");
13762 qdf_status = QDF_STATUS_E_NOMEM;
13763 goto end;
13764 }
13765
13766 buf_ptr = (uint8_t *)wmi_buf_data(buf);
13767 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
13768 buf_ptr;
13769
13770 WMITLV_SET_HDR(&cmd->tlv_header,
13771 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
13772 WMITLV_GET_STRUCT_TLVLEN
13773 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
13774 cmd->pdev_id = param->pdev_id;
13775 cmd->requestor_id = param->requestor_id;
13776 cmd->disable_hw_ack = param->disable_hw_ack;
13777 cmd->cac_duration_ms = param->cac_duration_ms;
13778 cmd->num_vdevs = param->num_vdevs;
13779
13780 buf_ptr += sizeof(*cmd);
13781
13782 WMITLV_SET_HDR(buf_ptr,
13783 WMITLV_TAG_ARRAY_UINT32,
13784 sizeof(A_UINT32) * param->num_vdevs);
13785 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
13786 for (i = 0; i < param->num_vdevs; i++) {
13787 vdev_ids[i] = param->vdev_ids[i];
13788 }
13789
13790 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
13791
13792 WMITLV_SET_HDR(buf_ptr,
13793 WMITLV_TAG_STRUC_wmi_channel,
13794 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053013795 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053013796 tchan_info = &(param->ch_param);
13797 chan_info->mhz = tchan_info->mhz;
13798 chan_info->band_center_freq1 = tchan_info->cfreq1;
13799 chan_info->band_center_freq2 = tchan_info->cfreq2;
13800 if (tchan_info->is_chan_passive)
13801 WMI_SET_CHANNEL_FLAG(chan_info,
13802 WMI_CHAN_FLAG_PASSIVE);
13803 if (tchan_info->allow_vht)
13804 WMI_SET_CHANNEL_FLAG(chan_info,
13805 WMI_CHAN_FLAG_ALLOW_VHT);
13806 else if (tchan_info->allow_ht)
13807 WMI_SET_CHANNEL_FLAG(chan_info,
13808 WMI_CHAN_FLAG_ALLOW_HT);
13809 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
13810 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
13811 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
13812 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
13813 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
13814 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
13815
13816 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
13817 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
13818
13819 if (QDF_IS_STATUS_ERROR(qdf_status)) {
13820 WMI_LOGE("%s: Failed to send\n", __func__);
13821 wmi_buf_free(buf);
13822 }
13823
13824end:
13825 return qdf_status;
13826}
13827
13828/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080013829 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
13830 * @wmi_handle: wmi handle
13831 * @pdev_id: pdev id
13832 *
13833 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
13834 *
13835 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13836 */
13837static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
13838 uint32_t pdev_id)
13839{
13840 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
13841 wmi_buf_t buf;
13842 uint16_t len;
13843 QDF_STATUS ret;
13844
13845 len = sizeof(*cmd);
13846 buf = wmi_buf_alloc(wmi_handle, len);
13847
13848 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
13849
13850 if (!buf) {
13851 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13852 return QDF_STATUS_E_NOMEM;
13853 }
13854
13855 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
13856 wmi_buf_data(buf);
13857
13858 WMITLV_SET_HDR(&cmd->tlv_header,
13859 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
13860 WMITLV_GET_STRUCT_TLVLEN(
13861 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
13862
13863 cmd->pdev_id = pdev_id;
13864 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13865 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
13866 if (QDF_IS_STATUS_ERROR(ret)) {
13867 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
13868 __func__, ret, pdev_id);
13869 wmi_buf_free(buf);
13870 return QDF_STATUS_E_FAILURE;
13871 }
13872
13873 return QDF_STATUS_SUCCESS;
13874}
13875
13876/**
13877 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
13878 * @wmi_handle: wmi handle
13879 * @pdev_id: pdev id
13880 *
13881 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
13882 *
13883 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
13884 */
13885static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
13886 uint32_t pdev_id)
13887{
13888 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
13889 wmi_buf_t buf;
13890 uint16_t len;
13891 QDF_STATUS ret;
13892
13893 len = sizeof(*cmd);
13894 buf = wmi_buf_alloc(wmi_handle, len);
13895
13896 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
13897
13898 if (!buf) {
13899 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13900 return QDF_STATUS_E_NOMEM;
13901 }
13902
13903 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
13904 wmi_buf_data(buf);
13905
13906 WMITLV_SET_HDR(&cmd->tlv_header,
13907 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
13908 WMITLV_GET_STRUCT_TLVLEN(
13909 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
13910
13911 cmd->pdev_id = pdev_id;
13912 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13913 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
13914 if (QDF_IS_STATUS_ERROR(ret)) {
13915 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
13916 __func__, ret, pdev_id);
13917 wmi_buf_free(buf);
13918 return QDF_STATUS_E_FAILURE;
13919 }
13920
13921 return QDF_STATUS_SUCCESS;
13922}
13923
13924/**
Govind Singhe7f2f342016-05-23 12:12:52 +053013925 * init_cmd_send_tlv() - send initialization cmd to fw
13926 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053013927 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053013928 *
13929 * Return: QDF_STATUS_SUCCESS for success or error code
13930 */
13931static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053013932 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053013933{
13934 wmi_buf_t buf;
13935 wmi_init_cmd_fixed_param *cmd;
13936 wmi_abi_version my_vers;
13937 int num_whitelist;
13938 uint8_t *buf_ptr;
13939 wmi_resource_config *resource_cfg;
13940 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053013941 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053013942 uint16_t idx;
13943 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053013944 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053013945
Kiran Venkatappa26117052016-12-23 19:58:54 +053013946 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
13947 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053013948 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053013949
13950 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
13951 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
13952 WMI_TLV_HDR_SIZE +
13953 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
13954
13955 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053013956 if (!buf) {
13957 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
13958 return QDF_STATUS_E_FAILURE;
13959 }
13960
13961 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13962 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
13963 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
13964
13965 host_mem_chunks = (wlan_host_memory_chunk *)
13966 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
13967 + WMI_TLV_HDR_SIZE);
13968
13969 WMITLV_SET_HDR(&cmd->tlv_header,
13970 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
13971 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
13972
Kiran Venkatappa26117052016-12-23 19:58:54 +053013973 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053013974 WMITLV_SET_HDR(&resource_cfg->tlv_header,
13975 WMITLV_TAG_STRUC_wmi_resource_config,
13976 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
13977
Kiran Venkatappa26117052016-12-23 19:58:54 +053013978 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053013979 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
13980 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
13981 WMITLV_GET_STRUCT_TLVLEN
13982 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053013983 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
13984 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
13985 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053013986 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
13987 idx, host_mem_chunks[idx].size,
13988 host_mem_chunks[idx].ptr);
13989 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053013990 cmd->num_host_mem_chunks = param->num_mem_chunks;
13991 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
13992
Govind Singhe7f2f342016-05-23 12:12:52 +053013993 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
13994 WMITLV_TAG_ARRAY_STRUC,
13995 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053013996 param->num_mem_chunks));
13997
13998 /* Fill hw mode id config */
13999 buf_ptr = copy_hw_mode_in_init_cmd(buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053014000
14001 num_whitelist = sizeof(version_whitelist) /
14002 sizeof(wmi_whitelist_version_info);
14003 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
14004 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
14005 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
14006 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
14007 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
14008 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
14009
Govind Singh87542482016-06-08 19:40:11 +053014010#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014011 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
14012 &my_vers,
14013 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
14014 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053014015#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053014016 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
14017 __func__,
14018 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
14019 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
14020 cmd->host_abi_vers.abi_version_ns_0,
14021 cmd->host_abi_vers.abi_version_ns_1,
14022 cmd->host_abi_vers.abi_version_ns_2,
14023 cmd->host_abi_vers.abi_version_ns_3);
14024
14025 /* Save version sent from host -
14026 * Will be used to check ready event
14027 */
Govind Singh87542482016-06-08 19:40:11 +053014028#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014029 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
14030 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053014031#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053014032 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
14033 if (QDF_IS_STATUS_ERROR(ret)) {
14034 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
14035 ret);
14036 wmi_buf_free(buf);
14037 }
14038 return ret;
14039
Govind Singhe7f2f342016-05-23 12:12:52 +053014040}
14041
14042/**
14043 * save_service_bitmap_tlv() - save service bitmap
14044 * @wmi_handle: wmi handle
14045 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080014046 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053014047 *
14048 * Return: None
14049 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014050#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014051static
Rajeev Kumar77901472017-02-12 02:12:17 -080014052void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
14053 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053014054{
14055 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14056 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14057
14058 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
14059 param_buf->wmi_service_bitmap,
14060 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080014061
14062 if (bitmap_buf)
14063 qdf_mem_copy(bitmap_buf,
14064 param_buf->wmi_service_bitmap,
14065 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053014066}
14067#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014068static
Rajeev Kumar77901472017-02-12 02:12:17 -080014069void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
14070 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053014071{
Rajeev Kumar77901472017-02-12 02:12:17 -080014072 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14073 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053014074
Rajeev Kumar77901472017-02-12 02:12:17 -080014075 if (bitmap_buf)
14076 qdf_mem_copy(bitmap_buf,
14077 param_buf->wmi_service_bitmap,
14078 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
14079}
Govind Singhe7f2f342016-05-23 12:12:52 +053014080#endif
14081
14082/**
14083 * is_service_enabled_tlv() - Check if service enabled
14084 * @param wmi_handle: wmi handle
14085 * @param service_id: service identifier
14086 *
14087 * Return: 1 enabled, 0 disabled
14088 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014089#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014090static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
14091 uint32_t service_id)
14092{
14093 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
14094 service_id);
14095}
14096#else
14097static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
14098 uint32_t service_id)
14099{
14100 return false;
14101}
14102#endif
14103
14104/**
14105 * extract_service_ready_tlv() - extract service ready event
14106 * @wmi_handle: wmi handle
14107 * @param evt_buf: pointer to received event buffer
14108 * @param cap: pointer to hold target capability information extracted from even
14109 *
14110 * Return: QDF_STATUS_SUCCESS for success or error code
14111 */
14112static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014113 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053014114{
14115 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14116 wmi_service_ready_event_fixed_param *ev;
14117
14118
14119 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14120
14121 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14122 if (!ev) {
14123 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14124 return QDF_STATUS_E_FAILURE;
14125 }
14126
14127 cap->phy_capability = ev->phy_capability;
14128 cap->max_frag_entry = ev->max_frag_entry;
14129 cap->num_rf_chains = ev->num_rf_chains;
14130 cap->ht_cap_info = ev->ht_cap_info;
14131 cap->vht_cap_info = ev->vht_cap_info;
14132 cap->vht_supp_mcs = ev->vht_supp_mcs;
14133 cap->hw_min_tx_power = ev->hw_min_tx_power;
14134 cap->hw_max_tx_power = ev->hw_max_tx_power;
14135 cap->sys_cap_info = ev->sys_cap_info;
14136 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
14137 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
14138 cap->max_num_scan_channels = ev->max_num_scan_channels;
14139 cap->max_supported_macs = ev->max_supported_macs;
14140 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
14141 cap->txrx_chainmask = ev->txrx_chainmask;
14142 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
14143 cap->num_msdu_desc = ev->num_msdu_desc;
14144
14145 return QDF_STATUS_SUCCESS;
14146}
14147
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014148/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
14149 * to host internal WMI_HOST_REGDMN_MODE values.
14150 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
14151 * host currently. Add this in the future if required.
14152 * 11AX (Phase II) : 11ax related values are not currently
14153 * advertised separately by FW. As part of phase II regulatory bring-up,
14154 * finalize the advertisement mechanism.
14155 * @target_wireless_mode: target wireless mode received in message
14156 *
14157 * Return: returns the host internal wireless mode.
14158 */
14159static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
14160{
14161
14162 uint32_t wireless_modes = 0;
14163
14164 if (target_wireless_mode & REGDMN_MODE_11A)
14165 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
14166
14167 if (target_wireless_mode & REGDMN_MODE_TURBO)
14168 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
14169
14170 if (target_wireless_mode & REGDMN_MODE_11B)
14171 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
14172
14173 if (target_wireless_mode & REGDMN_MODE_PUREG)
14174 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
14175
14176 if (target_wireless_mode & REGDMN_MODE_11G)
14177 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
14178
14179 if (target_wireless_mode & REGDMN_MODE_108G)
14180 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
14181
14182 if (target_wireless_mode & REGDMN_MODE_108A)
14183 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
14184
14185 if (target_wireless_mode & REGDMN_MODE_XR)
14186 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
14187
14188 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
14189 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
14190
14191 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
14192 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
14193
14194 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
14195 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
14196
14197 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
14198 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
14199
14200 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
14201 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
14202
14203 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
14204 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
14205
14206 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
14207 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
14208
14209 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
14210 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
14211
14212 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
14213 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
14214
14215 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
14216 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
14217
14218 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
14219 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
14220
14221 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
14222 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
14223
14224 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
14225 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
14226
14227 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
14228 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
14229
14230 return wireless_modes;
14231}
14232
Govind Singhe7f2f342016-05-23 12:12:52 +053014233/**
14234 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
14235 * @wmi_handle: wmi handle
14236 * @param evt_buf: Pointer to event buffer
14237 * @param cap: pointer to hold HAL reg capabilities
14238 *
14239 * Return: QDF_STATUS_SUCCESS for success or error code
14240 */
14241static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014242 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053014243{
14244 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14245
14246 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14247
14248 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
14249 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080014250 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053014251
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014252 cap->wireless_modes = convert_wireless_modes_tlv(
14253 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053014254
Govind Singhe7f2f342016-05-23 12:12:52 +053014255 return QDF_STATUS_SUCCESS;
14256}
14257
14258/**
14259 * extract_host_mem_req_tlv() - Extract host memory request event
14260 * @wmi_handle: wmi handle
14261 * @param evt_buf: pointer to event buffer
14262 * @param num_entries: pointer to hold number of entries requested
14263 *
14264 * Return: Number of entries requested
14265 */
14266static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
14267 void *evt_buf, uint8_t *num_entries)
14268{
14269 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14270 wmi_service_ready_event_fixed_param *ev;
14271
14272 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14273
14274 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14275 if (!ev) {
14276 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14277 return NULL;
14278 }
14279
14280 *num_entries = ev->num_mem_reqs;
14281
14282 return (host_mem_req *)param_buf->mem_reqs;
14283}
14284
14285/**
14286 * save_fw_version_in_service_ready_tlv() - Save fw version in service
14287 * ready function
14288 * @wmi_handle: wmi handle
14289 * @param evt_buf: pointer to event buffer
14290 *
14291 * Return: QDF_STATUS_SUCCESS for success or error code
14292 */
14293static QDF_STATUS
14294save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
14295{
14296 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14297 wmi_service_ready_event_fixed_param *ev;
14298
14299
14300 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14301
14302 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14303 if (!ev) {
14304 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14305 return QDF_STATUS_E_FAILURE;
14306 }
14307
Govind Singh87542482016-06-08 19:40:11 +053014308#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014309 /*Save fw version from service ready message */
14310 /*This will be used while sending INIT message */
14311 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
14312 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053014313#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053014314 return QDF_STATUS_SUCCESS;
14315}
14316
14317/**
14318 * ready_extract_init_status_tlv() - Extract init status from ready event
14319 * @wmi_handle: wmi handle
14320 * @param evt_buf: Pointer to event buffer
14321 *
14322 * Return: ready status
14323 */
14324static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
14325 void *evt_buf)
14326{
14327 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
14328 wmi_ready_event_fixed_param *ev = NULL;
14329
14330
14331 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
14332 ev = param_buf->fixed_param;
14333
14334 qdf_print("%s:%d\n", __func__, ev->status);
14335
14336 return ev->status;
14337}
14338
14339/**
14340 * ready_extract_mac_addr_tlv() - extract mac address from ready event
14341 * @wmi_handle: wmi handle
14342 * @param evt_buf: pointer to event buffer
14343 * @param macaddr: Pointer to hold MAC address
14344 *
14345 * Return: QDF_STATUS_SUCCESS for success or error code
14346 */
14347static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
14348 void *evt_buf, uint8_t *macaddr)
14349{
14350 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
14351 wmi_ready_event_fixed_param *ev = NULL;
14352
14353
14354 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
14355 ev = param_buf->fixed_param;
14356
14357 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
14358
14359 return QDF_STATUS_SUCCESS;
14360}
14361
14362/**
14363 * extract_dbglog_data_len_tlv() - extract debuglog data length
14364 * @wmi_handle: wmi handle
14365 * @param evt_buf: pointer to event buffer
14366 *
14367 * Return: length
14368 */
14369static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080014370 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053014371{
14372 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
14373
14374 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
14375
14376 *len = param_buf->num_bufp;
14377
14378 return param_buf->bufp;
14379}
14380
14381/**
14382 * extract_vdev_start_resp_tlv() - extract vdev start response
14383 * @wmi_handle: wmi handle
14384 * @param evt_buf: pointer to event buffer
14385 * @param vdev_rsp: Pointer to hold vdev response
14386 *
14387 * Return: QDF_STATUS_SUCCESS for success or error code
14388 */
14389static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
14390 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
14391{
14392 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
14393 wmi_vdev_start_response_event_fixed_param *ev;
14394
14395 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
14396 if (!param_buf) {
14397 qdf_print("Invalid start response event buffer\n");
14398 return QDF_STATUS_E_INVAL;
14399 }
14400
14401 ev = param_buf->fixed_param;
14402 if (!ev) {
14403 qdf_print("Invalid start response event buffer\n");
14404 return QDF_STATUS_E_INVAL;
14405 }
14406
14407 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
14408
14409 vdev_rsp->vdev_id = ev->vdev_id;
14410 vdev_rsp->requestor_id = ev->requestor_id;
14411 vdev_rsp->resp_type = ev->resp_type;
14412 vdev_rsp->status = ev->status;
14413 vdev_rsp->chain_mask = ev->chain_mask;
14414 vdev_rsp->smps_mode = ev->smps_mode;
14415 vdev_rsp->mac_id = ev->mac_id;
14416 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
14417 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
14418
14419 return QDF_STATUS_SUCCESS;
14420}
14421
14422/**
14423 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
14424 * @wmi_handle: wmi handle
14425 * @param evt_buf: pointer to event buffer
14426 * @param vdev_map: Pointer to hold vdev map
14427 * @param tbttoffset_list: Pointer to tbtt offset list
14428 *
14429 * Return: QDF_STATUS_SUCCESS for success or error code
14430 */
14431static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
14432 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
14433{
14434 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
14435 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
14436
14437 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
14438 if (!param_buf) {
14439 qdf_print("Invalid tbtt update event buffer\n");
14440 return QDF_STATUS_E_INVAL;
14441 }
14442 tbtt_offset_event = param_buf->fixed_param;
14443
14444 *vdev_map = tbtt_offset_event->vdev_map;
14445 *tbttoffset_list = param_buf->tbttoffset_list;
14446
14447 return QDF_STATUS_SUCCESS;
14448}
14449
14450/**
14451 * extract_mgmt_rx_params_tlv() - extract management rx params from event
14452 * @wmi_handle: wmi handle
14453 * @param evt_buf: pointer to event buffer
14454 * @param hdr: Pointer to hold header
14455 * @param bufp: Pointer to hold pointer to rx param buffer
14456 *
14457 * Return: QDF_STATUS_SUCCESS for success or error code
14458 */
14459static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053014460 void *evt_buf, struct mgmt_rx_event_params *hdr,
14461 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053014462{
14463 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
14464 wmi_mgmt_rx_hdr *ev_hdr = NULL;
14465
14466 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
14467 if (!param_tlvs) {
14468 WMI_LOGE("Get NULL point message from FW");
14469 return QDF_STATUS_E_INVAL;
14470 }
14471
14472 ev_hdr = param_tlvs->hdr;
14473 if (!hdr) {
14474 WMI_LOGE("Rx event is NULL");
14475 return QDF_STATUS_E_INVAL;
14476 }
14477
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053014478 hdr->pdev_id = ev_hdr->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014479
14480 hdr->channel = ev_hdr->channel;
14481 hdr->snr = ev_hdr->snr;
14482 hdr->rate = ev_hdr->rate;
14483 hdr->phy_mode = ev_hdr->phy_mode;
14484 hdr->buf_len = ev_hdr->buf_len;
14485 hdr->status = ev_hdr->status;
14486 hdr->flags = ev_hdr->flags;
14487 hdr->rssi = ev_hdr->rssi;
14488 hdr->tsf_delta = ev_hdr->tsf_delta;
14489 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
14490
14491 *bufp = param_tlvs->bufp;
14492
14493 return QDF_STATUS_SUCCESS;
14494}
14495
14496/**
14497 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
14498 * @wmi_handle: wmi handle
14499 * @param evt_buf: pointer to event buffer
14500 * @param vdev_id: Pointer to hold vdev identifier
14501 *
14502 * Return: QDF_STATUS_SUCCESS for success or error code
14503 */
14504static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
14505 void *evt_buf, uint32_t *vdev_id)
14506{
14507 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
14508 wmi_vdev_stopped_event_fixed_param *resp_event;
14509
14510 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
14511 if (!param_buf) {
14512 WMI_LOGE("Invalid event buffer");
14513 return QDF_STATUS_E_INVAL;
14514 }
14515 resp_event = param_buf->fixed_param;
14516 *vdev_id = resp_event->vdev_id;
14517
14518 return QDF_STATUS_SUCCESS;
14519}
14520
14521/**
14522 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
14523 * @wmi_handle: wmi handle
14524 * @param evt_buf: pointer to event buffer
14525 * @param param: Pointer to hold roam param
14526 *
14527 * Return: QDF_STATUS_SUCCESS for success or error code
14528 */
14529static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
14530 void *evt_buf, wmi_host_roam_event *param)
14531{
14532 WMI_ROAM_EVENTID_param_tlvs *param_buf;
14533 wmi_roam_event_fixed_param *evt;
14534
14535 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
14536 if (!param_buf) {
14537 WMI_LOGE("Invalid roam event buffer");
14538 return QDF_STATUS_E_INVAL;
14539 }
14540
14541 evt = param_buf->fixed_param;
14542 qdf_mem_zero(param, sizeof(*param));
14543
14544 param->vdev_id = evt->vdev_id;
14545 param->reason = evt->reason;
14546 param->rssi = evt->rssi;
14547
14548 return QDF_STATUS_SUCCESS;
14549}
14550
14551/**
14552 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
14553 * @wmi_handle: wmi handle
14554 * @param evt_buf: pointer to event buffer
14555 * @param param: Pointer to hold vdev scan param
14556 *
14557 * Return: QDF_STATUS_SUCCESS for success or error code
14558 */
14559static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
14560 void *evt_buf, wmi_host_scan_event *param)
14561{
14562 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
14563 wmi_scan_event_fixed_param *evt = NULL;
14564
14565 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
14566 evt = param_buf->fixed_param;
14567
14568 qdf_mem_zero(param, sizeof(*param));
14569 switch (evt->event) {
14570 case WMI_SCAN_EVENT_STARTED:
14571 param->event = WMI_HOST_SCAN_EVENT_STARTED;
14572 break;
14573 case WMI_SCAN_EVENT_COMPLETED:
14574 param->event = WMI_HOST_SCAN_EVENT_COMPLETED;
14575 break;
14576 case WMI_SCAN_EVENT_BSS_CHANNEL:
14577 param->event = WMI_HOST_SCAN_EVENT_BSS_CHANNEL;
14578 break;
14579 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
14580 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL;
14581 break;
14582 case WMI_SCAN_EVENT_DEQUEUED:
14583 param->event = WMI_HOST_SCAN_EVENT_DEQUEUED;
14584 break;
14585 case WMI_SCAN_EVENT_PREEMPTED:
14586 param->event = WMI_HOST_SCAN_EVENT_PREEMPTED;
14587 break;
14588 case WMI_SCAN_EVENT_START_FAILED:
14589 param->event = WMI_HOST_SCAN_EVENT_START_FAILED;
14590 break;
14591 case WMI_SCAN_EVENT_RESTARTED:
14592 param->event = WMI_HOST_SCAN_EVENT_RESTARTED;
14593 break;
14594 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
14595 param->event = WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
14596 break;
14597 case WMI_SCAN_EVENT_MAX:
14598 default:
14599 param->event = WMI_HOST_SCAN_EVENT_MAX;
14600 break;
14601 };
14602
14603 switch (evt->reason) {
14604 case WMI_SCAN_REASON_NONE:
14605 param->reason = WMI_HOST_SCAN_REASON_NONE;
14606 break;
14607 case WMI_SCAN_REASON_COMPLETED:
14608 param->reason = WMI_HOST_SCAN_REASON_COMPLETED;
14609 break;
14610 case WMI_SCAN_REASON_CANCELLED:
14611 param->reason = WMI_HOST_SCAN_REASON_CANCELLED;
14612 break;
14613 case WMI_SCAN_REASON_PREEMPTED:
14614 param->reason = WMI_HOST_SCAN_REASON_PREEMPTED;
14615 break;
14616 case WMI_SCAN_REASON_TIMEDOUT:
14617 param->reason = WMI_HOST_SCAN_REASON_TIMEDOUT;
14618 break;
14619 case WMI_SCAN_REASON_INTERNAL_FAILURE:
14620 param->reason = WMI_HOST_SCAN_REASON_INTERNAL_FAILURE;
14621 break;
14622 case WMI_SCAN_REASON_MAX:
14623 default:
14624 param->reason = WMI_HOST_SCAN_REASON_MAX;
14625 break;
14626 };
14627
14628 param->channel_freq = evt->channel_freq;
14629 param->requestor = evt->requestor;
14630 param->scan_id = evt->scan_id;
14631 param->vdev_id = evt->vdev_id;
14632
14633 return QDF_STATUS_SUCCESS;
14634}
14635
14636/**
14637 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
14638 * @wmi_handle: wmi handle
14639 * @param evt_buf: pointer to event buffer
14640 * @param param: Pointer to hold MGMT TX completion params
14641 *
14642 * Return: QDF_STATUS_SUCCESS for success or error code
14643 */
14644static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
14645 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
14646{
14647 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
14648 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
14649
14650 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
14651 evt_buf;
14652 if (!param_buf) {
14653 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
14654 return QDF_STATUS_E_INVAL;
14655 }
14656 cmpl_params = param_buf->fixed_param;
14657
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053014658 param->pdev_id = cmpl_params->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014659 param->desc_id = cmpl_params->desc_id;
14660 param->status = cmpl_params->status;
14661
14662 return QDF_STATUS_SUCCESS;
14663}
14664
14665/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014666 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
14667 * status tlv
14668 * @wmi_handle: wmi handle
14669 * @param evt_buf: pointer to event buffer
14670 * @param param: Pointer to hold csa switch count status event param
14671 *
14672 * Return: QDF_STATUS_SUCCESS for success or error code
14673 */
14674static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
14675 wmi_unified_t wmi_handle,
14676 void *evt_buf,
14677 struct pdev_csa_switch_count_status *param)
14678{
14679 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
14680 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
14681
14682 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
14683 evt_buf;
14684 if (!param_buf) {
14685 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
14686 return QDF_STATUS_E_INVAL;
14687 }
14688
14689 csa_status = param_buf->fixed_param;
14690
14691 param->pdev_id = csa_status->pdev_id;
14692 param->current_switch_count = csa_status->current_switch_count;
14693 param->num_vdevs = csa_status->num_vdevs;
14694 param->vdev_ids = param_buf->vdev_ids;
14695
14696 return QDF_STATUS_SUCCESS;
14697}
14698
14699/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014700 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
14701 * @wmi_handle: wmi handle
14702 * @param evt_buf: pointer to event buffer
14703 * @param vdev_map: Pointer to hold vdev map
14704 *
14705 * Return: QDF_STATUS_SUCCESS for success or error code
14706 */
14707static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
14708 void *evt_buf, uint32_t *vdev_map)
14709{
14710 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14711 wmi_host_swba_event_fixed_param *swba_event;
14712
14713 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14714 if (!param_buf) {
14715 WMI_LOGE("Invalid swba event buffer");
14716 return QDF_STATUS_E_INVAL;
14717 }
14718 swba_event = param_buf->fixed_param;
14719 *vdev_map = swba_event->vdev_map;
14720
14721 return QDF_STATUS_SUCCESS;
14722}
14723
14724/**
14725 * extract_swba_tim_info_tlv() - extract swba tim info from event
14726 * @wmi_handle: wmi handle
14727 * @param evt_buf: pointer to event buffer
14728 * @param idx: Index to bcn info
14729 * @param tim_info: Pointer to hold tim info
14730 *
14731 * Return: QDF_STATUS_SUCCESS for success or error code
14732 */
14733static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
14734 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
14735{
14736 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14737 wmi_tim_info *tim_info_ev;
14738
14739 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14740 if (!param_buf) {
14741 WMI_LOGE("Invalid swba event buffer");
14742 return QDF_STATUS_E_INVAL;
14743 }
14744
14745 tim_info_ev = &param_buf->tim_info[idx];
14746
14747 tim_info->tim_len = tim_info_ev->tim_len;
14748 tim_info->tim_mcast = tim_info_ev->tim_mcast;
14749 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
14750 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
14751 tim_info->tim_changed = tim_info_ev->tim_changed;
14752 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
14753
14754 return QDF_STATUS_SUCCESS;
14755}
14756
14757/**
14758 * extract_swba_noa_info_tlv() - extract swba NoA information from event
14759 * @wmi_handle: wmi handle
14760 * @param evt_buf: pointer to event buffer
14761 * @param idx: Index to bcn info
14762 * @param p2p_desc: Pointer to hold p2p NoA info
14763 *
14764 * Return: QDF_STATUS_SUCCESS for success or error code
14765 */
14766static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
14767 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
14768{
14769 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
14770 wmi_p2p_noa_info *p2p_noa_info;
14771 uint8_t i = 0;
14772
14773 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
14774 if (!param_buf) {
14775 WMI_LOGE("Invalid swba event buffer");
14776 return QDF_STATUS_E_INVAL;
14777 }
14778
14779 p2p_noa_info = &param_buf->p2p_noa_info[idx];
14780
14781 p2p_desc->modified = false;
14782 p2p_desc->num_descriptors = 0;
14783 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
14784 p2p_desc->modified = true;
14785 p2p_desc->index =
14786 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
14787 p2p_desc->oppPS =
14788 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
14789 p2p_desc->ctwindow =
14790 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
14791 p2p_desc->num_descriptors =
14792 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
14793 (p2p_noa_info);
14794 for (i = 0; i < p2p_desc->num_descriptors; i++) {
14795 p2p_desc->noa_descriptors[i].type_count =
14796 (uint8_t) p2p_noa_info->noa_descriptors[i].
14797 type_count;
14798 p2p_desc->noa_descriptors[i].duration =
14799 p2p_noa_info->noa_descriptors[i].duration;
14800 p2p_desc->noa_descriptors[i].interval =
14801 p2p_noa_info->noa_descriptors[i].interval;
14802 p2p_desc->noa_descriptors[i].start_time =
14803 p2p_noa_info->noa_descriptors[i].start_time;
14804 }
14805 }
14806
14807 return QDF_STATUS_SUCCESS;
14808}
14809
Wu Gaocd3a8512017-03-13 20:17:34 +080014810#ifdef CONVERGED_P2P_ENABLE
14811/**
14812 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
14813 * @wmi_handle: wmi handle
14814 * @param evt_buf: pointer to event buffer
14815 * @param param: Pointer to hold p2p noa info
14816 *
14817 * Return: QDF_STATUS_SUCCESS for success or error code
14818 */
14819static QDF_STATUS extract_p2p_noa_ev_param_tlv(
14820 wmi_unified_t wmi_handle, void *evt_buf,
14821 struct p2p_noa_info *param)
14822{
14823 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
14824 wmi_p2p_noa_event_fixed_param *fixed_param;
14825 uint8_t i;
14826 wmi_p2p_noa_info *wmi_noa_info;
14827 uint8_t *buf_ptr;
14828 uint32_t descriptors;
14829
14830 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
14831 if (!param_tlvs) {
14832 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
14833 return QDF_STATUS_E_INVAL;
14834 }
14835
14836 if (!param) {
14837 WMI_LOGE("noa information param is null");
14838 return QDF_STATUS_E_INVAL;
14839 }
14840
14841 fixed_param = param_tlvs->fixed_param;
14842 buf_ptr = (uint8_t *) fixed_param;
14843 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
14844 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
14845
14846 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
14847 WMI_LOGE("%s: noa attr is not modified", __func__);
14848 return QDF_STATUS_E_INVAL;
14849 }
14850
14851 param->vdev_id = fixed_param->vdev_id;
14852 param->index =
14853 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
14854 param->opps_ps =
14855 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
14856 param->ct_window =
14857 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
14858 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
14859 param->num_desc = (uint8_t) descriptors;
14860
14861 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
14862 param->index, param->opps_ps, param->ct_window,
14863 param->num_desc);
14864 for (i = 0; i < param->num_desc; i++) {
14865 param->noa_desc[i].type_count =
14866 (uint8_t) wmi_noa_info->noa_descriptors[i].
14867 type_count;
14868 param->noa_desc[i].duration =
14869 wmi_noa_info->noa_descriptors[i].duration;
14870 param->noa_desc[i].interval =
14871 wmi_noa_info->noa_descriptors[i].interval;
14872 param->noa_desc[i].start_time =
14873 wmi_noa_info->noa_descriptors[i].start_time;
14874 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
14875 __func__, i, param->noa_desc[i].type_count,
14876 param->noa_desc[i].duration,
14877 param->noa_desc[i].interval,
14878 param->noa_desc[i].start_time);
14879 }
14880
14881 return QDF_STATUS_SUCCESS;
14882}
14883
14884/**
14885 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
14886 * information from event
14887 * @wmi_handle: wmi handle
14888 * @param evt_buf: pointer to event buffer
14889 * @param param: Pointer to hold p2p lo stop event information
14890 *
14891 * Return: QDF_STATUS_SUCCESS for success or error code
14892 */
14893static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
14894 wmi_unified_t wmi_handle, void *evt_buf,
14895 struct p2p_lo_event *param)
14896{
14897 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
14898 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
14899
14900 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
14901 evt_buf;
14902 if (!param_tlvs) {
14903 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
14904 return QDF_STATUS_E_INVAL;
14905 }
14906
14907 if (!param) {
14908 WMI_LOGE("lo stop event param is null");
14909 return QDF_STATUS_E_INVAL;
14910 }
14911
14912 lo_param = param_tlvs->fixed_param;
14913 param->vdev_id = lo_param->vdev_id;
14914 param->reason_code = lo_param->reason;
14915 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
14916 param->vdev_id, param->reason_code);
14917
14918 return QDF_STATUS_SUCCESS;
14919}
14920#endif /* End of CONVERGED_P2P_ENABLE */
14921
Govind Singhe7f2f342016-05-23 12:12:52 +053014922/**
14923 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
14924 * @wmi_handle: wmi handle
14925 * @param evt_buf: pointer to event buffer
14926 * @param ev: Pointer to hold peer param
14927 *
14928 * Return: QDF_STATUS_SUCCESS for success or error code
14929 */
14930static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
14931 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
14932{
14933 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
14934 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
14935
14936 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
14937 kickout_event = param_buf->fixed_param;
14938
14939 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
14940 ev->peer_macaddr);
14941
14942 ev->reason = kickout_event->reason;
14943 ev->rssi = kickout_event->rssi;
14944
14945 return QDF_STATUS_SUCCESS;
14946}
14947
14948/**
14949 * extract_all_stats_counts_tlv() - extract all stats count from event
14950 * @wmi_handle: wmi handle
14951 * @param evt_buf: pointer to event buffer
14952 * @param stats_param: Pointer to hold stats count
14953 *
14954 * Return: QDF_STATUS_SUCCESS for success or error code
14955 */
14956static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
14957 void *evt_buf, wmi_host_stats_event *stats_param)
14958{
14959 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
14960 wmi_stats_event_fixed_param *ev;
14961
14962 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
14963
14964 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
14965 if (!ev) {
14966 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
14967 return QDF_STATUS_E_FAILURE;
14968 }
14969
14970 switch (ev->stats_id) {
14971 case WMI_REQUEST_PEER_STAT:
14972 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
14973 break;
14974
14975 case WMI_REQUEST_AP_STAT:
14976 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
14977 break;
14978
14979 case WMI_REQUEST_PDEV_STAT:
14980 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
14981 break;
14982
14983 case WMI_REQUEST_VDEV_STAT:
14984 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
14985 break;
14986
14987 case WMI_REQUEST_BCNFLT_STAT:
14988 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
14989 break;
14990
14991 case WMI_REQUEST_VDEV_RATE_STAT:
14992 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
14993 break;
14994
14995 default:
14996 stats_param->stats_id = 0;
14997 break;
14998
14999 }
15000
15001 stats_param->num_pdev_stats = ev->num_pdev_stats;
15002 stats_param->num_pdev_ext_stats = 0;
15003 stats_param->num_vdev_stats = ev->num_vdev_stats;
15004 stats_param->num_peer_stats = ev->num_peer_stats;
15005 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
15006 stats_param->num_chan_stats = ev->num_chan_stats;
15007
15008 return QDF_STATUS_SUCCESS;
15009}
15010
15011/**
15012 * extract_pdev_stats_tlv() - extract pdev stats from event
15013 * @wmi_handle: wmi handle
15014 * @param evt_buf: pointer to event buffer
15015 * @param index: Index into pdev stats
15016 * @param pdev_stats: Pointer to hold pdev stats
15017 *
15018 * Return: QDF_STATUS_SUCCESS for success or error code
15019 */
15020static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
15021 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
15022{
15023 return QDF_STATUS_SUCCESS;
15024}
15025
15026/**
15027 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
15028 * @wmi_handle: wmi handle
15029 * @param evt_buf: pointer to event buffer
15030 * @param index: Index into extended pdev stats
15031 * @param pdev_ext_stats: Pointer to hold extended pdev stats
15032 *
15033 * Return: QDF_STATUS_SUCCESS for success or error code
15034 */
15035static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
15036 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
15037{
15038 return QDF_STATUS_SUCCESS;
15039}
15040
15041/**
15042 * extract_vdev_stats_tlv() - extract vdev stats from event
15043 * @wmi_handle: wmi handle
15044 * @param evt_buf: pointer to event buffer
15045 * @param index: Index into vdev stats
15046 * @param vdev_stats: Pointer to hold vdev stats
15047 *
15048 * Return: QDF_STATUS_SUCCESS for success or error code
15049 */
15050static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
15051 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
15052{
15053 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15054 wmi_stats_event_fixed_param *ev_param;
15055 uint8_t *data;
15056
15057 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15058 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15059 data = (uint8_t *) param_buf->data;
15060
15061 if (index < ev_param->num_vdev_stats) {
15062 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
15063 ((ev_param->num_pdev_stats) *
15064 sizeof(wmi_pdev_stats)) +
15065 (index * sizeof(wmi_vdev_stats)));
15066
15067 vdev_stats->vdev_id = ev->vdev_id;
15068 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
15069 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
15070
15071 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
15072 sizeof(ev->tx_frm_cnt));
15073 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
15074 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
15075 ev->multiple_retry_cnt,
15076 sizeof(ev->multiple_retry_cnt));
15077 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
15078 sizeof(ev->fail_cnt));
15079 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
15080 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
15081 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
15082 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
15083 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
15084 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
15085 sizeof(ev->tx_rate_history));
15086 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
15087 sizeof(ev->bcn_rssi_history));
15088
15089 }
15090
15091 return QDF_STATUS_SUCCESS;
15092}
15093
15094/**
15095 * extract_peer_stats_tlv() - extract peer stats from event
15096 * @wmi_handle: wmi handle
15097 * @param evt_buf: pointer to event buffer
15098 * @param index: Index into peer stats
15099 * @param peer_stats: Pointer to hold peer stats
15100 *
15101 * Return: QDF_STATUS_SUCCESS for success or error code
15102 */
15103static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
15104 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
15105{
15106 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15107 wmi_stats_event_fixed_param *ev_param;
15108 uint8_t *data;
15109
15110 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15111 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15112 data = (uint8_t *) param_buf->data;
15113
15114 if (index < ev_param->num_peer_stats) {
15115 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
15116 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
15117 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
15118 (index * sizeof(wmi_peer_stats)));
15119
15120 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
15121
15122 OS_MEMCPY(&(peer_stats->peer_macaddr),
15123 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
15124
15125 peer_stats->peer_rssi = ev->peer_rssi;
15126 peer_stats->peer_tx_rate = ev->peer_tx_rate;
15127 peer_stats->peer_rx_rate = ev->peer_rx_rate;
15128 }
15129
15130 return QDF_STATUS_SUCCESS;
15131}
15132
15133/**
15134 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
15135 * @wmi_handle: wmi handle
15136 * @param evt_buf: pointer to event buffer
15137 * @param index: Index into bcn fault stats
15138 * @param bcnflt_stats: Pointer to hold bcn fault stats
15139 *
15140 * Return: QDF_STATUS_SUCCESS for success or error code
15141 */
15142static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
15143 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
15144{
15145 return QDF_STATUS_SUCCESS;
15146}
15147
15148/**
15149 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
15150 * @wmi_handle: wmi handle
15151 * @param evt_buf: pointer to event buffer
15152 * @param index: Index into extended peer stats
15153 * @param peer_extd_stats: Pointer to hold extended peer stats
15154 *
15155 * Return: QDF_STATUS_SUCCESS for success or error code
15156 */
15157static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
15158 void *evt_buf, uint32_t index,
15159 wmi_host_peer_extd_stats *peer_extd_stats)
15160{
15161 return QDF_STATUS_SUCCESS;
15162}
15163
15164/**
15165 * extract_chan_stats_tlv() - extract chan stats from event
15166 * @wmi_handle: wmi handle
15167 * @param evt_buf: pointer to event buffer
15168 * @param index: Index into chan stats
15169 * @param vdev_extd_stats: Pointer to hold chan stats
15170 *
15171 * Return: QDF_STATUS_SUCCESS for success or error code
15172 */
15173static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
15174 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
15175{
15176 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15177 wmi_stats_event_fixed_param *ev_param;
15178 uint8_t *data;
15179
15180 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15181 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15182 data = (uint8_t *) param_buf->data;
15183
15184 if (index < ev_param->num_chan_stats) {
15185 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
15186 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
15187 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
15188 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
15189 (index * sizeof(wmi_chan_stats)));
15190
15191
15192 /* Non-TLV doesnt have num_chan_stats */
15193 chan_stats->chan_mhz = ev->chan_mhz;
15194 chan_stats->sampling_period_us = ev->sampling_period_us;
15195 chan_stats->rx_clear_count = ev->rx_clear_count;
15196 chan_stats->tx_duration_us = ev->tx_duration_us;
15197 chan_stats->rx_duration_us = ev->rx_duration_us;
15198 }
15199
15200 return QDF_STATUS_SUCCESS;
15201}
15202
15203/**
15204 * extract_profile_ctx_tlv() - extract profile context from event
15205 * @wmi_handle: wmi handle
15206 * @param evt_buf: pointer to event buffer
15207 * @idx: profile stats index to extract
15208 * @param profile_ctx: Pointer to hold profile context
15209 *
15210 * Return: QDF_STATUS_SUCCESS for success or error code
15211 */
15212static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
15213 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
15214{
15215 return QDF_STATUS_SUCCESS;
15216}
15217
15218/**
15219 * extract_profile_data_tlv() - extract profile data from event
15220 * @wmi_handle: wmi handle
15221 * @param evt_buf: pointer to event buffer
15222 * @param profile_data: Pointer to hold profile data
15223 *
15224 * Return: QDF_STATUS_SUCCESS for success or error code
15225 */
15226static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
15227 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
15228{
15229
15230 return QDF_STATUS_SUCCESS;
15231}
15232
15233/**
15234 * extract_chan_info_event_tlv() - extract chan information from event
15235 * @wmi_handle: wmi handle
15236 * @param evt_buf: pointer to event buffer
15237 * @param chan_info: Pointer to hold chan information
15238 *
15239 * Return: QDF_STATUS_SUCCESS for success or error code
15240 */
15241static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
15242 void *evt_buf, wmi_host_chan_info_event *chan_info)
15243{
15244 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
15245 wmi_chan_info_event_fixed_param *ev;
15246
15247 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
15248
15249 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
15250 if (!ev) {
15251 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
15252 return QDF_STATUS_E_FAILURE;
15253 }
15254
15255 chan_info->err_code = ev->err_code;
15256 chan_info->freq = ev->freq;
15257 chan_info->cmd_flags = ev->cmd_flags;
15258 chan_info->noise_floor = ev->noise_floor;
15259 chan_info->rx_clear_count = ev->rx_clear_count;
15260 chan_info->cycle_count = ev->cycle_count;
15261
15262 return QDF_STATUS_SUCCESS;
15263}
15264
15265/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015266 * extract_pdev_utf_event_tlv() - extract UTF data info from event
15267 * @wmi_handle: WMI handle
15268 * @param evt_buf: Pointer to event buffer
15269 * @param param: Pointer to hold data
15270 *
15271 * Return : QDF_STATUS_SUCCESS for success or error code
15272 */
15273static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
15274 uint8_t *evt_buf,
15275 struct wmi_host_pdev_utf_event *event)
15276{
15277 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
15278
15279 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
15280 event->data = param_buf->data;
15281 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053015282 /* Set pdev_id=1 until FW adds support to include pdev_id */
15283 event->pdev_id = 1;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015284
15285 return QDF_STATUS_SUCCESS;
15286}
Govind Singhe7f2f342016-05-23 12:12:52 +053015287
Kiran Venkatappa06520822016-08-10 23:55:40 +053015288/**
15289 * extract_service_ready_ext_tlv() - extract basic extended service ready params
15290 * from event
15291 * @wmi_handle: wmi handle
15292 * @param evt_buf: pointer to event buffer
15293 * @param param: Pointer to hold evt buf
15294 *
15295 * Return: QDF_STATUS_SUCCESS for success or error code
15296 */
15297static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015298 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015299{
15300 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
15301 wmi_service_ready_ext_event_fixed_param *ev;
15302 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
15303 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
15304
15305 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15306 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015307 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015308
15309 ev = param_buf->fixed_param;
15310 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015311 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015312
15313 /* Move this to host based bitmap */
15314 param->default_conc_scan_config_bits =
15315 ev->default_conc_scan_config_bits;
15316 param->default_fw_config_bits = ev->default_fw_config_bits;
15317 param->he_cap_info = ev->he_cap_info;
15318 param->mpdu_density = ev->mpdu_density;
15319 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
15320 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
15321
15322 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015323 if (hw_caps)
15324 param->num_hw_modes = hw_caps->num_hw_modes;
15325 else
15326 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015327
15328 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015329 if (reg_caps)
15330 param->num_phy = reg_caps->num_phy;
15331 else
15332 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015333
15334 return QDF_STATUS_SUCCESS;
15335}
15336
15337/**
15338 * extract_hw_mode_cap_service_ready_ext_tlv() -
15339 * extract HW mode cap from service ready event
15340 * @wmi_handle: wmi handle
15341 * @param evt_buf: pointer to event buffer
15342 * @param param: Pointer to hold evt buf
15343 * @param hw_mode_idx: hw mode idx should be less than num_mode
15344 *
15345 * Return: QDF_STATUS_SUCCESS for success or error code
15346 */
15347static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
15348 wmi_unified_t wmi_handle,
15349 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015350 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015351{
15352 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
15353 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
15354
15355 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15356 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015357 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015358
15359 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015360 if (!hw_caps)
15361 return QDF_STATUS_E_INVAL;
15362
Kiran Venkatappa06520822016-08-10 23:55:40 +053015363 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015364 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015365
15366 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
15367 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
15368
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015369 param->hw_mode_config_type =
15370 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
15371
Kiran Venkatappa06520822016-08-10 23:55:40 +053015372 return QDF_STATUS_SUCCESS;
15373}
15374
15375/**
15376 * extract_mac_phy_cap_service_ready_ext_tlv() -
15377 * extract MAC phy cap from service ready event
15378 * @wmi_handle: wmi handle
15379 * @param evt_buf: pointer to event buffer
15380 * @param param: Pointer to hold evt buf
15381 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015382 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053015383 *
15384 * Return: QDF_STATUS_SUCCESS for success or error code
15385 */
15386static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
15387 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015388 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015389 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015390{
15391 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015392 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015393 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
15394 uint32_t phy_map;
15395 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015396
15397 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15398 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015399 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015400
15401 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015402 if (!hw_caps)
15403 return QDF_STATUS_E_INVAL;
15404
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015405 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
15406 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
15407 break;
15408
15409 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
15410 while (phy_map) {
15411 phy_map >>= 1;
15412 phy_idx++;
15413 }
15414 }
15415
15416 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015417 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015418
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015419 phy_idx += phy_id;
15420 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015421 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015422
15423 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053015424
15425 param->hw_mode_id = mac_phy_caps->hw_mode_id;
15426 param->pdev_id = mac_phy_caps->pdev_id;
15427 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015428 param->supports_11b =
15429 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
15430 param->supports_11g =
15431 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
15432 param->supports_11a =
15433 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
15434 param->supports_11n =
15435 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
15436 param->supports_11ac =
15437 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
15438 param->supports_11ax =
15439 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053015440
15441 param->supported_bands = mac_phy_caps->supported_bands;
15442 param->ampdu_density = mac_phy_caps->ampdu_density;
15443 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
15444 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
15445 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
15446 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
15447 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
15448 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
15449 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
15450 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
15451 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
15452 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
15453 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
15454 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
15455 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
15456 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
15457 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
15458 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080015459 qdf_mem_copy(&param->he_cap_phy_info_2G,
15460 &mac_phy_caps->he_cap_phy_info_2G,
15461 sizeof(param->he_cap_phy_info_2G));
15462 qdf_mem_copy(&param->he_cap_phy_info_5G,
15463 &mac_phy_caps->he_cap_phy_info_5G,
15464 sizeof(param->he_cap_phy_info_5G));
15465 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
15466 sizeof(param->he_ppet2G));
15467 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
15468 sizeof(param->he_ppet5G));
Kiran Venkatappa06520822016-08-10 23:55:40 +053015469
15470 return QDF_STATUS_SUCCESS;
15471}
15472
15473/**
15474 * extract_reg_cap_service_ready_ext_tlv() -
15475 * extract REG cap from service ready event
15476 * @wmi_handle: wmi handle
15477 * @param evt_buf: pointer to event buffer
15478 * @param param: Pointer to hold evt buf
15479 * @param phy_idx: phy idx should be less than num_mode
15480 *
15481 * Return: QDF_STATUS_SUCCESS for success or error code
15482 */
15483static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
15484 wmi_unified_t wmi_handle,
15485 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015486 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015487{
15488 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
15489 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
15490 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
15491
15492 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15493 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015494 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015495
15496 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015497 if (!reg_caps)
15498 return QDF_STATUS_E_INVAL;
15499
Kiran Venkatappa06520822016-08-10 23:55:40 +053015500 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015501 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015502
15503 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
15504
15505 param->phy_id = ext_reg_cap->phy_id;
15506 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
15507 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
15508 param->regcap1 = ext_reg_cap->regcap1;
15509 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015510 param->wireless_modes = convert_wireless_modes_tlv(
15511 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053015512 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
15513 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
15514 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
15515 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
15516
15517 return QDF_STATUS_SUCCESS;
15518}
15519
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015520/**
15521 * extract_dcs_interference_type_tlv() - extract dcs interference type
15522 * from event
15523 * @wmi_handle: wmi handle
15524 * @param evt_buf: pointer to event buffer
15525 * @param param: Pointer to hold dcs interference param
15526 *
15527 * Return: 0 for success or error code
15528 */
15529static QDF_STATUS extract_dcs_interference_type_tlv(
15530 wmi_unified_t wmi_handle,
15531 void *evt_buf, struct wmi_host_dcs_interference_param *param)
15532{
15533 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
15534
15535 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
15536 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015537 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015538
15539 param->interference_type = param_buf->fixed_param->interference_type;
15540 param->pdev_id = param_buf->fixed_param->pdev_id;
15541
15542 return QDF_STATUS_SUCCESS;
15543}
15544
15545/*
15546 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
15547 * @wmi_handle: wmi handle
15548 * @param evt_buf: pointer to event buffer
15549 * @param cw_int: Pointer to hold cw interference
15550 *
15551 * Return: 0 for success or error code
15552 */
15553static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
15554 void *evt_buf,
15555 wmi_host_ath_dcs_cw_int *cw_int)
15556{
15557 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
15558 wlan_dcs_cw_int *ev;
15559
15560 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
15561 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015562 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015563
15564 ev = param_buf->cw_int;
15565
15566 cw_int->channel = ev->channel;
15567
15568 return QDF_STATUS_SUCCESS;
15569}
15570
15571/**
15572 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
15573 * @wmi_handle: wmi handle
15574 * @param evt_buf: pointer to event buffer
15575 * @param wlan_stat: Pointer to hold wlan stats
15576 *
15577 * Return: 0 for success or error code
15578 */
15579static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
15580 void *evt_buf,
15581 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
15582{
15583 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
15584 wlan_dcs_im_tgt_stats_t *ev;
15585
15586 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
15587 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015588 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053015589
15590 ev = param_buf->wlan_stat;
15591 wlan_stat->reg_tsf32 = ev->reg_tsf32;
15592 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
15593 wlan_stat->tx_waste_time = ev->tx_waste_time;
15594 wlan_stat->rx_time = ev->rx_time;
15595 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
15596 wlan_stat->mib_stats.listen_time = ev->listen_time;
15597 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
15598 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
15599 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
15600 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
15601 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
15602 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
15603 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
15604 wlan_stat->chan_nf = ev->chan_nf;
15605 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
15606
15607 return QDF_STATUS_SUCCESS;
15608}
15609
Kiran Venkatappac813ec92016-12-29 22:07:14 +053015610#ifdef BIG_ENDIAN_HOST
15611/**
15612 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
15613 * @param data_len - data length
15614 * @param data - pointer to data
15615 *
15616 * Return: QDF_STATUS - success or error status
15617 */
15618static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
15619{
15620 uint8_t *data_aligned = NULL;
15621 int c;
15622 unsigned char *data_unaligned;
15623
15624 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
15625 FIPS_ALIGN));
15626 /* Assigning unaligned space to copy the data */
15627 /* Checking if kmalloc does succesful allocation */
15628 if (data_unaligned == NULL)
15629 return QDF_STATUS_E_FAILURE;
15630
15631 /* Checking if space is alligned */
15632 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
15633 /* align the data space */
15634 data_aligned =
15635 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
15636 } else {
15637 data_aligned = (u_int8_t *)data_unaligned;
15638 }
15639
15640 /* memset and copy content from data to data aligned */
15641 OS_MEMSET(data_aligned, 0, data_len);
15642 OS_MEMCPY(data_aligned, data, data_len);
15643 /* Endianness to LE */
15644 for (c = 0; c < data_len/4; c++) {
15645 *((u_int32_t *)data_aligned + c) =
15646 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
15647 }
15648
15649 /* Copy content to event->data */
15650 OS_MEMCPY(data, data_aligned, data_len);
15651
15652 /* clean up allocated space */
15653 qdf_mem_free(data_unaligned);
15654 data_aligned = NULL;
15655 data_unaligned = NULL;
15656
15657 /*************************************************************/
15658
15659 return QDF_STATUS_SUCCESS;
15660}
15661#else
15662/**
15663 * fips_conv_data_be() - DUMMY for LE platform
15664 *
15665 * Return: QDF_STATUS - success
15666 */
15667static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
15668{
15669 return QDF_STATUS_SUCCESS;
15670}
15671#endif
15672
15673/**
15674 * extract_fips_event_data_tlv() - extract fips event data
15675 * @wmi_handle: wmi handle
15676 * @param evt_buf: pointer to event buffer
15677 * @param param: pointer FIPS event params
15678 *
15679 * Return: 0 for success or error code
15680 */
15681static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
15682 void *evt_buf, struct wmi_host_fips_event_param *param)
15683{
15684 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
15685 wmi_pdev_fips_event_fixed_param *event;
15686
15687 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
15688 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
15689
15690 if (fips_conv_data_be(event->data_len, param_buf->data) !=
15691 QDF_STATUS_SUCCESS)
15692 return QDF_STATUS_E_FAILURE;
15693
15694 param->data = (uint32_t *)param_buf->data;
15695 param->data_len = event->data_len;
15696 param->error_status = event->error_status;
15697
15698 return QDF_STATUS_SUCCESS;
15699}
15700
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053015701/*
15702 * extract_peer_delete_response_event_tlv() - extract peer delete response event
15703 * @wmi_handle: wmi handle
15704 * @param evt_buf: pointer to event buffer
15705 * @param vdev_id: Pointer to hold vdev_id
15706 * @param mac_addr: Pointer to hold peer mac address
15707 *
15708 * Return: QDF_STATUS_SUCCESS for success or error code
15709 */
15710static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
15711 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
15712{
15713 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
15714 wmi_peer_delete_resp_event_fixed_param *ev;
15715
15716 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
15717
15718 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
15719 if (!ev) {
15720 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
15721 return QDF_STATUS_E_FAILURE;
15722 }
15723
15724 param->vdev_id = ev->vdev_id;
15725 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
15726 &param->mac_address.bytes[0]);
15727
15728 return QDF_STATUS_SUCCESS;
15729}
15730
Govind Singhecf03cd2016-05-12 12:45:51 +053015731static bool is_management_record_tlv(uint32_t cmd_id)
15732{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053015733 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053015734 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053015735
Govind Singhecf03cd2016-05-12 12:45:51 +053015736 return false;
15737}
15738
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053015739static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
15740{
15741 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
15742
15743 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
15744
15745 switch (set_cmd->param_id) {
15746 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
15747 case WMI_VDEV_PARAM_DTIM_POLICY:
15748 return HTC_TX_PACKET_TAG_AUTO_PM;
15749 default:
15750 break;
15751 }
15752
15753 return 0;
15754}
15755
15756static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
15757{
15758 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
15759
15760 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
15761
15762 switch (ps_cmd->param) {
15763 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
15764 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
15765 case WMI_STA_PS_ENABLE_QPOWER:
15766 return HTC_TX_PACKET_TAG_AUTO_PM;
15767 default:
15768 break;
15769 }
15770
15771 return 0;
15772}
15773
15774static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
15775 uint32_t cmd_id)
15776{
15777 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
15778 return 0;
15779
15780 switch (cmd_id) {
15781 case WMI_VDEV_SET_PARAM_CMDID:
15782 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
15783 case WMI_STA_POWERSAVE_PARAM_CMDID:
15784 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
15785 default:
15786 break;
15787 }
15788
15789 return 0;
15790}
15791
15792static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
15793{
15794 uint16_t tag = 0;
15795
15796 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
15797 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
15798 __func__);
15799 return tag;
15800 }
15801
15802 if (wmi_handle->tag_crash_inject)
15803 tag = HTC_TX_PACKET_TAG_AUTO_PM;
15804
15805 wmi_handle->tag_crash_inject = false;
15806 return tag;
15807}
15808
15809/**
15810 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
15811 * @wmi_handle: WMI handle
15812 * @buf: WMI buffer
15813 * @cmd_id: WMI command Id
15814 *
15815 * Return htc_tx_tag
15816 */
15817static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
15818 wmi_buf_t buf,
15819 uint32_t cmd_id)
15820{
15821 uint16_t htc_tx_tag = 0;
15822
15823 switch (cmd_id) {
15824 case WMI_WOW_ENABLE_CMDID:
15825 case WMI_PDEV_SUSPEND_CMDID:
15826 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
15827 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
15828 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
15829 case WMI_PDEV_RESUME_CMDID:
15830 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
15831 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
15832#ifdef FEATURE_WLAN_D0WOW
15833 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
15834#endif
15835 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
15836 break;
15837 case WMI_FORCE_FW_HANG_CMDID:
15838 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
15839 break;
15840 case WMI_VDEV_SET_PARAM_CMDID:
15841 case WMI_STA_POWERSAVE_PARAM_CMDID:
15842 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
15843 default:
15844 break;
15845 }
15846
15847 return htc_tx_tag;
15848}
15849
Sathish Kumard3ab1002017-02-07 17:10:59 +053015850/**
15851 * extract_channel_hopping_event_tlv() - extract channel hopping param
15852 * from event
15853 * @wmi_handle: wmi handle
15854 * @param evt_buf: pointer to event buffer
15855 * @param ch_hopping: Pointer to hold channel hopping param
15856 *
15857 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15858 */
15859static QDF_STATUS extract_channel_hopping_event_tlv(
15860 wmi_unified_t wmi_handle, void *evt_buf,
15861 wmi_host_pdev_channel_hopping_event *ch_hopping)
15862{
15863 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
15864 wmi_pdev_channel_hopping_event_fixed_param *event;
15865
15866 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
15867 event = (wmi_pdev_channel_hopping_event_fixed_param *)
15868 param_buf->fixed_param;
15869
15870 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
15871 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
15872
15873 return QDF_STATUS_SUCCESS;
15874}
15875
15876/**
15877 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
15878 * @wmi_handle: wmi handle
15879 * @param evt_buf: pointer to event buffer
15880 * @param param: Pointer to hold tpc param
15881 *
15882 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15883 */
15884static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
15885 void *evt_buf,
15886 wmi_host_pdev_tpc_event *param)
15887{
15888 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
15889 wmi_pdev_tpc_event_fixed_param *event;
15890
15891 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
15892 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
15893
15894 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
15895
15896 return QDF_STATUS_SUCCESS;
15897}
15898
15899
15900#ifdef BIG_ENDIAN_HOST
15901/**
15902 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
15903 * @param data_len - data length
15904 * @param data - pointer to data
15905 *
15906 * Return: QDF_STATUS - success or error status
15907 */
15908static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
15909{
15910 uint8_t *datap = (uint8_t *)ev;
15911 /* Skip swapping the first word */
15912 datap += sizeof(uint32_t);
15913 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
15914 i++, datap += sizeof(uint32_t)) {
15915 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
15916 }
15917
15918 return QDF_STATUS_SUCCESS;
15919}
15920#else
15921/**
15922 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
15923 * @param data_len - data length
15924 * @param data - pointer to data
15925 *
15926 * Return: QDF_STATUS - success or error status
15927 */
15928static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
15929{
15930 return QDF_STATUS_SUCCESS;
15931}
15932#endif
15933
15934/**
15935 * extract_wds_addr_event_tlv() - extract wds address from event
15936 * @wmi_handle: wmi handle
15937 * @param evt_buf: pointer to event buffer
15938 * @param wds_ev: Pointer to hold wds address
15939 *
15940 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15941 */
15942static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
15943 void *evt_buf,
15944 uint16_t len, wds_addr_event_t *wds_ev)
15945{
15946 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
15947 wmi_wds_addr_event_fixed_param *ev;
15948 int i;
15949
15950 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
15951 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
15952
15953 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
15954 return QDF_STATUS_E_FAILURE;
15955
15956 qdf_mem_copy(wds_ev->event_type, ev->event_type,
15957 sizeof(wds_ev->event_type));
15958 for (i = 0; i < 4; i++) {
15959 wds_ev->peer_mac[i] =
15960 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
15961 wds_ev->dest_mac[i] =
15962 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
15963 }
15964 for (i = 0; i < 2; i++) {
15965 wds_ev->peer_mac[4+i] =
15966 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
15967 wds_ev->dest_mac[4+i] =
15968 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
15969 }
15970 return QDF_STATUS_SUCCESS;
15971}
15972
15973/**
15974 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
15975 * from event
15976 * @wmi_handle: wmi handle
15977 * @param evt_buf: pointer to event buffer
15978 * @param ev: Pointer to hold peer param and ps state
15979 *
15980 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
15981 */
15982static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
15983 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
15984{
15985 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
15986 wmi_peer_sta_ps_statechange_event_fixed_param *event;
15987
15988 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
15989 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
15990 param_buf->fixed_param;
15991
15992 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
15993 ev->peer_ps_state = event->peer_ps_state;
15994
15995 return QDF_STATUS_SUCCESS;
15996}
15997
15998/**
15999 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
16000 * @wmi_handle: wmi handle
16001 * @param evt_buf: pointer to event buffer
16002 * @param inst_rssi_resp: Pointer to hold inst rssi response
16003 *
16004 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16005 */
16006static QDF_STATUS extract_inst_rssi_stats_event_tlv(
16007 wmi_unified_t wmi_handle, void *evt_buf,
16008 wmi_host_inst_stats_resp *inst_rssi_resp)
16009{
16010 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
16011 wmi_inst_rssi_stats_resp_fixed_param *event;
16012
16013 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
16014 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
16015
16016 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
16017 &(event->peer_macaddr), sizeof(wmi_mac_addr));
16018 inst_rssi_resp->iRSSI = event->iRSSI;
16019
16020 return QDF_STATUS_SUCCESS;
16021}
16022
Govind Singh5eb51532016-03-09 11:34:12 +053016023struct wmi_ops tlv_ops = {
16024 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
16025 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
16026 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053016027 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
16028 .send_hidden_ssid_vdev_restart_cmd =
16029 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016030 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
16031 .send_peer_param_cmd = send_peer_param_cmd_tlv,
16032 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016033 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016034 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016035 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070016036 .send_peer_rx_reorder_queue_setup_cmd =
16037 send_peer_rx_reorder_queue_setup_cmd_tlv,
16038 .send_peer_rx_reorder_queue_remove_cmd =
16039 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053016040 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
16041 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
16042 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016043 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
16044 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
16045 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
16046 .send_suspend_cmd = send_suspend_cmd_tlv,
16047 .send_resume_cmd = send_resume_cmd_tlv,
16048 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
16049 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
16050 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
16051 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
16052 .send_dbglog_cmd = send_dbglog_cmd_tlv,
16053 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
16054 .send_stats_request_cmd = send_stats_request_cmd_tlv,
16055 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
16056 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016057#ifndef CONFIG_MCL
16058 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
16059#endif
Govind Singh5eb51532016-03-09 11:34:12 +053016060 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
16061 .send_scan_start_cmd = send_scan_start_cmd_tlv,
16062 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
16063 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016064 .send_mgmt_cmd = send_mgmt_cmd_tlv,
16065 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
16066 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016067 .send_set_sta_uapsd_auto_trig_cmd =
16068 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016069 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
16070 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
16071 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080016072#ifdef CONVERGED_P2P_ENABLE
16073 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
16074 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
16075#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053016076 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
16077 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053016078 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
16079 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
16080 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
16081 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
16082 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
16083 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
16084 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016085 .send_ocb_start_timing_advert_cmd =
16086 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053016087 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
16088 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
16089 .send_set_mcc_channel_time_latency_cmd =
16090 send_set_mcc_channel_time_latency_cmd_tlv,
16091 .send_set_mcc_channel_time_quota_cmd =
16092 send_set_mcc_channel_time_quota_cmd_tlv,
16093 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
16094 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053016095 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016096 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
16097 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
16098 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016099 .send_probe_rsp_tmpl_send_cmd =
16100 send_probe_rsp_tmpl_send_cmd_tlv,
16101 .send_p2p_go_set_beacon_ie_cmd =
16102 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053016103 .send_setup_install_key_cmd =
16104 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016105 .send_set_gateway_params_cmd =
16106 send_set_gateway_params_cmd_tlv,
16107 .send_set_rssi_monitoring_cmd =
16108 send_set_rssi_monitoring_cmd_tlv,
16109 .send_scan_probe_setoui_cmd =
16110 send_scan_probe_setoui_cmd_tlv,
16111 .send_reset_passpoint_network_list_cmd =
16112 send_reset_passpoint_network_list_cmd_tlv,
16113 .send_set_passpoint_network_list_cmd =
16114 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053016115 .send_roam_scan_offload_rssi_thresh_cmd =
16116 send_roam_scan_offload_rssi_thresh_cmd_tlv,
16117 .send_roam_scan_filter_cmd =
16118 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016119 .send_set_epno_network_list_cmd =
16120 send_set_epno_network_list_cmd_tlv,
16121 .send_ipa_offload_control_cmd =
16122 send_ipa_offload_control_cmd_tlv,
16123 .send_extscan_get_capabilities_cmd =
16124 send_extscan_get_capabilities_cmd_tlv,
16125 .send_extscan_get_cached_results_cmd =
16126 send_extscan_get_cached_results_cmd_tlv,
16127 .send_extscan_stop_change_monitor_cmd =
16128 send_extscan_stop_change_monitor_cmd_tlv,
16129 .send_extscan_start_change_monitor_cmd =
16130 send_extscan_start_change_monitor_cmd_tlv,
16131 .send_extscan_stop_hotlist_monitor_cmd =
16132 send_extscan_stop_hotlist_monitor_cmd_tlv,
16133 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
16134 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
16135 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
16136 .send_plm_start_cmd = send_plm_start_cmd_tlv,
16137 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016138#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053016139 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016140#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053016141 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
16142 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
16143 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
16144 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
16145 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016146 .send_snr_request_cmd = send_snr_request_cmd_tlv,
16147 .send_snr_cmd = send_snr_cmd_tlv,
16148 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053016149#ifdef WLAN_PMO_ENABLE
16150 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
16151 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
16152 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
16153 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
16154 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
16155 .send_process_gtk_offload_getinfo_cmd =
16156 send_process_gtk_offload_getinfo_cmd_tlv,
16157 .send_enable_enhance_multicast_offload_cmd =
16158 send_enable_enhance_multicast_offload_tlv,
16159 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
16160#ifdef FEATURE_WLAN_RA_FILTERING
16161 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
16162#endif
16163 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016164 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
16165 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053016166 .send_lphb_config_tcp_pkt_filter_cmd =
16167 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016168 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
16169 .send_lphb_config_udp_pkt_filter_cmd =
16170 send_lphb_config_udp_pkt_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053016171#endif /* End of WLAN_PMO_ENABLE */
16172#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053016173 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
16174 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
16175 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016176 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
16177 .send_process_update_edca_param_cmd =
16178 send_process_update_edca_param_cmd_tlv,
16179 .send_roam_scan_offload_mode_cmd =
16180 send_roam_scan_offload_mode_cmd_tlv,
16181 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
16182 .send_roam_scan_offload_ap_profile_cmd =
16183 send_roam_scan_offload_ap_profile_cmd_tlv,
16184#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053016185 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
16186 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016187 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
16188 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
16189 .send_dfs_phyerr_filter_offload_en_cmd =
16190 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016191 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
16192 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
16193 .send_del_ts_cmd = send_del_ts_cmd_tlv,
16194 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
16195 .send_add_ts_cmd = send_add_ts_cmd_tlv,
16196 .send_enable_disable_packet_filter_cmd =
16197 send_enable_disable_packet_filter_cmd_tlv,
16198 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016199 .send_process_add_periodic_tx_ptrn_cmd =
16200 send_process_add_periodic_tx_ptrn_cmd_tlv,
16201 .send_process_del_periodic_tx_ptrn_cmd =
16202 send_process_del_periodic_tx_ptrn_cmd_tlv,
16203 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
16204 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
16205 .send_set_app_type2_params_in_fw_cmd =
16206 send_set_app_type2_params_in_fw_cmd_tlv,
16207 .send_set_auto_shutdown_timer_cmd =
16208 send_set_auto_shutdown_timer_cmd_tlv,
16209 .send_nan_req_cmd = send_nan_req_cmd_tlv,
16210 .send_process_dhcpserver_offload_cmd =
16211 send_process_dhcpserver_offload_cmd_tlv,
16212 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
16213 .send_process_ch_avoid_update_cmd =
16214 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053016215 .send_pdev_set_regdomain_cmd =
16216 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016217 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
16218 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
16219 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
16220 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
16221 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
16222 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053016223#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053016224 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053016225#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053016226 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053016227 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053016228 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053016229 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053016230 .send_set_base_macaddr_indicate_cmd =
16231 send_set_base_macaddr_indicate_cmd_tlv,
16232 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
16233 .send_enable_specific_fw_logs_cmd =
16234 send_enable_specific_fw_logs_cmd_tlv,
16235 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053016236 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053016237 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053016238 .send_pdev_set_dual_mac_config_cmd =
16239 send_pdev_set_dual_mac_config_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053016240 .send_enable_broadcast_filter_cmd =
16241 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053016242 .send_app_type1_params_in_fw_cmd =
16243 send_app_type1_params_in_fw_cmd_tlv,
16244 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
16245 .send_process_roam_synch_complete_cmd =
16246 send_process_roam_synch_complete_cmd_tlv,
16247 .send_unit_test_cmd = send_unit_test_cmd_tlv,
16248 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
16249 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053016250 .send_roam_scan_offload_scan_period_cmd =
16251 send_roam_scan_offload_scan_period_cmd_tlv,
16252 .send_roam_scan_offload_chan_list_cmd =
16253 send_roam_scan_offload_chan_list_cmd_tlv,
16254 .send_roam_scan_offload_rssi_change_cmd =
16255 send_roam_scan_offload_rssi_change_cmd_tlv,
16256 .send_get_buf_extscan_hotlist_cmd =
16257 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080016258 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053016259 .send_adapt_dwelltime_params_cmd =
16260 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053016261 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053016262 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
16263 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
16264 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
16265 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
16266 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
16267 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
16268 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
16269 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
16270 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053016271 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
16272 .send_smart_ant_set_training_info_cmd =
16273 send_smart_ant_set_training_info_cmd_tlv,
16274 .send_smart_ant_set_node_config_cmd =
16275 send_smart_ant_set_node_config_cmd_tlv,
16276 .send_set_atf_cmd = send_set_atf_cmd_tlv,
16277 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
16278 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053016279 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
16280 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
16281 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
16282 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
16283 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
16284 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
16285 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053016286 .get_target_cap_from_service_ready = extract_service_ready_tlv,
16287 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
16288 .extract_host_mem_req = extract_host_mem_req_tlv,
16289 .save_service_bitmap = save_service_bitmap_tlv,
16290 .is_service_enabled = is_service_enabled_tlv,
16291 .save_fw_version = save_fw_version_in_service_ready_tlv,
16292 .ready_extract_init_status = ready_extract_init_status_tlv,
16293 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
16294 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
16295 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
16296 .extract_tbttoffset_update_params =
16297 extract_tbttoffset_update_params_tlv,
16298 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
16299 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
16300 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
16301 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
16302 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
16303 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
16304 .extract_swba_tim_info = extract_swba_tim_info_tlv,
16305 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080016306#ifdef CONVERGED_P2P_ENABLE
16307 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
16308 .extract_p2p_lo_stop_ev_param =
16309 extract_p2p_lo_stop_ev_param_tlv,
16310#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053016311 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
16312 .extract_all_stats_count = extract_all_stats_counts_tlv,
16313 .extract_pdev_stats = extract_pdev_stats_tlv,
16314 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
16315 .extract_vdev_stats = extract_vdev_stats_tlv,
16316 .extract_peer_stats = extract_peer_stats_tlv,
16317 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
16318 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
16319 .extract_chan_stats = extract_chan_stats_tlv,
16320 .extract_profile_ctx = extract_profile_ctx_tlv,
16321 .extract_profile_data = extract_profile_data_tlv,
16322 .extract_chan_info_event = extract_chan_info_event_tlv,
16323 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053016324 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053016325 .send_encrypt_decrypt_send_cmd =
16326 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080016327 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053016328 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053016329 .send_multiple_vdev_restart_req_cmd =
16330 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053016331 .extract_service_ready_ext = extract_service_ready_ext_tlv,
16332 .extract_hw_mode_cap_service_ready_ext =
16333 extract_hw_mode_cap_service_ready_ext_tlv,
16334 .extract_mac_phy_cap_service_ready_ext =
16335 extract_mac_phy_cap_service_ready_ext_tlv,
16336 .extract_reg_cap_service_ready_ext =
16337 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016338 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053016339 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016340 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
16341 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
16342 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016343 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053016344 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053016345 .extract_peer_delete_response_event =
16346 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053016347 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053016348 .extract_pdev_csa_switch_count_status =
16349 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053016350 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
16351 .extract_wds_addr_event = extract_wds_addr_event_tlv,
16352 .extract_peer_sta_ps_statechange_ev =
16353 extract_peer_sta_ps_statechange_ev_tlv,
16354 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053016355 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080016356 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
16357 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016358};
16359
Govind Singhe7f2f342016-05-23 12:12:52 +053016360/**
16361 * populate_tlv_event_id() - populates wmi event ids
16362 *
16363 * @param event_ids: Pointer to hold event ids
16364 * Return: None
16365 */
16366static void populate_tlv_events_id(uint32_t *event_ids)
16367{
16368 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
16369 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
16370 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
16371 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
16372 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
16373 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
16374 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
16375 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
16376 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
16377 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
16378 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
16379 event_ids[wmi_service_ready_ext_event_id] =
16380 WMI_SERVICE_READY_EXT_EVENTID;
16381 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
16382 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
16383 event_ids[wmi_vdev_install_key_complete_event_id] =
16384 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
16385 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
16386 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
16387
16388 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
16389 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
16390 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
16391 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
16392 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
16393 event_ids[wmi_peer_estimated_linkspeed_event_id] =
16394 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
16395 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053016396 event_ids[wmi_peer_delete_response_event_id] =
16397 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016398 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
16399 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
16400 event_ids[wmi_tbttoffset_update_event_id] =
16401 WMI_TBTTOFFSET_UPDATE_EVENTID;
16402 event_ids[wmi_offload_bcn_tx_status_event_id] =
16403 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
16404 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
16405 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
16406 event_ids[wmi_mgmt_tx_completion_event_id] =
16407 WMI_MGMT_TX_COMPLETION_EVENTID;
16408
16409 event_ids[wmi_tx_delba_complete_event_id] =
16410 WMI_TX_DELBA_COMPLETE_EVENTID;
16411 event_ids[wmi_tx_addba_complete_event_id] =
16412 WMI_TX_ADDBA_COMPLETE_EVENTID;
16413 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
16414
16415 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
16416
16417 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
16418 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
16419
16420 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
16421
16422 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
16423
16424 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080016425 event_ids[wmi_p2p_lo_stop_event_id] =
16426 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016427 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
16428 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
16429 event_ids[wmi_do_wow_disable_ack_event_id] =
16430 WMI_D0_WOW_DISABLE_ACK_EVENTID;
16431 event_ids[wmi_wow_initial_wakeup_event_id] =
16432 WMI_WOW_INITIAL_WAKEUP_EVENTID;
16433
16434 event_ids[wmi_rtt_meas_report_event_id] =
16435 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
16436 event_ids[wmi_tsf_meas_report_event_id] =
16437 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
16438 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
16439 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
16440 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
16441 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
16442 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
16443 event_ids[wmi_update_fw_mem_dump_event_id] =
16444 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
16445 event_ids[wmi_diag_event_id_log_supported_event_id] =
16446 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
16447 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
16448 event_ids[wmi_nlo_scan_complete_event_id] =
16449 WMI_NLO_SCAN_COMPLETE_EVENTID;
16450 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
16451 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
16452
16453 event_ids[wmi_gtk_offload_status_event_id] =
16454 WMI_GTK_OFFLOAD_STATUS_EVENTID;
16455 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
16456 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
16457 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
16458
16459 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
16460
16461 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
16462
16463 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
16464 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
16465 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
16466 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
16467 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
16468 event_ids[wmi_wlan_profile_data_event_id] =
16469 WMI_WLAN_PROFILE_DATA_EVENTID;
16470 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
16471 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
16472 event_ids[wmi_vdev_get_keepalive_event_id] =
16473 WMI_VDEV_GET_KEEPALIVE_EVENTID;
16474 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
16475
16476 event_ids[wmi_diag_container_event_id] =
16477 WMI_DIAG_DATA_CONTAINER_EVENTID;
16478
16479 event_ids[wmi_host_auto_shutdown_event_id] =
16480 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
16481
16482 event_ids[wmi_update_whal_mib_stats_event_id] =
16483 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
16484
16485 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
16486 event_ids[wmi_update_vdev_rate_stats_event_id] =
16487 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
16488
16489 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
16490
16491 /** Set OCB Sched Response, deprecated */
16492 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
16493
16494 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
16495 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
16496 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
16497
16498 /* GPIO Event */
16499 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
16500 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
16501
16502 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
16503 event_ids[wmi_rfkill_state_change_event_id] =
16504 WMI_RFKILL_STATE_CHANGE_EVENTID;
16505
16506 /* TDLS Event */
16507 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
16508
16509 event_ids[wmi_batch_scan_enabled_event_id] =
16510 WMI_BATCH_SCAN_ENABLED_EVENTID;
16511 event_ids[wmi_batch_scan_result_event_id] =
16512 WMI_BATCH_SCAN_RESULT_EVENTID;
16513 /* OEM Event */
16514 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
16515 event_ids[wmi_oem_meas_report_event_id] =
16516 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
16517 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
16518
16519 /* NAN Event */
16520 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
16521
16522 /* LPI Event */
16523 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
16524 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
16525 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
16526
16527 /* ExtScan events */
16528 event_ids[wmi_extscan_start_stop_event_id] =
16529 WMI_EXTSCAN_START_STOP_EVENTID;
16530 event_ids[wmi_extscan_operation_event_id] =
16531 WMI_EXTSCAN_OPERATION_EVENTID;
16532 event_ids[wmi_extscan_table_usage_event_id] =
16533 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
16534 event_ids[wmi_extscan_cached_results_event_id] =
16535 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
16536 event_ids[wmi_extscan_wlan_change_results_event_id] =
16537 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
16538 event_ids[wmi_extscan_hotlist_match_event_id] =
16539 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
16540 event_ids[wmi_extscan_capabilities_event_id] =
16541 WMI_EXTSCAN_CAPABILITIES_EVENTID;
16542 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
16543 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
16544
16545 /* mDNS offload events */
16546 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
16547
16548 /* SAP Authentication offload events */
16549 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
16550 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
16551
16552 /** Out-of-context-of-bss (OCB) events */
16553 event_ids[wmi_ocb_set_config_resp_event_id] =
16554 WMI_OCB_SET_CONFIG_RESP_EVENTID;
16555 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
16556 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
16557 event_ids[wmi_dcc_get_stats_resp_event_id] =
16558 WMI_DCC_GET_STATS_RESP_EVENTID;
16559 event_ids[wmi_dcc_update_ndl_resp_event_id] =
16560 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
16561 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
16562 /* System-On-Chip events */
16563 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
16564 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
16565 event_ids[wmi_soc_hw_mode_transition_event_id] =
16566 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
16567 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
16568 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053016569 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053016570 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
16571 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016572}
16573
Soumya Bhat488092d2017-03-22 14:41:01 +053016574#ifndef CONFIG_MCL
16575/**
16576 * populate_tlv_service() - populates wmi services
16577 *
16578 * @param wmi_service: Pointer to hold wmi_service
16579 * Return: None
16580 */
16581static void populate_tlv_service(uint32_t *wmi_service)
16582{
16583 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
16584 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
16585 wmi_service[wmi_service_roam_scan_offload] =
16586 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
16587 wmi_service[wmi_service_bcn_miss_offload] =
16588 WMI_SERVICE_BCN_MISS_OFFLOAD;
16589 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
16590 wmi_service[wmi_service_sta_advanced_pwrsave] =
16591 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
16592 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
16593 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
16594 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
16595 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
16596 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
16597 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
16598 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
16599 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
16600 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
16601 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
16602 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
16603 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
16604 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
16605 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
16606 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
16607 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
16608 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
16609 wmi_service[wmi_service_packet_power_save] =
16610 WMI_SERVICE_PACKET_POWER_SAVE;
16611 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
16612 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
16613 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
16614 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
16615 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
16616 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
16617 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
16618 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
16619 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
16620 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
16621 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
16622 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
16623 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
16624 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
16625 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
16626 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
16627 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
16628 wmi_service[wmi_service_mcc_bcn_interval_change] =
16629 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
16630 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
16631 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
16632 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
16633 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
16634 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
16635 wmi_service[wmi_service_lte_ant_share_support] =
16636 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
16637 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
16638 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
16639 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
16640 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
16641 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
16642 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
16643 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
16644 wmi_service[wmi_service_bcn_txrate_override] =
16645 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
16646 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
16647 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
16648 wmi_service[wmi_service_estimate_linkspeed] =
16649 WMI_SERVICE_ESTIMATE_LINKSPEED;
16650 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
16651 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
16652 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
16653 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
16654 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
16655 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
16656 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
16657 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
16658 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
16659 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
16660 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
16661 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
16662 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
16663 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
16664 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
16665 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
16666 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
16667 wmi_service[wmi_service_sap_auth_offload] =
16668 WMI_SERVICE_SAP_AUTH_OFFLOAD;
16669 wmi_service[wmi_service_dual_band_simultaneous_support] =
16670 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
16671 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
16672 wmi_service[wmi_service_ap_arpns_offload] =
16673 WMI_SERVICE_AP_ARPNS_OFFLOAD;
16674 wmi_service[wmi_service_per_band_chainmask_support] =
16675 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
16676 wmi_service[wmi_service_packet_filter_offload] =
16677 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
16678 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
16679 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
16680 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
16681 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
16682 wmi_service[wmi_service_multiple_vdev_restart] =
16683 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
16684
16685 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
16686 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
16687 wmi_service[wmi_service_smart_antenna_sw_support] =
16688 WMI_SERVICE_UNAVAILABLE;
16689 wmi_service[wmi_service_smart_antenna_hw_support] =
16690 WMI_SERVICE_UNAVAILABLE;
16691 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
16692 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
16693 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
16694 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
16695 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
16696 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
16697 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
16698 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
16699 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
16700 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
16701 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
16702
16703 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
16704 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
16705 wmi_service[wmi_service_periodic_chan_stat_support] =
16706 WMI_SERVICE_UNAVAILABLE;
16707 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
16708 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
16709 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
16710 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
16711 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
16712 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
16713}
16714
Govind Singhe7f2f342016-05-23 12:12:52 +053016715/**
16716 * populate_pdev_param_tlv() - populates pdev params
16717 *
16718 * @param pdev_param: Pointer to hold pdev params
16719 * Return: None
16720 */
16721static void populate_pdev_param_tlv(uint32_t *pdev_param)
16722{
16723 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
16724 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
16725 pdev_param[wmi_pdev_param_txpower_limit2g] =
16726 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
16727 pdev_param[wmi_pdev_param_txpower_limit5g] =
16728 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
16729 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
16730 pdev_param[wmi_pdev_param_beacon_gen_mode] =
16731 WMI_PDEV_PARAM_BEACON_GEN_MODE;
16732 pdev_param[wmi_pdev_param_beacon_tx_mode] =
16733 WMI_PDEV_PARAM_BEACON_TX_MODE;
16734 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
16735 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
16736 pdev_param[wmi_pdev_param_protection_mode] =
16737 WMI_PDEV_PARAM_PROTECTION_MODE;
16738 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
16739 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
16740 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
16741 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
16742 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
16743 pdev_param[wmi_pdev_param_sta_kickout_th] =
16744 WMI_PDEV_PARAM_STA_KICKOUT_TH;
16745 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
16746 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
16747 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
16748 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
16749 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
16750 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
16751 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
16752 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
16753 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
16754 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
16755 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
16756 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
16757 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
16758 pdev_param[wmi_pdev_param_ltr_sleep_override] =
16759 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
16760 pdev_param[wmi_pdev_param_ltr_rx_override] =
16761 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
16762 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
16763 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
16764 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
16765 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
16766 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
16767 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
16768 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
16769 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
16770 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
16771 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
16772 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
16773 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
16774 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
16775 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
16776 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
16777 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
16778 pdev_param[wmi_pdev_param_peer_stats_update_period] =
16779 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
16780 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
16781 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
16782 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
16783 pdev_param[wmi_pdev_param_arp_ac_override] =
16784 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
16785 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
16786 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
16787 pdev_param[wmi_pdev_param_ani_poll_period] =
16788 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
16789 pdev_param[wmi_pdev_param_ani_listen_period] =
16790 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
16791 pdev_param[wmi_pdev_param_ani_ofdm_level] =
16792 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
16793 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
16794 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
16795 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
16796 pdev_param[wmi_pdev_param_idle_ps_config] =
16797 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
16798 pdev_param[wmi_pdev_param_power_gating_sleep] =
16799 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
16800 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
16801 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
16802 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
16803 pdev_param[wmi_pdev_param_hw_rfkill_config] =
16804 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
16805 pdev_param[wmi_pdev_param_low_power_rf_enable] =
16806 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
16807 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
16808 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
16809 pdev_param[wmi_pdev_param_power_collapse_enable] =
16810 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
16811 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
16812 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
16813 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
16814 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
16815 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
16816 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
16817 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
16818 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
16819 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
16820 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
16821 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
16822 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
16823 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
16824 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
16825 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
16826 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
16827 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
16828 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
16829 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
16830 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
16831 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
16832 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
16833 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
16834 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
16835 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
16836 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
16837 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
16838 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
16839 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
16840 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
16841 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
16842 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
16843 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
16844 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
16845 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
16846 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
16847 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
16848 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
16849 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
16850 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
16851 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
16852 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
16853 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
16854 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
16855 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
16856 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
16857 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
16858 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
16859 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
16860 WMI_UNAVAILABLE_PARAM;
16861 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
16862 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
16863 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
16864 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
16865 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
16866 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
16867 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
16868 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
16869 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
16870 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
16871 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
16872 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
16873 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
16874 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
16875 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
16876 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
16877 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
16878 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
16879 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
16880 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
16881 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
16882 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
16883 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
16884 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
16885 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
16886 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
16887 WMI_UNAVAILABLE_PARAM;
16888 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
16889 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
16890 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
16891 WMI_UNAVAILABLE_PARAM;
16892 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
16893 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
16894 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
16895 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
16896 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
16897 WMI_UNAVAILABLE_PARAM;
16898 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
16899 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
16900 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053016901 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
16902 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053016903 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053016904 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
16905 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053016906}
16907
16908/**
16909 * populate_vdev_param_tlv() - populates vdev params
16910 *
16911 * @param vdev_param: Pointer to hold vdev params
16912 * Return: None
16913 */
16914static void populate_vdev_param_tlv(uint32_t *vdev_param)
16915{
16916 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
16917 vdev_param[wmi_vdev_param_fragmentation_threshold] =
16918 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
16919 vdev_param[wmi_vdev_param_beacon_interval] =
16920 WMI_VDEV_PARAM_BEACON_INTERVAL;
16921 vdev_param[wmi_vdev_param_listen_interval] =
16922 WMI_VDEV_PARAM_LISTEN_INTERVAL;
16923 vdev_param[wmi_vdev_param_multicast_rate] =
16924 WMI_VDEV_PARAM_MULTICAST_RATE;
16925 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
16926 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
16927 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
16928 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
16929 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
16930 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
16931 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
16932 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
16933 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
16934 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
16935 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
16936 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
16937 vdev_param[wmi_vdev_param_bmiss_count_max] =
16938 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
16939 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
16940 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
16941 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
16942 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
16943 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
16944 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
16945 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
16946 vdev_param[wmi_vdev_param_disable_htprotection] =
16947 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
16948 vdev_param[wmi_vdev_param_sta_quickkickout] =
16949 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
16950 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
16951 vdev_param[wmi_vdev_param_protection_mode] =
16952 WMI_VDEV_PARAM_PROTECTION_MODE;
16953 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
16954 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
16955 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
16956 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
16957 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
16958 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
16959 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
16960 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
16961 vdev_param[wmi_vdev_param_bcast_data_rate] =
16962 WMI_VDEV_PARAM_BCAST_DATA_RATE;
16963 vdev_param[wmi_vdev_param_mcast_data_rate] =
16964 WMI_VDEV_PARAM_MCAST_DATA_RATE;
16965 vdev_param[wmi_vdev_param_mcast_indicate] =
16966 WMI_VDEV_PARAM_MCAST_INDICATE;
16967 vdev_param[wmi_vdev_param_dhcp_indicate] =
16968 WMI_VDEV_PARAM_DHCP_INDICATE;
16969 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
16970 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
16971 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
16972 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
16973 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
16974 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
16975 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
16976 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
16977 vdev_param[wmi_vdev_param_ap_enable_nawds] =
16978 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
16979 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
16980 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
16981 vdev_param[wmi_vdev_param_packet_powersave] =
16982 WMI_VDEV_PARAM_PACKET_POWERSAVE;
16983 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
16984 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
16985 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
16986 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
16987 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
16988 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
16989 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
16990 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
16991 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
16992 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
16993 vdev_param[wmi_vdev_param_early_rx_slop_step] =
16994 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
16995 vdev_param[wmi_vdev_param_early_rx_init_slop] =
16996 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
16997 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
16998 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
16999 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
17000 vdev_param[wmi_vdev_param_snr_num_for_cal] =
17001 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
17002 vdev_param[wmi_vdev_param_roam_fw_offload] =
17003 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
17004 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
17005 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
17006 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
17007 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
17008 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
17009 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
17010 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
17011 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
17012 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
17013 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
17014 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
17015 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
17016 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
17017 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
17018 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
17019 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
17020 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
17021 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
17022 vdev_param[wmi_vdev_param_inactivity_cnt] =
17023 WMI_VDEV_PARAM_INACTIVITY_CNT;
17024 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
17025 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
17026 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
17027 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
17028 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
17029 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
17030 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
17031 vdev_param[wmi_vdev_param_rx_leak_window] =
17032 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
17033 vdev_param[wmi_vdev_param_stats_avg_factor] =
17034 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
17035 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
17036 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
17037 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
17038 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
17039 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
17040 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053017041 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
17042 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053017043 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080017044 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
17045 vdev_param[wmi_vdev_param_he_range_ext_enable] =
17046 WMI_VDEV_PARAM_HE_RANGE_EXT;
17047 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
17048 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053017049 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
17050 vdev_param[wmi_vdev_param_dtim_enable_cts] =
17051 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
17052 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
17053 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
17054 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
17055 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Govind Singhe7f2f342016-05-23 12:12:52 +053017056}
17057#endif
17058
Govind Singh5eb51532016-03-09 11:34:12 +053017059/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017060 * populate_target_defines_tlv() - Populate target defines and params
17061 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053017062 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053017063 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053017064 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053017065#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017066static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053017067{
Govind Singhe7f2f342016-05-23 12:12:52 +053017068 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053017069 populate_pdev_param_tlv(wmi_handle->pdev_param);
17070 populate_vdev_param_tlv(wmi_handle->vdev_param);
17071}
17072#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017073static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
17074{ }
17075#endif
17076
17077/**
17078 * wmi_tlv_attach() - Attach TLV APIs
17079 *
17080 * Return: None
17081 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053017082void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053017083{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053017084 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053017085#ifdef WMI_INTERFACE_EVENT_LOGGING
17086 wmi_handle->log_info.buf_offset_command = 2;
17087 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053017088#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053017089 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017090 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053017091}