blob: 6e2f4dd8f68dbb3cfe85ae0de8c3bb6b7198ff3c [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));
Kiran Venkatappa72da3b02017-03-28 22:45:27 +0530976 cmd->pdev_id = mac_id;
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));
Kiran Venkatappa72da3b02017-03-28 22:45:27 +05301131 cmd->pdev_id = mac_id;
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;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001837 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301838 wmi_buf_t buf;
1839 int32_t len;
1840 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301841 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301842 uint32_t peer_legacy_rates_align;
1843 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001844 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301845
1846
1847 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1848 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301849
1850 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001851 (peer_legacy_rates_align * sizeof(uint8_t)) +
1852 WMI_TLV_HDR_SIZE +
1853 (peer_ht_rates_align * sizeof(uint8_t)) +
1854 sizeof(wmi_vht_rate_set) +
1855 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1856 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301857
1858 buf = wmi_buf_alloc(wmi_handle, len);
1859 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301860 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301861 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301862 }
1863
1864 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1865 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1866 WMITLV_SET_HDR(&cmd->tlv_header,
1867 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1868 WMITLV_GET_STRUCT_TLVLEN
1869 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301870
Govind Singhd3156eb2016-02-26 17:50:39 +05301871 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301872
Govind Singhd3156eb2016-02-26 17:50:39 +05301873 cmd->peer_new_assoc = param->peer_new_assoc;
1874 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301875
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301876 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301877 copy_peer_mac_addr_tlv(cmd, param);
1878
Govind Singhd3156eb2016-02-26 17:50:39 +05301879 cmd->peer_rate_caps = param->peer_rate_caps;
1880 cmd->peer_caps = param->peer_caps;
1881 cmd->peer_listen_intval = param->peer_listen_intval;
1882 cmd->peer_ht_caps = param->peer_ht_caps;
1883 cmd->peer_max_mpdu = param->peer_max_mpdu;
1884 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301885 cmd->peer_vht_caps = param->peer_vht_caps;
1886 cmd->peer_phymode = param->peer_phymode;
1887
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001888 /* Update 11ax capabilities */
1889 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1890 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001891 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1892 sizeof(param->peer_he_cap_phyinfo));
1893 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1894 sizeof(param->peer_ppet));
1895
Govind Singhd3156eb2016-02-26 17:50:39 +05301896 /* Update peer legacy rate information */
1897 buf_ptr += sizeof(*cmd);
1898 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301899 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301900 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301901 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301902 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301903 param->peer_legacy_rates.num_rates);
1904
1905 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001906 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301907 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301908 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301909 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301910 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301911 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301912 param->peer_ht_rates.num_rates);
1913
1914 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001915 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301916 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1917 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1918
1919 cmd->peer_nss = param->peer_nss;
1920 mcs = (wmi_vht_rate_set *) buf_ptr;
1921 if (param->vht_capable) {
1922 mcs->rx_max_rate = param->rx_max_rate;
1923 mcs->rx_mcs_set = param->rx_mcs_set;
1924 mcs->tx_max_rate = param->tx_max_rate;
1925 mcs->tx_mcs_set = param->tx_mcs_set;
1926 }
1927
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001928 /* HE Rates */
1929 cmd->peer_he_mcs = param->peer_he_mcs_count;
1930 buf_ptr += sizeof(wmi_vht_rate_set);
1931 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1932 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
1933 buf_ptr += WMI_TLV_HDR_SIZE;
1934
1935 /* Loop through the HE rate set */
1936 for (i = 0; i < param->peer_he_mcs_count; i++) {
1937 he_mcs = (wmi_he_rate_set *) buf_ptr;
1938 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
1939 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
1940
1941 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
1942 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
1943 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
1944 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
1945 buf_ptr += sizeof(wmi_he_rate_set);
1946 }
1947
1948
Govind Singhb53420c2016-03-09 14:32:57 +05301949 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05301950 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
1951 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001952 "cmd->peer_vht_caps %x "
1953 "HE cap_info %x ops %x "
1954 "HE phy %x %x %x ", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05301955 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
1956 cmd->peer_rate_caps, cmd->peer_caps,
1957 cmd->peer_listen_intval, cmd->peer_ht_caps,
1958 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
1959 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001960 cmd->peer_vht_caps, cmd->peer_he_cap_info,
1961 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
1962 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2]);
Govind Singhd3156eb2016-02-26 17:50:39 +05301963
1964 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1965 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301966 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301967 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05301968 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301969 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05301970 }
1971
1972 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301973}
1974
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301975/* copy_scan_notify_events() - Helper routine to copy scan notify events
1976 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05301977static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301978 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05301979 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301980{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05301981
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05301982 /* Scan events subscription */
1983 if (param->scan_ev_started)
1984 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
1985 if (param->scan_ev_completed)
1986 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
1987 if (param->scan_ev_bss_chan)
1988 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
1989 if (param->scan_ev_foreign_chan)
1990 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
1991 if (param->scan_ev_dequeued)
1992 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
1993 if (param->scan_ev_preempted)
1994 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
1995 if (param->scan_ev_start_failed)
1996 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
1997 if (param->scan_ev_restarted)
1998 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
1999 if (param->scan_ev_foreign_chn_exit)
2000 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2001 if (param->scan_ev_suspended)
2002 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2003 if (param->scan_ev_resumed)
2004 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302005
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302006 /** Set scan control flags */
2007 cmd->scan_ctrl_flags = 0;
2008 if (param->scan_f_passive)
2009 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2010 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302011 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302012 if (param->scan_f_promisc_mode)
2013 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2014 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302015 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302016 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302017 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302018 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302019 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302020 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302021 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302022 if (param->scan_f_ofdm_rates)
2023 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2024 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302025 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302026 if (param->scan_f_filter_prb_req)
2027 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2028 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302029 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302030 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302031 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302032 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302033 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302034 if (param->scan_f_force_active_dfs_chn)
2035 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2036 if (param->scan_f_add_tpc_ie_in_probe)
2037 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2038 if (param->scan_f_add_ds_ie_in_probe)
2039 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2040 if (param->scan_f_add_spoofed_mac_in_probe)
2041 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2042 if (param->scan_f_add_rand_seq_in_probe)
2043 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2044 if (param->scan_f_en_ie_whitelist_in_probe)
2045 cmd->scan_ctrl_flags |=
2046 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302047
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302048 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2049 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2050 param->adaptive_dwell_time_mode);
2051}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302052
2053/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302054static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302055 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302056{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302057 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302058}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302059
Anish Natarajdd855152017-03-20 12:49:08 +05302060/*
2061 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2062 * @param wmi_handle : Handle to WMI
2063 * @param vdev_id : vdev identifier
2064 *
2065 * Return : void *
2066 */
2067static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2068{
2069 struct wlan_objmgr_vdev *vdev = NULL;
2070 struct wlan_objmgr_pdev *pdev = NULL;
2071 uint8_t pdev_id = 0;
2072
2073 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2074 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2075 vdev_id, WLAN_SCAN_ID);
2076 if (vdev) {
2077 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2078 pdev = wlan_vdev_get_pdev(vdev);
2079 if (pdev)
2080 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2081 else {
2082 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2083 }
2084 } else {
2085 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2086 }
2087
2088 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2089}
2090
Govind Singh5eb51532016-03-09 11:34:12 +05302091/**
2092 * send_scan_start_cmd_tlv() - WMI scan start function
2093 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302094 * @param param : pointer to hold scan start cmd parameter
2095 *
2096 * Return: 0 on success and -ve on failure.
2097 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302098static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302099 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302100{
Govind Singhd3156eb2016-02-26 17:50:39 +05302101 int32_t ret = 0;
2102 int32_t i;
2103 wmi_buf_t wmi_buf;
2104 wmi_start_scan_cmd_fixed_param *cmd;
2105 uint8_t *buf_ptr;
2106 uint32_t *tmp_ptr;
2107 wmi_ssid *ssid = NULL;
2108 wmi_mac_addr *bssid;
2109 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302110 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302111
2112 /* Length TLV placeholder for array of uint32_t */
2113 len += WMI_TLV_HDR_SIZE;
2114 /* calculate the length of buffer required */
2115 if (params->num_chan)
2116 len += params->num_chan * sizeof(uint32_t);
2117
2118 /* Length TLV placeholder for array of wmi_ssid structures */
2119 len += WMI_TLV_HDR_SIZE;
2120 if (params->num_ssids)
2121 len += params->num_ssids * sizeof(wmi_ssid);
2122
2123 /* Length TLV placeholder for array of wmi_mac_addr structures */
2124 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302125 if (params->num_bssid)
2126 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302127
2128 /* Length TLV placeholder for array of bytes */
2129 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302130 if (params->extraie.len)
2131 extraie_len_with_pad =
2132 roundup(params->extraie.len, sizeof(uint32_t));
2133 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302134
2135 /* Allocate the memory */
2136 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2137 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302138 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302139 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302140 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302141 }
2142 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2143 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2144 WMITLV_SET_HDR(&cmd->tlv_header,
2145 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2146 WMITLV_GET_STRUCT_TLVLEN
2147 (wmi_start_scan_cmd_fixed_param));
2148
2149 cmd->scan_id = params->scan_id;
2150 cmd->scan_req_id = params->scan_req_id;
2151 cmd->vdev_id = params->vdev_id;
2152 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302153
2154 copy_scan_event_cntrl_flags(cmd, params);
2155
Govind Singhd3156eb2016-02-26 17:50:39 +05302156 cmd->dwell_time_active = params->dwell_time_active;
2157 cmd->dwell_time_passive = params->dwell_time_passive;
2158 cmd->min_rest_time = params->min_rest_time;
2159 cmd->max_rest_time = params->max_rest_time;
2160 cmd->repeat_probe_time = params->repeat_probe_time;
2161 cmd->probe_spacing_time = params->probe_spacing_time;
2162 cmd->idle_time = params->idle_time;
2163 cmd->max_scan_time = params->max_scan_time;
2164 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302165 cmd->burst_duration = params->burst_duration;
2166 cmd->num_chan = params->num_chan;
2167 cmd->num_bssid = params->num_bssid;
2168 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302169 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302170 cmd->n_probes = params->n_probes;
2171 buf_ptr += sizeof(*cmd);
2172 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2173 for (i = 0; i < params->num_chan; ++i)
2174 tmp_ptr[i] = params->chan_list[i];
2175
2176 WMITLV_SET_HDR(buf_ptr,
2177 WMITLV_TAG_ARRAY_UINT32,
2178 (params->num_chan * sizeof(uint32_t)));
2179 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302180 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302181 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302182 goto error;
2183 }
2184
2185 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2186 (params->num_ssids * sizeof(wmi_ssid)));
2187
2188 if (params->num_ssids) {
2189 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2190 for (i = 0; i < params->num_ssids; ++i) {
2191 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302192 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302193 params->ssid[i].length);
2194 ssid++;
2195 }
2196 }
2197 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2198
2199 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2200 (params->num_bssid * sizeof(wmi_mac_addr)));
2201 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302202
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302203 if (params->num_bssid) {
2204 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302205 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2206 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302207 bssid++;
2208 }
2209 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302210
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302211 buf_ptr += WMI_TLV_HDR_SIZE +
2212 (params->num_bssid * sizeof(wmi_mac_addr));
2213
2214 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2215 if (params->extraie.len)
2216 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2217 params);
2218
2219 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302220
Anish Natarajdd855152017-03-20 12:49:08 +05302221 ret = wmi_unified_cmd_send(
2222 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302223 len, WMI_START_SCAN_CMDID);
2224 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302225 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302226 wmi_buf_free(wmi_buf);
2227 }
2228 return ret;
2229error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302230 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302231 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302232}
2233
2234/**
2235 * send_scan_stop_cmd_tlv() - WMI scan start function
2236 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302237 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302238 *
2239 * Return: 0 on success and -ve on failure.
2240 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302241static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302242 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302243{
Govind Singhd3156eb2016-02-26 17:50:39 +05302244 wmi_stop_scan_cmd_fixed_param *cmd;
2245 int ret;
2246 int len = sizeof(*cmd);
2247 wmi_buf_t wmi_buf;
2248
2249 /* Allocate the memory */
2250 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2251 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302252 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302253 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302254 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302255 goto error;
2256 }
2257
2258 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2259 WMITLV_SET_HDR(&cmd->tlv_header,
2260 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2261 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2262 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302263 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302264 cmd->scan_id = param->scan_id;
Anish Natarajdd855152017-03-20 12:49:08 +05302265 cmd->pdev_id = param->pdev_id + 1;
Govind Singhd3156eb2016-02-26 17:50:39 +05302266 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302267 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2268 /* Cancelling all scans */
2269 cmd->req_type = WMI_SCAN_STOP_ALL;
2270 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2271 /* Cancelling VAP scans */
2272 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2273 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2274 /* Cancelling specific scan */
2275 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302276 } else {
2277 WMI_LOGE("%s: Invalid Command : ", __func__);
2278 wmi_buf_free(wmi_buf);
2279 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302280 }
2281
Anish Natarajdd855152017-03-20 12:49:08 +05302282 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302283 len, WMI_STOP_SCAN_CMDID);
2284 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302285 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302286 wmi_buf_free(wmi_buf);
2287 }
2288
2289error:
2290 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302291}
2292
Govind Singh87542482016-06-08 19:40:11 +05302293#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302294/**
2295 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2296 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302297 * @param param : pointer to hold scan channel list parameter
2298 *
2299 * Return: 0 on success and -ve on failure.
2300 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302301static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302302 struct scan_chan_list_params *chan_list)
2303{
2304 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302305 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302306 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302307 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302308 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302309 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302310 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2311
2312 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2313 buf = wmi_buf_alloc(wmi_handle, len);
2314 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302315 WMI_LOGE("Failed to allocate memory");
2316 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302317 goto end;
2318 }
2319
2320 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2321 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2322 WMITLV_SET_HDR(&cmd->tlv_header,
2323 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2324 WMITLV_GET_STRUCT_TLVLEN
2325 (wmi_scan_chan_list_cmd_fixed_param));
2326
Govind Singhb53420c2016-03-09 14:32:57 +05302327 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302328
2329 cmd->num_scan_chans = chan_list->num_scan_chans;
2330 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2331 WMITLV_TAG_ARRAY_STRUC,
2332 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302333 chan_info = (wmi_channel_param *)
2334 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302335 tchan_info = chan_list->chan_info;
2336
2337 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2338 WMITLV_SET_HDR(&chan_info->tlv_header,
2339 WMITLV_TAG_STRUC_wmi_channel,
2340 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2341 chan_info->mhz = tchan_info->mhz;
2342 chan_info->band_center_freq1 =
2343 tchan_info->band_center_freq1;
2344 chan_info->band_center_freq2 =
2345 tchan_info->band_center_freq2;
2346 chan_info->info = tchan_info->info;
2347 chan_info->reg_info_1 = tchan_info->reg_info_1;
2348 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302349 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302350
2351 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2352 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2353 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2354 tchan_info++;
2355 chan_info++;
2356 }
Anish Natarajdd855152017-03-20 12:49:08 +05302357 cmd->pdev_id = chan_list->pdev_id + 1;
Govind Singhd3156eb2016-02-26 17:50:39 +05302358
Anish Natarajdd855152017-03-20 12:49:08 +05302359 qdf_status = wmi_unified_cmd_send(wmi_handle,
2360 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302361
Govind Singh67922e82016-04-01 16:48:57 +05302362 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302363 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302364 wmi_buf_free(buf);
2365 }
Govind Singh67922e82016-04-01 16:48:57 +05302366
Govind Singhd3156eb2016-02-26 17:50:39 +05302367end:
Govind Singhb53420c2016-03-09 14:32:57 +05302368 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302369}
Govind Singh87542482016-06-08 19:40:11 +05302370#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302371static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302372 struct scan_chan_list_params *chan_list)
2373{
2374 wmi_buf_t buf;
2375 QDF_STATUS qdf_status;
2376 wmi_scan_chan_list_cmd_fixed_param *cmd;
2377 int i;
2378 uint8_t *buf_ptr;
2379 wmi_channel *chan_info;
2380 struct channel_param *tchan_info;
2381 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302382
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302383 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302384 buf = wmi_buf_alloc(wmi_handle, len);
2385 if (!buf) {
2386 WMI_LOGE("Failed to allocate memory");
2387 qdf_status = QDF_STATUS_E_NOMEM;
2388 goto end;
2389 }
2390
2391 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2392 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2393 WMITLV_SET_HDR(&cmd->tlv_header,
2394 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2395 WMITLV_GET_STRUCT_TLVLEN
2396 (wmi_scan_chan_list_cmd_fixed_param));
2397
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302398 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302399
Kiran Venkatappa8e146df2017-02-08 14:51:13 +05302400 cmd->pdev_id = chan_list->pdev_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302401 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302402 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2403 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302404 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302405 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2406 tchan_info = &(chan_list->ch_param[0]);
2407
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302408 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302409 WMITLV_SET_HDR(&chan_info->tlv_header,
2410 WMITLV_TAG_STRUC_wmi_channel,
2411 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2412 chan_info->mhz = tchan_info->mhz;
2413 chan_info->band_center_freq1 =
2414 tchan_info->cfreq1;
2415 chan_info->band_center_freq2 =
2416 tchan_info->cfreq2;
2417
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302418 if (tchan_info->is_chan_passive)
2419 WMI_SET_CHANNEL_FLAG(chan_info,
2420 WMI_CHAN_FLAG_PASSIVE);
2421
2422 if (tchan_info->allow_vht)
2423 WMI_SET_CHANNEL_FLAG(chan_info,
2424 WMI_CHAN_FLAG_ALLOW_VHT);
2425 else if (tchan_info->allow_ht)
2426 WMI_SET_CHANNEL_FLAG(chan_info,
2427 WMI_CHAN_FLAG_ALLOW_HT);
2428 WMI_SET_CHANNEL_MODE(chan_info,
2429 tchan_info->phy_mode);
2430
2431 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2432 * after FW support
2433 */
2434
2435 /* also fill in power information */
2436 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2437 tchan_info->minpower);
2438 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2439 tchan_info->maxpower);
2440 WMI_SET_CHANNEL_REG_POWER(chan_info,
2441 tchan_info->maxregpower);
2442 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2443 tchan_info->antennamax);
2444 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2445 tchan_info->reg_class_id);
2446
Govind Singh87542482016-06-08 19:40:11 +05302447 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2448
Govind Singh87542482016-06-08 19:40:11 +05302449 tchan_info++;
2450 chan_info++;
2451 }
Anish Natarajdd855152017-03-20 12:49:08 +05302452 cmd->pdev_id = chan_list->pdev_id + 1;
Govind Singh87542482016-06-08 19:40:11 +05302453
Anish Natarajdd855152017-03-20 12:49:08 +05302454 qdf_status = wmi_unified_cmd_send(
2455 wmi_handle,
2456 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302457
2458 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2459 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2460 wmi_buf_free(buf);
2461 }
2462
2463end:
2464 return qdf_status;
2465}
2466#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302467/**
2468 * send_mgmt_cmd_tlv() - WMI scan start function
2469 * @wmi_handle : handle to WMI.
2470 * @param : pointer to hold mgmt cmd parameter
2471 *
2472 * Return: 0 on success and -ve on failure.
2473 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302474static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302475 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302476{
Govind Singh427ee5a2016-02-26 18:09:36 +05302477 wmi_buf_t buf;
2478 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2479 int32_t cmd_len;
2480 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302481 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302482 uint8_t *bufp;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302483 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302484 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2485 mgmt_tx_dl_frm_len;
2486
2487 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2488 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2489
2490 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2491 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302492 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2493 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302494 }
2495
2496 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2497 bufp = (uint8_t *) cmd;
2498 WMITLV_SET_HDR(&cmd->tlv_header,
2499 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2500 WMITLV_GET_STRUCT_TLVLEN
2501 (wmi_mgmt_tx_send_cmd_fixed_param));
2502
2503 cmd->vdev_id = param->vdev_id;
2504
Govind Singh224a7312016-06-21 14:33:26 +05302505 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302506 cmd->chanfreq = param->chanfreq;
2507 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2508 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2509 sizeof(uint32_t)));
2510 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302511 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302512
2513 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2514 QDF_DMA_TO_DEVICE);
2515 if (status != QDF_STATUS_SUCCESS) {
2516 WMI_LOGE("%s: wmi buf map failed", __func__);
2517 goto err1;
2518 }
2519
Govind Singhb53420c2016-03-09 14:32:57 +05302520 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302521 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002522#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302523 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2524#endif
2525 cmd->frame_len = param->frm_len;
2526 cmd->buf_len = bufp_len;
2527
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002528 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002529 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002530
Govind Singh427ee5a2016-02-26 18:09:36 +05302531 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2532 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302533 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302534 goto err1;
2535 }
Govind Singhb53420c2016-03-09 14:32:57 +05302536 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302537
2538err1:
2539 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302540 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302541}
2542
2543/**
2544 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2545 * @wmi_handle: wmi handle
2546 * @param_value: parameter value
2547 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302548 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302549 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302550static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302551 uint32_t param_value)
2552{
Govind Singh67922e82016-04-01 16:48:57 +05302553 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302554 wmi_modem_power_state_cmd_param *cmd;
2555 wmi_buf_t buf;
2556 uint16_t len = sizeof(*cmd);
2557
2558 buf = wmi_buf_alloc(wmi_handle, len);
2559 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302560 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302561 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302562 }
2563 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2564 WMITLV_SET_HDR(&cmd->tlv_header,
2565 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2566 WMITLV_GET_STRUCT_TLVLEN
2567 (wmi_modem_power_state_cmd_param));
2568 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302569 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302570 param_value);
2571 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2572 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302573 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302574 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302575 wmi_buf_free(buf);
2576 }
Govind Singh67922e82016-04-01 16:48:57 +05302577
Govind Singh427ee5a2016-02-26 18:09:36 +05302578 return ret;
2579}
2580
2581/**
2582 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2583 * @wmi_handle: wmi handle
2584 * @vdev_id: vdev id
2585 * @val: value
2586 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302587 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302588 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302589static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302590 uint32_t vdev_id, uint8_t val)
2591{
2592 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2593 wmi_buf_t buf;
2594 int32_t len = sizeof(*cmd);
2595
Govind Singhb53420c2016-03-09 14:32:57 +05302596 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302597
2598 buf = wmi_buf_alloc(wmi_handle, len);
2599 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302600 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302601 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302602 }
2603 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2604 WMITLV_SET_HDR(&cmd->tlv_header,
2605 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2606 WMITLV_GET_STRUCT_TLVLEN
2607 (wmi_sta_powersave_mode_cmd_fixed_param));
2608 cmd->vdev_id = vdev_id;
2609 if (val)
2610 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2611 else
2612 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2613
2614 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2615 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302616 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302617 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302618 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302619 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302620 }
Govind Singh5eb51532016-03-09 11:34:12 +05302621 return 0;
2622}
2623
Govind Singh427ee5a2016-02-26 18:09:36 +05302624/**
2625 * send_set_mimops_cmd_tlv() - set MIMO powersave
2626 * @wmi_handle: wmi handle
2627 * @vdev_id: vdev id
2628 * @value: value
2629 *
Govind Singhb53420c2016-03-09 14:32:57 +05302630 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302631 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302632static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302633 uint8_t vdev_id, int value)
2634{
Govind Singh67922e82016-04-01 16:48:57 +05302635 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302636 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2637 wmi_buf_t buf;
2638 uint16_t len = sizeof(*cmd);
2639
2640 buf = wmi_buf_alloc(wmi_handle, len);
2641 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302642 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302643 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302644 }
2645 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2646 WMITLV_SET_HDR(&cmd->tlv_header,
2647 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2648 WMITLV_GET_STRUCT_TLVLEN
2649 (wmi_sta_smps_force_mode_cmd_fixed_param));
2650
2651 cmd->vdev_id = vdev_id;
2652
Houston Hoffmanb5168052016-04-14 02:18:01 -07002653 /* WMI_SMPS_FORCED_MODE values do not directly map
2654 * to SM power save values defined in the specification.
2655 * Make sure to send the right mapping.
2656 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302657 switch (value) {
2658 case 0:
2659 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2660 break;
2661 case 1:
2662 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2663 break;
2664 case 2:
2665 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2666 break;
2667 case 3:
2668 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2669 break;
2670 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302671 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2672 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302673 }
2674
Govind Singhb53420c2016-03-09 14:32:57 +05302675 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302676
2677 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2678 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302679 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302680 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302681 wmi_buf_free(buf);
2682 }
2683
2684 return ret;
2685}
2686
2687/**
2688 * send_set_smps_params_cmd_tlv() - set smps params
2689 * @wmi_handle: wmi handle
2690 * @vdev_id: vdev id
2691 * @value: value
2692 *
Govind Singhb53420c2016-03-09 14:32:57 +05302693 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302694 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302695static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302696 int value)
2697{
Govind Singh67922e82016-04-01 16:48:57 +05302698 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302699 wmi_sta_smps_param_cmd_fixed_param *cmd;
2700 wmi_buf_t buf;
2701 uint16_t len = sizeof(*cmd);
2702
2703 buf = wmi_buf_alloc(wmi_handle, len);
2704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302705 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302706 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302707 }
2708 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2709 WMITLV_SET_HDR(&cmd->tlv_header,
2710 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2711 WMITLV_GET_STRUCT_TLVLEN
2712 (wmi_sta_smps_param_cmd_fixed_param));
2713
2714 cmd->vdev_id = vdev_id;
2715 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2716 cmd->param =
2717 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2718
Govind Singhb53420c2016-03-09 14:32:57 +05302719 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302720 cmd->param);
2721
2722 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2723 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302724 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302725 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302726 wmi_buf_free(buf);
2727 }
2728
2729 return ret;
2730}
2731
2732/**
2733 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2734 * @wmi_handle: wmi handle
2735 * @noa: p2p power save parameters
2736 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302737 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302738 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302739static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302740 struct p2p_ps_params *noa)
2741{
2742 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2743 wmi_p2p_noa_descriptor *noa_discriptor;
2744 wmi_buf_t buf;
2745 uint8_t *buf_ptr;
2746 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302747 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302748 uint32_t duration;
2749
Govind Singhb53420c2016-03-09 14:32:57 +05302750 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302751 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2752 buf = wmi_buf_alloc(wmi_handle, len);
2753 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302754 WMI_LOGE("Failed to allocate memory");
2755 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302756 goto end;
2757 }
2758
2759 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2760 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2761 WMITLV_SET_HDR(&cmd->tlv_header,
2762 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2763 WMITLV_GET_STRUCT_TLVLEN
2764 (wmi_p2p_set_noa_cmd_fixed_param));
2765 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2766 cmd->vdev_id = noa->session_id;
2767 cmd->enable = (duration) ? true : false;
2768 cmd->num_noa = 1;
2769
2770 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2771 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2772 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2773 sizeof
2774 (wmi_p2p_set_noa_cmd_fixed_param)
2775 + WMI_TLV_HDR_SIZE);
2776 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2777 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2778 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2779 noa_discriptor->type_count = noa->count;
2780 noa_discriptor->duration = duration;
2781 noa_discriptor->interval = noa->interval;
2782 noa_discriptor->start_time = 0;
2783
Govind Singhb53420c2016-03-09 14:32:57 +05302784 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302785 cmd->vdev_id, noa->count, noa_discriptor->duration,
2786 noa->interval);
2787 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2788 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302789 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302790 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302791 wmi_buf_free(buf);
2792 }
2793
2794end:
Govind Singhb53420c2016-03-09 14:32:57 +05302795 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302796 return status;
2797}
2798
2799
2800/**
2801 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2802 * @wmi_handle: wmi handle
2803 * @noa: p2p opp power save parameters
2804 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302805 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302806 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302807static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302808 struct p2p_ps_params *oppps)
2809{
2810 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2811 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302812 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302813
Govind Singhb53420c2016-03-09 14:32:57 +05302814 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302815 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2816 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302817 WMI_LOGE("Failed to allocate memory");
2818 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302819 goto end;
2820 }
2821
2822 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2823 WMITLV_SET_HDR(&cmd->tlv_header,
2824 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2825 WMITLV_GET_STRUCT_TLVLEN
2826 (wmi_p2p_set_oppps_cmd_fixed_param));
2827 cmd->vdev_id = oppps->session_id;
2828 if (oppps->ctwindow)
2829 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2830
2831 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302832 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302833 cmd->vdev_id, oppps->ctwindow);
2834 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2835 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302836 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302837 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302838 wmi_buf_free(buf);
2839 }
2840
2841end:
Govind Singhb53420c2016-03-09 14:32:57 +05302842 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302843 return status;
2844}
2845
Wu Gaocd3a8512017-03-13 20:17:34 +08002846#ifdef CONVERGED_P2P_ENABLE
2847/**
2848 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
2849 * @wmi_handle: wmi handle
2850 * @param: p2p listen offload start parameters
2851 *
2852 * Return: QDF status
2853 */
2854static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
2855 struct p2p_lo_start *param)
2856{
2857 wmi_buf_t buf;
2858 wmi_p2p_lo_start_cmd_fixed_param *cmd;
2859 int32_t len = sizeof(*cmd);
2860 uint8_t *buf_ptr;
2861 QDF_STATUS status;
2862 int device_types_len_aligned;
2863 int probe_resp_len_aligned;
2864
2865 if (!param) {
2866 WMI_LOGE("lo start param is null");
2867 return QDF_STATUS_E_INVAL;
2868 }
2869
2870 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
2871
2872 device_types_len_aligned =
2873 qdf_roundup(param->dev_types_len,
2874 sizeof(A_UINT32));
2875 probe_resp_len_aligned =
2876 qdf_roundup(param->probe_resp_len,
2877 sizeof(A_UINT32));
2878
2879 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
2880 probe_resp_len_aligned;
2881
2882 buf = wmi_buf_alloc(wmi_handle, len);
2883 if (!buf) {
2884 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
2885 __func__);
2886 return QDF_STATUS_E_NOMEM;
2887 }
2888
2889 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
2890 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2891
2892 WMITLV_SET_HDR(&cmd->tlv_header,
2893 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
2894 WMITLV_GET_STRUCT_TLVLEN(
2895 wmi_p2p_lo_start_cmd_fixed_param));
2896
2897 cmd->vdev_id = param->vdev_id;
2898 cmd->ctl_flags = param->ctl_flags;
2899 cmd->channel = param->freq;
2900 cmd->period = param->period;
2901 cmd->interval = param->interval;
2902 cmd->count = param->count;
2903 cmd->device_types_len = param->dev_types_len;
2904 cmd->prob_resp_len = param->probe_resp_len;
2905
2906 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
2907 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2908 device_types_len_aligned);
2909 buf_ptr += WMI_TLV_HDR_SIZE;
2910 qdf_mem_copy(buf_ptr, param->device_types,
2911 param->dev_types_len);
2912
2913 buf_ptr += device_types_len_aligned;
2914 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
2915 probe_resp_len_aligned);
2916 buf_ptr += WMI_TLV_HDR_SIZE;
2917 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
2918 param->probe_resp_len);
2919
2920 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
2921 cmd->channel, cmd->period, cmd->interval, cmd->count);
2922
2923 status = wmi_unified_cmd_send(wmi_handle,
2924 buf, len,
2925 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
2926 if (status != QDF_STATUS_SUCCESS) {
2927 WMI_LOGE("%s: Failed to send p2p lo start: %d",
2928 __func__, status);
2929 wmi_buf_free(buf);
2930 return status;
2931 }
2932
2933 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
2934
2935 return QDF_STATUS_SUCCESS;
2936}
2937
2938/**
2939 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
2940 * @wmi_handle: wmi handle
2941 * @param: p2p listen offload stop parameters
2942 *
2943 * Return: QDF status
2944 */
2945static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
2946 uint8_t vdev_id)
2947{
2948 wmi_buf_t buf;
2949 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
2950 int32_t len;
2951 QDF_STATUS status;
2952
2953 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
2954
2955 len = sizeof(*cmd);
2956 buf = wmi_buf_alloc(wmi_handle, len);
2957 if (!buf) {
2958 qdf_print("%s: Failed to allocate memory for p2p lo stop",
2959 __func__);
2960 return QDF_STATUS_E_NOMEM;
2961 }
2962 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
2963
2964 WMITLV_SET_HDR(&cmd->tlv_header,
2965 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
2966 WMITLV_GET_STRUCT_TLVLEN(
2967 wmi_p2p_lo_stop_cmd_fixed_param));
2968
2969 cmd->vdev_id = vdev_id;
2970
2971 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
2972
2973 status = wmi_unified_cmd_send(wmi_handle,
2974 buf, len,
2975 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
2976 if (status != QDF_STATUS_SUCCESS) {
2977 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
2978 __func__, status);
2979 wmi_buf_free(buf);
2980 return status;
2981 }
2982
2983 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
2984
2985 return QDF_STATUS_SUCCESS;
2986}
2987#endif /* End of CONVERGED_P2P_ENABLE */
2988
Govind Singh427ee5a2016-02-26 18:09:36 +05302989/**
2990 * send_get_temperature_cmd_tlv() - get pdev temperature req
2991 * @wmi_handle: wmi handle
2992 *
Govind Singhb53420c2016-03-09 14:32:57 +05302993 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302994 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302995static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05302996{
2997 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
2998 wmi_buf_t wmi_buf;
2999 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3000 uint8_t *buf_ptr;
3001
3002 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303003 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3004 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303005 }
3006
3007 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3008 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303009 WMI_LOGE(FL("wmi_buf_alloc failed"));
3010 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303011 }
3012
3013 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3014
3015 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3016 WMITLV_SET_HDR(&cmd->tlv_header,
3017 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3018 WMITLV_GET_STRUCT_TLVLEN
3019 (wmi_pdev_get_temperature_cmd_fixed_param));
3020
3021 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3022 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303023 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303024 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303025 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303026 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303027
Govind Singhb53420c2016-03-09 14:32:57 +05303028 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303029}
3030
3031/**
3032 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3033 * @wmi_handle: wmi handle
3034 * @vdevid: vdev id
3035 * @peer_addr: peer mac address
3036 * @auto_triggerparam: auto trigger parameters
3037 * @num_ac: number of access category
3038 *
3039 * This function sets the trigger
3040 * uapsd params such as service interval, delay interval
3041 * and suspend interval which will be used by the firmware
3042 * to send trigger frames periodically when there is no
3043 * traffic on the transmit side.
3044 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303045 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303046 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303047static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303048 struct sta_uapsd_trig_params *param)
3049{
3050 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303051 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303052 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3053 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3054 uint32_t i;
3055 wmi_buf_t buf;
3056 uint8_t *buf_ptr;
3057
3058 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3059 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303060 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303061 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303062 }
3063
3064 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3065 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3066 WMITLV_SET_HDR(&cmd->tlv_header,
3067 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3068 WMITLV_GET_STRUCT_TLVLEN
3069 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3070 cmd->vdev_id = param->vdevid;
3071 cmd->num_ac = param->num_ac;
3072 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3073
3074 /* TLV indicating array of structures to follow */
3075 buf_ptr += sizeof(*cmd);
3076 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3077
3078 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05303079 qdf_mem_copy(buf_ptr, param->auto_triggerparam, param_len);
Govind Singh427ee5a2016-02-26 18:09:36 +05303080
3081 /*
3082 * Update tag and length for uapsd auto trigger params (this will take
3083 * care of updating tag and length if it is not pre-filled by caller).
3084 */
3085 for (i = 0; i < param->num_ac; i++) {
3086 WMITLV_SET_HDR((buf_ptr +
3087 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3088 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3089 WMITLV_GET_STRUCT_TLVLEN
3090 (wmi_sta_uapsd_auto_trig_param));
3091 }
3092
3093 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3094 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303095 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303096 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303097 wmi_buf_free(buf);
3098 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303099
Govind Singh427ee5a2016-02-26 18:09:36 +05303100 return ret;
3101}
3102
Govind Singh2edc80f2016-03-01 15:30:53 +05303103/**
3104 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3105 * @wmi_handle: pointer to the wmi handle
3106 * @utc: pointer to the UTC time struct
3107 *
3108 * Return: 0 on succes
3109 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303110static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303111 struct ocb_utc_param *utc)
3112{
Govind Singh67922e82016-04-01 16:48:57 +05303113 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303114 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3115 uint8_t *buf_ptr;
3116 uint32_t len, i;
3117 wmi_buf_t buf;
3118
3119 len = sizeof(*cmd);
3120 buf = wmi_buf_alloc(wmi_handle, len);
3121 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303122 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303123 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303124 }
3125
3126 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3127 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3128 WMITLV_SET_HDR(&cmd->tlv_header,
3129 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3130 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3131 cmd->vdev_id = utc->vdev_id;
3132
3133 for (i = 0; i < SIZE_UTC_TIME; i++)
3134 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3135
3136 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3137 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3138
3139 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3140 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303141 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303142 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303143 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303144 }
3145
Govind Singh67922e82016-04-01 16:48:57 +05303146 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303147}
3148
3149/**
3150 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3151 * frames on a channel
3152 * @wmi_handle: pointer to the wmi handle
3153 * @timing_advert: pointer to the timing advertisement struct
3154 *
3155 * Return: 0 on succes
3156 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303157static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303158 struct ocb_timing_advert_param *timing_advert)
3159{
Govind Singh67922e82016-04-01 16:48:57 +05303160 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303161 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3162 uint8_t *buf_ptr;
3163 uint32_t len, len_template;
3164 wmi_buf_t buf;
3165
3166 len = sizeof(*cmd) +
3167 WMI_TLV_HDR_SIZE;
3168
3169 len_template = timing_advert->template_length;
3170 /* Add padding to the template if needed */
3171 if (len_template % 4 != 0)
3172 len_template += 4 - (len_template % 4);
3173 len += len_template;
3174
3175 buf = wmi_buf_alloc(wmi_handle, len);
3176 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303177 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303178 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303179 }
3180
3181 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3182 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3183 WMITLV_SET_HDR(&cmd->tlv_header,
3184 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3185 WMITLV_GET_STRUCT_TLVLEN(
3186 wmi_ocb_start_timing_advert_cmd_fixed_param));
3187 cmd->vdev_id = timing_advert->vdev_id;
3188 cmd->repeat_rate = timing_advert->repeat_rate;
3189 cmd->channel_freq = timing_advert->chan_freq;
3190 cmd->timestamp_offset = timing_advert->timestamp_offset;
3191 cmd->time_value_offset = timing_advert->time_value_offset;
3192 cmd->timing_advert_template_length = timing_advert->template_length;
3193 buf_ptr += sizeof(*cmd);
3194
3195 /* Add the timing advert template */
3196 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3197 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303198 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303199 (uint8_t *)timing_advert->template_value,
3200 timing_advert->template_length);
3201
3202 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3203 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303204 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303205 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303206 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303207 }
3208
Govind Singh67922e82016-04-01 16:48:57 +05303209 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303210}
3211
3212/**
3213 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3214 * on a channel
3215 * @wmi_handle: pointer to the wmi handle
3216 * @timing_advert: pointer to the timing advertisement struct
3217 *
3218 * Return: 0 on succes
3219 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303220static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303221 struct ocb_timing_advert_param *timing_advert)
3222{
Govind Singh67922e82016-04-01 16:48:57 +05303223 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303224 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3225 uint8_t *buf_ptr;
3226 uint32_t len;
3227 wmi_buf_t buf;
3228
3229 len = sizeof(*cmd);
3230 buf = wmi_buf_alloc(wmi_handle, len);
3231 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303232 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303233 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303234 }
3235
3236 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3237 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3238 WMITLV_SET_HDR(&cmd->tlv_header,
3239 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3240 WMITLV_GET_STRUCT_TLVLEN(
3241 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3242 cmd->vdev_id = timing_advert->vdev_id;
3243 cmd->channel_freq = timing_advert->chan_freq;
3244
3245 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3246 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303247 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303248 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303249 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303250 }
3251
Govind Singh67922e82016-04-01 16:48:57 +05303252 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303253}
3254
3255/**
3256 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3257 * @wmi_handle: pointer to the wmi handle
3258 * @request: pointer to the request
3259 *
3260 * Return: 0 on succes
3261 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303262static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303263 uint8_t vdev_id)
3264{
Govind Singhb53420c2016-03-09 14:32:57 +05303265 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303266 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3267 uint8_t *buf_ptr;
3268 wmi_buf_t buf;
3269 int32_t len;
3270
3271 len = sizeof(*cmd);
3272 buf = wmi_buf_alloc(wmi_handle, len);
3273 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303274 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303275 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303276 }
3277 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3278
3279 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303280 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303281 WMITLV_SET_HDR(&cmd->tlv_header,
3282 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3283 WMITLV_GET_STRUCT_TLVLEN(
3284 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3285 cmd->vdev_id = vdev_id;
3286
3287 /* Send the WMI command */
3288 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3289 WMI_OCB_GET_TSF_TIMER_CMDID);
3290 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303291 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303292 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303293 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303294 }
3295
Govind Singh67922e82016-04-01 16:48:57 +05303296 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303297}
3298
3299/**
3300 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3301 * @wmi_handle: pointer to the wmi handle
3302 * @get_stats_param: pointer to the dcc stats
3303 *
3304 * Return: 0 on succes
3305 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303306static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303307 struct dcc_get_stats_param *get_stats_param)
3308{
Govind Singh67922e82016-04-01 16:48:57 +05303309 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303310 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3311 wmi_dcc_channel_stats_request *channel_stats_array;
3312 wmi_buf_t buf;
3313 uint8_t *buf_ptr;
3314 uint32_t len;
3315 uint32_t i;
3316
3317 /* Validate the input */
3318 if (get_stats_param->request_array_len !=
3319 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303320 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303321 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303322 }
3323
3324 /* Allocate memory for the WMI command */
3325 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3326 get_stats_param->request_array_len;
3327
3328 buf = wmi_buf_alloc(wmi_handle, len);
3329 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303330 WMI_LOGE(FL("wmi_buf_alloc failed"));
3331 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303332 }
3333
3334 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303335 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303336
3337 /* Populate the WMI command */
3338 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3339 buf_ptr += sizeof(*cmd);
3340
3341 WMITLV_SET_HDR(&cmd->tlv_header,
3342 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3343 WMITLV_GET_STRUCT_TLVLEN(
3344 wmi_dcc_get_stats_cmd_fixed_param));
3345 cmd->vdev_id = get_stats_param->vdev_id;
3346 cmd->num_channels = get_stats_param->channel_count;
3347
3348 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3349 get_stats_param->request_array_len);
3350 buf_ptr += WMI_TLV_HDR_SIZE;
3351
3352 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303353 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303354 get_stats_param->request_array_len);
3355 for (i = 0; i < cmd->num_channels; i++)
3356 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3357 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3358 WMITLV_GET_STRUCT_TLVLEN(
3359 wmi_dcc_channel_stats_request));
3360
3361 /* Send the WMI command */
3362 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3363 WMI_DCC_GET_STATS_CMDID);
3364
Govind Singh67922e82016-04-01 16:48:57 +05303365 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303366 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303367 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303368 }
3369
Govind Singh67922e82016-04-01 16:48:57 +05303370 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303371}
3372
3373/**
3374 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3375 * @wmi_handle: pointer to the wmi handle
3376 * @vdev_id: vdev id
3377 * @dcc_stats_bitmap: dcc status bitmap
3378 *
3379 * Return: 0 on succes
3380 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303381static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303382 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3383{
Govind Singh67922e82016-04-01 16:48:57 +05303384 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303385 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3386 wmi_buf_t buf;
3387 uint8_t *buf_ptr;
3388 uint32_t len;
3389
3390 /* Allocate memory for the WMI command */
3391 len = sizeof(*cmd);
3392
3393 buf = wmi_buf_alloc(wmi_handle, len);
3394 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303395 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303396 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303397 }
3398
3399 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303400 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303401
3402 /* Populate the WMI command */
3403 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3404
3405 WMITLV_SET_HDR(&cmd->tlv_header,
3406 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3407 WMITLV_GET_STRUCT_TLVLEN(
3408 wmi_dcc_clear_stats_cmd_fixed_param));
3409 cmd->vdev_id = vdev_id;
3410 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3411
3412 /* Send the WMI command */
3413 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3414 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303415 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303416 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303417 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303418 }
3419
Govind Singh67922e82016-04-01 16:48:57 +05303420 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303421}
3422
3423/**
3424 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3425 * @wmi_handle: pointer to the wmi handle
3426 * @update_ndl_param: pointer to the request parameters
3427 *
3428 * Return: 0 on success
3429 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303430static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303431 struct dcc_update_ndl_param *update_ndl_param)
3432{
Govind Singhb53420c2016-03-09 14:32:57 +05303433 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303434 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3435 wmi_dcc_ndl_chan *ndl_chan_array;
3436 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3437 uint32_t active_state_count;
3438 wmi_buf_t buf;
3439 uint8_t *buf_ptr;
3440 uint32_t len;
3441 uint32_t i;
3442
3443 /* validate the input */
3444 if (update_ndl_param->dcc_ndl_chan_list_len !=
3445 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303446 WMI_LOGE(FL("Invalid parameter"));
3447 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303448 }
3449 active_state_count = 0;
3450 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3451 for (i = 0; i < update_ndl_param->channel_count; i++)
3452 active_state_count +=
3453 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3454 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3455 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303456 WMI_LOGE(FL("Invalid parameter"));
3457 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303458 }
3459
3460 /* Allocate memory for the WMI command */
3461 len = sizeof(*cmd) +
3462 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3463 WMI_TLV_HDR_SIZE +
3464 update_ndl_param->dcc_ndl_active_state_list_len;
3465
3466 buf = wmi_buf_alloc(wmi_handle, len);
3467 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303468 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303469 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303470 }
3471
3472 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303473 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303474
3475 /* Populate the WMI command */
3476 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3477 buf_ptr += sizeof(*cmd);
3478
3479 WMITLV_SET_HDR(&cmd->tlv_header,
3480 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3481 WMITLV_GET_STRUCT_TLVLEN(
3482 wmi_dcc_update_ndl_cmd_fixed_param));
3483 cmd->vdev_id = update_ndl_param->vdev_id;
3484 cmd->num_channel = update_ndl_param->channel_count;
3485
3486 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3487 update_ndl_param->dcc_ndl_chan_list_len);
3488 buf_ptr += WMI_TLV_HDR_SIZE;
3489
3490 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303491 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303492 update_ndl_param->dcc_ndl_chan_list_len);
3493 for (i = 0; i < cmd->num_channel; i++)
3494 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3495 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3496 WMITLV_GET_STRUCT_TLVLEN(
3497 wmi_dcc_ndl_chan));
3498 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3499
3500 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3501 update_ndl_param->dcc_ndl_active_state_list_len);
3502 buf_ptr += WMI_TLV_HDR_SIZE;
3503
3504 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303505 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303506 update_ndl_param->dcc_ndl_active_state_list,
3507 update_ndl_param->dcc_ndl_active_state_list_len);
3508 for (i = 0; i < active_state_count; i++) {
3509 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3510 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3511 WMITLV_GET_STRUCT_TLVLEN(
3512 wmi_dcc_ndl_active_state_config));
3513 }
3514 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3515
3516 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303517 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303518 WMI_DCC_UPDATE_NDL_CMDID);
3519 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303520 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303521 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303522 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303523 }
3524
Govind Singh67922e82016-04-01 16:48:57 +05303525 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303526}
3527
3528/**
3529 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3530 * @wmi_handle: pointer to the wmi handle
3531 * @config: the OCB configuration
3532 *
3533 * Return: 0 on success
3534 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303535static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303536 struct ocb_config_param *config, uint32_t *ch_mhz)
3537{
Govind Singh67922e82016-04-01 16:48:57 +05303538 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303539 wmi_ocb_set_config_cmd_fixed_param *cmd;
3540 wmi_channel *chan;
3541 wmi_ocb_channel *ocb_chan;
3542 wmi_qos_parameter *qos_param;
3543 wmi_dcc_ndl_chan *ndl_chan;
3544 wmi_dcc_ndl_active_state_config *ndl_active_config;
3545 wmi_ocb_schedule_element *sched_elem;
3546 uint8_t *buf_ptr;
3547 wmi_buf_t buf;
3548 int32_t len;
3549 int32_t i, j, active_state_count;
3550
3551 /*
3552 * Validate the dcc_ndl_chan_list_len and count the number of active
3553 * states. Validate dcc_ndl_active_state_list_len.
3554 */
3555 active_state_count = 0;
3556 if (config->dcc_ndl_chan_list_len) {
3557 if (!config->dcc_ndl_chan_list ||
3558 config->dcc_ndl_chan_list_len !=
3559 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303560 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303561 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303562 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303563 }
3564
3565 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3566 i < config->channel_count; ++i, ++ndl_chan)
3567 active_state_count +=
3568 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3569
3570 if (active_state_count) {
3571 if (!config->dcc_ndl_active_state_list ||
3572 config->dcc_ndl_active_state_list_len !=
3573 active_state_count *
3574 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303575 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303576 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303577 }
3578 }
3579 }
3580
3581 len = sizeof(*cmd) +
3582 WMI_TLV_HDR_SIZE + config->channel_count *
3583 sizeof(wmi_channel) +
3584 WMI_TLV_HDR_SIZE + config->channel_count *
3585 sizeof(wmi_ocb_channel) +
3586 WMI_TLV_HDR_SIZE + config->channel_count *
3587 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3588 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3589 WMI_TLV_HDR_SIZE + active_state_count *
3590 sizeof(wmi_dcc_ndl_active_state_config) +
3591 WMI_TLV_HDR_SIZE + config->schedule_size *
3592 sizeof(wmi_ocb_schedule_element);
3593 buf = wmi_buf_alloc(wmi_handle, len);
3594 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303595 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303596 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303597 }
3598
3599 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3600 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3601 WMITLV_SET_HDR(&cmd->tlv_header,
3602 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3603 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3604 cmd->vdev_id = config->session_id;
3605 cmd->channel_count = config->channel_count;
3606 cmd->schedule_size = config->schedule_size;
3607 cmd->flags = config->flags;
3608 buf_ptr += sizeof(*cmd);
3609
3610 /* Add the wmi_channel info */
3611 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3612 config->channel_count*sizeof(wmi_channel));
3613 buf_ptr += WMI_TLV_HDR_SIZE;
3614 for (i = 0; i < config->channel_count; i++) {
3615 chan = (wmi_channel *)buf_ptr;
3616 WMITLV_SET_HDR(&chan->tlv_header,
3617 WMITLV_TAG_STRUC_wmi_channel,
3618 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3619 chan->mhz = config->channels[i].chan_freq;
3620 chan->band_center_freq1 = config->channels[i].chan_freq;
3621 chan->band_center_freq2 = 0;
3622 chan->info = 0;
3623
3624 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3625 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3626 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3627 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3628 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3629 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3630 config->channels[i].antenna_max);
3631
3632 if (config->channels[i].bandwidth < 10)
3633 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3634 else if (config->channels[i].bandwidth < 20)
3635 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3636 buf_ptr += sizeof(*chan);
3637 }
3638
3639 /* Add the wmi_ocb_channel info */
3640 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3641 config->channel_count*sizeof(wmi_ocb_channel));
3642 buf_ptr += WMI_TLV_HDR_SIZE;
3643 for (i = 0; i < config->channel_count; i++) {
3644 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3645 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3646 WMITLV_TAG_STRUC_wmi_ocb_channel,
3647 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3648 ocb_chan->bandwidth = config->channels[i].bandwidth;
3649 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3650 config->channels[i].mac_address.bytes,
3651 &ocb_chan->mac_address);
3652 buf_ptr += sizeof(*ocb_chan);
3653 }
3654
3655 /* Add the wmi_qos_parameter info */
3656 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3657 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3658 buf_ptr += WMI_TLV_HDR_SIZE;
3659 /* WMI_MAX_NUM_AC parameters for each channel */
3660 for (i = 0; i < config->channel_count; i++) {
3661 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3662 qos_param = (wmi_qos_parameter *)buf_ptr;
3663 WMITLV_SET_HDR(&qos_param->tlv_header,
3664 WMITLV_TAG_STRUC_wmi_qos_parameter,
3665 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3666 qos_param->aifsn =
3667 config->channels[i].qos_params[j].aifsn;
3668 qos_param->cwmin =
3669 config->channels[i].qos_params[j].cwmin;
3670 qos_param->cwmax =
3671 config->channels[i].qos_params[j].cwmax;
3672 buf_ptr += sizeof(*qos_param);
3673 }
3674 }
3675
3676 /* Add the wmi_dcc_ndl_chan (per channel) */
3677 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3678 config->dcc_ndl_chan_list_len);
3679 buf_ptr += WMI_TLV_HDR_SIZE;
3680 if (config->dcc_ndl_chan_list_len) {
3681 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303682 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303683 config->dcc_ndl_chan_list_len);
3684 for (i = 0; i < config->channel_count; i++)
3685 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3686 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3687 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3688 buf_ptr += config->dcc_ndl_chan_list_len;
3689 }
3690
3691 /* Add the wmi_dcc_ndl_active_state_config */
3692 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3693 sizeof(wmi_dcc_ndl_active_state_config));
3694 buf_ptr += WMI_TLV_HDR_SIZE;
3695 if (active_state_count) {
3696 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303697 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303698 config->dcc_ndl_active_state_list,
3699 active_state_count * sizeof(*ndl_active_config));
3700 for (i = 0; i < active_state_count; ++i)
3701 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3702 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3703 WMITLV_GET_STRUCT_TLVLEN(
3704 wmi_dcc_ndl_active_state_config));
3705 buf_ptr += active_state_count *
3706 sizeof(*ndl_active_config);
3707 }
3708
3709 /* Add the wmi_ocb_schedule_element info */
3710 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3711 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3712 buf_ptr += WMI_TLV_HDR_SIZE;
3713 for (i = 0; i < config->schedule_size; i++) {
3714 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3715 WMITLV_SET_HDR(&sched_elem->tlv_header,
3716 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3717 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3718 sched_elem->channel_freq = config->schedule[i].chan_freq;
3719 sched_elem->total_duration = config->schedule[i].total_duration;
3720 sched_elem->guard_interval = config->schedule[i].guard_interval;
3721 buf_ptr += sizeof(*sched_elem);
3722 }
3723
3724
3725 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3726 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303727 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303728 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303729 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303730 }
3731
Govind Singh67922e82016-04-01 16:48:57 +05303732 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303733}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303734
3735/**
3736 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3737 * @wmi_handle: wmi handle
3738 * @mcc_adaptive_scheduler: enable/disable
3739 *
3740 * This function enable/disable mcc adaptive scheduler in fw.
3741 *
Govind Singhb53420c2016-03-09 14:32:57 +05303742 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303743 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303744static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003745 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3746 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303747{
Govind Singh67922e82016-04-01 16:48:57 +05303748 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303749 wmi_buf_t buf = 0;
3750 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3751 uint16_t len =
3752 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3753
3754 buf = wmi_buf_alloc(wmi_handle, len);
3755 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303756 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3757 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303758 }
3759 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3760 wmi_buf_data(buf);
3761
3762 WMITLV_SET_HDR(&cmd->tlv_header,
3763 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3764 WMITLV_GET_STRUCT_TLVLEN
3765 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3766 cmd->enable = mcc_adaptive_scheduler;
Govind Singh4df47142016-04-16 19:24:23 -07003767 cmd->pdev_id = pdev_id;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303768
3769 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3770 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303771 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303772 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303773 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303774 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303775 }
Govind Singh67922e82016-04-01 16:48:57 +05303776
3777 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303778}
3779
3780/**
3781 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3782 * @wmi: wmi handle
3783 * @mcc_channel: mcc channel
3784 * @mcc_channel_time_latency: MCC channel time latency.
3785 *
3786 * Currently used to set time latency for an MCC vdev/adapter using operating
3787 * channel of it and channel number. The info is provided run time using
3788 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3789 *
3790 * Return: CDF status
3791 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303792static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303793 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3794{
Govind Singh67922e82016-04-01 16:48:57 +05303795 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303796 wmi_buf_t buf = 0;
3797 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3798 uint16_t len = 0;
3799 uint8_t *buf_ptr = NULL;
3800 wmi_resmgr_chan_latency chan_latency;
3801 /* Note: we only support MCC time latency for a single channel */
3802 uint32_t num_channels = 1;
3803 uint32_t chan1_freq = mcc_channel_freq;
3804 uint32_t latency_chan1 = mcc_channel_time_latency;
3805
3806
3807 /* If 0ms latency is provided, then FW will set to a default.
3808 * Otherwise, latency must be at least 30ms.
3809 */
3810 if ((latency_chan1 > 0) &&
3811 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303812 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303813 "Minimum is 30ms (or 0 to use default value by "
3814 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303815 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303816 }
3817
3818 /* Set WMI CMD for channel time latency here */
3819 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3820 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3821 num_channels * sizeof(wmi_resmgr_chan_latency);
3822 buf = wmi_buf_alloc(wmi_handle, len);
3823 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303824 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3825 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303826 }
3827 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3828 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3829 wmi_buf_data(buf);
3830 WMITLV_SET_HDR(&cmdTL->tlv_header,
3831 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3832 WMITLV_GET_STRUCT_TLVLEN
3833 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3834 cmdTL->num_chans = num_channels;
3835 /* Update channel time latency information for home channel(s) */
3836 buf_ptr += sizeof(*cmdTL);
3837 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3838 num_channels * sizeof(wmi_resmgr_chan_latency));
3839 buf_ptr += WMI_TLV_HDR_SIZE;
3840 chan_latency.chan_mhz = chan1_freq;
3841 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303842 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303843 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3844 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303845 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303846 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303847 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303848 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303849 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303850 }
Govind Singh67922e82016-04-01 16:48:57 +05303851
3852 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303853}
3854
3855/**
3856 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3857 * @wmi: wmi handle
3858 * @adapter_1_chan_number: adapter 1 channel number
3859 * @adapter_1_quota: adapter 1 quota
3860 * @adapter_2_chan_number: adapter 2 channel number
3861 *
3862 * Return: CDF status
3863 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303864static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303865 uint32_t adapter_1_chan_freq,
3866 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
3867{
Govind Singh67922e82016-04-01 16:48:57 +05303868 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303869 wmi_buf_t buf = 0;
3870 uint16_t len = 0;
3871 uint8_t *buf_ptr = NULL;
3872 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
3873 wmi_resmgr_chan_time_quota chan_quota;
3874 uint32_t quota_chan1 = adapter_1_quota;
3875 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
3876 uint32_t quota_chan2 = 100 - quota_chan1;
3877 /* Note: setting time quota for MCC requires info for 2 channels */
3878 uint32_t num_channels = 2;
3879 uint32_t chan1_freq = adapter_1_chan_freq;
3880 uint32_t chan2_freq = adapter_2_chan_freq;
3881
Govind Singhb53420c2016-03-09 14:32:57 +05303882 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303883 "freq2:%dMHz, Quota2:%dms", __func__,
3884 chan1_freq, quota_chan1, chan2_freq,
3885 quota_chan2);
3886
3887 /*
3888 * Perform sanity check on time quota values provided.
3889 */
3890 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
3891 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05303892 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303893 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303894 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303895 }
3896 /* Set WMI CMD for channel time quota here */
3897 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
3898 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
3899 num_channels * sizeof(wmi_resmgr_chan_time_quota);
3900 buf = wmi_buf_alloc(wmi_handle, len);
3901 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303902 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3903 QDF_ASSERT(0);
3904 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303905 }
3906 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3907 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
3908 wmi_buf_data(buf);
3909 WMITLV_SET_HDR(&cmdTQ->tlv_header,
3910 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
3911 WMITLV_GET_STRUCT_TLVLEN
3912 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
3913 cmdTQ->num_chans = num_channels;
3914
3915 /* Update channel time quota information for home channel(s) */
3916 buf_ptr += sizeof(*cmdTQ);
3917 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3918 num_channels * sizeof(wmi_resmgr_chan_time_quota));
3919 buf_ptr += WMI_TLV_HDR_SIZE;
3920 chan_quota.chan_mhz = chan1_freq;
3921 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303922 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303923 /* Construct channel and quota record for the 2nd MCC mode. */
3924 buf_ptr += sizeof(chan_quota);
3925 chan_quota.chan_mhz = chan2_freq;
3926 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05303927 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303928
3929 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3930 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303931 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303932 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05303933 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303934 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303935 }
Govind Singh67922e82016-04-01 16:48:57 +05303936
3937 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303938}
3939
3940/**
3941 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
3942 * @wmi_handle: Pointer to wmi handle
3943 * @thermal_info: Thermal command information
3944 *
3945 * This function sends the thermal management command
3946 * to the firmware
3947 *
Govind Singhb53420c2016-03-09 14:32:57 +05303948 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05303949 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303950static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303951 struct thermal_cmd_params *thermal_info)
3952{
3953 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
3954 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05303955 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303956 uint32_t len = 0;
3957
3958 len = sizeof(*cmd);
3959
3960 buf = wmi_buf_alloc(wmi_handle, len);
3961 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303962 WMI_LOGE("Failed to allocate buffer to send set key cmd");
3963 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303964 }
3965
3966 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
3967
3968 WMITLV_SET_HDR(&cmd->tlv_header,
3969 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
3970 WMITLV_GET_STRUCT_TLVLEN
3971 (wmi_thermal_mgmt_cmd_fixed_param));
3972
3973 cmd->lower_thresh_degreeC = thermal_info->min_temp;
3974 cmd->upper_thresh_degreeC = thermal_info->max_temp;
3975 cmd->enable = thermal_info->thermal_enable;
3976
Govind Singhb53420c2016-03-09 14:32:57 +05303977 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303978 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
3979
3980 status = wmi_unified_cmd_send(wmi_handle, buf, len,
3981 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303982 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05303983 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303984 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303985 }
3986
Govind Singh67922e82016-04-01 16:48:57 +05303987 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303988}
3989
3990
3991/**
3992 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05303993 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05303994 * @wmi_lro_cmd: Pointer to LRO configuration parameters
3995 *
3996 * This function sends down the LRO configuration parameters to
3997 * the firmware to enable LRO, sets the TCP flags and sets the
3998 * seed values for the toeplitz hash generation
3999 *
Govind Singhb53420c2016-03-09 14:32:57 +05304000 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304001 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304002static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304003 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4004{
4005 wmi_lro_info_cmd_fixed_param *cmd;
4006 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304007 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304008
4009
4010 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4011 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304012 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4013 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304014 }
4015
4016 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4017
4018 WMITLV_SET_HDR(&cmd->tlv_header,
4019 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4020 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4021
4022 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4023 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4024 wmi_lro_cmd->tcp_flag);
4025 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4026 wmi_lro_cmd->tcp_flag_mask);
4027 cmd->toeplitz_hash_ipv4_0_3 =
4028 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4029 cmd->toeplitz_hash_ipv4_4_7 =
4030 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4031 cmd->toeplitz_hash_ipv4_8_11 =
4032 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4033 cmd->toeplitz_hash_ipv4_12_15 =
4034 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4035 cmd->toeplitz_hash_ipv4_16 =
4036 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4037
4038 cmd->toeplitz_hash_ipv6_0_3 =
4039 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4040 cmd->toeplitz_hash_ipv6_4_7 =
4041 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4042 cmd->toeplitz_hash_ipv6_8_11 =
4043 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4044 cmd->toeplitz_hash_ipv6_12_15 =
4045 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4046 cmd->toeplitz_hash_ipv6_16_19 =
4047 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4048 cmd->toeplitz_hash_ipv6_20_23 =
4049 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4050 cmd->toeplitz_hash_ipv6_24_27 =
4051 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4052 cmd->toeplitz_hash_ipv6_28_31 =
4053 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4054 cmd->toeplitz_hash_ipv6_32_35 =
4055 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4056 cmd->toeplitz_hash_ipv6_36_39 =
4057 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4058 cmd->toeplitz_hash_ipv6_40 =
4059 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4060
Govind Singhb53420c2016-03-09 14:32:57 +05304061 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304062 cmd->lro_enable, cmd->tcp_flag_u32);
4063
4064 status = wmi_unified_cmd_send(wmi_handle, buf,
4065 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304066 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304067 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304068 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304069 }
4070
Govind Singh67922e82016-04-01 16:48:57 +05304071 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304072}
4073
Govind Singh4eacd2b2016-03-07 14:24:22 +05304074/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304075 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4076 * @wmi_handle: Pointer to wmi handle
4077 * @rate_report_params: Pointer to peer rate report parameters
4078 *
4079 *
4080 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4081 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304082static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304083 struct wmi_peer_rate_report_params *rate_report_params)
4084{
4085 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4086 wmi_buf_t buf = NULL;
4087 QDF_STATUS status = 0;
4088 uint32_t len = 0;
4089 uint32_t i, j;
4090
4091 len = sizeof(*cmd);
4092
4093 buf = wmi_buf_alloc(wmi_handle, len);
4094 if (!buf) {
4095 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4096 return QDF_STATUS_E_FAILURE;
4097 }
4098
4099 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4100 wmi_buf_data(buf);
4101
4102 WMITLV_SET_HDR(
4103 &cmd->tlv_header,
4104 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4105 WMITLV_GET_STRUCT_TLVLEN(
4106 wmi_peer_set_rate_report_condition_fixed_param));
4107
4108 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4109 cmd->report_backoff_time = rate_report_params->backoff_time;
4110 cmd->report_timer_period = rate_report_params->timer_period;
4111 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4112 cmd->cond_per_phy[i].val_cond_flags =
4113 rate_report_params->report_per_phy[i].cond_flags;
4114 cmd->cond_per_phy[i].rate_delta.min_delta =
4115 rate_report_params->report_per_phy[i].delta.delta_min;
4116 cmd->cond_per_phy[i].rate_delta.percentage =
4117 rate_report_params->report_per_phy[i].delta.percent;
4118 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4119 cmd->cond_per_phy[i].rate_threshold[j] =
4120 rate_report_params->report_per_phy[i].
4121 report_rate_threshold[j];
4122 }
4123 }
4124
4125 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4126 cmd->enable_rate_report,
4127 cmd->report_backoff_time, cmd->report_timer_period);
4128
4129 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4130 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4131 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304132 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304133 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4134 __func__);
4135 }
4136 return status;
4137}
4138
4139/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304140 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4141 * @wmi_handle: wmi handle
4142 * @param: bcn ll cmd parameter
4143 *
Govind Singhb53420c2016-03-09 14:32:57 +05304144 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304145 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304146static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304147 wmi_bcn_send_from_host_cmd_fixed_param *param)
4148{
4149 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4150 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304151 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304152
4153 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4154 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304155 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4156 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304157 }
4158
4159 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4160 WMITLV_SET_HDR(&cmd->tlv_header,
4161 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4162 WMITLV_GET_STRUCT_TLVLEN
4163 (wmi_bcn_send_from_host_cmd_fixed_param));
4164 cmd->vdev_id = param->vdev_id;
4165 cmd->data_len = param->data_len;
4166 cmd->frame_ctrl = param->frame_ctrl;
4167 cmd->frag_ptr = param->frag_ptr;
4168 cmd->dtim_flag = param->dtim_flag;
4169
4170 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4171 WMI_PDEV_SEND_BCN_CMDID);
4172
Govind Singh67922e82016-04-01 16:48:57 +05304173 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304174 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304175 wmi_buf_free(wmi_buf);
4176 }
4177
4178 return ret;
4179}
4180
4181/**
4182 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4183 * @wmi_handle: wmi handle
4184 * @vdev_id: vdev id
4185 * @max_retries: max retries
4186 * @retry_interval: retry interval
4187 * This function sets sta query related parameters in fw.
4188 *
Govind Singhb53420c2016-03-09 14:32:57 +05304189 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304190 */
4191
Sathish Kumarfd347372017-02-13 12:29:09 +05304192static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304193 uint8_t vdev_id, uint32_t max_retries,
4194 uint32_t retry_interval)
4195{
4196 wmi_buf_t buf;
4197 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4198 int len;
4199
4200 len = sizeof(*cmd);
4201 buf = wmi_buf_alloc(wmi_handle, len);
4202 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304203 WMI_LOGE(FL("wmi_buf_alloc failed"));
4204 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304205 }
4206
4207 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4208 WMITLV_SET_HDR(&cmd->tlv_header,
4209 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4210 WMITLV_GET_STRUCT_TLVLEN
4211 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4212
4213
4214 cmd->vdev_id = vdev_id;
4215 cmd->sa_query_max_retry_count = max_retries;
4216 cmd->sa_query_retry_interval = retry_interval;
4217
Govind Singhb53420c2016-03-09 14:32:57 +05304218 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304219 vdev_id, retry_interval, max_retries);
4220
4221 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4222 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304223 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304224 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304225 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304226 }
4227
Govind Singhb53420c2016-03-09 14:32:57 +05304228 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304229 return 0;
4230}
4231
4232/**
4233 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4234 * @wmi_handle: wmi handle
4235 * @params: sta keep alive parameter
4236 *
4237 * This function sets keep alive related parameters in fw.
4238 *
4239 * Return: CDF status
4240 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304241static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304242 struct sta_params *params)
4243{
4244 wmi_buf_t buf;
4245 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4246 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4247 uint8_t *buf_ptr;
4248 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304249 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304250
Govind Singhb53420c2016-03-09 14:32:57 +05304251 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304252
Govind Singh4eacd2b2016-03-07 14:24:22 +05304253 len = sizeof(*cmd) + sizeof(*arp_rsp);
4254 buf = wmi_buf_alloc(wmi_handle, len);
4255 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304256 WMI_LOGE("wmi_buf_alloc failed");
4257 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304258 }
4259
4260 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4261 buf_ptr = (uint8_t *) cmd;
4262 WMITLV_SET_HDR(&cmd->tlv_header,
4263 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4264 WMITLV_GET_STRUCT_TLVLEN
4265 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4266 cmd->interval = params->timeperiod;
4267 cmd->enable = (params->timeperiod) ? 1 : 0;
4268 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304269 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304270 params->timeperiod, params->method);
4271 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4272 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4273 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4274 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4275
4276 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4277 if ((NULL == params->hostv4addr) ||
4278 (NULL == params->destv4addr) ||
4279 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304280 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304281 "destv4addr:%p destmac:%p ", __func__,
4282 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304283 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304284 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304285 }
4286 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304287 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304288 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304289 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304290 WMI_IPV4_ADDR_LEN);
4291 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4292 } else {
4293 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4294 }
4295
Govind Singh67922e82016-04-01 16:48:57 +05304296 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4297 WMI_STA_KEEPALIVE_CMDID);
4298 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304299 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304300 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304301 }
4302
Govind Singhb53420c2016-03-09 14:32:57 +05304303 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304304 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304305}
4306
4307/**
4308 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4309 * @wmi_handle: wmi handle
4310 * @if_id: vdev id
4311 * @gtx_info: GTX config params
4312 *
4313 * This function set GTX related params in firmware.
4314 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304315 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304316 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304317static 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 +05304318 struct wmi_gtx_config *gtx_info)
4319{
4320 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4321 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304322 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304323 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304324
Govind Singh4eacd2b2016-03-07 14:24:22 +05304325 buf = wmi_buf_alloc(wmi_handle, len);
4326 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304327 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304328 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304329 }
4330 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4331 WMITLV_SET_HDR(&cmd->tlv_header,
4332 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4333 WMITLV_GET_STRUCT_TLVLEN
4334 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4335 cmd->vdev_id = if_id;
4336
4337 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4338 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4339 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4340 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4341 cmd->gtxPERMargin = gtx_info->gtx_margin;
4342 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4343 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4344 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4345
Govind Singhb53420c2016-03-09 14:32:57 +05304346 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304347 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4348 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4349 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4350 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4351
Abhishek Singh716c46c2016-05-04 16:24:07 +05304352 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304353 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304354 if (QDF_IS_STATUS_ERROR(ret)) {
4355 WMI_LOGE("Failed to set GTX PARAMS");
4356 wmi_buf_free(buf);
4357 }
4358 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304359}
4360
4361/**
4362 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4363 * @wmi_handle: wmi handle
4364 * @edca_params: edca parameters
4365 *
4366 * This function updates EDCA parameters to the target
4367 *
4368 * Return: CDF Status
4369 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304370static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304371 uint8_t vdev_id,
4372 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4373{
4374 uint8_t *buf_ptr;
4375 wmi_buf_t buf;
4376 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4377 wmi_wmm_vparams *wmm_param, *twmm_param;
4378 int len = sizeof(*cmd);
4379 int ac;
4380
4381 buf = wmi_buf_alloc(wmi_handle, len);
4382
4383 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304384 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4385 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304386 }
4387
4388 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4389 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4390 WMITLV_SET_HDR(&cmd->tlv_header,
4391 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4392 WMITLV_GET_STRUCT_TLVLEN
4393 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4394 cmd->vdev_id = vdev_id;
4395
4396 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4397 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4398 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4399 WMITLV_SET_HDR(&wmm_param->tlv_header,
4400 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4401 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4402 wmm_param->cwmin = twmm_param->cwmin;
4403 wmm_param->cwmax = twmm_param->cwmax;
4404 wmm_param->aifs = twmm_param->aifs;
4405 wmm_param->txoplimit = twmm_param->txoplimit;
4406 wmm_param->acm = twmm_param->acm;
4407 wmm_param->no_ack = twmm_param->no_ack;
4408 }
4409
4410 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4411 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4412 goto fail;
4413
Govind Singhb53420c2016-03-09 14:32:57 +05304414 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304415
4416fail:
4417 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304418 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4419 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304420}
4421
4422/**
4423 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4424 * @wmi_handle: wmi handle
4425 * @vdev_id: vdev id
4426 * @probe_rsp_info: probe response info
4427 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304428 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304429 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304430static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304431 uint8_t vdev_id,
4432 struct wmi_probe_resp_params *probe_rsp_info,
4433 uint8_t *frm)
4434{
4435 wmi_prb_tmpl_cmd_fixed_param *cmd;
4436 wmi_bcn_prb_info *bcn_prb_info;
4437 wmi_buf_t wmi_buf;
4438 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4439 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304440 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304441
Govind Singhb53420c2016-03-09 14:32:57 +05304442 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304443
4444 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4445 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4446
4447 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4448 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4449 tmpl_len_aligned;
4450
4451 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304452 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304453 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304454 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304455 }
4456
4457 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4458 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304459 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304460 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304461 }
4462
4463 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4464
4465 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4466 WMITLV_SET_HDR(&cmd->tlv_header,
4467 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4468 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4469 cmd->vdev_id = vdev_id;
4470 cmd->buf_len = tmpl_len;
4471 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4472
4473 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4474 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4475 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4476 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4477 bcn_prb_info->caps = 0;
4478 bcn_prb_info->erp = 0;
4479 buf_ptr += sizeof(wmi_bcn_prb_info);
4480
4481 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4482 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304483 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304484
4485 ret = wmi_unified_cmd_send(wmi_handle,
4486 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304487 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304488 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304489 wmi_buf_free(wmi_buf);
4490 }
4491
4492 return ret;
4493}
4494
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304495#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304496#define WPI_IV_LEN 16
4497
4498/**
4499 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4500 *
4501 * @dest_tx: destination address of tsc key counter
4502 * @src_tx: source address of tsc key counter
4503 * @dest_rx: destination address of rsc key counter
4504 * @src_rx: source address of rsc key counter
4505 *
4506 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4507 *
4508 * Return: None
4509 *
4510 */
4511static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4512 uint8_t *dest_rx, uint8_t *src_rx)
4513{
4514 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4515 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4516}
4517#else
4518static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4519 uint8_t *dest_rx, uint8_t *src_rx)
4520{
4521 return;
4522}
4523#endif
4524
4525/**
4526 * send_setup_install_key_cmd_tlv() - set key parameters
4527 * @wmi_handle: wmi handle
4528 * @key_params: key parameters
4529 *
4530 * This function fills structure from information
4531 * passed in key_params.
4532 *
4533 * Return: QDF_STATUS_SUCCESS - success
4534 * QDF_STATUS_E_FAILURE - failure
4535 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4536 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304537static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304538 struct set_key_params *key_params)
4539{
4540 wmi_vdev_install_key_cmd_fixed_param *cmd;
4541 wmi_buf_t buf;
4542 uint8_t *buf_ptr;
4543 uint32_t len;
4544 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304545 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304546
4547 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4548 WMI_TLV_HDR_SIZE;
4549
4550 buf = wmi_buf_alloc(wmi_handle, len);
4551 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304552 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304553 return QDF_STATUS_E_NOMEM;
4554 }
4555
4556 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4557 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4558 WMITLV_SET_HDR(&cmd->tlv_header,
4559 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4560 WMITLV_GET_STRUCT_TLVLEN
4561 (wmi_vdev_install_key_cmd_fixed_param));
4562 cmd->vdev_id = key_params->vdev_id;
4563 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304564
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304565
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304566 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4567 cmd->key_flags |= key_params->key_flags;
4568 cmd->key_cipher = key_params->key_cipher;
4569 if ((key_params->key_txmic_len) &&
4570 (key_params->key_rxmic_len)) {
4571 cmd->key_txmic_len = key_params->key_txmic_len;
4572 cmd->key_rxmic_len = key_params->key_rxmic_len;
4573 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304574#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304575 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4576 key_params->tx_iv,
4577 cmd->wpi_key_rsc_counter,
4578 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304579#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304580 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4581 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4582 roundup(key_params->key_len, sizeof(uint32_t)));
4583 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4584 qdf_mem_copy((void *)key_data,
4585 (const void *)key_params->key_data, key_params->key_len);
4586 cmd->key_len = key_params->key_len;
4587
4588 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4589 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304590 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304591 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304592
Govind Singh67922e82016-04-01 16:48:57 +05304593 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304594}
4595
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304596/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004597 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4598 * @wmi_handle: wmi handle
4599 * @params: sar limit params
4600 *
4601 * Return: QDF_STATUS_SUCCESS for success or error code
4602 */
4603static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4604 struct sar_limit_cmd_params *sar_limit_params)
4605{
4606 wmi_buf_t buf;
4607 QDF_STATUS qdf_status;
4608 wmi_sar_limits_cmd_fixed_param *cmd;
4609 int i;
4610 uint8_t *buf_ptr;
4611 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4612 struct sar_limit_cmd_row *sar_rows_list;
4613 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4614
4615 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4616 buf = wmi_buf_alloc(wmi_handle, len);
4617 if (!buf) {
4618 WMI_LOGE("Failed to allocate memory");
4619 qdf_status = QDF_STATUS_E_NOMEM;
4620 goto end;
4621 }
4622
4623 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4624 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4625 WMITLV_SET_HDR(&cmd->tlv_header,
4626 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4627 WMITLV_GET_STRUCT_TLVLEN
4628 (wmi_sar_limits_cmd_fixed_param));
4629 cmd->sar_enable = sar_limit_params->sar_enable;
4630 cmd->commit_limits = sar_limit_params->commit_limits;
4631 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4632
4633 WMI_LOGD("no of sar rows = %d, len = %d",
4634 sar_limit_params->num_limit_rows, len);
4635 buf_ptr += sizeof(*cmd);
4636 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4637 sizeof(wmi_sar_limit_cmd_row) *
4638 sar_limit_params->num_limit_rows);
4639 if (cmd->num_limit_rows == 0)
4640 goto send_sar_limits;
4641
4642 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4643 (buf_ptr + WMI_TLV_HDR_SIZE);
4644 sar_rows_list = sar_limit_params->sar_limit_row_list;
4645
4646 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4647 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4648 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4649 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4650 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4651 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4652 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4653 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4654 wmi_sar_rows_list->validity_bitmap =
4655 sar_rows_list->validity_bitmap;
4656 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4657 i, wmi_sar_rows_list->band_id,
4658 wmi_sar_rows_list->chain_id,
4659 wmi_sar_rows_list->mod_id,
4660 wmi_sar_rows_list->limit_value,
4661 wmi_sar_rows_list->validity_bitmap);
4662 sar_rows_list++;
4663 wmi_sar_rows_list++;
4664 }
4665send_sar_limits:
4666 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4667 WMI_SAR_LIMITS_CMDID);
4668
4669 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4670 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4671 wmi_buf_free(buf);
4672 }
4673
4674end:
4675 return qdf_status;
4676}
4677
4678/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304679 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4680 * @wmi_handle: wmi handle
4681 * @params: encrypt/decrypt params
4682 *
4683 * Return: QDF_STATUS_SUCCESS for success or error code
4684 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004685static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304686QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4687 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4688{
4689 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4690 wmi_buf_t wmi_buf;
4691 uint8_t *buf_ptr;
4692 QDF_STATUS ret;
4693 uint32_t len;
4694
4695 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4696
4697 len = sizeof(*cmd) +
4698 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4699 WMI_TLV_HDR_SIZE;
4700 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4701 if (!wmi_buf) {
4702 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4703 __func__);
4704 return QDF_STATUS_E_NOMEM;
4705 }
4706
4707 buf_ptr = wmi_buf_data(wmi_buf);
4708 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4709
4710 WMITLV_SET_HDR(&cmd->tlv_header,
4711 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4712 WMITLV_GET_STRUCT_TLVLEN(
4713 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4714
4715 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4716 cmd->key_flag = encrypt_decrypt_params->key_flag;
4717 cmd->key_idx = encrypt_decrypt_params->key_idx;
4718 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4719 cmd->key_len = encrypt_decrypt_params->key_len;
4720 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4721 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4722
4723 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4724 encrypt_decrypt_params->key_len);
4725
4726 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4727 MAX_MAC_HEADER_LEN);
4728
4729 cmd->data_len = encrypt_decrypt_params->data_len;
4730
4731 if (cmd->data_len) {
4732 buf_ptr += sizeof(*cmd);
4733 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4734 roundup(encrypt_decrypt_params->data_len,
4735 sizeof(A_UINT32)));
4736 buf_ptr += WMI_TLV_HDR_SIZE;
4737 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4738 encrypt_decrypt_params->data_len);
4739 }
4740
4741 /* This conversion is to facilitate data to FW in little endian */
4742 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4743 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4744 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4745 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4746 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4747 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4748
4749 ret = wmi_unified_cmd_send(wmi_handle,
4750 wmi_buf, len,
4751 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4752 if (QDF_IS_STATUS_ERROR(ret)) {
4753 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4754 wmi_buf_free(wmi_buf);
4755 }
4756
4757 return ret;
4758}
4759
4760
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304761
Govind Singh4eacd2b2016-03-07 14:24:22 +05304762/**
4763 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4764 * @wmi_handle: wmi handle
4765 * @vdev_id: vdev id
4766 * @p2p_ie: p2p IE
4767 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304768 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304769 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304770static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304771 A_UINT32 vdev_id, uint8_t *p2p_ie)
4772{
Govind Singh67922e82016-04-01 16:48:57 +05304773 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304774 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4775 wmi_buf_t wmi_buf;
4776 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4777 uint8_t *buf_ptr;
4778
4779 ie_len = (uint32_t) (p2p_ie[1] + 2);
4780
4781 /* More than one P2P IE may be included in a single frame.
4782 If multiple P2P IEs are present, the complete P2P attribute
4783 data consists of the concatenation of the P2P Attribute
4784 fields of the P2P IEs. The P2P Attributes field of each
4785 P2P IE may be any length up to the maximum (251 octets).
4786 In this case host sends one P2P IE to firmware so the length
4787 should not exceed more than 251 bytes
4788 */
4789 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304790 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304791 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304792 }
4793
4794 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4795
4796 wmi_buf_len =
4797 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4798 WMI_TLV_HDR_SIZE;
4799
4800 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4801 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304802 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304803 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304804 }
4805
4806 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4807
4808 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4809 WMITLV_SET_HDR(&cmd->tlv_header,
4810 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4811 WMITLV_GET_STRUCT_TLVLEN
4812 (wmi_p2p_go_set_beacon_ie_fixed_param));
4813 cmd->vdev_id = vdev_id;
4814 cmd->ie_buf_len = ie_len;
4815
4816 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4817 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4818 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304819 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304820
Govind Singhb53420c2016-03-09 14:32:57 +05304821 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304822
4823 ret = wmi_unified_cmd_send(wmi_handle,
4824 wmi_buf, wmi_buf_len,
4825 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304826 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304827 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304828 wmi_buf_free(wmi_buf);
4829 }
4830
Govind Singhb53420c2016-03-09 14:32:57 +05304831 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304832 return ret;
4833}
4834
4835/**
4836 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4837 * @wmi_handle: wmi handle
4838 * @req: gateway parameter update request structure
4839 *
4840 * This function reads the incoming @req and fill in the destination
4841 * WMI structure and sends down the gateway configs down to the firmware
4842 *
Govind Singhb53420c2016-03-09 14:32:57 +05304843 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304844 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304845static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304846 struct gateway_update_req_param *req)
4847{
4848 wmi_roam_subnet_change_config_fixed_param *cmd;
4849 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304850 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304851 int len = sizeof(*cmd);
4852
4853 buf = wmi_buf_alloc(wmi_handle, len);
4854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304855 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4856 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304857 }
4858
4859 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4860 WMITLV_SET_HDR(&cmd->tlv_header,
4861 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4862 WMITLV_GET_STRUCT_TLVLEN(
4863 wmi_roam_subnet_change_config_fixed_param));
4864
4865 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304866 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
4867 QDF_IPV4_ADDR_SIZE);
4868 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
4869 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304870 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
4871 &cmd->inet_gw_mac_addr);
4872 cmd->max_retries = req->max_retries;
4873 cmd->timeout = req->timeout;
4874 cmd->num_skip_subnet_change_detection_bssid_list = 0;
4875 cmd->flag = 0;
4876 if (req->ipv4_addr_type)
4877 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
4878
4879 if (req->ipv6_addr_type)
4880 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
4881
4882 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4883 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304884 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304885 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05304886 ret);
4887 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304888 }
4889
Govind Singh67922e82016-04-01 16:48:57 +05304890 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304891}
4892
4893/**
4894 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
4895 * @wmi_handle: wmi handle
4896 * @req: rssi monitoring request structure
4897 *
4898 * This function reads the incoming @req and fill in the destination
4899 * WMI structure and send down the rssi monitoring configs down to the firmware
4900 *
4901 * Return: 0 on success; error number otherwise
4902 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304903static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304904 struct rssi_monitor_param *req)
4905{
4906 wmi_rssi_breach_monitor_config_fixed_param *cmd;
4907 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304908 QDF_STATUS ret;
4909 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304910
4911 buf = wmi_buf_alloc(wmi_handle, len);
4912 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304913 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4914 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304915 }
4916
4917 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
4918 WMITLV_SET_HDR(&cmd->tlv_header,
4919 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
4920 WMITLV_GET_STRUCT_TLVLEN(
4921 wmi_rssi_breach_monitor_config_fixed_param));
4922
4923 cmd->vdev_id = req->session_id;
4924 cmd->request_id = req->request_id;
4925 cmd->lo_rssi_reenable_hysteresis = 0;
4926 cmd->hi_rssi_reenable_histeresis = 0;
4927 cmd->min_report_interval = 0;
4928 cmd->max_num_report = 1;
4929 if (req->control) {
4930 /* enable one threshold for each min/max */
4931 cmd->enabled_bitmap = 0x09;
4932 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
4933 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
4934 } else {
4935 cmd->enabled_bitmap = 0;
4936 cmd->low_rssi_breach_threshold[0] = 0;
4937 cmd->hi_rssi_breach_threshold[0] = 0;
4938 }
4939
4940 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4941 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304942 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304943 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304944 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304945 }
4946
Govind Singhb53420c2016-03-09 14:32:57 +05304947 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05304948 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304949}
4950
4951/**
4952 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
4953 * @wmi_handle: wmi handle
4954 * @psetoui: OUI parameters
4955 *
4956 * set scan probe OUI parameters in firmware
4957 *
4958 * Return: CDF status
4959 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304960static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304961 struct scan_mac_oui *psetoui)
4962{
4963 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
4964 wmi_buf_t wmi_buf;
4965 uint32_t len;
4966 uint8_t *buf_ptr;
4967 uint32_t *oui_buf;
4968
4969 len = sizeof(*cmd);
4970 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4971 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304972 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4973 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304974 }
4975 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4976 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
4977 WMITLV_SET_HDR(&cmd->tlv_header,
4978 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
4979 WMITLV_GET_STRUCT_TLVLEN
4980 (wmi_scan_prob_req_oui_cmd_fixed_param));
4981
4982 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05304983 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304984 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
4985 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05304986 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304987 cmd->prob_req_oui);
4988
4989 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
4990 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304991 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304992 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304993 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304994 }
Govind Singhb53420c2016-03-09 14:32:57 +05304995 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304996}
4997
4998/**
4999 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5000 * @wmi_handle: wmi handle
5001 * @req: passpoint network request structure
5002 *
5003 * This function sends down WMI command with network id set to wildcard id.
5004 * firmware shall clear all the config entries
5005 *
Govind Singhb53420c2016-03-09 14:32:57 +05305006 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305007 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305008static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305009 struct wifi_passpoint_req_param *req)
5010{
5011 wmi_passpoint_config_cmd_fixed_param *cmd;
5012 wmi_buf_t buf;
5013 uint32_t len;
5014 int ret;
5015
5016 len = sizeof(*cmd);
5017 buf = wmi_buf_alloc(wmi_handle, len);
5018 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305019 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5020 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 }
5022
5023 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5024
5025 WMITLV_SET_HDR(&cmd->tlv_header,
5026 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5027 WMITLV_GET_STRUCT_TLVLEN(
5028 wmi_passpoint_config_cmd_fixed_param));
5029 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5030
5031 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5032 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5033 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305034 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305035 __func__);
5036 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305037 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305038 }
5039
Govind Singhb53420c2016-03-09 14:32:57 +05305040 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305041}
5042
5043/**
5044 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5045 * @wmi_handle: wmi handle
5046 * @req: passpoint network request structure
5047 *
5048 * This function reads the incoming @req and fill in the destination
5049 * WMI structure and send down the passpoint configs down to the firmware
5050 *
Govind Singhb53420c2016-03-09 14:32:57 +05305051 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305052 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305053static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305054 struct wifi_passpoint_req_param *req)
5055{
5056 wmi_passpoint_config_cmd_fixed_param *cmd;
5057 u_int8_t i, j, *bytes;
5058 wmi_buf_t buf;
5059 uint32_t len;
5060 int ret;
5061
5062 len = sizeof(*cmd);
5063 for (i = 0; i < req->num_networks; i++) {
5064 buf = wmi_buf_alloc(wmi_handle, len);
5065 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305066 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5067 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305068 }
5069
5070 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5071 wmi_buf_data(buf);
5072
5073 WMITLV_SET_HDR(&cmd->tlv_header,
5074 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5075 WMITLV_GET_STRUCT_TLVLEN(
5076 wmi_passpoint_config_cmd_fixed_param));
5077 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305078 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5079 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305080 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305081 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305082 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5083 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305084 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305085 j, bytes[0], bytes[1], bytes[2], bytes[3],
5086 bytes[4], bytes[5], bytes[6], bytes[7]);
5087
Govind Singhb53420c2016-03-09 14:32:57 +05305088 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305089 &req->networks[i].roaming_consortium_ids[j],
5090 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5091 }
Govind Singhb53420c2016-03-09 14:32:57 +05305092 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305093 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305094 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305095 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5096
5097 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5098 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5099 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305100 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305101 __func__);
5102 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305103 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305104 }
5105 }
5106
Govind Singhb53420c2016-03-09 14:32:57 +05305107 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305108}
5109
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305110/**
5111 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5112 * @wmi_handle: wmi handle
5113 * @scan_cmd_fp: start scan command ptr
5114 * @roam_req: roam request param
5115 *
5116 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5117 * of WMI_ROAM_SCAN_MODE.
5118 *
5119 * Return: QDF status
5120 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305121static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305122 wmi_start_scan_cmd_fixed_param *
5123 scan_cmd_fp,
5124 struct roam_offload_scan_params *roam_req)
5125{
5126 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305127 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305128 int len;
5129 uint8_t *buf_ptr;
5130 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305131
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305132#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5133 int auth_mode = roam_req->auth_mode;
5134 wmi_roam_offload_tlv_param *roam_offload_params;
5135 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5136 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5137 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305138 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305139#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5140 /* Need to create a buf with roam_scan command at
5141 * front and piggyback with scan command */
5142 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5143#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5144 (2 * WMI_TLV_HDR_SIZE) +
5145#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5146 sizeof(wmi_start_scan_cmd_fixed_param);
5147#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5148 if (roam_req->is_roam_req_valid &&
5149 roam_req->roam_offload_enabled) {
5150 len += sizeof(wmi_roam_offload_tlv_param);
5151 len += WMI_TLV_HDR_SIZE;
5152 if ((auth_mode != WMI_AUTH_NONE) &&
5153 ((auth_mode != WMI_AUTH_OPEN) ||
5154 (auth_mode == WMI_AUTH_OPEN &&
5155 roam_req->mdid.mdie_present) ||
5156 roam_req->is_ese_assoc)) {
5157 len += WMI_TLV_HDR_SIZE;
5158 if (roam_req->is_ese_assoc)
5159 len +=
5160 sizeof(wmi_roam_ese_offload_tlv_param);
5161 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5162 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5163 (auth_mode == WMI_AUTH_OPEN &&
5164 roam_req->mdid.mdie_present))
5165 len +=
5166 sizeof(wmi_roam_11r_offload_tlv_param);
5167 else
5168 len +=
5169 sizeof(wmi_roam_11i_offload_tlv_param);
5170 } else {
5171 len += WMI_TLV_HDR_SIZE;
5172 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305173
5174 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5175 + roundup(roam_req->assoc_ie_length,
5176 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305177 } else {
5178 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305179 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305180 __func__, roam_req->roam_offload_enabled);
5181 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305182 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305183 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305184 }
5185 if (roam_req->is_roam_req_valid &&
5186 roam_req->roam_offload_enabled) {
5187 roam_req->mode = roam_req->mode |
5188 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5189 }
5190#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5191
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305192 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5193 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5194 len = sizeof(wmi_roam_scan_mode_fixed_param);
5195
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305196 buf = wmi_buf_alloc(wmi_handle, len);
5197 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305198 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305199 return QDF_STATUS_E_NOMEM;
5200 }
5201
5202 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305203
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305204 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5205 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5206 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5207 WMITLV_GET_STRUCT_TLVLEN
5208 (wmi_roam_scan_mode_fixed_param));
5209
5210 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5211 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305212 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5213 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5214 goto send_roam_scan_mode_cmd;
5215
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305216 /* Fill in scan parameters suitable for roaming scan */
5217 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305218
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305219 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5220 sizeof(wmi_start_scan_cmd_fixed_param));
5221 /* Ensure there is no additional IEs */
5222 scan_cmd_fp->ie_len = 0;
5223 WMITLV_SET_HDR(buf_ptr,
5224 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5225 WMITLV_GET_STRUCT_TLVLEN
5226 (wmi_start_scan_cmd_fixed_param));
5227#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5228 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5229 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5230 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5231 sizeof(wmi_roam_offload_tlv_param));
5232 buf_ptr += WMI_TLV_HDR_SIZE;
5233 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5234 WMITLV_SET_HDR(buf_ptr,
5235 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5236 WMITLV_GET_STRUCT_TLVLEN
5237 (wmi_roam_offload_tlv_param));
5238 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5239 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5240 roam_offload_params->select_5g_margin =
5241 roam_req->select_5ghz_margin;
5242 roam_offload_params->reassoc_failure_timeout =
5243 roam_req->reassoc_failure_timeout;
5244
5245 /* Fill the capabilities */
5246 roam_offload_params->capability =
5247 roam_req->roam_offload_params.capability;
5248 roam_offload_params->ht_caps_info =
5249 roam_req->roam_offload_params.ht_caps_info;
5250 roam_offload_params->ampdu_param =
5251 roam_req->roam_offload_params.ampdu_param;
5252 roam_offload_params->ht_ext_cap =
5253 roam_req->roam_offload_params.ht_ext_cap;
5254 roam_offload_params->ht_txbf =
5255 roam_req->roam_offload_params.ht_txbf;
5256 roam_offload_params->asel_cap =
5257 roam_req->roam_offload_params.asel_cap;
5258 roam_offload_params->qos_caps =
5259 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005260 roam_offload_params->qos_enabled =
5261 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305262 roam_offload_params->wmm_caps =
5263 roam_req->roam_offload_params.wmm_caps;
5264 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5265 (uint8_t *)roam_req->roam_offload_params.mcsset,
5266 ROAM_OFFLOAD_NUM_MCS_SET);
5267
5268 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5269 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5270 * they are filled in the same order.Depending on the
5271 * authentication type, the other mode TLV's are nullified
5272 * and only headers are filled.*/
5273 if ((auth_mode != WMI_AUTH_NONE) &&
5274 ((auth_mode != WMI_AUTH_OPEN) ||
5275 (auth_mode == WMI_AUTH_OPEN
5276 && roam_req->mdid.mdie_present) ||
5277 roam_req->is_ese_assoc)) {
5278 if (roam_req->is_ese_assoc) {
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 sizeof(wmi_roam_ese_offload_tlv_param));
5287 buf_ptr += WMI_TLV_HDR_SIZE;
5288 roam_offload_ese =
5289 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5290 qdf_mem_copy(roam_offload_ese->krk,
5291 roam_req->krk,
5292 sizeof(roam_req->krk));
5293 qdf_mem_copy(roam_offload_ese->btk,
5294 roam_req->btk,
5295 sizeof(roam_req->btk));
5296 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5297 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5298 WMITLV_GET_STRUCT_TLVLEN
5299 (wmi_roam_ese_offload_tlv_param));
5300 buf_ptr +=
5301 sizeof(wmi_roam_ese_offload_tlv_param);
5302 } else if (auth_mode == WMI_AUTH_FT_RSNA
5303 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5304 || (auth_mode == WMI_AUTH_OPEN
5305 && roam_req->mdid.mdie_present)) {
5306 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5307 0);
5308 buf_ptr += WMI_TLV_HDR_SIZE;
5309 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5310 sizeof(wmi_roam_11r_offload_tlv_param));
5311 buf_ptr += WMI_TLV_HDR_SIZE;
5312 roam_offload_11r =
5313 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5314 roam_offload_11r->r0kh_id_len =
5315 roam_req->rokh_id_length;
5316 qdf_mem_copy(roam_offload_11r->r0kh_id,
5317 roam_req->rokh_id,
5318 roam_offload_11r->r0kh_id_len);
5319 qdf_mem_copy(roam_offload_11r->psk_msk,
5320 roam_req->psk_pmk,
5321 sizeof(roam_req->psk_pmk));
5322 roam_offload_11r->psk_msk_len =
5323 roam_req->pmk_len;
5324 roam_offload_11r->mdie_present =
5325 roam_req->mdid.mdie_present;
5326 roam_offload_11r->mdid =
5327 roam_req->mdid.mobility_domain;
5328 if (auth_mode == WMI_AUTH_OPEN) {
5329 /* If FT-Open ensure pmk length
5330 and r0khid len are zero */
5331 roam_offload_11r->r0kh_id_len = 0;
5332 roam_offload_11r->psk_msk_len = 0;
5333 }
5334 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5335 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5336 WMITLV_GET_STRUCT_TLVLEN
5337 (wmi_roam_11r_offload_tlv_param));
5338 buf_ptr +=
5339 sizeof(wmi_roam_11r_offload_tlv_param);
5340 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5341 WMITLV_GET_STRUCT_TLVLEN(0));
5342 buf_ptr += WMI_TLV_HDR_SIZE;
5343 } else {
5344 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5345 sizeof(wmi_roam_11i_offload_tlv_param));
5346 buf_ptr += WMI_TLV_HDR_SIZE;
5347 roam_offload_11i =
5348 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005349 if (roam_req->roam_key_mgmt_offload_enabled &&
5350 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305351 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5352 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305353 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305354 } else {
5355 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5356 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305357 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305358 }
5359
5360 qdf_mem_copy(roam_offload_11i->pmk,
5361 roam_req->psk_pmk,
5362 sizeof(roam_req->psk_pmk));
5363 roam_offload_11i->pmk_len = roam_req->pmk_len;
5364 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5365 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5366 WMITLV_GET_STRUCT_TLVLEN
5367 (wmi_roam_11i_offload_tlv_param));
5368 buf_ptr +=
5369 sizeof(wmi_roam_11i_offload_tlv_param);
5370 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5371 0);
5372 buf_ptr += WMI_TLV_HDR_SIZE;
5373 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5374 0);
5375 buf_ptr += WMI_TLV_HDR_SIZE;
5376 }
5377 } else {
5378 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5379 WMITLV_GET_STRUCT_TLVLEN(0));
5380 buf_ptr += WMI_TLV_HDR_SIZE;
5381 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5382 WMITLV_GET_STRUCT_TLVLEN(0));
5383 buf_ptr += WMI_TLV_HDR_SIZE;
5384 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5385 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305386 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305387 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305388
5389 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5390 sizeof(*assoc_ies));
5391 buf_ptr += WMI_TLV_HDR_SIZE;
5392
5393 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5394 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5395 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5396 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5397 assoc_ies->buf_len = roam_req->assoc_ie_length;
5398
5399 buf_ptr += sizeof(*assoc_ies);
5400
5401 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5402 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5403 buf_ptr += WMI_TLV_HDR_SIZE;
5404
5405 if (assoc_ies->buf_len != 0) {
5406 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5407 assoc_ies->buf_len);
5408 }
5409
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305410 } else {
5411 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5412 WMITLV_GET_STRUCT_TLVLEN(0));
5413 buf_ptr += WMI_TLV_HDR_SIZE;
5414 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5415 WMITLV_GET_STRUCT_TLVLEN(0));
5416 buf_ptr += WMI_TLV_HDR_SIZE;
5417 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5418 WMITLV_GET_STRUCT_TLVLEN(0));
5419 buf_ptr += WMI_TLV_HDR_SIZE;
5420 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5421 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305422 buf_ptr += WMI_TLV_HDR_SIZE;
5423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5424 WMITLV_GET_STRUCT_TLVLEN(0));
5425 buf_ptr += WMI_TLV_HDR_SIZE;
5426 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5427 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305428 }
5429#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305430
5431send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305432 status = wmi_unified_cmd_send(wmi_handle, buf,
5433 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305434 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305435 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305436 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5437 status);
5438 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305439 }
5440
Govind Singh67922e82016-04-01 16:48:57 +05305441 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305442}
5443
5444
5445/**
5446 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5447 * rssi threashold
5448 * @wmi_handle: wmi handle
5449 * @roam_req: Roaming request buffer
5450 *
5451 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5452 *
5453 * Return: QDF status
5454 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305455static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305456 struct roam_offload_scan_rssi_params *roam_req)
5457{
5458 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305459 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305460 int len;
5461 uint8_t *buf_ptr;
5462 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5463 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5464 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305465 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305466
5467 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5468 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5469 len += sizeof(wmi_roam_scan_extended_threshold_param);
5470 len += WMI_TLV_HDR_SIZE;
5471 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305472 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5473 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305474 buf = wmi_buf_alloc(wmi_handle, len);
5475 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305476 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305477 return QDF_STATUS_E_NOMEM;
5478 }
5479
5480 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5481 rssi_threshold_fp =
5482 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5483 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5484 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5485 WMITLV_GET_STRUCT_TLVLEN
5486 (wmi_roam_scan_rssi_threshold_fixed_param));
5487 /* fill in threshold values */
5488 rssi_threshold_fp->vdev_id = roam_req->session_id;
5489 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5490 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5491 rssi_threshold_fp->hirssi_scan_max_count =
5492 roam_req->hi_rssi_scan_max_count;
5493 rssi_threshold_fp->hirssi_scan_delta =
5494 roam_req->hi_rssi_scan_rssi_delta;
5495 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5496
5497 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5498 WMITLV_SET_HDR(buf_ptr,
5499 WMITLV_TAG_ARRAY_STRUC,
5500 sizeof(wmi_roam_scan_extended_threshold_param));
5501 buf_ptr += WMI_TLV_HDR_SIZE;
5502 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5503
5504 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5505 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5506 ext_thresholds->boost_threshold_5g =
5507 roam_req->boost_threshold_5g;
5508
5509 ext_thresholds->boost_algorithm_5g =
5510 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5511 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5512 ext_thresholds->penalty_algorithm_5g =
5513 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5514 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5515 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5516 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5517 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5518
5519 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5520 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5521 WMITLV_GET_STRUCT_TLVLEN
5522 (wmi_roam_scan_extended_threshold_param));
5523 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5524 WMITLV_SET_HDR(buf_ptr,
5525 WMITLV_TAG_ARRAY_STRUC,
5526 sizeof(wmi_roam_earlystop_rssi_thres_param));
5527 buf_ptr += WMI_TLV_HDR_SIZE;
5528 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5529 early_stop_thresholds->roam_earlystop_thres_min =
5530 roam_req->roam_earlystop_thres_min;
5531 early_stop_thresholds->roam_earlystop_thres_max =
5532 roam_req->roam_earlystop_thres_max;
5533 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5534 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5535 WMITLV_GET_STRUCT_TLVLEN
5536 (wmi_roam_earlystop_rssi_thres_param));
5537
Gupta, Kapil7e652922016-04-12 15:02:00 +05305538 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5540 sizeof(wmi_roam_dense_thres_param));
5541 buf_ptr += WMI_TLV_HDR_SIZE;
5542 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5543 dense_thresholds->roam_dense_rssi_thres_offset =
5544 roam_req->dense_rssi_thresh_offset;
5545 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5546 dense_thresholds->roam_dense_traffic_thres =
5547 roam_req->traffic_threshold;
5548 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5549 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5550 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5551 WMITLV_GET_STRUCT_TLVLEN
5552 (wmi_roam_dense_thres_param));
5553
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305554 status = wmi_unified_cmd_send(wmi_handle, buf,
5555 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305556 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305557 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305558 status);
5559 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305560 }
5561
Govind Singh67922e82016-04-01 16:48:57 +05305562 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305563}
5564
5565/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305566 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5567 * configuration params
5568 * @wma_handle: wma handler
5569 * @dwelltime_params: pointer to dwelltime_params
5570 *
5571 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5572 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005573static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305574QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5575 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5576{
5577 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5578 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5579 wmi_buf_t buf;
5580 uint8_t *buf_ptr;
5581 int32_t err;
5582 int len;
5583
5584 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5585 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5586 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5587 buf = wmi_buf_alloc(wmi_handle, len);
5588 if (!buf) {
5589 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5590 __func__);
5591 return QDF_STATUS_E_NOMEM;
5592 }
5593 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5594 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5595 WMITLV_SET_HDR(&dwell_param->tlv_header,
5596 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5597 WMITLV_GET_STRUCT_TLVLEN
5598 (wmi_scan_adaptive_dwell_config_fixed_param));
5599
5600 dwell_param->enable = dwelltime_params->is_enabled;
5601 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5602 WMITLV_SET_HDR(buf_ptr,
5603 WMITLV_TAG_ARRAY_STRUC,
5604 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5605 buf_ptr += WMI_TLV_HDR_SIZE;
5606
5607 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5608 WMITLV_SET_HDR(&cmd->tlv_header,
5609 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5610 WMITLV_GET_STRUCT_TLVLEN(
5611 wmi_scan_adaptive_dwell_parameters_tlv));
5612
5613 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5614 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5615 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5616 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5617 err = wmi_unified_cmd_send(wmi_handle, buf,
5618 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5619 if (err) {
5620 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5621 wmi_buf_free(buf);
5622 return QDF_STATUS_E_FAILURE;
5623 }
5624
5625 return QDF_STATUS_SUCCESS;
5626}
5627
5628
5629/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305630 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5631 * @wmi_handle: wmi handle
5632 * @roam_req: Request which contains the filters
5633 *
5634 * There are filters such as whitelist, blacklist and preferred
5635 * list that need to be applied to the scan results to form the
5636 * probable candidates for roaming.
5637 *
5638 * Return: Return success upon succesfully passing the
5639 * parameters to the firmware, otherwise failure.
5640 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305641static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305642 struct roam_scan_filter_params *roam_req)
5643{
5644 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305645 QDF_STATUS status;
5646 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305647 uint32_t len;
5648 uint8_t *buf_ptr;
5649 wmi_roam_filter_fixed_param *roam_filter;
5650 uint8_t *bssid_src_ptr = NULL;
5651 wmi_mac_addr *bssid_dst_ptr = NULL;
5652 wmi_ssid *ssid_ptr = NULL;
5653 uint32_t *bssid_preferred_factor_ptr = NULL;
5654
5655 len = sizeof(wmi_roam_filter_fixed_param);
5656 len += WMI_TLV_HDR_SIZE;
5657 len += roam_req->len;
5658
5659 buf = wmi_buf_alloc(wmi_handle, len);
5660 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305661 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305662 return QDF_STATUS_E_NOMEM;
5663 }
5664
5665 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5666 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5667 WMITLV_SET_HDR(&roam_filter->tlv_header,
5668 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5669 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5670 /* fill in fixed values */
5671 roam_filter->vdev_id = roam_req->session_id;
5672 roam_filter->flags = 0;
5673 roam_filter->op_bitmap = roam_req->op_bitmap;
5674 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5675 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5676 roam_filter->num_bssid_preferred_list =
5677 roam_req->num_bssid_preferred_list;
5678 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5679
5680 WMITLV_SET_HDR((buf_ptr),
5681 WMITLV_TAG_ARRAY_FIXED_STRUC,
5682 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5683 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5684 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5685 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5686 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5687 bssid_src_ptr += ATH_MAC_LEN;
5688 bssid_dst_ptr++;
5689 }
5690 buf_ptr += WMI_TLV_HDR_SIZE +
5691 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5692 WMITLV_SET_HDR((buf_ptr),
5693 WMITLV_TAG_ARRAY_FIXED_STRUC,
5694 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5695 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5696 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5697 qdf_mem_copy(&ssid_ptr->ssid,
5698 &roam_req->ssid_allowed_list[i].mac_ssid,
5699 roam_req->ssid_allowed_list[i].length);
5700 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5701 ssid_ptr++;
5702 }
5703 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5704 sizeof(wmi_ssid));
5705 WMITLV_SET_HDR((buf_ptr),
5706 WMITLV_TAG_ARRAY_FIXED_STRUC,
5707 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5708 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5709 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5710 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5711 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5712 (wmi_mac_addr *)bssid_dst_ptr);
5713 bssid_src_ptr += ATH_MAC_LEN;
5714 bssid_dst_ptr++;
5715 }
5716 buf_ptr += WMI_TLV_HDR_SIZE +
5717 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5718 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5719 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5720 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5721 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5722 *bssid_preferred_factor_ptr =
5723 roam_req->bssid_favored_factor[i];
5724 bssid_preferred_factor_ptr++;
5725 }
5726 buf_ptr += WMI_TLV_HDR_SIZE +
5727 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5728
5729 status = wmi_unified_cmd_send(wmi_handle, buf,
5730 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305731 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305732 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305733 status);
5734 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305735 }
Govind Singh67922e82016-04-01 16:48:57 +05305736
5737 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305738}
5739
Govind Singh4eacd2b2016-03-07 14:24:22 +05305740/** send_set_epno_network_list_cmd_tlv() - set epno network list
5741 * @wmi_handle: wmi handle
5742 * @req: epno config params request structure
5743 *
5744 * This function reads the incoming epno config request structure
5745 * and constructs the WMI message to the firmware.
5746 *
5747 * Returns: 0 on success, error number otherwise
5748 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305749static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305750 struct wifi_enhanched_pno_params *req)
5751{
5752 wmi_nlo_config_cmd_fixed_param *cmd;
5753 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305754 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305755 u_int8_t i, *buf_ptr;
5756 wmi_buf_t buf;
5757 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305758 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305759
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305760 /* Fixed Params */
5761 len = sizeof(*cmd);
5762 if (req->num_networks) {
5763 /* TLV place holder for array of structures
5764 * then each nlo_configured_parameters(nlo_list) TLV.
5765 */
5766 len += WMI_TLV_HDR_SIZE;
5767 len += (sizeof(nlo_configured_parameters)
5768 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5769 /* TLV for array of uint32 channel_list */
5770 len += WMI_TLV_HDR_SIZE;
5771 /* TLV for nlo_channel_prediction_cfg */
5772 len += WMI_TLV_HDR_SIZE;
5773 /* TLV for candidate score params */
5774 len += sizeof(enlo_candidate_score_params);
5775 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305776
5777 buf = wmi_buf_alloc(wmi_handle, len);
5778 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305779 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5780 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305781 }
5782
5783 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5784
5785 buf_ptr = (u_int8_t *) cmd;
5786 WMITLV_SET_HDR(&cmd->tlv_header,
5787 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5788 WMITLV_GET_STRUCT_TLVLEN(
5789 wmi_nlo_config_cmd_fixed_param));
5790 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305791
5792 /* set flag to reset if num of networks are 0 */
5793 cmd->flags = (req->num_networks == 0 ?
5794 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305795
5796 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5797
Govind Singhb53420c2016-03-09 14:32:57 +05305798 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305799 WMI_LOGD("SSID count: %d flags: %d",
5800 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305801
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305802 /* Fill nlo_config only when num_networks are non zero */
5803 if (cmd->no_of_ssids) {
5804 /* Fill networks */
5805 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5806 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5807 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305808
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305809 nlo_list = (nlo_configured_parameters *) buf_ptr;
5810 for (i = 0; i < cmd->no_of_ssids; i++) {
5811 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5812 WMITLV_TAG_ARRAY_BYTE,
5813 WMITLV_GET_STRUCT_TLVLEN(
5814 nlo_configured_parameters));
5815 /* Copy ssid and it's length */
5816 nlo_list[i].ssid.valid = true;
5817 nlo_list[i].ssid.ssid.ssid_len =
5818 req->networks[i].ssid.length;
5819 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5820 req->networks[i].ssid.mac_ssid,
5821 nlo_list[i].ssid.ssid.ssid_len);
5822 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5823 nlo_list[i].ssid.ssid.ssid_len,
5824 (char *) nlo_list[i].ssid.ssid.ssid,
5825 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305826
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305827 /* Copy pno flags */
5828 nlo_list[i].bcast_nw_type.valid = true;
5829 nlo_list[i].bcast_nw_type.bcast_nw_type =
5830 req->networks[i].flags;
5831 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305832 nlo_list[i].bcast_nw_type.bcast_nw_type);
5833
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305834 /* Copy auth bit field */
5835 nlo_list[i].auth_type.valid = true;
5836 nlo_list[i].auth_type.auth_type =
5837 req->networks[i].auth_bit_field;
5838 WMI_LOGD("Auth bit field (%u)",
5839 nlo_list[i].auth_type.auth_type);
5840 }
5841
5842 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5843 /* Fill the channel list */
5844 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5845 buf_ptr += WMI_TLV_HDR_SIZE;
5846
5847 /* Fill prediction_param */
5848 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5849 buf_ptr += WMI_TLV_HDR_SIZE;
5850
5851 /* Fill epno candidate score params */
5852 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5853 WMITLV_SET_HDR(buf_ptr,
5854 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5855 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5856 cand_score_params->min5GHz_rssi =
5857 req->min_5ghz_rssi;
5858 cand_score_params->min24GHz_rssi =
5859 req->min_24ghz_rssi;
5860 cand_score_params->initial_score_max =
5861 req->initial_score_max;
5862 cand_score_params->current_connection_bonus =
5863 req->current_connection_bonus;
5864 cand_score_params->same_network_bonus =
5865 req->same_network_bonus;
5866 cand_score_params->secure_bonus =
5867 req->secure_bonus;
5868 cand_score_params->band5GHz_bonus =
5869 req->band_5ghz_bonus;
5870 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305871 }
5872
Govind Singh4eacd2b2016-03-07 14:24:22 +05305873 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305874 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305875 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305876 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305877 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305878 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305879 }
5880
Govind Singhb53420c2016-03-09 14:32:57 +05305881 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305882 req->session_id);
5883
Govind Singh67922e82016-04-01 16:48:57 +05305884 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305885}
5886
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305887
Govind Singh4eacd2b2016-03-07 14:24:22 +05305888/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
5889 * @wmi_handle: wmi handle
5890 * @ipa_offload: ipa offload control parameter
5891 *
5892 * Returns: 0 on success, error number otherwise
5893 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305894static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305895 struct ipa_offload_control_params *ipa_offload)
5896{
5897 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
5898 wmi_buf_t wmi_buf;
5899 uint32_t len;
5900 u_int8_t *buf_ptr;
5901
5902 len = sizeof(*cmd);
5903 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5904 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305905 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
5906 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305907 }
5908
Govind Singhb53420c2016-03-09 14:32:57 +05305909 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305910 ipa_offload->offload_type, ipa_offload->enable);
5911
5912 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
5913
5914 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
5915 WMITLV_SET_HDR(&cmd->tlv_header,
5916 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
5917 WMITLV_GET_STRUCT_TLVLEN(
5918 wmi_ipa_offload_enable_disable_cmd_fixed_param));
5919
5920 cmd->offload_type = ipa_offload->offload_type;
5921 cmd->vdev_id = ipa_offload->vdev_id;
5922 cmd->enable = ipa_offload->enable;
5923
5924 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5925 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305926 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305927 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305928 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305929 }
5930
Govind Singhb53420c2016-03-09 14:32:57 +05305931 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305932}
5933
5934/**
5935 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
5936 * @wmi_handle: wmi handle
5937 * @pgetcapab: get capabilities params
5938 *
5939 * This function send request to fw to get extscan capabilities.
5940 *
5941 * Return: CDF status
5942 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305943static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305944 struct extscan_capabilities_params *pgetcapab)
5945{
5946 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
5947 wmi_buf_t wmi_buf;
5948 uint32_t len;
5949 uint8_t *buf_ptr;
5950
5951 len = sizeof(*cmd);
5952 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5953 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305954 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5955 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305956 }
5957 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5958
5959 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
5960 WMITLV_SET_HDR(&cmd->tlv_header,
5961 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
5962 WMITLV_GET_STRUCT_TLVLEN
5963 (wmi_extscan_get_capabilities_cmd_fixed_param));
5964
5965 cmd->request_id = pgetcapab->request_id;
5966
5967 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5968 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305969 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305970 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305971 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305972 }
Govind Singhb53420c2016-03-09 14:32:57 +05305973 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305974}
5975
5976/**
5977 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
5978 * @wmi_handle: wmi handle
5979 * @pcached_results: cached results parameters
5980 *
5981 * This function send request to fw to get cached results.
5982 *
5983 * Return: CDF status
5984 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305985static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305986 struct extscan_cached_result_params *pcached_results)
5987{
5988 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
5989 wmi_buf_t wmi_buf;
5990 uint32_t len;
5991 uint8_t *buf_ptr;
5992
5993 len = sizeof(*cmd);
5994 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5995 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305996 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5997 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305998 }
5999 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6000
6001 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6002 WMITLV_SET_HDR(&cmd->tlv_header,
6003 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6004 WMITLV_GET_STRUCT_TLVLEN
6005 (wmi_extscan_get_cached_results_cmd_fixed_param));
6006
6007 cmd->request_id = pcached_results->request_id;
6008 cmd->vdev_id = pcached_results->session_id;
6009 cmd->control_flags = pcached_results->flush;
6010
6011 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6012 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306013 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306014 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306015 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306016 }
Govind Singhb53420c2016-03-09 14:32:57 +05306017 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306018}
6019
6020/**
6021 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6022 * @wmi_handle: wmi handle
6023 * @reset_req: Reset change request params
6024 *
6025 * This function sends stop change monitor request to fw.
6026 *
6027 * Return: CDF status
6028 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306029static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306030 struct extscan_capabilities_reset_params *reset_req)
6031{
6032 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6033 wmi_buf_t wmi_buf;
6034 uint32_t len;
6035 uint8_t *buf_ptr;
6036 int change_list = 0;
6037
6038 len = sizeof(*cmd);
6039
6040 /* reset significant change tlv is set to 0 */
6041 len += WMI_TLV_HDR_SIZE;
6042 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6043 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6044 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306045 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6046 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306047 }
6048 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6049
6050 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6051 buf_ptr;
6052 WMITLV_SET_HDR(&cmd->tlv_header,
6053 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6054 WMITLV_GET_STRUCT_TLVLEN
6055 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6056
6057 cmd->request_id = reset_req->request_id;
6058 cmd->vdev_id = reset_req->session_id;
6059 cmd->mode = 0;
6060
6061 buf_ptr += sizeof(*cmd);
6062 WMITLV_SET_HDR(buf_ptr,
6063 WMITLV_TAG_ARRAY_STRUC,
6064 change_list *
6065 sizeof(wmi_extscan_wlan_change_bssid_param));
6066 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6067 sizeof
6068 (wmi_extscan_wlan_change_bssid_param));
6069
6070 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6071 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306072 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306073 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306074 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306075 }
Govind Singhb53420c2016-03-09 14:32:57 +05306076 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306077}
6078
6079/**
6080 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6081 * @wmi_handle: wmi handle
6082 * @psigchange: change monitor request params
6083 * @buf: wmi buffer
6084 * @buf_len: buffer length
6085 *
6086 * This function fills elements of change monitor request buffer.
6087 *
6088 * Return: CDF status
6089 */
Govind Singhb53420c2016-03-09 14:32:57 +05306090static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306091 struct extscan_set_sig_changereq_params
6092 *psigchange, wmi_buf_t *buf, int *buf_len)
6093{
6094 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6095 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6096 uint8_t *buf_ptr;
6097 int j;
6098 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006099 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306100 struct ap_threshold_params *src_ap = psigchange->ap;
6101
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006102 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306103 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6104 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306105 }
6106 len += WMI_TLV_HDR_SIZE;
6107 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6108
6109 *buf = wmi_buf_alloc(wmi_handle, len);
6110 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306111 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306112 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306113 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306114 }
6115 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6116 cmd =
6117 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6118 buf_ptr;
6119 WMITLV_SET_HDR(&cmd->tlv_header,
6120 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6121 WMITLV_GET_STRUCT_TLVLEN
6122 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6123
6124 cmd->request_id = psigchange->request_id;
6125 cmd->vdev_id = psigchange->session_id;
6126 cmd->total_entries = numap;
6127 cmd->mode = 1;
6128 cmd->num_entries_in_page = numap;
6129 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6130 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6131 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6132 cmd->max_out_of_range_count = psigchange->min_breaching;
6133
6134 buf_ptr += sizeof(*cmd);
6135 WMITLV_SET_HDR(buf_ptr,
6136 WMITLV_TAG_ARRAY_STRUC,
6137 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6138 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6139 (buf_ptr + WMI_TLV_HDR_SIZE);
6140
6141 for (j = 0; j < numap; j++) {
6142 WMITLV_SET_HDR(dest_chglist,
6143 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6144 WMITLV_GET_STRUCT_TLVLEN
6145 (wmi_extscan_wlan_change_bssid_param));
6146
6147 dest_chglist->lower_rssi_limit = src_ap->low;
6148 dest_chglist->upper_rssi_limit = src_ap->high;
6149 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6150 &dest_chglist->bssid);
6151
Govind Singhb53420c2016-03-09 14:32:57 +05306152 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306153 dest_chglist->lower_rssi_limit);
6154 dest_chglist++;
6155 src_ap++;
6156 }
6157 buf_ptr += WMI_TLV_HDR_SIZE +
6158 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6159 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306160 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306161}
6162
6163/**
6164 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6165 * @wmi_handle: wmi handle
6166 * @psigchange: change monitor request params
6167 *
6168 * This function sends start change monitor request to fw.
6169 *
6170 * Return: CDF status
6171 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306172static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306173 struct extscan_set_sig_changereq_params *
6174 psigchange)
6175{
Govind Singhb53420c2016-03-09 14:32:57 +05306176 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306177 wmi_buf_t buf;
6178 int len;
6179
6180
Govind Singhb53420c2016-03-09 14:32:57 +05306181 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306182 psigchange, &buf,
6183 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306184 if (qdf_status != QDF_STATUS_SUCCESS) {
6185 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306186 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306187 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306188 }
6189 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306190 WMI_LOGE("%s: Failed to get buffer", __func__);
6191 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306192 }
6193 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6194 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306195 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306196 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306197 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306198 }
Govind Singhb53420c2016-03-09 14:32:57 +05306199 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306200}
6201
6202/**
6203 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6204 * @wmi_handle: wmi handle
6205 * @photlist_reset: hotlist reset params
6206 *
6207 * This function configures hotlist monitor to stop in fw.
6208 *
6209 * Return: CDF status
6210 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306211static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306212 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6213{
6214 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6215 wmi_buf_t wmi_buf;
6216 uint32_t len;
6217 uint8_t *buf_ptr;
6218 int hotlist_entries = 0;
6219
6220 len = sizeof(*cmd);
6221
6222 /* reset bssid hotlist with tlv set to 0 */
6223 len += WMI_TLV_HDR_SIZE;
6224 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6225
6226 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6227 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306228 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6229 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306230 }
6231
6232 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6233 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6234 buf_ptr;
6235 WMITLV_SET_HDR(&cmd->tlv_header,
6236 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6237 WMITLV_GET_STRUCT_TLVLEN
6238 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6239
6240 cmd->request_id = photlist_reset->request_id;
6241 cmd->vdev_id = photlist_reset->session_id;
6242 cmd->mode = 0;
6243
6244 buf_ptr += sizeof(*cmd);
6245 WMITLV_SET_HDR(buf_ptr,
6246 WMITLV_TAG_ARRAY_STRUC,
6247 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6248 buf_ptr += WMI_TLV_HDR_SIZE +
6249 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6250
6251 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6252 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306253 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306254 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306255 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306256 }
Govind Singhb53420c2016-03-09 14:32:57 +05306257 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306258}
6259
6260/**
6261 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6262 * @wmi_handle: wmi handle
6263 * @pstopcmd: stop scan command request params
6264 *
6265 * This function sends stop extscan request to fw.
6266 *
6267 * Return: CDF Status.
6268 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306269static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306270 struct extscan_stop_req_params *pstopcmd)
6271{
6272 wmi_extscan_stop_cmd_fixed_param *cmd;
6273 wmi_buf_t wmi_buf;
6274 uint32_t len;
6275 uint8_t *buf_ptr;
6276
6277 len = sizeof(*cmd);
6278 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6279 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306280 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6281 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306282 }
6283 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6284 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6285 WMITLV_SET_HDR(&cmd->tlv_header,
6286 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6287 WMITLV_GET_STRUCT_TLVLEN
6288 (wmi_extscan_stop_cmd_fixed_param));
6289
6290 cmd->request_id = pstopcmd->request_id;
6291 cmd->vdev_id = pstopcmd->session_id;
6292
6293 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6294 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306295 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306296 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306297 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306298 }
6299
Govind Singhb53420c2016-03-09 14:32:57 +05306300 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306301}
6302
6303/**
6304 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6305 * @wmi_handle: wmi handle
6306 * @pstart: scan command request params
6307 * @buf: event buffer
6308 * @buf_len: length of buffer
6309 *
6310 * This function fills individual elements of extscan request and
6311 * TLV for buckets, channel list.
6312 *
6313 * Return: CDF Status.
6314 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006315static
Govind Singhb53420c2016-03-09 14:32:57 +05306316QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306317 struct wifi_scan_cmd_req_params *pstart,
6318 wmi_buf_t *buf, int *buf_len)
6319{
6320 wmi_extscan_start_cmd_fixed_param *cmd;
6321 wmi_extscan_bucket *dest_blist;
6322 wmi_extscan_bucket_channel *dest_clist;
6323 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6324 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6325 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6326
6327 uint8_t *buf_ptr;
6328 int i, k, count = 0;
6329 int len = sizeof(*cmd);
6330 int nbuckets = pstart->numBuckets;
6331 int nchannels = 0;
6332
6333 /* These TLV's are are NULL by default */
6334 uint32_t ie_len_with_pad = 0;
6335 int num_ssid = 0;
6336 int num_bssid = 0;
6337 int ie_len = 0;
6338
6339 uint32_t base_period = pstart->basePeriod;
6340
6341 /* TLV placeholder for ssid_list (NULL) */
6342 len += WMI_TLV_HDR_SIZE;
6343 len += num_ssid * sizeof(wmi_ssid);
6344
6345 /* TLV placeholder for bssid_list (NULL) */
6346 len += WMI_TLV_HDR_SIZE;
6347 len += num_bssid * sizeof(wmi_mac_addr);
6348
6349 /* TLV placeholder for ie_data (NULL) */
6350 len += WMI_TLV_HDR_SIZE;
6351 len += ie_len * sizeof(uint32_t);
6352
6353 /* TLV placeholder for bucket */
6354 len += WMI_TLV_HDR_SIZE;
6355 len += nbuckets * sizeof(wmi_extscan_bucket);
6356
6357 /* TLV channel placeholder */
6358 len += WMI_TLV_HDR_SIZE;
6359 for (i = 0; i < nbuckets; i++) {
6360 nchannels += src_bucket->numChannels;
6361 src_bucket++;
6362 }
6363
Govind Singhb53420c2016-03-09 14:32:57 +05306364 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306365 __func__, nbuckets, nchannels);
6366 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6367 /* Allocate the memory */
6368 *buf = wmi_buf_alloc(wmi_handle, len);
6369 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306370 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306371 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306372 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306373 }
6374 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6375 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6376 WMITLV_SET_HDR(&cmd->tlv_header,
6377 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6378 WMITLV_GET_STRUCT_TLVLEN
6379 (wmi_extscan_start_cmd_fixed_param));
6380
6381 cmd->request_id = pstart->requestId;
6382 cmd->vdev_id = pstart->sessionId;
6383 cmd->base_period = pstart->basePeriod;
6384 cmd->num_buckets = nbuckets;
6385 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306386 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306387 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306388 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306389 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306390#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306391 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6392 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306393 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6394 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6395#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306396 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6397
6398 /* The max dwell time is retrieved from the first channel
6399 * of the first bucket and kept common for all channels.
6400 */
6401 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6402 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6403 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6404 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6405 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6406 cmd->max_table_usage = pstart->report_threshold_percent;
6407 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6408
6409 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306410 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306411 cmd->probe_delay = 0;
6412 cmd->probe_spacing_time = 0;
6413 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306414 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6415 WMI_SCAN_ADD_CCK_RATES |
6416 WMI_SCAN_ADD_OFDM_RATES |
6417 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6418 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306419 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6420 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306421 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306422 cmd->num_ssids = 0;
6423 cmd->num_bssid = 0;
6424 cmd->ie_len = 0;
6425 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6426 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6427
6428 buf_ptr += sizeof(*cmd);
6429 WMITLV_SET_HDR(buf_ptr,
6430 WMITLV_TAG_ARRAY_FIXED_STRUC,
6431 num_ssid * sizeof(wmi_ssid));
6432 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6433
6434 WMITLV_SET_HDR(buf_ptr,
6435 WMITLV_TAG_ARRAY_FIXED_STRUC,
6436 num_bssid * sizeof(wmi_mac_addr));
6437 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6438
6439 ie_len_with_pad = 0;
6440 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6441 ie_len_with_pad);
6442 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6443
6444 WMITLV_SET_HDR(buf_ptr,
6445 WMITLV_TAG_ARRAY_STRUC,
6446 nbuckets * sizeof(wmi_extscan_bucket));
6447 dest_blist = (wmi_extscan_bucket *)
6448 (buf_ptr + WMI_TLV_HDR_SIZE);
6449 src_bucket = pstart->buckets;
6450
6451 /* Retrieve scanning information from each bucket and
6452 * channels and send it to the target
6453 */
6454 for (i = 0; i < nbuckets; i++) {
6455 WMITLV_SET_HDR(dest_blist,
6456 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6457 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6458
6459 dest_blist->bucket_id = src_bucket->bucket;
6460 dest_blist->base_period_multiplier =
6461 src_bucket->period / base_period;
6462 dest_blist->min_period = src_bucket->period;
6463 dest_blist->max_period = src_bucket->max_period;
6464 dest_blist->exp_backoff = src_bucket->exponent;
6465 dest_blist->exp_max_step_count = src_bucket->step_count;
6466 dest_blist->channel_band = src_bucket->band;
6467 dest_blist->num_channels = src_bucket->numChannels;
6468 dest_blist->notify_extscan_events = 0;
6469
6470 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6471 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006472 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6473 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306474
6475 if (src_bucket->reportEvents &
6476 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6477 dest_blist->forwarding_flags =
6478 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6479 dest_blist->notify_extscan_events |=
6480 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6481 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6482 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6483 } else {
6484 dest_blist->forwarding_flags =
6485 WMI_EXTSCAN_NO_FORWARDING;
6486 }
6487
6488 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6489 dest_blist->configuration_flags = 0;
6490 else
6491 dest_blist->configuration_flags =
6492 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6493
Govind Singhb53420c2016-03-09 14:32:57 +05306494 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306495 __func__, dest_blist->notify_extscan_events,
6496 dest_blist->configuration_flags,
6497 dest_blist->forwarding_flags);
6498
6499 dest_blist->min_dwell_time_active =
6500 src_bucket->min_dwell_time_active;
6501 dest_blist->max_dwell_time_active =
6502 src_bucket->max_dwell_time_active;
6503 dest_blist->min_dwell_time_passive =
6504 src_bucket->min_dwell_time_passive;
6505 dest_blist->max_dwell_time_passive =
6506 src_bucket->max_dwell_time_passive;
6507 src_channel = src_bucket->channels;
6508
6509 /* save the channel info to later populate
6510 * the channel TLV
6511 */
6512 for (k = 0; k < src_bucket->numChannels; k++) {
6513 save_channel[count++].channel = src_channel->channel;
6514 src_channel++;
6515 }
6516 dest_blist++;
6517 src_bucket++;
6518 }
6519 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6520 WMITLV_SET_HDR(buf_ptr,
6521 WMITLV_TAG_ARRAY_STRUC,
6522 nchannels * sizeof(wmi_extscan_bucket_channel));
6523 dest_clist = (wmi_extscan_bucket_channel *)
6524 (buf_ptr + WMI_TLV_HDR_SIZE);
6525
6526 /* Active or passive scan is based on the bucket dwell time
6527 * and channel specific active,passive scans are not
6528 * supported yet
6529 */
6530 for (i = 0; i < nchannels; i++) {
6531 WMITLV_SET_HDR(dest_clist,
6532 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6533 WMITLV_GET_STRUCT_TLVLEN
6534 (wmi_extscan_bucket_channel));
6535 dest_clist->channel = save_channel[i].channel;
6536 dest_clist++;
6537 }
6538 buf_ptr += WMI_TLV_HDR_SIZE +
6539 (nchannels * sizeof(wmi_extscan_bucket_channel));
6540 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306541 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306542}
6543
6544/**
6545 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6546 * @wmi_handle: wmi handle
6547 * @pstart: scan command request params
6548 *
6549 * This function sends start extscan request to fw.
6550 *
6551 * Return: CDF Status.
6552 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306553static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306554 struct wifi_scan_cmd_req_params *pstart)
6555{
Govind Singhb53420c2016-03-09 14:32:57 +05306556 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306557 wmi_buf_t buf;
6558 int len;
6559
6560 /* Fill individual elements of extscan request and
6561 * TLV for buckets, channel list.
6562 */
Govind Singhb53420c2016-03-09 14:32:57 +05306563 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306564 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306565 if (qdf_status != QDF_STATUS_SUCCESS) {
6566 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6567 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306568 }
6569 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306570 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306571 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306572 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306573 }
6574 if (wmi_unified_cmd_send(wmi_handle, buf,
6575 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306576 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306577 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306578 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306579 }
6580
Govind Singhb53420c2016-03-09 14:32:57 +05306581 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306582}
6583
6584/**
6585 * send_plm_stop_cmd_tlv() - plm stop request
6586 * @wmi_handle: wmi handle
6587 * @plm: plm request parameters
6588 *
6589 * This function request FW to stop PLM.
6590 *
6591 * Return: CDF status
6592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306593static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306594 const struct plm_req_params *plm)
6595{
6596 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6597 int32_t len;
6598 wmi_buf_t buf;
6599 uint8_t *buf_ptr;
6600 int ret;
6601
6602 len = sizeof(*cmd);
6603 buf = wmi_buf_alloc(wmi_handle, len);
6604 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306605 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6606 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306607 }
6608
6609 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6610
6611 buf_ptr = (uint8_t *) cmd;
6612
6613 WMITLV_SET_HDR(&cmd->tlv_header,
6614 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6615 WMITLV_GET_STRUCT_TLVLEN
6616 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6617
6618 cmd->vdev_id = plm->session_id;
6619
6620 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306621 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306622
6623 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6624 WMI_VDEV_PLMREQ_STOP_CMDID);
6625 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306626 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306627 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306628 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306629 }
6630
Govind Singhb53420c2016-03-09 14:32:57 +05306631 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306632}
6633
6634/**
6635 * send_plm_start_cmd_tlv() - plm start request
6636 * @wmi_handle: wmi handle
6637 * @plm: plm request parameters
6638 *
6639 * This function request FW to start PLM.
6640 *
6641 * Return: CDF status
6642 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306643static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306644 const struct plm_req_params *plm,
6645 uint32_t *gchannel_list)
6646{
6647 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6648 uint32_t *channel_list;
6649 int32_t len;
6650 wmi_buf_t buf;
6651 uint8_t *buf_ptr;
6652 uint8_t count;
6653 int ret;
6654
6655 /* TLV place holder for channel_list */
6656 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6657 len += sizeof(uint32_t) * plm->plm_num_ch;
6658
6659 buf = wmi_buf_alloc(wmi_handle, len);
6660 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306661 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6662 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306663 }
6664 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6665
6666 buf_ptr = (uint8_t *) cmd;
6667
6668 WMITLV_SET_HDR(&cmd->tlv_header,
6669 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6670 WMITLV_GET_STRUCT_TLVLEN
6671 (wmi_vdev_plmreq_start_cmd_fixed_param));
6672
6673 cmd->vdev_id = plm->session_id;
6674
6675 cmd->meas_token = plm->meas_token;
6676 cmd->dialog_token = plm->diag_token;
6677 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306678 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306679 cmd->off_duration = plm->meas_duration;
6680 cmd->burst_cycle = plm->burst_len;
6681 cmd->tx_power = plm->desired_tx_pwr;
6682 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6683 cmd->num_chans = plm->plm_num_ch;
6684
6685 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6686
Govind Singhb53420c2016-03-09 14:32:57 +05306687 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6688 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6689 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6690 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6691 WMI_LOGD("off_duration: %d", cmd->off_duration);
6692 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6693 WMI_LOGD("tx_power: %d", cmd->tx_power);
6694 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306695
6696 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6697 (cmd->num_chans * sizeof(uint32_t)));
6698
6699 buf_ptr += WMI_TLV_HDR_SIZE;
6700 if (cmd->num_chans) {
6701 channel_list = (uint32_t *) buf_ptr;
6702 for (count = 0; count < cmd->num_chans; count++) {
6703 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306704 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306705 channel_list[count] =
6706 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306707 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306708 }
6709 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6710 }
6711
6712 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6713 WMI_VDEV_PLMREQ_START_CMDID);
6714 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306715 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306716 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306717 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306718 }
6719
Govind Singhb53420c2016-03-09 14:32:57 +05306720 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306721}
6722
6723/**
6724 * send_pno_stop_cmd_tlv() - PNO stop request
6725 * @wmi_handle: wmi handle
6726 * @vdev_id: vdev id
6727 *
6728 * This function request FW to stop ongoing PNO operation.
6729 *
6730 * Return: CDF status
6731 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306732static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306733{
6734 wmi_nlo_config_cmd_fixed_param *cmd;
6735 int32_t len = sizeof(*cmd);
6736 wmi_buf_t buf;
6737 uint8_t *buf_ptr;
6738 int ret;
6739
6740 /*
6741 * TLV place holder for array of structures nlo_configured_parameters
6742 * TLV place holder for array of uint32_t channel_list
6743 * TLV place holder for chnl prediction cfg
6744 */
6745 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6746 buf = wmi_buf_alloc(wmi_handle, len);
6747 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306748 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6749 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306750 }
6751
6752 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6753 buf_ptr = (uint8_t *) cmd;
6754
6755 WMITLV_SET_HDR(&cmd->tlv_header,
6756 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6757 WMITLV_GET_STRUCT_TLVLEN
6758 (wmi_nlo_config_cmd_fixed_param));
6759
6760 cmd->vdev_id = vdev_id;
6761 cmd->flags = WMI_NLO_CONFIG_STOP;
6762 buf_ptr += sizeof(*cmd);
6763
6764 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6765 buf_ptr += WMI_TLV_HDR_SIZE;
6766
6767 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6768 buf_ptr += WMI_TLV_HDR_SIZE;
6769
6770 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6771 buf_ptr += WMI_TLV_HDR_SIZE;
6772
6773
6774 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6775 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6776 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306777 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306778 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306779 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306780 }
6781
Govind Singhb53420c2016-03-09 14:32:57 +05306782 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306783}
6784
6785/**
Govind Singhccb0c272016-04-01 16:30:08 +05306786 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6787 * @buf_ptr: Buffer passed by upper layers
6788 * @pno: Buffer to be sent to the firmware
6789 *
6790 * Copy the PNO Channel prediction configuration parameters
6791 * passed by the upper layers to a WMI format TLV and send it
6792 * down to the firmware.
6793 *
6794 * Return: None
6795 */
6796static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6797 struct pno_scan_req_params *pno)
6798{
6799 nlo_channel_prediction_cfg *channel_prediction_cfg =
6800 (nlo_channel_prediction_cfg *) buf_ptr;
6801 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6802 WMITLV_TAG_ARRAY_BYTE,
6803 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306804#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306805 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6806 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6807 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6808 channel_prediction_cfg->full_scan_period_ms =
6809 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306810#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306811 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6812 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6813 channel_prediction_cfg->enable,
6814 channel_prediction_cfg->top_k_num,
6815 channel_prediction_cfg->stationary_threshold,
6816 channel_prediction_cfg->full_scan_period_ms);
6817}
6818
6819/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306820 * send_pno_start_cmd_tlv() - PNO start request
6821 * @wmi_handle: wmi handle
6822 * @pno: PNO request
6823 *
6824 * This function request FW to start PNO request.
6825 * Request: CDF status
6826 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306827static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306828 struct pno_scan_req_params *pno,
6829 uint32_t *gchannel_freq_list)
6830{
6831 wmi_nlo_config_cmd_fixed_param *cmd;
6832 nlo_configured_parameters *nlo_list;
6833 uint32_t *channel_list;
6834 int32_t len;
6835 wmi_buf_t buf;
6836 uint8_t *buf_ptr;
6837 uint8_t i;
6838 int ret;
6839
6840 /*
6841 * TLV place holder for array nlo_configured_parameters(nlo_list)
6842 * TLV place holder for array of uint32_t channel_list
6843 * TLV place holder for chnnl prediction cfg
6844 */
6845 len = sizeof(*cmd) +
6846 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6847
Govind Singhb53420c2016-03-09 14:32:57 +05306848 len += sizeof(uint32_t) * QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306849 WMI_NLO_MAX_CHAN);
6850 len += sizeof(nlo_configured_parameters) *
Govind Singhb53420c2016-03-09 14:32:57 +05306851 QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306852 len += sizeof(nlo_channel_prediction_cfg);
6853
6854 buf = wmi_buf_alloc(wmi_handle, len);
6855 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306856 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6857 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306858 }
6859
6860 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6861
6862 buf_ptr = (uint8_t *) cmd;
6863 WMITLV_SET_HDR(&cmd->tlv_header,
6864 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6865 WMITLV_GET_STRUCT_TLVLEN
6866 (wmi_nlo_config_cmd_fixed_param));
6867 cmd->vdev_id = pno->sessionId;
6868 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
6869
Govind Singh87542482016-06-08 19:40:11 +05306870#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05306871 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
6872 pno->pnoscan_adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05306873#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306874 /* Current FW does not support min-max range for dwell time */
6875 cmd->active_dwell_time = pno->active_max_time;
6876 cmd->passive_dwell_time = pno->passive_max_time;
6877
6878 /* Copy scan interval */
6879 cmd->fast_scan_period = pno->fast_scan_period;
6880 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08006881 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306882 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05306883 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306884 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05306885 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306886
6887 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
6888
Govind Singhb53420c2016-03-09 14:32:57 +05306889 cmd->no_of_ssids = QDF_MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
6890 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306891 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6892 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
6893 buf_ptr += WMI_TLV_HDR_SIZE;
6894
6895 nlo_list = (nlo_configured_parameters *) buf_ptr;
6896 for (i = 0; i < cmd->no_of_ssids; i++) {
6897 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
6898 WMITLV_TAG_ARRAY_BYTE,
6899 WMITLV_GET_STRUCT_TLVLEN
6900 (nlo_configured_parameters));
6901 /* Copy ssid and it's length */
6902 nlo_list[i].ssid.valid = true;
6903 nlo_list[i].ssid.ssid.ssid_len = pno->aNetworks[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05306904 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306905 pno->aNetworks[i].ssid.mac_ssid,
6906 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05306907 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306908 nlo_list[i].ssid.ssid.ssid_len,
6909 (char *)nlo_list[i].ssid.ssid.ssid,
6910 nlo_list[i].ssid.ssid.ssid_len);
6911
6912 /* Copy rssi threshold */
6913 if (pno->aNetworks[i].rssiThreshold &&
6914 pno->aNetworks[i].rssiThreshold > WMI_RSSI_THOLD_DEFAULT) {
6915 nlo_list[i].rssi_cond.valid = true;
6916 nlo_list[i].rssi_cond.rssi =
6917 pno->aNetworks[i].rssiThreshold;
Govind Singhb53420c2016-03-09 14:32:57 +05306918 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306919 nlo_list[i].rssi_cond.rssi);
6920 }
6921 nlo_list[i].bcast_nw_type.valid = true;
6922 nlo_list[i].bcast_nw_type.bcast_nw_type =
6923 pno->aNetworks[i].bcastNetwType;
Govind Singhb53420c2016-03-09 14:32:57 +05306924 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306925 nlo_list[i].bcast_nw_type.bcast_nw_type);
6926 }
6927 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
6928
6929 /* Copy channel info */
Govind Singhb53420c2016-03-09 14:32:57 +05306930 cmd->num_of_channels = QDF_MIN(pno->aNetworks[0].ucChannelCount,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306931 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05306932 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6934 (cmd->num_of_channels * sizeof(uint32_t)));
6935 buf_ptr += WMI_TLV_HDR_SIZE;
6936
6937 channel_list = (uint32_t *) buf_ptr;
6938 for (i = 0; i < cmd->num_of_channels; i++) {
6939 channel_list[i] = pno->aNetworks[0].aChannels[i];
6940
6941 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
6942 channel_list[i] = gchannel_freq_list[i];
6943
Govind Singhb53420c2016-03-09 14:32:57 +05306944 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306945 }
6946 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
6947 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
6948 sizeof(nlo_channel_prediction_cfg));
6949 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05306950 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306951 buf_ptr += WMI_TLV_HDR_SIZE;
6952 /** TODO: Discrete firmware doesn't have command/option to configure
6953 * App IE which comes from wpa_supplicant as of part PNO start request.
6954 */
6955 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6956 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6957 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306958 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306959 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306960 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306961 }
6962
Govind Singhb53420c2016-03-09 14:32:57 +05306963 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306964}
6965
6966/* send_set_ric_req_cmd_tlv() - set ric request element
6967 * @wmi_handle: wmi handle
6968 * @msg: message
6969 * @is_add_ts: is addts required
6970 *
6971 * This function sets ric request element for 11r roaming.
6972 *
6973 * Return: CDF status
6974 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306975static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306976 void *msg, uint8_t is_add_ts)
6977{
6978 wmi_ric_request_fixed_param *cmd;
6979 wmi_ric_tspec *tspec_param;
6980 wmi_buf_t buf;
6981 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05306982 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306983 int32_t len = sizeof(wmi_ric_request_fixed_param) +
6984 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
6985
6986 buf = wmi_buf_alloc(wmi_handle, len);
6987 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306988 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
6989 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306990 }
6991
6992 buf_ptr = (uint8_t *) wmi_buf_data(buf);
6993
6994 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
6995 WMITLV_SET_HDR(&cmd->tlv_header,
6996 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
6997 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
6998 if (is_add_ts)
6999 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
7000 else
7001 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7002 cmd->num_ric_request = 1;
7003 cmd->is_add_ric = is_add_ts;
7004
7005 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7006 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7007
7008 buf_ptr += WMI_TLV_HDR_SIZE;
7009 tspec_param = (wmi_ric_tspec *) buf_ptr;
7010 WMITLV_SET_HDR(&tspec_param->tlv_header,
7011 WMITLV_TAG_STRUC_wmi_ric_tspec,
7012 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7013
7014 if (is_add_ts)
7015 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307016#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307017 else
7018 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307019#endif
7020 if (ptspecIE) {
7021 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307022#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307023 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7024 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307025#else
Govind Singh87542482016-06-08 19:40:11 +05307026 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7027 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307028#endif /* ANI_LITTLE_BIT_ENDIAN */
7029
Govind Singh87542482016-06-08 19:40:11 +05307030 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7031 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7032 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7033 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7034 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7035 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7036 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7037 tspec_param->min_data_rate = ptspecIE->minDataRate;
7038 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7039 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7040 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7041 tspec_param->delay_bound = ptspecIE->delayBound;
7042 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7043 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7044 tspec_param->medium_time = 0;
7045 }
Govind Singhb53420c2016-03-09 14:32:57 +05307046 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307047
7048 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7049 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307050 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307051 __func__);
7052 if (is_add_ts)
7053 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307054 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307055 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307056 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307057 }
7058
Govind Singhb53420c2016-03-09 14:32:57 +05307059 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307060}
7061
7062/**
7063 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7064 * @wmi_handle: wmi handle
7065 * @clear_req: ll stats clear request command params
7066 *
Govind Singhb53420c2016-03-09 14:32:57 +05307067 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307068 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307069static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307070 const struct ll_stats_clear_params *clear_req,
7071 uint8_t addr[IEEE80211_ADDR_LEN])
7072{
7073 wmi_clear_link_stats_cmd_fixed_param *cmd;
7074 int32_t len;
7075 wmi_buf_t buf;
7076 uint8_t *buf_ptr;
7077 int ret;
7078
7079 len = sizeof(*cmd);
7080 buf = wmi_buf_alloc(wmi_handle, len);
7081
7082 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307083 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7084 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307085 }
7086
7087 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307088 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307089 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7090
7091 WMITLV_SET_HDR(&cmd->tlv_header,
7092 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7093 WMITLV_GET_STRUCT_TLVLEN
7094 (wmi_clear_link_stats_cmd_fixed_param));
7095
7096 cmd->stop_stats_collection_req = clear_req->stop_req;
7097 cmd->vdev_id = clear_req->sta_id;
7098 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7099
7100 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7101 &cmd->peer_macaddr);
7102
Govind Singhb53420c2016-03-09 14:32:57 +05307103 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7104 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7105 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7106 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7107 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307108 cmd->peer_macaddr); */
7109
7110 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7111 WMI_CLEAR_LINK_STATS_CMDID);
7112 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307113 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307114 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307115 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307116 }
7117
Govind Singhb53420c2016-03-09 14:32:57 +05307118 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7119 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307120}
7121
7122/**
7123 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7124 * @wmi_handle: wmi handle
7125 * @setReq: ll stats set request command params
7126 *
Govind Singhb53420c2016-03-09 14:32:57 +05307127 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307128 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307129static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307130 const struct ll_stats_set_params *set_req)
7131{
7132 wmi_start_link_stats_cmd_fixed_param *cmd;
7133 int32_t len;
7134 wmi_buf_t buf;
7135 uint8_t *buf_ptr;
7136 int ret;
7137
7138 len = sizeof(*cmd);
7139 buf = wmi_buf_alloc(wmi_handle, len);
7140
7141 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307142 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7143 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307144 }
7145
7146 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307147 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307148 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7149
7150 WMITLV_SET_HDR(&cmd->tlv_header,
7151 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7152 WMITLV_GET_STRUCT_TLVLEN
7153 (wmi_start_link_stats_cmd_fixed_param));
7154
7155 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7156 cmd->aggressive_statistics_gathering =
7157 set_req->aggressive_statistics_gathering;
7158
Govind Singhb53420c2016-03-09 14:32:57 +05307159 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7160 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7161 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307162
7163 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7164 WMI_START_LINK_STATS_CMDID);
7165 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307166 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307167 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307168 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307169 }
7170
Govind Singhb53420c2016-03-09 14:32:57 +05307171 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307172}
7173
7174/**
7175 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7176 * @wmi_handle:wmi handle
7177 * @get_req:ll stats get request command params
7178 * @addr: mac address
7179 *
Govind Singhb53420c2016-03-09 14:32:57 +05307180 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307181 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307182static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307183 const struct ll_stats_get_params *get_req,
7184 uint8_t addr[IEEE80211_ADDR_LEN])
7185{
7186 wmi_request_link_stats_cmd_fixed_param *cmd;
7187 int32_t len;
7188 wmi_buf_t buf;
7189 uint8_t *buf_ptr;
7190 int ret;
7191
7192 len = sizeof(*cmd);
7193 buf = wmi_buf_alloc(wmi_handle, len);
7194
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307195 if (!buf) {
7196 WMI_LOGE("%s: buf allocation failed", __func__);
7197 return QDF_STATUS_E_NOMEM;
7198 }
7199
Govind Singh4eacd2b2016-03-07 14:24:22 +05307200 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307201 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307202 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7203
7204 WMITLV_SET_HDR(&cmd->tlv_header,
7205 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7206 WMITLV_GET_STRUCT_TLVLEN
7207 (wmi_request_link_stats_cmd_fixed_param));
7208
7209 cmd->request_id = get_req->req_id;
7210 cmd->stats_type = get_req->param_id_mask;
7211 cmd->vdev_id = get_req->sta_id;
7212
7213 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7214 &cmd->peer_macaddr);
7215
Govind Singhb53420c2016-03-09 14:32:57 +05307216 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
7217 WMI_LOGD("Request ID : %d", cmd->request_id);
7218 WMI_LOGD("Stats Type : %d", cmd->stats_type);
7219 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7220 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307221
7222 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7223 WMI_REQUEST_LINK_STATS_CMDID);
7224 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307225 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307226 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307227 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307228 }
7229
Govind Singhb53420c2016-03-09 14:32:57 +05307230 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307231}
7232
7233/**
7234 * send_get_stats_cmd_tlv() - get stats request
7235 * @wmi_handle: wmi handle
7236 * @get_stats_param: stats params
7237 * @addr: mac address
7238 *
7239 * Return: CDF status
7240 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307241static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307242 struct pe_stats_req *get_stats_param,
7243 uint8_t addr[IEEE80211_ADDR_LEN])
7244{
7245 wmi_buf_t buf;
7246 wmi_request_stats_cmd_fixed_param *cmd;
7247 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7248
7249 buf = wmi_buf_alloc(wmi_handle, len);
7250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307251 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7252 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307253 }
7254
7255
7256 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7257 WMITLV_SET_HDR(&cmd->tlv_header,
7258 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7259 WMITLV_GET_STRUCT_TLVLEN
7260 (wmi_request_stats_cmd_fixed_param));
7261 cmd->stats_id =
7262 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05307263 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307264 cmd->vdev_id = get_stats_param->session_id;
7265 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307266 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307267 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7268 WMI_REQUEST_STATS_CMDID)) {
7269
Govind Singhb53420c2016-03-09 14:32:57 +05307270 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307271 __func__);
7272 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307273 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307274 }
7275
Govind Singhb53420c2016-03-09 14:32:57 +05307276 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307277
7278}
7279
Govind Singh20c5dac2016-03-07 15:33:31 +05307280/**
7281 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7282 * @wmi_handle: wmi handle
7283 * @rssi_req: get RSSI request
7284 *
7285 * Return: CDF status
7286 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307287static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307288{
7289 wmi_buf_t buf;
7290 wmi_request_stats_cmd_fixed_param *cmd;
7291 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7292
7293 buf = wmi_buf_alloc(wmi_handle, len);
7294 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307295 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7296 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307297 }
7298
7299 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7300 WMITLV_SET_HDR(&cmd->tlv_header,
7301 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7302 WMITLV_GET_STRUCT_TLVLEN
7303 (wmi_request_stats_cmd_fixed_param));
7304 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7305 if (wmi_unified_cmd_send
7306 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307307 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307308 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307309 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307310 }
7311
Govind Singhb53420c2016-03-09 14:32:57 +05307312 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307313}
7314
7315/**
7316 * send_snr_cmd_tlv() - get RSSI from fw
7317 * @wmi_handle: wmi handle
7318 * @vdev_id: vdev id
7319 *
7320 * Return: CDF status
7321 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307322static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307323{
7324 wmi_buf_t buf;
7325 wmi_request_stats_cmd_fixed_param *cmd;
7326 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7327
7328 buf = wmi_buf_alloc(wmi_handle, len);
7329 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307330 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7331 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307332 }
7333
7334 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7335 cmd->vdev_id = vdev_id;
7336
7337 WMITLV_SET_HDR(&cmd->tlv_header,
7338 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7339 WMITLV_GET_STRUCT_TLVLEN
7340 (wmi_request_stats_cmd_fixed_param));
7341 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7342 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7343 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307344 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307345 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307346 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307347 }
7348
Govind Singhb53420c2016-03-09 14:32:57 +05307349 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307350}
7351
7352/**
7353 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7354 * @wmi_handle: wmi handle
7355 * @link_status: get link params
7356 *
7357 * Return: CDF status
7358 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307359static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307360 struct link_status_params *link_status)
7361{
7362 wmi_buf_t buf;
7363 wmi_request_stats_cmd_fixed_param *cmd;
7364 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7365
7366 buf = wmi_buf_alloc(wmi_handle, len);
7367 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307368 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7369 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307370 }
7371
7372 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7373 WMITLV_SET_HDR(&cmd->tlv_header,
7374 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7375 WMITLV_GET_STRUCT_TLVLEN
7376 (wmi_request_stats_cmd_fixed_param));
7377 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7378 cmd->vdev_id = link_status->session_id;
7379 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7380 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307381 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307382 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307383 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307384 }
7385
Govind Singhb53420c2016-03-09 14:32:57 +05307386 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307387}
7388
Govind Singh20c5dac2016-03-07 15:33:31 +05307389/**
7390 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7391 * @wmi_handle: wmi handle
7392 * @ta_dhcp_ind: DHCP indication parameter
7393 *
7394 * Return: CDF Status
7395 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307396static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307397 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7398{
Govind Singh67922e82016-04-01 16:48:57 +05307399 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307400 wmi_buf_t buf = NULL;
7401 uint8_t *buf_ptr;
7402 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7403 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7404
7405
7406 buf = wmi_buf_alloc(wmi_handle, len);
7407 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307408 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7409 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307410 }
7411
7412 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7413 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7414 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7415 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7416 WMITLV_GET_STRUCT_TLVLEN
7417 (wmi_peer_set_param_cmd_fixed_param));
7418
7419 /* fill in values */
7420 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7421 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7422 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307423 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307424 &ta_dhcp_ind->peer_macaddr,
7425 sizeof(ta_dhcp_ind->peer_macaddr));
7426
7427 status = wmi_unified_cmd_send(wmi_handle, buf,
7428 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307429 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307430 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307431 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307432 wmi_buf_free(buf);
7433 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307434
Govind Singh67922e82016-04-01 16:48:57 +05307435 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307436}
7437
7438/**
7439 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7440 * @wmi_handle: wmi handle
7441 * @pLinkSpeed: link speed info
7442 *
7443 * Return: CDF status
7444 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307445static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307446 wmi_mac_addr peer_macaddr)
7447{
7448 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7449 wmi_buf_t wmi_buf;
7450 uint32_t len;
7451 uint8_t *buf_ptr;
7452
7453 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7454 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7455 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307456 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7457 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307458 }
7459 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7460
7461 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7462 WMITLV_SET_HDR(&cmd->tlv_header,
7463 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7464 WMITLV_GET_STRUCT_TLVLEN
7465 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7466
7467 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307468 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307469 &peer_macaddr,
7470 sizeof(peer_macaddr));
7471
7472
7473 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7474 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307475 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307476 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307477 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307478 }
Govind Singhb53420c2016-03-09 14:32:57 +05307479 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307480}
7481
7482/**
7483 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7484 * @wmi_handle: wmi handler
7485 * @egap_params: pointer to egap_params
7486 *
7487 * Return: 0 for success, otherwise appropriate error code
7488 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307489static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307490 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7491{
7492 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7493 wmi_buf_t buf;
7494 int32_t err;
7495
7496 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7497 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307498 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7499 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307500 }
7501 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7502 WMITLV_SET_HDR(&cmd->tlv_header,
7503 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7504 WMITLV_GET_STRUCT_TLVLEN(
7505 wmi_ap_ps_egap_param_cmd_fixed_param));
7506
7507 cmd->enable = egap_params->enable;
7508 cmd->inactivity_time = egap_params->inactivity_time;
7509 cmd->wait_time = egap_params->wait_time;
7510 cmd->flags = egap_params->flags;
7511 err = wmi_unified_cmd_send(wmi_handle, buf,
7512 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7513 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307514 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307515 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307516 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307517 }
7518
Govind Singhb53420c2016-03-09 14:32:57 +05307519 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307520}
7521
7522/**
7523 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7524 * @wmi_handl: wmi handle
7525 * @cmd: Profiling command index
7526 * @value1: parameter1 value
7527 * @value2: parameter2 value
7528 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307529 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307530 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307531static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307532 uint32_t cmd, uint32_t value1, uint32_t value2)
7533{
7534 wmi_buf_t buf;
7535 int32_t len = 0;
7536 int ret;
7537 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7538 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7539 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7540 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7541
7542 switch (cmd) {
7543 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7544 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7545 buf = wmi_buf_alloc(wmi_handle, len);
7546 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307547 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307548 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307549 }
7550 prof_trig_cmd =
7551 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7552 wmi_buf_data(buf);
7553 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7554 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7555 WMITLV_GET_STRUCT_TLVLEN
7556 (wmi_wlan_profile_trigger_cmd_fixed_param));
7557 prof_trig_cmd->enable = value1;
7558 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7559 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7560 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307561 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307562 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307563 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307564 return ret;
7565 }
7566 break;
7567
7568 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7569 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7570 buf = wmi_buf_alloc(wmi_handle, len);
7571 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307572 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307573 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307574 }
7575 profile_getdata_cmd =
7576 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7577 wmi_buf_data(buf);
7578 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7579 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7580 WMITLV_GET_STRUCT_TLVLEN
7581 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7582 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7583 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7584 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307585 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307586 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307587 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307588 return ret;
7589 }
7590 break;
7591
7592 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7593 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7594 buf = wmi_buf_alloc(wmi_handle, len);
7595 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307596 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307597 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307598 }
7599 hist_intvl_cmd =
7600 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7601 wmi_buf_data(buf);
7602 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7603 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7604 WMITLV_GET_STRUCT_TLVLEN
7605 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7606 hist_intvl_cmd->profile_id = value1;
7607 hist_intvl_cmd->value = value2;
7608 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7609 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7610 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307611 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307612 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307613 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307614 return ret;
7615 }
7616 break;
7617
7618 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7619 len =
7620 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7621 buf = wmi_buf_alloc(wmi_handle, len);
7622 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307623 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307624 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307625 }
7626 profile_enable_cmd =
7627 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7628 wmi_buf_data(buf);
7629 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7630 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7631 WMITLV_GET_STRUCT_TLVLEN
7632 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7633 profile_enable_cmd->profile_id = value1;
7634 profile_enable_cmd->enable = value2;
7635 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7636 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7637 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307638 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307639 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307640 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307641 return ret;
7642 }
7643 break;
7644
7645 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307646 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307647 break;
7648 }
7649
7650 return 0;
7651}
7652
Govind Singh20c5dac2016-03-07 15:33:31 +05307653/**
7654 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7655 * @wmi_handle: wmi handle
7656 * @vdev_id: vdev id
7657 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307658 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307659 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307660static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307661{
7662 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7663 wmi_buf_t buf;
7664 int32_t len = sizeof(*cmd);
7665
Govind Singhb53420c2016-03-09 14:32:57 +05307666 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307667 buf = wmi_buf_alloc(wmi_handle, len);
7668 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307669 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307670 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307671 }
7672 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7673 wmi_buf_data(buf);
7674 WMITLV_SET_HDR(&cmd->tlv_header,
7675 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7676 WMITLV_GET_STRUCT_TLVLEN
7677 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7678 cmd->vdev_id = vdev_id;
7679 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7680 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7681 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307682 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307683 __func__);
7684 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307685 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307686 }
7687
7688 return 0;
7689}
7690
7691/**
7692 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7693 * @wmi_handle: wmi handle
7694 * @vdev_id: vdev id
7695 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307696 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307697 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307698static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307699 uint8_t vdev_id)
7700{
7701 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7702 wmi_buf_t buf;
7703 int32_t len = sizeof(*cmd);
7704
Govind Singhb53420c2016-03-09 14:32:57 +05307705 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307706 buf = wmi_buf_alloc(wmi_handle, len);
7707 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307708 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307709 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307710 }
7711 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7712 WMITLV_SET_HDR(&cmd->tlv_header,
7713 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7714 WMITLV_GET_STRUCT_TLVLEN
7715 (wmi_csa_offload_enable_cmd_fixed_param));
7716 cmd->vdev_id = vdev_id;
7717 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7718 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7719 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307720 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307721 __func__);
7722 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307723 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307724 }
7725
7726 return 0;
7727}
7728
7729/**
7730 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7731 * @wmi_handle: wmi handle
7732 * @startOemDataReq: start request params
7733 *
7734 * Return: CDF status
7735 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307736static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007737 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307738 uint8_t *data)
7739{
7740 wmi_buf_t buf;
7741 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307742 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307743
7744 buf = wmi_buf_alloc(wmi_handle,
7745 (data_len + WMI_TLV_HDR_SIZE));
7746 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307747 WMI_LOGE(FL("wmi_buf_alloc failed"));
7748 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307749 }
7750
7751 cmd = (uint8_t *) wmi_buf_data(buf);
7752
7753 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7754 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307755 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307756 data_len);
7757
Govind Singhb53420c2016-03-09 14:32:57 +05307758 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307759 data_len);
7760
7761 ret = wmi_unified_cmd_send(wmi_handle, buf,
7762 (data_len +
7763 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7764
Govind Singh67922e82016-04-01 16:48:57 +05307765 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307766 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307767 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307768 }
7769
Govind Singh67922e82016-04-01 16:48:57 +05307770 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307771}
7772
7773/**
7774 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7775 * @wmi_handle: wmi handle
7776 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7777 *
7778 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7779 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7780 * to firmware based on phyerr filtering
7781 * offload status.
7782 *
7783 * Return: 1 success, 0 failure
7784 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307785static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307786send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7787 bool dfs_phyerr_filter_offload)
7788{
7789 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7790 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7791 wmi_buf_t buf;
7792 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307793 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307794
7795
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007796 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307797 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307798 __func__);
7799 len = sizeof(*disable_phyerr_offload_cmd);
7800 buf = wmi_buf_alloc(wmi_handle, len);
7801 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307802 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307803 return 0;
7804 }
7805 disable_phyerr_offload_cmd =
7806 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7807 wmi_buf_data(buf);
7808
7809 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7810 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7811 WMITLV_GET_STRUCT_TLVLEN
7812 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7813
7814 /*
7815 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
7816 * to the firmware to disable the phyerror
7817 * filtering offload.
7818 */
7819 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7820 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05307821 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307822 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307823 __func__, ret);
7824 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307825 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307826 }
Govind Singhb53420c2016-03-09 14:32:57 +05307827 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307828 __func__);
7829 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05307830 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307831 __func__);
7832
7833 len = sizeof(*enable_phyerr_offload_cmd);
7834 buf = wmi_buf_alloc(wmi_handle, len);
7835 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307836 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7837 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307838 }
7839
7840 enable_phyerr_offload_cmd =
7841 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
7842 wmi_buf_data(buf);
7843
7844 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
7845 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
7846 WMITLV_GET_STRUCT_TLVLEN
7847 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
7848
7849 /*
7850 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
7851 * to the firmware to enable the phyerror
7852 * filtering offload.
7853 */
7854 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7855 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
7856
Govind Singh67922e82016-04-01 16:48:57 +05307857 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307858 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307859 __func__, ret);
7860 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307861 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307862 }
Govind Singhb53420c2016-03-09 14:32:57 +05307863 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05307864 __func__);
7865 }
7866
Govind Singhb53420c2016-03-09 14:32:57 +05307867 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307868}
7869
7870#if !defined(REMOVE_PKT_LOG)
7871/**
7872 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
7873 * @wmi_handle: wmi handle
7874 * @pktlog_event: pktlog event
7875 * @cmd_id: pktlog cmd id
7876 *
7877 * Return: CDF status
7878 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307879static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307880 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05307881 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05307882{
7883 WMI_PKTLOG_EVENT PKTLOG_EVENT;
7884 WMI_CMD_ID CMD_ID;
7885 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
7886 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
7887 int len = 0;
7888 wmi_buf_t buf;
7889
7890 PKTLOG_EVENT = pktlog_event;
7891 CMD_ID = cmd_id;
7892
7893 switch (CMD_ID) {
7894 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
7895 len = sizeof(*cmd);
7896 buf = wmi_buf_alloc(wmi_handle, len);
7897 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307898 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7899 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307900 }
7901 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
7902 wmi_buf_data(buf);
7903 WMITLV_SET_HDR(&cmd->tlv_header,
7904 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
7905 WMITLV_GET_STRUCT_TLVLEN
7906 (wmi_pdev_pktlog_enable_cmd_fixed_param));
7907 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05307908 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
7909 : WMI_PKTLOG_ENABLE_AUTO;
Govind Singh4df47142016-04-16 19:24:23 -07007910 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307911 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7912 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307913 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307914 goto wmi_send_failed;
7915 }
7916 break;
7917 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
7918 len = sizeof(*disable_cmd);
7919 buf = wmi_buf_alloc(wmi_handle, len);
7920 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307921 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
7922 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307923 }
7924 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
7925 wmi_buf_data(buf);
7926 WMITLV_SET_HDR(&disable_cmd->tlv_header,
7927 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
7928 WMITLV_GET_STRUCT_TLVLEN
7929 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Govind Singh4df47142016-04-16 19:24:23 -07007930 disable_cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singh20c5dac2016-03-07 15:33:31 +05307931 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7932 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05307934 goto wmi_send_failed;
7935 }
7936 break;
7937 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307938 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307939 break;
7940 }
7941
Govind Singhb53420c2016-03-09 14:32:57 +05307942 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307943
7944wmi_send_failed:
7945 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307946 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307947}
7948#endif /* REMOVE_PKT_LOG */
7949
7950/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307951 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
7952 * @wmi_handle: wmi handle
7953 * @ptrn_id: pattern id
7954 * @vdev_id: vdev id
7955 *
7956 * Return: CDF status
7957 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05307958static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
7959 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307960{
7961 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
7962 wmi_buf_t buf;
7963 int32_t len;
7964 int ret;
7965
7966 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
7967
7968
7969 buf = wmi_buf_alloc(wmi_handle, len);
7970 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307971 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7972 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307973 }
7974
7975 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
7976
7977 WMITLV_SET_HDR(&cmd->tlv_header,
7978 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
7979 WMITLV_GET_STRUCT_TLVLEN(
7980 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
7981 cmd->vdev_id = vdev_id;
7982 cmd->pattern_id = ptrn_id;
7983 cmd->pattern_type = WOW_BITMAP_PATTERN;
7984
Govind Singhb53420c2016-03-09 14:32:57 +05307985 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05307986 cmd->pattern_id, vdev_id);
7987
7988 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7989 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
7990 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307991 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307992 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307993 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307994 }
7995
Govind Singhb53420c2016-03-09 14:32:57 +05307996 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307997}
7998
7999/**
8000 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8001 * @wmi_handle: wmi handle
8002 *
8003 * Sends host wakeup indication to FW. On receiving this indication,
8004 * FW will come out of WOW.
8005 *
8006 * Return: CDF status
8007 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308008static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308009{
8010 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8011 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308012 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308013 int32_t len;
8014 int ret;
8015
8016 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8017
8018 buf = wmi_buf_alloc(wmi_handle, len);
8019 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308020 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8021 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308022 }
8023
8024 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8025 wmi_buf_data(buf);
8026 WMITLV_SET_HDR(&cmd->tlv_header,
8027 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8028 WMITLV_GET_STRUCT_TLVLEN
8029 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8030
8031
8032 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8033 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8034 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308035 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308036 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308037 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308038 }
8039
Govind Singhb53420c2016-03-09 14:32:57 +05308040 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308041}
8042
8043/**
8044 * send_del_ts_cmd_tlv() - send DELTS request to fw
8045 * @wmi_handle: wmi handle
8046 * @msg: delts params
8047 *
8048 * Return: CDF status
8049 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308050static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308051 uint8_t ac)
8052{
8053 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8054 wmi_buf_t buf;
8055 int32_t len = sizeof(*cmd);
8056
8057 buf = wmi_buf_alloc(wmi_handle, len);
8058 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308059 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8060 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308061 }
8062 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8063 WMITLV_SET_HDR(&cmd->tlv_header,
8064 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8065 WMITLV_GET_STRUCT_TLVLEN
8066 (wmi_vdev_wmm_delts_cmd_fixed_param));
8067 cmd->vdev_id = vdev_id;
8068 cmd->ac = ac;
8069
Govind Singhb53420c2016-03-09 14:32:57 +05308070 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308071 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8072 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8073 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308074 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308075 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308076 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308077 }
8078
Govind Singhb53420c2016-03-09 14:32:57 +05308079 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308080}
8081
8082/**
8083 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8084 * @wmi_handle: handle to wmi
8085 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8086 *
Govind Singhb53420c2016-03-09 14:32:57 +05308087 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308088 * ADD_TS requestes to firmware in loop for all the ACs with
8089 * active flow.
8090 *
8091 * Return: CDF status
8092 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308093static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308094 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8095{
8096 int i = 0;
8097 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8098 wmi_buf_t buf;
8099 int32_t len = sizeof(*cmd);
8100
8101 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8102 /* if flow in this AC is active */
8103 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8104 /*
8105 * as per implementation of wma_add_ts_req() we
8106 * are not waiting any response from firmware so
8107 * apart from sending ADDTS to firmware just send
8108 * success to upper layers
8109 */
Govind Singhb53420c2016-03-09 14:32:57 +05308110 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308111
8112 buf = wmi_buf_alloc(wmi_handle, len);
8113 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308114 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8115 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308116 }
8117 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8118 wmi_buf_data(buf);
8119 WMITLV_SET_HDR(&cmd->tlv_header,
8120 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8121 WMITLV_GET_STRUCT_TLVLEN
8122 (wmi_vdev_wmm_addts_cmd_fixed_param));
8123 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8124 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308125 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308126 traffic.userPrio);
8127 cmd->medium_time_us =
8128 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8129 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308130 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308131 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8132 cmd->medium_time_us, cmd->downgrade_type);
8133 if (wmi_unified_cmd_send
8134 (wmi_handle, buf, len,
8135 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308136 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308137 __func__);
8138 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308139 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308140 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308141 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308142 }
8143 }
8144 }
8145
Govind Singhb53420c2016-03-09 14:32:57 +05308146 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308147}
8148
8149/**
8150 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8151 * @wmi_handle: wmi handle
8152 * @msg: ADDTS params
8153 *
8154 * Return: CDF status
8155 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308156static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308157 struct add_ts_param *msg)
8158{
8159 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8160 wmi_buf_t buf;
8161 int32_t len = sizeof(*cmd);
8162
Govind Singhb53420c2016-03-09 14:32:57 +05308163 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308164
8165 buf = wmi_buf_alloc(wmi_handle, len);
8166 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308167 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8168 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308169 }
8170 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8171 WMITLV_SET_HDR(&cmd->tlv_header,
8172 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8173 WMITLV_GET_STRUCT_TLVLEN
8174 (wmi_vdev_wmm_addts_cmd_fixed_param));
8175 cmd->vdev_id = msg->sme_session_id;
8176 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8177 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8178 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308179 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308180 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8181 cmd->downgrade_type, __func__, __LINE__);
8182 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8183 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308184 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8185 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308186 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308187 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308188 }
8189
Govind Singhb53420c2016-03-09 14:32:57 +05308190 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308191}
8192
8193/**
8194 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter in target
8195 * @wmi_handle: wmi handle
8196 * @vdev_id: vdev id
8197 * @enable: Flag to enable/disable packet filter
8198 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308199 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308200 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308201static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308202 uint8_t vdev_id, bool enable)
8203{
8204 int32_t len;
8205 int ret = 0;
8206 wmi_buf_t buf;
8207 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
8208
8209 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
8210
8211 buf = wmi_buf_alloc(wmi_handle, len);
8212 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308213 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308214 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308215 }
8216
8217 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
8218 WMITLV_SET_HDR(&cmd->tlv_header,
8219 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
8220 WMITLV_GET_STRUCT_TLVLEN(
8221 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
8222
8223 cmd->vdev_id = vdev_id;
8224 if (enable)
8225 cmd->enable = PACKET_FILTER_SET_ENABLE;
8226 else
8227 cmd->enable = PACKET_FILTER_SET_DISABLE;
8228
Govind Singhb53420c2016-03-09 14:32:57 +05308229 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308230 __func__, cmd->enable, vdev_id);
8231
8232 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8233 WMI_PACKET_FILTER_ENABLE_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308234 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308235 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
Abhishek Singh716c46c2016-05-04 16:24:07 +05308236 wmi_buf_free(buf);
8237 }
Govind Singh20c5dac2016-03-07 15:33:31 +05308238
8239 return ret;
8240}
8241
8242/**
8243 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
8244 * @wmi_handle: wmi handle
8245 * @vdev_id: vdev id
8246 * @rcv_filter_param: Packet filter parameters
8247 * @filter_id: Filter id
8248 * @enable: Flag to add/delete packet filter configuration
8249 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308250 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308251 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308252static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308253 uint8_t vdev_id, struct rcv_pkt_filter_config *rcv_filter_param,
8254 uint8_t filter_id, bool enable)
8255{
8256 int len, i;
8257 int err = 0;
8258 wmi_buf_t buf;
8259 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
8260
8261
8262 /* allocate the memory */
8263 len = sizeof(*cmd);
8264 buf = wmi_buf_alloc(wmi_handle, len);
8265 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308266 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308267 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308268 }
8269
8270 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
8271 WMITLV_SET_HDR(&cmd->tlv_header,
8272 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
8273 WMITLV_GET_STRUCT_TLVLEN
8274 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
8275
8276 cmd->vdev_id = vdev_id;
8277 cmd->filter_id = filter_id;
8278 if (enable)
8279 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
8280 else
8281 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
8282
8283 if (enable) {
Govind Singhb53420c2016-03-09 14:32:57 +05308284 cmd->num_params = QDF_MIN(
Govind Singh20c5dac2016-03-07 15:33:31 +05308285 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
8286 rcv_filter_param->numFieldParams);
8287 cmd->filter_type = rcv_filter_param->filterType;
8288 cmd->coalesce_time = rcv_filter_param->coalesceTime;
8289
8290 for (i = 0; i < cmd->num_params; i++) {
8291 cmd->paramsData[i].proto_type =
8292 rcv_filter_param->paramsData[i].protocolLayer;
8293 cmd->paramsData[i].cmp_type =
8294 rcv_filter_param->paramsData[i].cmpFlag;
8295 cmd->paramsData[i].data_length =
8296 rcv_filter_param->paramsData[i].dataLength;
8297 cmd->paramsData[i].data_offset =
8298 rcv_filter_param->paramsData[i].dataOffset;
8299 memcpy(&cmd->paramsData[i].compareData,
8300 rcv_filter_param->paramsData[i].compareData,
8301 sizeof(cmd->paramsData[i].compareData));
8302 memcpy(&cmd->paramsData[i].dataMask,
8303 rcv_filter_param->paramsData[i].dataMask,
8304 sizeof(cmd->paramsData[i].dataMask));
8305 }
8306 }
8307
Govind Singhb53420c2016-03-09 14:32:57 +05308308 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308309 cmd->filter_action, cmd->filter_id, cmd->num_params);
8310 /* send the command along with data */
8311 err = wmi_unified_cmd_send(wmi_handle, buf, len,
8312 WMI_PACKET_FILTER_CONFIG_CMDID);
8313 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05308314 WMI_LOGE("Failed to send pkt_filter cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308315 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308316 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308317 }
8318
8319
8320 return 0;
8321}
8322
8323/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308324 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8325 * @wmi_handle: wmi handle
8326 * @pAddPeriodicTxPtrnParams: tx ptrn params
8327 *
8328 * Retrun: CDF status
8329 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308330static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308331 struct periodic_tx_pattern *
8332 pAddPeriodicTxPtrnParams,
8333 uint8_t vdev_id)
8334{
8335 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8336 wmi_buf_t wmi_buf;
8337 uint32_t len;
8338 uint8_t *buf_ptr;
8339 uint32_t ptrn_len, ptrn_len_aligned;
8340 int j;
8341
8342 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8343 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8344 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8345 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8346
8347 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8348 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308349 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8350 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308351 }
8352
8353 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8354
8355 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8356 WMITLV_SET_HDR(&cmd->tlv_header,
8357 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8358 WMITLV_GET_STRUCT_TLVLEN
8359 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8360
8361 /* Pass the pattern id to delete for the corresponding vdev id */
8362 cmd->vdev_id = vdev_id;
8363 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8364 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8365 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8366
8367 /* Pattern info */
8368 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8369 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8370 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308371 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308372 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308373 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308374
Govind Singhb53420c2016-03-09 14:32:57 +05308375 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308376 __func__, cmd->pattern_id, cmd->vdev_id);
8377
8378 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8379 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308380 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308381 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308382 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308383 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308384 }
Govind Singhb53420c2016-03-09 14:32:57 +05308385 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308386}
8387
8388/**
8389 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8390 * @wmi_handle: wmi handle
8391 * @vdev_id: vdev id
8392 * @pattern_id: pattern id
8393 *
8394 * Retrun: CDF status
8395 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308396static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308397 uint8_t vdev_id,
8398 uint8_t pattern_id)
8399{
8400 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8401 wmi_buf_t wmi_buf;
8402 uint32_t len =
8403 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8404
8405 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8406 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308407 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8408 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308409 }
8410
8411 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8412 wmi_buf_data(wmi_buf);
8413 WMITLV_SET_HDR(&cmd->tlv_header,
8414 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8415 WMITLV_GET_STRUCT_TLVLEN
8416 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8417
8418 /* Pass the pattern id to delete for the corresponding vdev id */
8419 cmd->vdev_id = vdev_id;
8420 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308421 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308422 __func__, cmd->pattern_id, cmd->vdev_id);
8423
8424 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8425 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308426 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308427 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308428 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308429 }
Govind Singhb53420c2016-03-09 14:32:57 +05308430 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308431}
8432
8433/**
8434 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8435 * @wmi_handle: wmi handle
8436 * @preq: stats ext params
8437 *
8438 * Return: CDF status
8439 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308440static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308441 struct stats_ext_params *preq)
8442{
Govind Singh67922e82016-04-01 16:48:57 +05308443 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308444 wmi_req_stats_ext_cmd_fixed_param *cmd;
8445 wmi_buf_t buf;
8446 uint16_t len;
8447 uint8_t *buf_ptr;
8448
8449 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8450
8451 buf = wmi_buf_alloc(wmi_handle, len);
8452 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308453 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308454 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308455 }
8456
8457 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8458 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8459
8460 WMITLV_SET_HDR(&cmd->tlv_header,
8461 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8462 WMITLV_GET_STRUCT_TLVLEN
8463 (wmi_req_stats_ext_cmd_fixed_param));
8464 cmd->vdev_id = preq->vdev_id;
8465 cmd->data_len = preq->request_data_len;
8466
Govind Singhb53420c2016-03-09 14:32:57 +05308467 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308468 __func__, preq->request_data_len, preq->vdev_id);
8469
8470 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8471 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8472
8473 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308474 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308475
8476 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8477 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308478 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308479 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308480 ret);
8481 wmi_buf_free(buf);
8482 }
8483
8484 return ret;
8485}
8486
8487/**
8488 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8489 * @wmi_handle: wmi handle
8490 * @params: ext wow params
8491 *
8492 * Return:0 for success or error code
8493 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308494static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308495 struct ext_wow_params *params)
8496{
8497 wmi_extwow_enable_cmd_fixed_param *cmd;
8498 wmi_buf_t buf;
8499 int32_t len;
8500 int ret;
8501
8502 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8503 buf = wmi_buf_alloc(wmi_handle, len);
8504 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308505 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8506 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308507 }
8508
8509 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8510
8511 WMITLV_SET_HDR(&cmd->tlv_header,
8512 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8513 WMITLV_GET_STRUCT_TLVLEN
8514 (wmi_extwow_enable_cmd_fixed_param));
8515
8516 cmd->vdev_id = params->vdev_id;
8517 cmd->type = params->type;
8518 cmd->wakeup_pin_num = params->wakeup_pin_num;
8519
Govind Singhb53420c2016-03-09 14:32:57 +05308520 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308521 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8522
8523 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8524 WMI_EXTWOW_ENABLE_CMDID);
8525 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308526 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308527 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308528 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308529 }
8530
Govind Singhb53420c2016-03-09 14:32:57 +05308531 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308532
8533}
8534
8535/**
8536 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8537 * @wmi_handle: wmi handle
8538 * @app_type1_params: app type1 params
8539 *
8540 * Return: CDF status
8541 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308542static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308543 struct app_type1_params *app_type1_params)
8544{
8545 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8546 wmi_buf_t buf;
8547 int32_t len;
8548 int ret;
8549
8550 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8551 buf = wmi_buf_alloc(wmi_handle, len);
8552 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308553 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8554 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308555 }
8556
8557 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8558 wmi_buf_data(buf);
8559
8560 WMITLV_SET_HDR(&cmd->tlv_header,
8561 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8562 WMITLV_GET_STRUCT_TLVLEN
8563 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8564
8565 cmd->vdev_id = app_type1_params->vdev_id;
8566 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8567 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308568 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308569 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308570 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308571 cmd->passwd_len = app_type1_params->pass_length;
8572
Govind Singhb53420c2016-03-09 14:32:57 +05308573 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308574 "identification_id %.8s id_length %u "
8575 "password %.16s pass_length %u",
8576 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8577 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8578
8579 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8580 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8581 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308582 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308583 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308584 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308585 }
8586
Govind Singhb53420c2016-03-09 14:32:57 +05308587 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308588}
8589
8590/**
8591 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8592 * @wmi_handle: wmi handle
8593 * @appType2Params: app type2 params
8594 *
8595 * Return: CDF status
8596 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308597static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308598 struct app_type2_params *appType2Params)
8599{
8600 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8601 wmi_buf_t buf;
8602 int32_t len;
8603 int ret;
8604
8605 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8606 buf = wmi_buf_alloc(wmi_handle, len);
8607 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308608 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8609 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308610 }
8611
8612 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8613 wmi_buf_data(buf);
8614
8615 WMITLV_SET_HDR(&cmd->tlv_header,
8616 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8617 WMITLV_GET_STRUCT_TLVLEN
8618 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8619
8620 cmd->vdev_id = appType2Params->vdev_id;
8621
Govind Singhb53420c2016-03-09 14:32:57 +05308622 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308623 cmd->rc4_key_len = appType2Params->rc4_key_len;
8624
8625 cmd->ip_id = appType2Params->ip_id;
8626 cmd->ip_device_ip = appType2Params->ip_device_ip;
8627 cmd->ip_server_ip = appType2Params->ip_server_ip;
8628
8629 cmd->tcp_src_port = appType2Params->tcp_src_port;
8630 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8631 cmd->tcp_seq = appType2Params->tcp_seq;
8632 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8633
8634 cmd->keepalive_init = appType2Params->keepalive_init;
8635 cmd->keepalive_min = appType2Params->keepalive_min;
8636 cmd->keepalive_max = appType2Params->keepalive_max;
8637 cmd->keepalive_inc = appType2Params->keepalive_inc;
8638
8639 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8640 &cmd->gateway_mac);
8641 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8642 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8643
Govind Singhb53420c2016-03-09 14:32:57 +05308644 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308645 "rc4_key %.16s rc4_key_len %u "
8646 "ip_id %x ip_device_ip %x ip_server_ip %x "
8647 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8648 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8649 "keepalive_max %u keepalive_inc %u "
8650 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8651 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8652 cmd->rc4_key, cmd->rc4_key_len,
8653 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8654 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8655 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8656 cmd->keepalive_max, cmd->keepalive_inc,
8657 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8658
8659 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8660 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8661 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308662 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308663 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308664 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308665 }
8666
Govind Singhb53420c2016-03-09 14:32:57 +05308667 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308668
8669}
8670
8671/**
8672 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8673 * @wmi_handle: wmi handle
8674 * @timer_val: auto shutdown timer value
8675 *
8676 * Return: CDF status
8677 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308678static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308679 uint32_t timer_val)
8680{
Govind Singh67922e82016-04-01 16:48:57 +05308681 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308682 wmi_buf_t buf = NULL;
8683 uint8_t *buf_ptr;
8684 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8685 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8686
Govind Singhb53420c2016-03-09 14:32:57 +05308687 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308688 __func__, timer_val);
8689
8690 buf = wmi_buf_alloc(wmi_handle, len);
8691 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308692 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8693 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308694 }
8695
8696 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8697 wmi_auto_sh_cmd =
8698 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8699 wmi_auto_sh_cmd->timer_value = timer_val;
8700
8701 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8702 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8703 WMITLV_GET_STRUCT_TLVLEN
8704 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8705
8706 status = wmi_unified_cmd_send(wmi_handle, buf,
8707 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308708 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308709 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308710 __func__, status);
8711 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308712 }
8713
Govind Singh67922e82016-04-01 16:48:57 +05308714 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308715}
8716
8717/**
8718 * send_nan_req_cmd_tlv() - to send nan request to target
8719 * @wmi_handle: wmi handle
8720 * @nan_req: request data which will be non-null
8721 *
8722 * Return: CDF status
8723 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308724static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308725 struct nan_req_params *nan_req)
8726{
Govind Singh67922e82016-04-01 16:48:57 +05308727 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308728 wmi_nan_cmd_param *cmd;
8729 wmi_buf_t buf;
8730 uint16_t len = sizeof(*cmd);
8731 uint16_t nan_data_len, nan_data_len_aligned;
8732 uint8_t *buf_ptr;
8733
8734 /*
8735 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8736 * +------------+----------+-----------------------+--------------+
8737 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8738 * +------------+----------+-----------------------+--------------+
8739 */
8740 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308741 WMI_LOGE("%s:nan req is not valid", __func__);
8742 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308743 }
8744 nan_data_len = nan_req->request_data_len;
8745 nan_data_len_aligned = roundup(nan_req->request_data_len,
8746 sizeof(uint32_t));
8747 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8748 buf = wmi_buf_alloc(wmi_handle, len);
8749 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308750 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8751 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308752 }
8753 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8754 cmd = (wmi_nan_cmd_param *) buf_ptr;
8755 WMITLV_SET_HDR(&cmd->tlv_header,
8756 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8757 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8758 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308759 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308760 __func__, nan_req->request_data_len);
8761 buf_ptr += sizeof(wmi_nan_cmd_param);
8762 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8763 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308764 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308765
8766 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8767 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308768 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308769 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308770 __func__, ret);
8771 wmi_buf_free(buf);
8772 }
8773
8774 return ret;
8775}
8776
8777/**
8778 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8779 * @wmi_handle: wmi handle
8780 * @pDhcpSrvOffloadInfo: DHCP server offload info
8781 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308782 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308783 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308784static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308785 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8786{
8787 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8788 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308789 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308790
8791 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8792 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308793 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308794 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308795 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308796 }
8797
8798 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308799 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308800
8801 WMITLV_SET_HDR(&cmd->tlv_header,
8802 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8803 WMITLV_GET_STRUCT_TLVLEN
8804 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8805 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8806 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8807 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8808 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8809 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308810 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308811 sizeof(*cmd),
8812 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308813 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308814 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308815 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308816 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308817 }
Govind Singhb53420c2016-03-09 14:32:57 +05308818 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308819 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308820
8821 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308822}
8823
8824/**
8825 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8826 * @wmi_handle: wmi handle
8827 * @flashing: flashing request
8828 *
8829 * Return: CDF status
8830 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308831static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308832 struct flashing_req_params *flashing)
8833{
8834 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308835 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308836 wmi_buf_t buf;
8837 uint8_t *buf_ptr;
8838 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8839
8840 buf = wmi_buf_alloc(wmi_handle, len);
8841 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308842 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308843 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308844 }
8845 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8846 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8847 WMITLV_SET_HDR(&cmd->tlv_header,
8848 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8849 WMITLV_GET_STRUCT_TLVLEN
8850 (wmi_set_led_flashing_cmd_fixed_param));
8851 cmd->pattern_id = flashing->pattern_id;
8852 cmd->led_x0 = flashing->led_x0;
8853 cmd->led_x1 = flashing->led_x1;
8854
8855 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8856 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308857 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308858 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308859 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308860 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308861 }
Govind Singh67922e82016-04-01 16:48:57 +05308862
8863 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308864}
8865
8866/**
8867 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8868 * @wmi_handle: wmi handle
8869 * @ch_avoid_update_req: channel avoid update params
8870 *
8871 * Return: CDF status
8872 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308873static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308874{
Govind Singh67922e82016-04-01 16:48:57 +05308875 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308876 wmi_buf_t buf = NULL;
8877 uint8_t *buf_ptr;
8878 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8879 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8880
8881
8882 buf = wmi_buf_alloc(wmi_handle, len);
8883 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308884 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8885 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308886 }
8887
8888 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8889 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8890 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8891 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8892 WMITLV_GET_STRUCT_TLVLEN
8893 (wmi_chan_avoid_update_cmd_param));
8894
8895 status = wmi_unified_cmd_send(wmi_handle, buf,
8896 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308897 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308898 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308899 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8900 " returned Error %d", status);
8901 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308902 }
8903
Govind Singh67922e82016-04-01 16:48:57 +05308904 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308905}
8906
8907/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05308908 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
8909 * @wmi_handle: wmi handle
8910 * @param: pointer to pdev regdomain params
8911 *
8912 * Return: 0 for success or error code
8913 */
8914static QDF_STATUS
8915send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
8916 struct pdev_set_regdomain_params *param)
8917{
8918 wmi_buf_t buf;
8919 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8920 int32_t len = sizeof(*cmd);
8921
8922
8923 buf = wmi_buf_alloc(wmi_handle, len);
8924 if (!buf) {
8925 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8926 return QDF_STATUS_E_NOMEM;
8927 }
8928 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8929 WMITLV_SET_HDR(&cmd->tlv_header,
8930 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8931 WMITLV_GET_STRUCT_TLVLEN
8932 (wmi_pdev_set_regdomain_cmd_fixed_param));
8933
8934 cmd->reg_domain = param->currentRDinuse;
8935 cmd->reg_domain_2G = param->currentRD2G;
8936 cmd->reg_domain_5G = param->currentRD5G;
8937 cmd->conformance_test_limit_2G = param->ctl_2G;
8938 cmd->conformance_test_limit_5G = param->ctl_5G;
8939 cmd->dfs_domain = param->dfsDomain;
8940 cmd->pdev_id = param->pdev_id;
8941
8942 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8943 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
8944 WMI_LOGE("%s: Failed to send pdev set regdomain command",
8945 __func__);
8946 wmi_buf_free(buf);
8947 return QDF_STATUS_E_FAILURE;
8948 }
8949
8950 return QDF_STATUS_SUCCESS;
8951}
8952
8953/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308954 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
8955 * @wmi_handle: wmi handle
8956 * @reg_dmn: reg domain
8957 * @regdmn2G: 2G reg domain
8958 * @regdmn5G: 5G reg domain
8959 * @ctl2G: 2G test limit
8960 * @ctl5G: 5G test limit
8961 *
8962 * Return: none
8963 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308964static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308965 uint32_t reg_dmn, uint16_t regdmn2G,
8966 uint16_t regdmn5G, int8_t ctl2G,
8967 int8_t ctl5G)
8968{
8969 wmi_buf_t buf;
8970 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8971 int32_t len = sizeof(*cmd);
8972
8973
8974 buf = wmi_buf_alloc(wmi_handle, len);
8975 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308976 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8977 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308978 }
8979 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8980 WMITLV_SET_HDR(&cmd->tlv_header,
8981 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8982 WMITLV_GET_STRUCT_TLVLEN
8983 (wmi_pdev_set_regdomain_cmd_fixed_param));
8984 cmd->reg_domain = reg_dmn;
8985 cmd->reg_domain_2G = regdmn2G;
8986 cmd->reg_domain_5G = regdmn5G;
8987 cmd->conformance_test_limit_2G = ctl2G;
8988 cmd->conformance_test_limit_5G = ctl5G;
8989
8990 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8991 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308992 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308993 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308994 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308995 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308996 }
8997
Govind Singhb53420c2016-03-09 14:32:57 +05308998 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308999}
9000
9001
9002/**
9003 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9004 * @wmi_handle: wmi handle
9005 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9006 *
9007 * This function sets tdls off channel mode
9008 *
9009 * Return: 0 on success; Negative errno otherwise
9010 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309011static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309012 struct tdls_channel_switch_params *chan_switch_params)
9013{
9014 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9015 wmi_buf_t wmi_buf;
9016 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9017
9018 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9019 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309020 WMI_LOGE(FL("wmi_buf_alloc failed"));
9021 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309022 }
9023 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9024 wmi_buf_data(wmi_buf);
9025 WMITLV_SET_HDR(&cmd->tlv_header,
9026 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9027 WMITLV_GET_STRUCT_TLVLEN(
9028 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9029
9030 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9031 &cmd->peer_macaddr);
9032 cmd->vdev_id = chan_switch_params->vdev_id;
9033 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9034 cmd->is_peer_responder = chan_switch_params->is_responder;
9035 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9036 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9037 cmd->offchan_oper_class = chan_switch_params->oper_class;
9038
Govind Singhb53420c2016-03-09 14:32:57 +05309039 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309040 cmd->peer_macaddr.mac_addr31to0,
9041 cmd->peer_macaddr.mac_addr47to32);
9042
Govind Singhb53420c2016-03-09 14:32:57 +05309043 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309044 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9045 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9046 ),
9047 cmd->vdev_id,
9048 cmd->offchan_mode,
9049 cmd->offchan_num,
9050 cmd->offchan_bw_bitmap,
9051 cmd->is_peer_responder,
9052 cmd->offchan_oper_class);
9053
9054 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9055 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309056 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309057 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309058 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309059 }
9060
9061
Govind Singhb53420c2016-03-09 14:32:57 +05309062 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309063}
9064
9065/**
9066 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9067 * @wmi_handle: wmi handle
9068 * @pwmaTdlsparams: TDLS params
9069 *
9070 * Return: 0 for sucess or error code
9071 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309072static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309073 void *tdls_param, uint8_t tdls_state)
9074{
9075 wmi_tdls_set_state_cmd_fixed_param *cmd;
9076 wmi_buf_t wmi_buf;
9077
9078 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9079 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9080
9081 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9082 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309083 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9084 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309085 }
9086 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9087 WMITLV_SET_HDR(&cmd->tlv_header,
9088 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9089 WMITLV_GET_STRUCT_TLVLEN
9090 (wmi_tdls_set_state_cmd_fixed_param));
9091 cmd->vdev_id = wmi_tdls->vdev_id;
9092 cmd->state = tdls_state;
9093 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9094 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9095 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9096 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9097 cmd->rssi_delta = wmi_tdls->rssi_delta;
9098 cmd->tdls_options = wmi_tdls->tdls_options;
9099 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9100 cmd->tdls_peer_traffic_response_timeout_ms =
9101 wmi_tdls->peer_traffic_response_timeout;
9102 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9103 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9104 cmd->tdls_puapsd_rx_frame_threshold =
9105 wmi_tdls->puapsd_rx_frame_threshold;
9106 cmd->teardown_notification_ms =
9107 wmi_tdls->teardown_notification_ms;
9108 cmd->tdls_peer_kickout_threshold =
9109 wmi_tdls->tdls_peer_kickout_threshold;
9110
Govind Singhb53420c2016-03-09 14:32:57 +05309111 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309112 "notification_interval_ms: %d, "
9113 "tx_discovery_threshold: %d, "
9114 "tx_teardown_threshold: %d, "
9115 "rssi_teardown_threshold: %d, "
9116 "rssi_delta: %d, "
9117 "tdls_options: 0x%x, "
9118 "tdls_peer_traffic_ind_window: %d, "
9119 "tdls_peer_traffic_response_timeout: %d, "
9120 "tdls_puapsd_mask: 0x%x, "
9121 "tdls_puapsd_inactivity_time: %d, "
9122 "tdls_puapsd_rx_frame_threshold: %d, "
9123 "teardown_notification_ms: %d, "
9124 "tdls_peer_kickout_threshold: %d",
9125 __func__, tdls_state, cmd->state,
9126 cmd->notification_interval_ms,
9127 cmd->tx_discovery_threshold,
9128 cmd->tx_teardown_threshold,
9129 cmd->rssi_teardown_threshold,
9130 cmd->rssi_delta,
9131 cmd->tdls_options,
9132 cmd->tdls_peer_traffic_ind_window,
9133 cmd->tdls_peer_traffic_response_timeout_ms,
9134 cmd->tdls_puapsd_mask,
9135 cmd->tdls_puapsd_inactivity_time_ms,
9136 cmd->tdls_puapsd_rx_frame_threshold,
9137 cmd->teardown_notification_ms,
9138 cmd->tdls_peer_kickout_threshold);
9139
9140 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9141 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309142 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309143 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309144 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309145 }
Govind Singhb53420c2016-03-09 14:32:57 +05309146 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309147
Govind Singhb53420c2016-03-09 14:32:57 +05309148 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309149}
9150
9151/**
9152 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9153 * @wmi_handle: wmi handle
9154 * @peerStateParams: TDLS peer state params
9155 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309156 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309157 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309158static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309159 struct tdls_peer_state_params *peerStateParams,
9160 uint32_t *ch_mhz)
9161{
9162 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9163 wmi_tdls_peer_capabilities *peer_cap;
9164 wmi_channel *chan_info;
9165 wmi_buf_t wmi_buf;
9166 uint8_t *buf_ptr;
9167 uint32_t i;
9168 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9169 sizeof(wmi_tdls_peer_capabilities);
9170
9171
9172 len += WMI_TLV_HDR_SIZE +
9173 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9174
9175 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9176 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309177 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9178 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309179 }
9180
9181 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9182 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9183 WMITLV_SET_HDR(&cmd->tlv_header,
9184 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9185 WMITLV_GET_STRUCT_TLVLEN
9186 (wmi_tdls_peer_update_cmd_fixed_param));
9187
9188 cmd->vdev_id = peerStateParams->vdevId;
9189 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9190 &cmd->peer_macaddr);
9191
9192
9193 cmd->peer_state = peerStateParams->peerState;
9194
Govind Singhb53420c2016-03-09 14:32:57 +05309195 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309196 "peer_macaddr.mac_addr31to0: 0x%x, "
9197 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9198 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9199 cmd->peer_macaddr.mac_addr31to0,
9200 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9201
9202 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9203 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9204 WMITLV_SET_HDR(&peer_cap->tlv_header,
9205 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9206 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9207
9208 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9209 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9210 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9211 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9212 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9213 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9214 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9215 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9216
9217 /* Ack and More Data Ack are sent as 0, so no need to set
9218 * but fill SP
9219 */
9220 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9221 peerStateParams->peerCap.peerMaxSp);
9222
9223 peer_cap->buff_sta_support =
9224 peerStateParams->peerCap.peerBuffStaSupport;
9225 peer_cap->off_chan_support =
9226 peerStateParams->peerCap.peerOffChanSupport;
9227 peer_cap->peer_curr_operclass =
9228 peerStateParams->peerCap.peerCurrOperClass;
9229 /* self curr operclass is not being used and so pass op class for
9230 * preferred off chan in it.
9231 */
9232 peer_cap->self_curr_operclass =
9233 peerStateParams->peerCap.opClassForPrefOffChan;
9234 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9235 peer_cap->peer_operclass_len =
9236 peerStateParams->peerCap.peerOperClassLen;
9237
Govind Singhb53420c2016-03-09 14:32:57 +05309238 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309239 __func__, peer_cap->peer_operclass_len);
9240 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9241 peer_cap->peer_operclass[i] =
9242 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309243 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309244 __func__, i, peer_cap->peer_operclass[i]);
9245 }
9246
9247 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9248 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9249 peer_cap->pref_offchan_bw =
9250 peerStateParams->peerCap.prefOffChanBandwidth;
9251
Govind Singhb53420c2016-03-09 14:32:57 +05309252 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309253 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9254 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9255 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9256 " %d, pref_offchan_bw: %d",
9257 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9258 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9259 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9260 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9261 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9262
9263 /* next fill variable size array of peer chan info */
9264 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9265 WMITLV_SET_HDR(buf_ptr,
9266 WMITLV_TAG_ARRAY_STRUC,
9267 sizeof(wmi_channel) *
9268 peerStateParams->peerCap.peerChanLen);
9269 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9270
9271 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9272 WMITLV_SET_HDR(&chan_info->tlv_header,
9273 WMITLV_TAG_STRUC_wmi_channel,
9274 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9275 chan_info->mhz = ch_mhz[i];
9276 chan_info->band_center_freq1 = chan_info->mhz;
9277 chan_info->band_center_freq2 = 0;
9278
Govind Singhb53420c2016-03-09 14:32:57 +05309279 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309280
9281 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9282 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309283 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309284 peerStateParams->peerCap.peerChan[i].chanId,
9285 peerStateParams->peerCap.peerChan[i].dfsSet);
9286 }
9287
9288 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9289 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9290 else
9291 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9292
9293 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9294 peerStateParams->peerCap.
9295 peerChan[i].pwr);
9296
9297 WMI_SET_CHANNEL_REG_POWER(chan_info,
9298 peerStateParams->peerCap.peerChan[i].
9299 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309300 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309301 peerStateParams->peerCap.peerChan[i].pwr);
9302
9303 chan_info++;
9304 }
9305
9306 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9307 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309308 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309309 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309310 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309311 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309312 }
9313
9314
Govind Singhb53420c2016-03-09 14:32:57 +05309315 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309316}
9317
9318/*
9319 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9320 * firmware
9321 * @wmi_handle: Pointer to wmi handle
9322 * @mem_dump_req: Pointer for mem_dump_req
9323 *
9324 * This function sends memory dump request to firmware
9325 *
Govind Singhb53420c2016-03-09 14:32:57 +05309326 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309327 *
9328 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309329static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309330 struct fw_dump_req_param *mem_dump_req)
9331{
9332 wmi_get_fw_mem_dump_fixed_param *cmd;
9333 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309334 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309335 int32_t len;
9336 wmi_buf_t buf;
9337 u_int8_t *buf_ptr;
9338 int ret, loop;
9339
9340 /*
9341 * len = sizeof(fixed param) that includes tlv header +
9342 * tlv header for array of struc +
9343 * sizeof (each struct)
9344 */
9345 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9346 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9347 buf = wmi_buf_alloc(wmi_handle, len);
9348
9349 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309350 WMI_LOGE(FL("Failed allocate wmi buffer"));
9351 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309352 }
9353
9354 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309355 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309356 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9357
9358 WMITLV_SET_HDR(&cmd->tlv_header,
9359 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9360 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9361
9362 cmd->request_id = mem_dump_req->request_id;
9363 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9364
9365 /* TLV indicating array of structures to follow */
9366 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9367 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9368 sizeof(wmi_fw_mem_dump) *
9369 cmd->num_fw_mem_dump_segs);
9370
9371 buf_ptr += WMI_TLV_HDR_SIZE;
9372 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9373
Govind Singhb53420c2016-03-09 14:32:57 +05309374 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309375 mem_dump_req->request_id, mem_dump_req->num_seg);
9376 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309377 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309378 ((uint8_t *)(mem_dump_req->segment) +
9379 loop * sizeof(*seg_req));
9380 WMITLV_SET_HDR(&dump_params->tlv_header,
9381 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9382 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9383 dump_params->seg_id = seg_req->seg_id;
9384 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9385 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9386 dump_params->seg_length = seg_req->seg_length;
9387 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9388 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309389 WMI_LOGI(FL("seg_number:%d"), loop);
9390 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309391 dump_params->seg_id, dump_params->seg_start_addr_lo,
9392 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309393 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309394 dump_params->seg_length, dump_params->dest_addr_lo,
9395 dump_params->dest_addr_hi);
9396 dump_params++;
9397 }
9398
9399 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9400 WMI_GET_FW_MEM_DUMP_CMDID);
9401 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309402 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309403 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309404 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309405 }
9406
Govind Singhb53420c2016-03-09 14:32:57 +05309407 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9408 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309409}
9410
9411/*
9412 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9413 * @wmi_handle: Pointer to WMi handle
9414 * @ie_data: Pointer for ie data
9415 *
9416 * This function sends IE information to firmware
9417 *
Govind Singhb53420c2016-03-09 14:32:57 +05309418 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309419 *
9420 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309421static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309422 struct vdev_ie_info_param *ie_info)
9423{
9424 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9425 wmi_buf_t buf;
9426 uint8_t *buf_ptr;
9427 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309428 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309429
9430
9431 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9432 /* Allocate memory for the WMI command */
9433 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9434
9435 buf = wmi_buf_alloc(wmi_handle, len);
9436 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309437 WMI_LOGE(FL("wmi_buf_alloc failed"));
9438 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309439 }
9440
9441 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309442 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309443
9444 /* Populate the WMI command */
9445 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9446
9447 WMITLV_SET_HDR(&cmd->tlv_header,
9448 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9449 WMITLV_GET_STRUCT_TLVLEN(
9450 wmi_vdev_set_ie_cmd_fixed_param));
9451 cmd->vdev_id = ie_info->vdev_id;
9452 cmd->ie_id = ie_info->ie_id;
9453 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009454 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309455
Govind Singhb53420c2016-03-09 14:32:57 +05309456 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309457 ie_info->length, ie_info->vdev_id);
9458
9459 buf_ptr += sizeof(*cmd);
9460 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9461 buf_ptr += WMI_TLV_HDR_SIZE;
9462
Govind Singhb53420c2016-03-09 14:32:57 +05309463 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309464
9465 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9466 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309467 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309468 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309469 wmi_buf_free(buf);
9470 }
9471
9472 return ret;
9473}
9474
Sathish Kumar497bef42017-03-01 14:02:36 +05309475/**
9476 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9477 *
9478 * @param wmi_handle : handle to WMI.
9479 * @param param : pointer to antenna param
9480 *
9481 * This function sends smart antenna enable command to FW
9482 *
9483 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9484 */
9485static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9486 struct smart_ant_enable_params *param)
9487{
9488 /* Send WMI COMMAND to Enable */
9489 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9490 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9491 wmi_buf_t buf;
9492 uint8_t *buf_ptr;
9493 int len = 0;
9494 QDF_STATUS ret;
9495 int loop = 0;
9496
9497 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9498 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9499 buf = wmi_buf_alloc(wmi_handle, len);
9500
9501 if (!buf) {
9502 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9503 return QDF_STATUS_E_NOMEM;
9504 }
9505
9506 buf_ptr = wmi_buf_data(buf);
9507 qdf_mem_zero(buf_ptr, len);
9508 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9509
9510 WMITLV_SET_HDR(&cmd->tlv_header,
9511 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9512 WMITLV_GET_STRUCT_TLVLEN(
9513 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9514
9515 cmd->pdev_id = param->pdev_id;
9516 cmd->enable = param->enable;
9517 cmd->mode = param->mode;
9518 cmd->rx_antenna = param->rx_antenna;
9519 cmd->tx_default_antenna = param->rx_antenna;
9520
9521 /* TLV indicating array of structures to follow */
9522 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9523 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9524 WMI_HAL_MAX_SANTENNA *
9525 sizeof(wmi_pdev_smart_ant_gpio_handle));
9526
9527 buf_ptr += WMI_TLV_HDR_SIZE;
9528 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9529
9530 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9531 WMITLV_SET_HDR(&gpio_param->tlv_header,
9532 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9533 WMITLV_GET_STRUCT_TLVLEN(
9534 wmi_pdev_smart_ant_gpio_handle));
9535 if (param->mode == SMART_ANT_MODE_SERIAL) {
9536 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9537 gpio_param->gpio_pin = param->gpio_pin[loop];
9538 gpio_param->gpio_func = param->gpio_func[loop];
9539 } else {
9540 gpio_param->gpio_pin = 0;
9541 gpio_param->gpio_func = 0;
9542 }
9543 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9544 gpio_param->gpio_pin = param->gpio_pin[loop];
9545 gpio_param->gpio_func = param->gpio_func[loop];
9546 }
9547 /* Setting it to 0 for now */
9548 gpio_param->pdev_id = param->pdev_id;
9549 gpio_param++;
9550 }
9551
9552 ret = wmi_unified_cmd_send(wmi_handle,
9553 buf,
9554 len,
9555 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9556
9557 if (ret != 0) {
9558 WMI_LOGE(" %s :WMI Failed\n", __func__);
9559 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9560 cmd->enable,
9561 cmd->mode,
9562 cmd->rx_antenna,
9563 param->gpio_pin[0], param->gpio_pin[1],
9564 param->gpio_pin[2], param->gpio_pin[3],
9565 param->gpio_func[0], param->gpio_func[1],
9566 param->gpio_func[2], param->gpio_func[3],
9567 ret);
9568 wmi_buf_free(buf);
9569 }
9570
9571 return ret;
9572}
9573
9574/**
9575 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9576 *
9577 * @param wmi_handle : handle to WMI.
9578 * @param param : pointer to rx antenna param
9579 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9580 */
9581static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9582 struct smart_ant_rx_ant_params *param)
9583{
9584 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9585 wmi_buf_t buf;
9586 uint8_t *buf_ptr;
9587 uint32_t len;
9588 QDF_STATUS ret;
9589
9590 len = sizeof(*cmd);
9591 buf = wmi_buf_alloc(wmi_handle, len);
9592 WMI_LOGD("%s:\n", __func__);
9593 if (!buf) {
9594 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9595 return QDF_STATUS_E_NOMEM;
9596 }
9597
9598 buf_ptr = wmi_buf_data(buf);
9599 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9600 WMITLV_SET_HDR(&cmd->tlv_header,
9601 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9602 WMITLV_GET_STRUCT_TLVLEN(
9603 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9604 cmd->rx_antenna = param->antenna;
9605 cmd->pdev_id = param->pdev_id;
9606
9607 ret = wmi_unified_cmd_send(wmi_handle,
9608 buf,
9609 len,
9610 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9611
9612 if (ret != 0) {
9613 WMI_LOGE(" %s :WMI Failed\n", __func__);
9614 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9615 __func__,
9616 cmd->rx_antenna,
9617 ret);
9618 wmi_buf_free(buf);
9619 }
9620
9621 return ret;
9622}
9623
9624/**
9625 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9626 * @wmi_handle: wmi handle
9627 * @param: pointer to hold ctl table param
9628 *
9629 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9630 */
9631static QDF_STATUS
9632send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9633 struct ctl_table_params *param)
9634{
9635 uint16_t len, ctl_tlv_len;
9636 uint8_t *buf_ptr;
9637 wmi_buf_t buf;
9638 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9639 uint32_t *ctl_array;
9640
9641 if (!param->ctl_array)
9642 return QDF_STATUS_E_FAILURE;
9643
9644 if (param->ctl_cmd_len !=
9645 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9646 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9647 qdf_print("CTL array len not correct\n");
9648 return QDF_STATUS_E_FAILURE;
9649 }
9650
9651 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9652 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9653 len = sizeof(*cmd) + ctl_tlv_len;
9654
9655 buf = wmi_buf_alloc(wmi_handle, len);
9656 if (!buf) {
9657 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9658 return QDF_STATUS_E_FAILURE;
9659 }
9660
9661 buf_ptr = wmi_buf_data(buf);
9662 qdf_mem_zero(buf_ptr, len);
9663
9664 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9665
9666 WMITLV_SET_HDR(&cmd->tlv_header,
9667 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9668 WMITLV_GET_STRUCT_TLVLEN(
9669 wmi_pdev_set_ctl_table_cmd_fixed_param));
9670 cmd->ctl_len = param->ctl_cmd_len;
9671 cmd->pdev_id = param->pdev_id;
9672
9673 buf_ptr += sizeof(*cmd);
9674 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9675 (cmd->ctl_len));
9676 buf_ptr += WMI_TLV_HDR_SIZE;
9677 ctl_array = (uint32_t *)buf_ptr;
9678
9679 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9680 sizeof(param->ctl_band));
9681 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9682 param->ctl_cmd_len -
9683 sizeof(param->ctl_band));
9684
9685 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9686 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9687 WMI_LOGE("%s:Failed to send command\n", __func__);
9688 wmi_buf_free(buf);
9689 return QDF_STATUS_E_FAILURE;
9690 }
9691
9692 return QDF_STATUS_SUCCESS;
9693}
9694
9695/**
9696 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9697 * @wmi_handle: wmi handle
9698 * @param: pointer to hold mimogain table param
9699 *
9700 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9701 */
9702static QDF_STATUS
9703send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9704 struct mimogain_table_params *param)
9705{
9706 uint16_t len, table_tlv_len;
9707 wmi_buf_t buf;
9708 uint8_t *buf_ptr;
9709 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
9710 uint32_t *gain_table;
9711
9712 if (!param->array_gain)
9713 return QDF_STATUS_E_FAILURE;
9714
9715 /* len must be multiple of a single array gain table */
9716 if (param->tbl_len %
9717 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
9718 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
9719 WMI_LOGE("Array gain table len not correct\n");
9720 return QDF_STATUS_E_FAILURE;
9721 }
9722
9723 table_tlv_len = WMI_TLV_HDR_SIZE +
9724 roundup(param->tbl_len, sizeof(uint32_t));
9725 len = sizeof(*cmd) + table_tlv_len;
9726
9727 buf = wmi_buf_alloc(wmi_handle, len);
9728 if (!buf) {
9729 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9730 return QDF_STATUS_E_FAILURE;
9731 }
9732
9733 buf_ptr = wmi_buf_data(buf);
9734 qdf_mem_zero(buf_ptr, len);
9735
9736 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
9737
9738 WMITLV_SET_HDR(&cmd->tlv_header,
9739 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
9740 WMITLV_GET_STRUCT_TLVLEN(
9741 wmi_pdev_set_mimogain_table_cmd_fixed_param));
9742
9743 cmd->pdev_id = param->pdev_id;
9744 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
9745 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
9746 param->multichain_gain_bypass);
9747
9748 buf_ptr += sizeof(*cmd);
9749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9750 (param->tbl_len));
9751 buf_ptr += WMI_TLV_HDR_SIZE;
9752 gain_table = (uint32_t *)buf_ptr;
9753
9754 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
9755 param->array_gain,
9756 param->tbl_len);
9757
9758 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9759 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
9760 return QDF_STATUS_E_FAILURE;
9761 }
9762
9763 return QDF_STATUS_SUCCESS;
9764}
9765
9766/**
9767 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
9768 * info to fw
9769 * @wmi_handle: wmi handle
9770 * @param: pointer to hold packet power info param
9771 *
9772 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9773 */
9774static QDF_STATUS
9775send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
9776 struct packet_power_info_params *param)
9777{
9778 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
9779 wmi_buf_t wmibuf;
9780 uint8_t *buf_ptr;
9781 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
9782
9783 wmibuf = wmi_buf_alloc(wmi_handle, len);
9784 if (wmibuf == NULL)
9785 return QDF_STATUS_E_NOMEM;
9786
9787 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
9788
9789 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
9790 WMITLV_SET_HDR(&cmd->tlv_header,
9791 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
9792 WMITLV_GET_STRUCT_TLVLEN(
9793 wmi_pdev_get_tpc_cmd_fixed_param));
9794 cmd->pdev_id = param->pdev_id;
9795 cmd->rate_flags = param->rate_flags;
9796 cmd->nss = param->nss;
9797 cmd->preamble = param->preamble;
9798 cmd->hw_rate = param->hw_rate;
9799 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
9800 __func__,
9801 __LINE__,
9802 WMI_PDEV_GET_TPC_CMDID,
9803 *((u_int32_t *)cmd));
9804 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
9805 WMI_PDEV_GET_TPC_CMDID)) {
9806 WMI_LOGE(FL("Failed to get tpc command\n"));
9807 wmi_buf_free(wmibuf);
9808 return QDF_STATUS_E_FAILURE;
9809 }
9810
9811 return QDF_STATUS_SUCCESS;
9812}
9813
9814/**
9815 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
9816 * @wmi_handle: wmi handle
9817 * @param: pointer to hold config ratemask params
9818 *
9819 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9820 */
9821static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
9822 struct config_ratemask_params *param)
9823{
9824 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
9825 wmi_buf_t buf;
9826 int32_t len = sizeof(*cmd);
9827
9828 buf = wmi_buf_alloc(wmi_handle, len);
9829 if (!buf) {
9830 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9831 return QDF_STATUS_E_FAILURE;
9832 }
9833 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
9834 WMITLV_SET_HDR(&cmd->tlv_header,
9835 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
9836 WMITLV_GET_STRUCT_TLVLEN(
9837 wmi_vdev_config_ratemask_cmd_fixed_param));
9838 cmd->vdev_id = param->vdev_id;
9839 cmd->type = param->type;
9840 cmd->mask_lower32 = param->lower32;
9841 cmd->mask_higher32 = param->higher32;
9842 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
9843 param->vdev_id, param->type, param->lower32, param->higher32);
9844
9845 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9846 WMI_VDEV_RATEMASK_CMDID)) {
9847 WMI_LOGE("Seting vdev ratemask failed\n");
9848 wmi_buf_free(buf);
9849 return QDF_STATUS_E_FAILURE;
9850 }
9851
9852 return QDF_STATUS_SUCCESS;
9853}
9854
9855/**
9856 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
9857 * @wmi_handle: wmi handle
9858 * @param: pointer to hold vap dscp tid map param
9859 *
9860 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9861 */
9862static QDF_STATUS
9863send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
9864 struct vap_dscp_tid_map_params *param)
9865{
9866 wmi_buf_t buf;
9867 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
9868 int32_t len = sizeof(*cmd);
9869
9870 buf = wmi_buf_alloc(wmi_handle, len);
9871 if (!buf) {
9872 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9873 return QDF_STATUS_E_FAILURE;
9874 }
9875
9876 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
9877 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
9878 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
9879
9880 cmd->vdev_id = param->vdev_id;
9881 cmd->enable_override = 0;
9882
9883 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
9884 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9885 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
9886 WMI_LOGE("Failed to set dscp cmd\n");
9887 wmi_buf_free(buf);
9888 return QDF_STATUS_E_FAILURE;
9889 }
9890
9891 return QDF_STATUS_SUCCESS;
9892}
9893
9894/**
9895 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
9896 * @wmi_handle: wmi handle
9897 * @macaddr: vdev mac address
9898 * @param: pointer to hold neigbour rx param
9899 *
9900 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9901 */
9902static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
9903 uint8_t macaddr[IEEE80211_ADDR_LEN],
9904 struct set_neighbour_rx_params *param)
9905{
9906 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
9907 wmi_buf_t buf;
9908 int32_t len = sizeof(*cmd);
9909
9910 buf = wmi_buf_alloc(wmi_handle, len);
9911 if (!buf) {
9912 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9913 return QDF_STATUS_E_FAILURE;
9914 }
9915 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
9916 WMITLV_SET_HDR(&cmd->tlv_header,
9917 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
9918 WMITLV_GET_STRUCT_TLVLEN(
9919 wmi_vdev_filter_nrp_config_cmd_fixed_param));
9920 cmd->vdev_id = param->vdev_id;
9921 cmd->bssid_idx = param->idx;
9922 cmd->action = param->action;
9923 cmd->type = param->type;
9924 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
9925 cmd->flag = 0;
9926
9927 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9928 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
9929 WMI_LOGE("Failed to set neighbour rx param\n");
9930 wmi_buf_free(buf);
9931 return QDF_STATUS_E_FAILURE;
9932 }
9933
9934 return QDF_STATUS_SUCCESS;
9935}
9936
9937/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +05309938 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +05309939 * @param wmi_handle : handle to WMI.
9940 * @param macaddr : vdev mac address
9941 * @param param : pointer to tx antenna param
9942 *
9943 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9944 */
9945static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9946 uint8_t macaddr[IEEE80211_ADDR_LEN],
9947 struct smart_ant_tx_ant_params *param)
9948{
9949 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
9950 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
9951 wmi_buf_t buf;
9952 int32_t len = 0;
9953 int i;
9954 uint8_t *buf_ptr;
9955 QDF_STATUS ret;
9956
9957 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9958 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
9959 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
9960 buf = wmi_buf_alloc(wmi_handle, len);
9961
9962 if (!buf) {
9963 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9964 return QDF_STATUS_E_NOMEM;
9965 }
9966
9967 buf_ptr = (uint8_t *)wmi_buf_data(buf);
9968 qdf_mem_zero(buf_ptr, len);
9969 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
9970
9971 WMITLV_SET_HDR(&cmd->tlv_header,
9972 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
9973 WMITLV_GET_STRUCT_TLVLEN(
9974 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
9975
9976 cmd->vdev_id = param->vdev_id;
9977 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
9978
9979 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
9980 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9981 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
9982 buf_ptr += WMI_TLV_HDR_SIZE;
9983 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
9984
9985 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
9986 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
9987 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
9988 WMITLV_GET_STRUCT_TLVLEN(
9989 wmi_peer_smart_ant_set_tx_antenna_series));
9990 ant_tx_series->antenna_series = param->antenna_array[i];
9991 ant_tx_series++;
9992 }
9993
9994 ret = wmi_unified_cmd_send(wmi_handle,
9995 buf,
9996 len,
9997 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
9998
9999 if (ret != 0) {
10000 WMI_LOGE(" %s :WMI Failed\n", __func__);
10001 wmi_buf_free(buf);
10002 }
10003
10004 return ret;
10005}
10006
Sathish Kumar02c3b542017-02-22 17:24:45 +053010007/**
10008 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10009 * @wmi_handle: wmi handle
10010 * @param: pointer to hold ant switch tbl param
10011 *
10012 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10013 */
10014static QDF_STATUS
10015send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10016 struct ant_switch_tbl_params *param)
10017{
10018 uint8_t len;
10019 wmi_buf_t buf;
10020 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10021 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10022 uint8_t *buf_ptr;
10023
10024 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10025 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10026 buf = wmi_buf_alloc(wmi_handle, len);
10027
10028 if (!buf) {
10029 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10030 return QDF_STATUS_E_NOMEM;
10031 }
10032
10033 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10034 qdf_mem_zero(buf_ptr, len);
10035 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10036
10037 WMITLV_SET_HDR(&cmd->tlv_header,
10038 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10039 WMITLV_GET_STRUCT_TLVLEN(
10040 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10041
10042 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10043 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
10044 cmd->mac_id = param->pdev_id; /* Setting it to 0 for now */
10045
10046 /* TLV indicating array of structures to follow */
10047 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10048 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10049 sizeof(wmi_pdev_set_ant_ctrl_chain));
10050 buf_ptr += WMI_TLV_HDR_SIZE;
10051 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10052
10053 ctrl_chain->pdev_id = param->pdev_id;
10054 ctrl_chain->antCtrlChain = param->antCtrlChain;
10055
10056 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10057 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10058 wmi_buf_free(buf);
10059 return QDF_STATUS_E_FAILURE;
10060 }
10061
10062 return QDF_STATUS_SUCCESS;
10063}
10064
10065/**
10066 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10067 * training information function
10068 * @param wmi_handle : handle to WMI.
10069 * @macaddr : vdev mac address
10070 * @param param : pointer to tx antenna param
10071 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10072 */
10073static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10074 wmi_unified_t wmi_handle,
10075 uint8_t macaddr[IEEE80211_ADDR_LEN],
10076 struct smart_ant_training_info_params *param)
10077{
10078 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10079 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10080 wmi_buf_t buf;
10081 uint8_t *buf_ptr;
10082 int32_t len = 0;
10083 QDF_STATUS ret;
10084 int loop;
10085
10086 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10087 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10088 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10089 buf = wmi_buf_alloc(wmi_handle, len);
10090
10091 if (!buf) {
10092 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10093 return QDF_STATUS_E_NOMEM;
10094 }
10095
10096 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10097 qdf_mem_zero(buf_ptr, len);
10098 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10099
10100 WMITLV_SET_HDR(&cmd->tlv_header,
10101 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10102 WMITLV_GET_STRUCT_TLVLEN(
10103 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10104
10105 cmd->vdev_id = param->vdev_id;
10106 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10107 cmd->num_pkts = param->numpkts;
10108
10109 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10110 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10111 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10112 WMI_SMART_ANT_MAX_RATE_SERIES);
10113
10114 buf_ptr += WMI_TLV_HDR_SIZE;
10115 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10116
10117 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10118 WMITLV_SET_HDR(&train_param->tlv_header,
10119 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10120 WMITLV_GET_STRUCT_TLVLEN(
10121 wmi_peer_smart_ant_set_train_antenna_param));
10122 train_param->train_rate_series = param->rate_array[loop];
10123 train_param->train_antenna_series = param->antenna_array[loop];
10124 train_param->rc_flags = 0;
10125 WMI_LOGI(FL("Series number:%d\n"), loop);
10126 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10127 train_param->train_rate_series,
10128 train_param->train_antenna_series);
10129 train_param++;
10130 }
10131
10132 ret = wmi_unified_cmd_send(wmi_handle,
10133 buf,
10134 len,
10135 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10136
10137 if (ret != 0) {
10138 WMI_LOGE(" %s :WMI Failed\n", __func__);
10139 wmi_buf_free(buf);
10140 return QDF_STATUS_E_FAILURE;
10141 }
10142
10143 return ret;
10144}
10145
10146/**
10147 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10148 * configuration function
10149 * @param wmi_handle : handle to WMI.
10150 * @macaddr : vdev mad address
10151 * @param param : pointer to tx antenna param
10152 *
10153 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10154 */
10155static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10156 wmi_unified_t wmi_handle,
10157 uint8_t macaddr[IEEE80211_ADDR_LEN],
10158 struct smart_ant_node_config_params *param)
10159{
10160 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10161 wmi_buf_t buf;
10162 uint8_t *buf_ptr;
10163 int32_t len = 0, args_tlv_len;
10164 int ret;
10165 int i = 0;
10166 A_UINT32 *node_config_args;
10167
10168 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10169 len = sizeof(*cmd) + args_tlv_len;
10170
10171 if ((param->args_count == 0)) {
10172 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10173 __func__, param->args_count);
10174 return QDF_STATUS_E_FAILURE;
10175 }
10176
10177 buf = wmi_buf_alloc(wmi_handle, len);
10178 if (!buf) {
10179 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10180 return QDF_STATUS_E_NOMEM;
10181 }
10182
10183 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10184 wmi_buf_data(buf);
10185 buf_ptr = (uint8_t *)cmd;
10186 WMITLV_SET_HDR(&cmd->tlv_header,
10187 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10188 WMITLV_GET_STRUCT_TLVLEN(
10189 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10190 cmd->vdev_id = param->vdev_id;
10191 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10192 cmd->cmd_id = param->cmd_id;
10193 cmd->args_count = param->args_count;
10194 buf_ptr += sizeof(
10195 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10196 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10197 (cmd->args_count * sizeof(A_UINT32)));
10198 buf_ptr += WMI_TLV_HDR_SIZE;
10199 node_config_args = (A_UINT32 *)buf_ptr;
10200
10201 for (i = 0; i < param->args_count; i++) {
10202 node_config_args[i] = param->args_arr[i];
10203 WMI_LOGI("%d", param->args_arr[i]);
10204 }
10205
10206 ret = wmi_unified_cmd_send(wmi_handle,
10207 buf,
10208 len,
10209 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10210
10211 if (ret != 0) {
10212 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10213 __func__, param->cmd_id, macaddr[0],
10214 macaddr[1], macaddr[2], macaddr[3],
10215 macaddr[4], macaddr[5], ret);
10216 wmi_buf_free(buf);
10217 }
10218
10219 return ret;
10220}
10221
10222/**
10223 * send_set_atf_cmd_tlv() - send set atf command to fw
10224 * @wmi_handle: wmi handle
10225 * @param: pointer to set atf param
10226 *
10227 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10228 */
10229static QDF_STATUS
10230send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10231 struct set_atf_params *param)
10232{
10233 wmi_atf_peer_info *peer_info;
10234 wmi_peer_atf_request_fixed_param *cmd;
10235 wmi_buf_t buf;
10236 uint8_t *buf_ptr;
10237 int i;
10238 int32_t len = 0;
10239 QDF_STATUS retval;
10240
10241 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10242 len += param->num_peers * sizeof(wmi_atf_peer_info);
10243 buf = wmi_buf_alloc(wmi_handle, len);
10244 if (!buf) {
10245 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10246 return QDF_STATUS_E_FAILURE;
10247 }
10248 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10249 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10250 WMITLV_SET_HDR(&cmd->tlv_header,
10251 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10252 WMITLV_GET_STRUCT_TLVLEN(
10253 wmi_peer_atf_request_fixed_param));
10254 cmd->num_peers = param->num_peers;
10255
10256 buf_ptr += sizeof(*cmd);
10257 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10258 sizeof(wmi_atf_peer_info) *
10259 cmd->num_peers);
10260 buf_ptr += WMI_TLV_HDR_SIZE;
10261 peer_info = (wmi_atf_peer_info *)buf_ptr;
10262
10263 for (i = 0; i < cmd->num_peers; i++) {
10264 WMITLV_SET_HDR(&peer_info->tlv_header,
10265 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10266 WMITLV_GET_STRUCT_TLVLEN(
10267 wmi_atf_peer_info));
10268 peer_info->atf_units = param->peer_info[i].percentage_peer;
10269 /*
10270 * TLV definition for peer atf request fixed param combines
10271 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10272 * stats and atf extension stats as two different
10273 * implementations.
10274 * Need to discuss with FW on this.
10275 *
10276 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10277 * peer_info->atf_units_reserved =
10278 * param->peer_ext_info[i].atf_index_reserved;
10279 */
10280 peer_info++;
10281 }
10282
10283 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10284 WMI_PEER_ATF_REQUEST_CMDID);
10285
10286 if (retval != QDF_STATUS_SUCCESS) {
10287 WMI_LOGE("%s : WMI Failed\n", __func__);
10288 wmi_buf_free(buf);
10289 }
10290
10291 return retval;
10292}
10293
10294/**
10295 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10296 * @wmi_handle: wmi handle
10297 * @param: pointer to hold fwtest param
10298 *
10299 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10300 */
10301static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10302 struct set_fwtest_params *param)
10303{
10304 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10305 wmi_buf_t buf;
10306 int32_t len = sizeof(*cmd);
10307
10308 buf = wmi_buf_alloc(wmi_handle, len);
10309
10310 if (!buf) {
10311 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10312 return QDF_STATUS_E_FAILURE;
10313 }
10314
10315 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10316 WMITLV_SET_HDR(&cmd->tlv_header,
10317 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10318 WMITLV_GET_STRUCT_TLVLEN(
10319 wmi_fwtest_set_param_cmd_fixed_param));
10320 cmd->param_id = param->arg;
10321 cmd->param_value = param->value;
10322
10323 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10324 WMI_LOGE("Setting FW test param failed\n");
10325 wmi_buf_free(buf);
10326 return QDF_STATUS_E_FAILURE;
10327 }
10328
10329 return QDF_STATUS_SUCCESS;
10330}
10331
10332/**
10333 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10334 * @wmi_handle: wmi handle
10335 * @param: pointer to qboost params
10336 * @macaddr: vdev mac address
10337 *
10338 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10339 */
10340static QDF_STATUS
10341send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10342 uint8_t macaddr[IEEE80211_ADDR_LEN],
10343 struct set_qboost_params *param)
10344{
10345 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10346 wmi_buf_t buf;
10347 int32_t len;
10348 QDF_STATUS ret;
10349
10350 len = sizeof(*cmd);
10351
10352 buf = wmi_buf_alloc(wmi_handle, len);
10353 if (!buf) {
10354 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10355 return QDF_STATUS_E_FAILURE;
10356 }
10357
10358 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10359 WMITLV_SET_HDR(&cmd->tlv_header,
10360 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10361 WMITLV_GET_STRUCT_TLVLEN(
10362 WMI_QBOOST_CFG_CMD_fixed_param));
10363 cmd->vdev_id = param->vdev_id;
10364 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10365 cmd->qb_enable = param->value;
10366
10367 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10368 WMI_QBOOST_CFG_CMDID);
10369
10370 if (ret != 0) {
10371 WMI_LOGE("Setting qboost cmd failed\n");
10372 wmi_buf_free(buf);
10373 }
10374
10375 return ret;
10376}
10377
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010378/**
10379 * send_gpio_config_cmd_tlv() - send gpio config to fw
10380 * @wmi_handle: wmi handle
10381 * @param: pointer to hold gpio config param
10382 *
10383 * Return: 0 for success or error code
10384 */
10385static QDF_STATUS
10386send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10387 struct gpio_config_params *param)
10388{
10389 wmi_gpio_config_cmd_fixed_param *cmd;
10390 wmi_buf_t buf;
10391 int32_t len;
10392 QDF_STATUS ret;
10393
10394 len = sizeof(*cmd);
10395
10396 /* Sanity Checks */
10397 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10398 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10399 return QDF_STATUS_E_FAILURE;
10400 }
10401
10402 buf = wmi_buf_alloc(wmi_handle, len);
10403 if (!buf) {
10404 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10405 return QDF_STATUS_E_FAILURE;
10406 }
10407
10408 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10409 WMITLV_SET_HDR(&cmd->tlv_header,
10410 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10411 WMITLV_GET_STRUCT_TLVLEN(
10412 wmi_gpio_config_cmd_fixed_param));
10413 cmd->gpio_num = param->gpio_num;
10414 cmd->input = param->input;
10415 cmd->pull_type = param->pull_type;
10416 cmd->intr_mode = param->intr_mode;
10417
10418 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10419 WMI_GPIO_CONFIG_CMDID);
10420
10421 if (ret != 0) {
10422 WMI_LOGE("Sending GPIO config cmd failed\n");
10423 wmi_buf_free(buf);
10424 }
10425
10426 return ret;
10427}
10428
10429/**
10430 * send_gpio_output_cmd_tlv() - send gpio output to fw
10431 * @wmi_handle: wmi handle
10432 * @param: pointer to hold gpio output param
10433 *
10434 * Return: 0 for success or error code
10435 */
10436static QDF_STATUS
10437send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10438 struct gpio_output_params *param)
10439{
10440 wmi_gpio_output_cmd_fixed_param *cmd;
10441 wmi_buf_t buf;
10442 int32_t len;
10443 QDF_STATUS ret;
10444
10445 len = sizeof(*cmd);
10446
10447 buf = wmi_buf_alloc(wmi_handle, len);
10448 if (!buf) {
10449 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10450 return QDF_STATUS_E_FAILURE;
10451 }
10452
10453 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10454 WMITLV_SET_HDR(&cmd->tlv_header,
10455 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10456 WMITLV_GET_STRUCT_TLVLEN(
10457 wmi_gpio_output_cmd_fixed_param));
10458 cmd->gpio_num = param->gpio_num;
10459 cmd->set = param->set;
10460
10461 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10462 WMI_GPIO_OUTPUT_CMDID);
10463
10464 if (ret != 0) {
10465 WMI_LOGE("Sending GPIO output cmd failed\n");
10466 wmi_buf_free(buf);
10467 }
10468
10469 return ret;
10470
10471}
10472
10473/**
10474 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10475 *
10476 * @param wmi_handle : handle to WMI.
10477 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10478 */
10479static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10480{
10481 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10482 wmi_buf_t buf;
10483 QDF_STATUS ret;
10484 int32_t len;
10485
10486 len = sizeof(*cmd);
10487
10488 buf = wmi_buf_alloc(wmi_handle, len);
10489 if (!buf) {
10490 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10491 return QDF_STATUS_E_FAILURE;
10492 }
10493
10494 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10495 WMITLV_SET_HDR(&cmd->tlv_header,
10496 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10497 WMITLV_GET_STRUCT_TLVLEN(
10498 wmi_pdev_dfs_disable_cmd_fixed_param));
10499 /* Filling it with WMI_PDEV_ID_SOC for now */
10500 cmd->pdev_id = WMI_PDEV_ID_SOC;
10501
10502 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10503 WMI_PDEV_DFS_DISABLE_CMDID);
10504
10505 if (ret != 0) {
10506 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10507 wmi_buf_free(buf);
10508 }
10509
10510 return ret;
10511}
10512
10513/**
10514 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10515 *
10516 * @param wmi_handle : handle to WMI.
10517 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10518 */
10519static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10520{
10521 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10522 wmi_buf_t buf;
10523 QDF_STATUS ret;
10524 int32_t len;
10525
10526 len = sizeof(*cmd);
10527
10528 buf = wmi_buf_alloc(wmi_handle, len);
10529 if (!buf) {
10530 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10531 return QDF_STATUS_E_FAILURE;
10532 }
10533
10534 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10535 WMITLV_SET_HDR(&cmd->tlv_header,
10536 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10537 WMITLV_GET_STRUCT_TLVLEN(
10538 wmi_pdev_dfs_enable_cmd_fixed_param));
10539 /* Reserved for future use */
10540 cmd->reserved0 = 0;
10541
10542 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10543 WMI_PDEV_DFS_ENABLE_CMDID);
10544
10545 if (ret != 0) {
10546 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10547 wmi_buf_free(buf);
10548 }
10549
10550 return ret;
10551}
10552
10553/**
10554 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10555 * @wmi_handle: wmi handle
10556 *
10557 * Return: 0 for success or error code
10558 */
10559static QDF_STATUS
10560send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10561{
10562 wmi_buf_t buf;
10563 QDF_STATUS ret;
10564
10565 buf = wmi_buf_alloc(wmi_handle, 0);
10566 if (buf == NULL)
10567 return QDF_STATUS_E_NOMEM;
10568
10569 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10570 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10571 if (ret != 0) {
10572 WMI_LOGE("Sending get nfcal power cmd failed\n");
10573 wmi_buf_free(buf);
10574 }
10575
10576 return ret;
10577}
10578
10579/**
10580 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10581 * @wmi_handle: wmi handle
10582 * @param: pointer to ht ie param
10583 *
10584 * Return: 0 for success or error code
10585 */
10586static QDF_STATUS
10587send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10588 struct ht_ie_params *param)
10589{
10590 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10591 wmi_buf_t buf;
10592 QDF_STATUS ret;
10593 int32_t len;
10594 uint8_t *buf_ptr;
10595
10596 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10597 roundup(param->ie_len, sizeof(uint32_t));
10598
10599 buf = wmi_buf_alloc(wmi_handle, len);
10600 if (!buf) {
10601 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10602 return QDF_STATUS_E_FAILURE;
10603 }
10604
10605 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10606 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10607 WMITLV_SET_HDR(&cmd->tlv_header,
10608 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10609 WMITLV_GET_STRUCT_TLVLEN(
10610 wmi_pdev_set_ht_ie_cmd_fixed_param));
10611 cmd->reserved0 = 0;
10612 cmd->ie_len = param->ie_len;
10613 cmd->tx_streams = param->tx_streams;
10614 cmd->rx_streams = param->rx_streams;
10615
10616 buf_ptr += sizeof(*cmd);
10617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10618 buf_ptr += WMI_TLV_HDR_SIZE;
10619 if (param->ie_len)
10620 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10621 cmd->ie_len);
10622
10623 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10624 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10625
10626 if (ret != 0) {
10627 WMI_LOGE("Sending set ht ie cmd failed\n");
10628 wmi_buf_free(buf);
10629 }
10630
10631 return ret;
10632}
10633
10634/**
10635 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10636 * @wmi_handle: wmi handle
10637 * @param: pointer to vht ie param
10638 *
10639 * Return: 0 for success or error code
10640 */
10641static QDF_STATUS
10642send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10643 struct vht_ie_params *param)
10644{
10645 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10646 wmi_buf_t buf;
10647 QDF_STATUS ret;
10648 int32_t len;
10649 uint8_t *buf_ptr;
10650
10651 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10652 roundup(param->ie_len, sizeof(uint32_t));
10653
10654 buf = wmi_buf_alloc(wmi_handle, len);
10655 if (!buf) {
10656 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10657 return QDF_STATUS_E_FAILURE;
10658 }
10659
10660 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10661 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10662 WMITLV_SET_HDR(&cmd->tlv_header,
10663 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10664 WMITLV_GET_STRUCT_TLVLEN(
10665 wmi_pdev_set_vht_ie_cmd_fixed_param));
10666 cmd->reserved0 = 0;
10667 cmd->ie_len = param->ie_len;
10668 cmd->tx_streams = param->tx_streams;
10669 cmd->rx_streams = param->rx_streams;
10670
10671 buf_ptr += sizeof(*cmd);
10672 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10673 buf_ptr += WMI_TLV_HDR_SIZE;
10674 if (param->ie_len)
10675 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10676 cmd->ie_len);
10677
10678 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10679 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
10680
10681 if (ret != 0) {
10682 WMI_LOGE("Sending set vht ie cmd failed\n");
10683 wmi_buf_free(buf);
10684 }
10685
10686 return ret;
10687}
10688
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053010689/**
10690 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
10691 * @wmi_handle: wmi handle
10692 * @param: pointer to quiet mode params
10693 *
10694 * Return: 0 for success or error code
10695 */
10696static QDF_STATUS
10697send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
10698 struct set_quiet_mode_params *param)
10699{
10700 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
10701 wmi_buf_t buf;
10702 QDF_STATUS ret;
10703 int32_t len;
10704
10705 len = sizeof(*quiet_cmd);
10706 buf = wmi_buf_alloc(wmi_handle, len);
10707 if (!buf) {
10708 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10709 return QDF_STATUS_E_FAILURE;
10710 }
10711
10712 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
10713 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
10714 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
10715 WMITLV_GET_STRUCT_TLVLEN(
10716 wmi_pdev_set_quiet_cmd_fixed_param));
10717 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
10718 quiet_cmd->enabled = param->enabled;
10719 quiet_cmd->period = (param->period)*(param->intval);
10720 quiet_cmd->duration = param->duration;
10721 quiet_cmd->next_start = param->offset;
10722 quiet_cmd->pdev_id = WMI_PDEV_ID_SOC;
10723
10724 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10725 WMI_PDEV_SET_QUIET_MODE_CMDID);
10726
10727 if (ret != 0) {
10728 WMI_LOGE("Sending set quiet cmd failed\n");
10729 wmi_buf_free(buf);
10730 }
10731
10732 return ret;
10733}
10734
10735/**
10736 * send_set_bwf_cmd_tlv() - send set bwf command to fw
10737 * @wmi_handle: wmi handle
10738 * @param: pointer to set bwf param
10739 *
10740 * Return: 0 for success or error code
10741 */
10742static QDF_STATUS
10743send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
10744 struct set_bwf_params *param)
10745{
10746 wmi_bwf_peer_info *peer_info;
10747 wmi_peer_bwf_request_fixed_param *cmd;
10748 wmi_buf_t buf;
10749 QDF_STATUS retval;
10750 int32_t len;
10751 uint8_t *buf_ptr;
10752 int i;
10753
10754 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10755 len += param->num_peers * sizeof(wmi_bwf_peer_info);
10756 buf = wmi_buf_alloc(wmi_handle, len);
10757 if (!buf) {
10758 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10759 return QDF_STATUS_E_FAILURE;
10760 }
10761 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10762 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
10763 WMITLV_SET_HDR(&cmd->tlv_header,
10764 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
10765 WMITLV_GET_STRUCT_TLVLEN(
10766 wmi_peer_bwf_request_fixed_param));
10767 cmd->num_peers = param->num_peers;
10768
10769 buf_ptr += sizeof(*cmd);
10770 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10771 sizeof(wmi_bwf_peer_info) *
10772 cmd->num_peers);
10773 buf_ptr += WMI_TLV_HDR_SIZE;
10774 peer_info = (wmi_bwf_peer_info *)buf_ptr;
10775
10776 for (i = 0; i < cmd->num_peers; i++) {
10777 WMITLV_SET_HDR(&peer_info->tlv_header,
10778 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
10779 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
10780 peer_info->bwf_guaranteed_bandwidth =
10781 param->peer_info[i].throughput;
10782 peer_info->bwf_max_airtime =
10783 param->peer_info[i].max_airtime;
10784 peer_info->bwf_peer_priority =
10785 param->peer_info[i].priority;
10786 qdf_mem_copy(&peer_info->peer_macaddr,
10787 &param->peer_info[i].peer_macaddr,
10788 sizeof(param->peer_info[i].peer_macaddr));
10789 peer_info++;
10790 }
10791
10792 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10793 WMI_PEER_BWF_REQUEST_CMDID);
10794
10795 if (retval != QDF_STATUS_SUCCESS) {
10796 WMI_LOGE("%s : WMI Failed\n", __func__);
10797 wmi_buf_free(buf);
10798 }
10799
10800 return retval;
10801}
10802
10803/**
10804 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
10805 * @wmi_handle: wmi handle
10806 * @param: pointer to hold mcast update param
10807 *
10808 * Return: 0 for success or error code
10809 */
10810static QDF_STATUS
10811send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
10812 struct mcast_group_update_params *param)
10813{
10814 wmi_peer_mcast_group_cmd_fixed_param *cmd;
10815 wmi_buf_t buf;
10816 QDF_STATUS ret;
10817 int32_t len;
10818 int offset = 0;
10819 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
10820
10821 len = sizeof(*cmd);
10822 buf = wmi_buf_alloc(wmi_handle, len);
10823 if (!buf) {
10824 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10825 return QDF_STATUS_E_FAILURE;
10826 }
10827 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
10828 WMITLV_SET_HDR(&cmd->tlv_header,
10829 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
10830 WMITLV_GET_STRUCT_TLVLEN(
10831 wmi_peer_mcast_group_cmd_fixed_param));
10832 /* confirm the buffer is 4-byte aligned */
10833 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
10834 qdf_mem_zero(cmd, sizeof(*cmd));
10835
10836 cmd->vdev_id = param->vap_id;
10837 /* construct the message assuming our endianness matches the target */
10838 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
10839 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
10840 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
10841 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
10842 if (param->is_action_delete)
10843 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
10844
10845 if (param->is_mcast_addr_len)
10846 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
10847
10848 if (param->is_filter_mode_snoop)
10849 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
10850
10851 /* unicast address spec only applies for non-wildcard cases */
10852 if (!param->wildcard && param->ucast_mac_addr) {
10853 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
10854 &cmd->ucast_mac_addr);
10855 }
10856 if (param->mcast_ip_addr) {
10857 QDF_ASSERT(param->mcast_ip_addr_bytes <=
10858 sizeof(cmd->mcast_ip_addr));
10859 offset = sizeof(cmd->mcast_ip_addr) -
10860 param->mcast_ip_addr_bytes;
10861 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
10862 param->mcast_ip_addr,
10863 param->mcast_ip_addr_bytes);
10864 }
10865 if (!param->mask)
10866 param->mask = &dummymask[0];
10867
10868 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
10869 param->mask,
10870 param->mcast_ip_addr_bytes);
10871
10872 if (param->srcs && param->nsrcs) {
10873 cmd->num_filter_addr = param->nsrcs;
10874 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
10875 sizeof(cmd->filter_addr));
10876
10877 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
10878 param->nsrcs * param->mcast_ip_addr_bytes);
10879 }
10880
10881 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10882 WMI_PEER_MCAST_GROUP_CMDID);
10883
10884 if (ret != QDF_STATUS_SUCCESS) {
10885 WMI_LOGE("%s : WMI Failed\n", __func__);
10886 wmi_buf_free(buf);
10887 }
10888
10889 return ret;
10890}
10891
10892/**
10893 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
10894 * command to fw
10895 * @wmi_handle: wmi handle
10896 * @param: pointer to hold spectral config parameter
10897 *
10898 * Return: 0 for success or error code
10899 */
10900static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
10901 struct vdev_spectral_configure_params *param)
10902{
10903 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
10904 wmi_buf_t buf;
10905 QDF_STATUS ret;
10906 int32_t len;
10907
10908 len = sizeof(*cmd);
10909 buf = wmi_buf_alloc(wmi_handle, len);
10910 if (!buf) {
10911 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10912 return QDF_STATUS_E_FAILURE;
10913 }
10914
10915 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
10916 WMITLV_SET_HDR(&cmd->tlv_header,
10917 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
10918 WMITLV_GET_STRUCT_TLVLEN(
10919 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param));
10920
10921 cmd->vdev_id = param->vdev_id;
10922 cmd->spectral_scan_count = param->count;
10923 cmd->spectral_scan_period = param->period;
10924 cmd->spectral_scan_priority = param->spectral_pri;
10925 cmd->spectral_scan_fft_size = param->fft_size;
10926 cmd->spectral_scan_gc_ena = param->gc_enable;
10927 cmd->spectral_scan_restart_ena = param->restart_enable;
10928 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
10929 cmd->spectral_scan_init_delay = param->init_delay;
10930 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
10931 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
10932 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
10933 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
10934 cmd->spectral_scan_rssi_thr = param->rssi_thr;
10935 cmd->spectral_scan_pwr_format = param->pwr_format;
10936 cmd->spectral_scan_rpt_mode = param->rpt_mode;
10937 cmd->spectral_scan_bin_scale = param->bin_scale;
10938 cmd->spectral_scan_dBm_adj = param->dBm_adj;
10939 cmd->spectral_scan_chn_mask = param->chn_mask;
10940
10941 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10942 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
10943
10944 if (ret != 0) {
10945 WMI_LOGE("Sending set quiet cmd failed\n");
10946 wmi_buf_free(buf);
10947 }
10948
10949 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
10950 __func__);
10951
10952 WMI_LOGI("vdev_id = %u\n"
10953 "spectral_scan_count = %u\n"
10954 "spectral_scan_period = %u\n"
10955 "spectral_scan_priority = %u\n"
10956 "spectral_scan_fft_size = %u\n"
10957 "spectral_scan_gc_ena = %u\n"
10958 "spectral_scan_restart_ena = %u\n"
10959 "spectral_scan_noise_floor_ref = %u\n"
10960 "spectral_scan_init_delay = %u\n"
10961 "spectral_scan_nb_tone_thr = %u\n"
10962 "spectral_scan_str_bin_thr = %u\n"
10963 "spectral_scan_wb_rpt_mode = %u\n"
10964 "spectral_scan_rssi_rpt_mode = %u\n"
10965 "spectral_scan_rssi_thr = %u\n"
10966 "spectral_scan_pwr_format = %u\n"
10967 "spectral_scan_rpt_mode = %u\n"
10968 "spectral_scan_bin_scale = %u\n"
10969 "spectral_scan_dBm_adj = %u\n"
10970 "spectral_scan_chn_mask = %u\n",
10971 param->vdev_id,
10972 param->count,
10973 param->period,
10974 param->spectral_pri,
10975 param->fft_size,
10976 param->gc_enable,
10977 param->restart_enable,
10978 param->noise_floor_ref,
10979 param->init_delay,
10980 param->nb_tone_thr,
10981 param->str_bin_thr,
10982 param->wb_rpt_mode,
10983 param->rssi_rpt_mode,
10984 param->rssi_thr,
10985 param->pwr_format,
10986 param->rpt_mode,
10987 param->bin_scale,
10988 param->dBm_adj,
10989 param->chn_mask);
10990 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
10991
10992 return ret;
10993}
10994
10995/**
10996 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
10997 * command to fw
10998 * @wmi_handle: wmi handle
10999 * @param: pointer to hold spectral enable parameter
11000 *
11001 * Return: 0 for success or error code
11002 */
11003static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11004 struct vdev_spectral_enable_params *param)
11005{
11006 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11007 wmi_buf_t buf;
11008 QDF_STATUS ret;
11009 int32_t len;
11010
11011 len = sizeof(*cmd);
11012 buf = wmi_buf_alloc(wmi_handle, len);
11013 if (!buf) {
11014 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11015 return QDF_STATUS_E_FAILURE;
11016 }
11017
11018 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11019 WMITLV_SET_HDR(&cmd->tlv_header,
11020 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11021 WMITLV_GET_STRUCT_TLVLEN(
11022 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param));
11023
11024 cmd->vdev_id = param->vdev_id;
11025
11026 if (param->active_valid) {
11027 cmd->trigger_cmd = param->active ? 1 : 2;
11028 /* 1: Trigger, 2: Clear Trigger */
11029 } else {
11030 cmd->trigger_cmd = 0; /* 0: Ignore */
11031 }
11032
11033 if (param->enabled_valid) {
11034 cmd->enable_cmd = param->enabled ? 1 : 2;
11035 /* 1: Enable 2: Disable */
11036 } else {
11037 cmd->enable_cmd = 0; /* 0: Ignore */
11038 }
11039
11040 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11041 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11042
11043 if (ret != 0) {
11044 WMI_LOGE("Sending scan enable CMD failed\n");
11045 wmi_buf_free(buf);
11046 }
11047
11048 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11049
11050 WMI_LOGI("vdev_id = %u\n"
11051 "trigger_cmd = %u\n"
11052 "enable_cmd = %u\n",
11053 cmd->vdev_id,
11054 cmd->trigger_cmd,
11055 cmd->enable_cmd);
11056
11057 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11058
11059 return ret;
11060}
11061
11062/**
11063 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11064 * @wmi_handle: wmi handle
11065 * @param: pointer to pdev_qvit_params
11066 *
11067 * Return: 0 for success or error code
11068 */
11069static QDF_STATUS
11070send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11071 struct pdev_qvit_params *param)
11072{
11073 wmi_buf_t buf;
11074 QDF_STATUS ret;
11075 uint8_t *cmd;
11076 static uint8_t msgref = 1;
11077 uint8_t segnumber = 0, seginfo, numsegments;
11078 uint16_t chunk_len, total_bytes;
11079 uint8_t *bufpos;
11080 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11081
11082 bufpos = param->utf_payload;
11083 total_bytes = param->len;
11084 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11085 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11086 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11087
11088 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11089 numsegments++;
11090
11091 while (param->len) {
11092 if (param->len > MAX_WMI_QVIT_LEN)
11093 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11094 else
11095 chunk_len = param->len;
11096
11097 buf = wmi_buf_alloc(wmi_handle,
11098 (chunk_len + sizeof(seghdrinfo) +
11099 WMI_TLV_HDR_SIZE));
11100 if (!buf) {
11101 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11102 return QDF_STATUS_E_NOMEM;
11103 }
11104
11105 cmd = (uint8_t *) wmi_buf_data(buf);
11106
11107 seghdrinfo.len = total_bytes;
11108 seghdrinfo.msgref = msgref;
11109 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11110 seghdrinfo.segmentInfo = seginfo;
11111
11112 segnumber++;
11113
11114 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11115 (chunk_len + sizeof(seghdrinfo)));
11116 cmd += WMI_TLV_HDR_SIZE;
11117 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11118 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11119
11120 ret = wmi_unified_cmd_send(wmi_handle, buf,
11121 (chunk_len + sizeof(seghdrinfo) +
11122 WMI_TLV_HDR_SIZE),
11123 WMI_PDEV_QVIT_CMDID);
11124
11125 if (ret != 0) {
11126 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11127 wmi_buf_free(buf);
11128 break;
11129 }
11130
11131 param->len -= chunk_len;
11132 bufpos += chunk_len;
11133 }
11134 msgref++;
11135
11136 return ret;
11137}
11138
11139/**
11140 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11141 * @wmi_handle: wmi handle
11142 * @param: pointer to wmm update param
11143 *
11144 * Return: 0 for success or error code
11145 */
11146static QDF_STATUS
11147send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11148 struct wmm_update_params *param)
11149{
11150 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11151 wmi_wmm_params *wmm_param;
11152 wmi_buf_t buf;
11153 QDF_STATUS ret;
11154 int32_t len;
11155 int ac = 0;
11156 struct wmi_host_wmeParams *wmep;
11157 uint8_t *buf_ptr;
11158
11159 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11160 buf = wmi_buf_alloc(wmi_handle, len);
11161 if (!buf) {
11162 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11163 return QDF_STATUS_E_FAILURE;
11164 }
11165
11166 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11167 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11168 WMITLV_SET_HDR(&cmd->tlv_header,
11169 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11170 WMITLV_GET_STRUCT_TLVLEN
11171 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11172
11173 cmd->reserved0 = WMI_PDEV_ID_SOC;
11174
11175 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11176
11177 for (ac = 0; ac < WME_NUM_AC; ac++) {
11178 wmep = &param->wmep_array[ac];
11179 wmm_param = (wmi_wmm_params *)buf_ptr;
11180 WMITLV_SET_HDR(&wmm_param->tlv_header,
11181 WMITLV_TAG_STRUC_wmi_wmm_params,
11182 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11183 wmm_param->aifs = wmep->wmep_aifsn;
11184 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11185 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11186 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11187 wmm_param->acm = wmep->wmep_acm;
11188 wmm_param->no_ack = wmep->wmep_noackPolicy;
11189 buf_ptr += sizeof(wmi_wmm_params);
11190 }
11191 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11192 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11193
11194 if (ret != 0) {
11195 WMI_LOGE("Sending WMM update CMD failed\n");
11196 wmi_buf_free(buf);
11197 }
11198
11199 return ret;
11200}
11201
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011202static
Govind Singh9ddd5162016-03-07 16:30:32 +053011203void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011204 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011205{
Govind Singhe7f2f342016-05-23 12:12:52 +053011206 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011207 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11208 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11209 resource_cfg->num_offload_reorder_buffs =
11210 tgt_res_cfg->num_offload_reorder_buffs;
11211 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11212 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11213 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11214 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11215 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11216 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11217 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11218 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11219 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11220 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11221 resource_cfg->scan_max_pending_req =
11222 tgt_res_cfg->scan_max_pending_req;
11223 resource_cfg->bmiss_offload_max_vdev =
11224 tgt_res_cfg->bmiss_offload_max_vdev;
11225 resource_cfg->roam_offload_max_vdev =
11226 tgt_res_cfg->roam_offload_max_vdev;
11227 resource_cfg->roam_offload_max_ap_profiles =
11228 tgt_res_cfg->roam_offload_max_ap_profiles;
11229 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11230 resource_cfg->num_mcast_table_elems =
11231 tgt_res_cfg->num_mcast_table_elems;
11232 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11233 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11234 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11235 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11236 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11237 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11238 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11239 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11240 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11241 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11242 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11243 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11244 resource_cfg->num_tdls_conn_table_entries =
11245 tgt_res_cfg->num_tdls_conn_table_entries;
11246 resource_cfg->beacon_tx_offload_max_vdev =
11247 tgt_res_cfg->beacon_tx_offload_max_vdev;
11248 resource_cfg->num_multicast_filter_entries =
11249 tgt_res_cfg->num_multicast_filter_entries;
11250 resource_cfg->num_wow_filters =
11251 tgt_res_cfg->num_wow_filters;
11252 resource_cfg->num_keep_alive_pattern =
11253 tgt_res_cfg->num_keep_alive_pattern;
11254 resource_cfg->keep_alive_pattern_size =
11255 tgt_res_cfg->keep_alive_pattern_size;
11256 resource_cfg->max_tdls_concurrent_sleep_sta =
11257 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11258 resource_cfg->max_tdls_concurrent_buffer_sta =
11259 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11260 resource_cfg->wmi_send_separate =
11261 tgt_res_cfg->wmi_send_separate;
11262 resource_cfg->num_ocb_vdevs =
11263 tgt_res_cfg->num_ocb_vdevs;
11264 resource_cfg->num_ocb_channels =
11265 tgt_res_cfg->num_ocb_channels;
11266 resource_cfg->num_ocb_schedules =
11267 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011268 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11269 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11270 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Govind Singh9ddd5162016-03-07 16:30:32 +053011271}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011272#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011273/**
11274 * send_init_cmd_tlv() - wmi init command
11275 * @wmi_handle: pointer to wmi handle
11276 * @res_cfg: resource config
11277 * @num_mem_chunks: no of mem chunck
11278 * @mem_chunk: pointer to mem chunck structure
11279 *
11280 * This function sends IE information to firmware
11281 *
Govind Singhb53420c2016-03-09 14:32:57 +053011282 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011283 *
11284 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011285static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011286 wmi_resource_config *tgt_res_cfg,
11287 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11288 bool action)
11289{
11290 wmi_buf_t buf;
11291 wmi_init_cmd_fixed_param *cmd;
11292 wmi_abi_version my_vers;
11293 int num_whitelist;
11294 uint8_t *buf_ptr;
11295 wmi_resource_config *resource_cfg;
11296 wlan_host_memory_chunk *host_mem_chunks;
11297 uint32_t mem_chunk_len = 0;
11298 uint16_t idx;
11299 int len;
11300 int ret;
11301
11302 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11303 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11304 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11305 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011306 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11307 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011308 }
11309
11310 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11311 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11312 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11313
11314 host_mem_chunks = (wlan_host_memory_chunk *)
11315 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11316 + WMI_TLV_HDR_SIZE);
11317
11318 WMITLV_SET_HDR(&cmd->tlv_header,
11319 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11320 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11321
Govind Singhb53420c2016-03-09 14:32:57 +053011322 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011323 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11324 WMITLV_TAG_STRUC_wmi_resource_config,
11325 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11326
11327 for (idx = 0; idx < num_mem_chunks; ++idx) {
11328 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11329 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11330 WMITLV_GET_STRUCT_TLVLEN
11331 (wlan_host_memory_chunk));
11332 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11333 host_mem_chunks[idx].size = mem_chunks[idx].len;
11334 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011335 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011336 idx, host_mem_chunks[idx].size,
11337 host_mem_chunks[idx].ptr);
11338 }
11339 cmd->num_host_mem_chunks = num_mem_chunks;
11340 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11341 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11342 WMITLV_TAG_ARRAY_STRUC,
11343 (sizeof(wlan_host_memory_chunk) *
11344 num_mem_chunks));
11345
11346 num_whitelist = sizeof(version_whitelist) /
11347 sizeof(wmi_whitelist_version_info);
11348 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11349 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11350 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11351 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11352 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11353 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011354#ifdef CONFIG_MCL
11355 /* This needs to be enabled for WIN Lithium after removing dependency
11356 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011357 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11358 &my_vers,
11359 &wmi_handle->fw_abi_version,
11360 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011361#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011362 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011363 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11364 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11365 cmd->host_abi_vers.abi_version_ns_0,
11366 cmd->host_abi_vers.abi_version_ns_1,
11367 cmd->host_abi_vers.abi_version_ns_2,
11368 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011369#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011370 /* Save version sent from host -
11371 * Will be used to check ready event
11372 */
Govind Singhb53420c2016-03-09 14:32:57 +053011373 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011374 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011375#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011376 if (action) {
11377 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11378 WMI_INIT_CMDID);
11379 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011380 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011381 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011382 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011383 }
11384 } else {
11385 wmi_handle->saved_wmi_init_cmd.buf = buf;
11386 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11387 }
11388
Govind Singhb53420c2016-03-09 14:32:57 +053011389 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011390
11391}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011392#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011393/**
11394 * send_saved_init_cmd_tlv() - wmi init command
11395 * @wmi_handle: pointer to wmi handle
11396 *
11397 * This function sends IE information to firmware
11398 *
Govind Singhb53420c2016-03-09 14:32:57 +053011399 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011400 *
11401 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011402static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053011403{
11404 int status;
11405
11406 if (!wmi_handle->saved_wmi_init_cmd.buf ||
11407 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053011408 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
11409 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011410 }
11411 status = wmi_unified_cmd_send(wmi_handle,
11412 wmi_handle->saved_wmi_init_cmd.buf,
11413 wmi_handle->saved_wmi_init_cmd.buf_len,
11414 WMI_INIT_CMDID);
11415 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053011416 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053011417 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011418 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011419 }
11420 wmi_handle->saved_wmi_init_cmd.buf = NULL;
11421 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
11422
Govind Singhb53420c2016-03-09 14:32:57 +053011423 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011424}
11425
Sathish Kumarfd347372017-02-13 12:29:09 +053011426static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053011427{
11428 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11429 wmi_service_ready_event_fixed_param *ev;
11430
11431
11432 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11433
11434 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11435 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053011436 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011437
Govind Singh87542482016-06-08 19:40:11 +053011438#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011439 /*Save fw version from service ready message */
11440 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053011441 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011442 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011443#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011444 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011445}
11446
11447/**
11448 * wmi_unified_save_fw_version_cmd() - save fw version
11449 * @wmi_handle: pointer to wmi handle
11450 * @res_cfg: resource config
11451 * @num_mem_chunks: no of mem chunck
11452 * @mem_chunk: pointer to mem chunck structure
11453 *
11454 * This function sends IE information to firmware
11455 *
Govind Singhb53420c2016-03-09 14:32:57 +053011456 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011457 *
11458 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011459static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011460 void *evt_buf)
11461{
11462 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11463 wmi_ready_event_fixed_param *ev = NULL;
11464
11465 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11466 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053011467#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011468 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
11469 &ev->fw_abi_vers)) {
11470 /*
11471 * Error: Our host version and the given firmware version
11472 * are incompatible.
11473 **/
Govind Singhb53420c2016-03-09 14:32:57 +053011474 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053011475 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
11476 __func__,
11477 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
11478 abi_version_0),
11479 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
11480 abi_version_0),
11481 wmi_handle->final_abi_vers.abi_version_ns_0,
11482 wmi_handle->final_abi_vers.abi_version_ns_1,
11483 wmi_handle->final_abi_vers.abi_version_ns_2,
11484 wmi_handle->final_abi_vers.abi_version_ns_3,
11485 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
11486 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
11487 ev->fw_abi_vers.abi_version_ns_0,
11488 ev->fw_abi_vers.abi_version_ns_1,
11489 ev->fw_abi_vers.abi_version_ns_2,
11490 ev->fw_abi_vers.abi_version_ns_3);
11491
Govind Singhb53420c2016-03-09 14:32:57 +053011492 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011493 }
Govind Singhb53420c2016-03-09 14:32:57 +053011494 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011495 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053011496 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011497 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011498#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011499
Govind Singhb53420c2016-03-09 14:32:57 +053011500 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011501}
Govind Singha4836fd2016-03-07 16:45:38 +053011502
11503/**
11504 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
11505 * @wmi_handle: wmi handle
11506 * @custom_addr: base mac address
11507 *
Govind Singhe7f2f342016-05-23 12:12:52 +053011508 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053011509 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011510static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011511 uint8_t *custom_addr)
11512{
11513 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
11514 wmi_buf_t buf;
11515 int err;
11516
11517 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011519 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053011520 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011521 }
11522
11523 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011524 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053011525
11526 WMITLV_SET_HDR(&cmd->tlv_header,
11527 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
11528 WMITLV_GET_STRUCT_TLVLEN
11529 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
11530 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Govind Singh4df47142016-04-16 19:24:23 -070011531 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011532 err = wmi_unified_cmd_send(wmi_handle, buf,
11533 sizeof(*cmd),
11534 WMI_PDEV_SET_BASE_MACADDR_CMDID);
11535 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053011536 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053011537 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011538 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011539 }
11540
11541 return 0;
11542}
11543
11544/**
11545 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
11546 * @handle: wmi handle
11547 * @event: Event received from FW
11548 * @len: Length of the event
11549 *
11550 * Enables the low frequency events and disables the high frequency
11551 * events. Bit 17 indicates if the event if low/high frequency.
11552 * 1 - high frequency, 0 - low frequency
11553 *
11554 * Return: 0 on successfully enabling/disabling the events
11555 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011556static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011557 uint8_t *event,
11558 uint32_t len)
11559{
11560 uint32_t num_of_diag_events_logs;
11561 wmi_diag_event_log_config_fixed_param *cmd;
11562 wmi_buf_t buf;
11563 uint8_t *buf_ptr;
11564 uint32_t *cmd_args, *evt_args;
11565 uint32_t buf_len, i;
11566
11567 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
11568 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
11569
Govind Singhb53420c2016-03-09 14:32:57 +053011570 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053011571
11572 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
11573 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011574 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053011575 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011576 }
11577 wmi_event = param_buf->fixed_param;
11578 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
11579 evt_args = param_buf->diag_events_logs_list;
11580 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053011581 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011582 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053011583 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011584 }
11585
Govind Singhb53420c2016-03-09 14:32:57 +053011586 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011587 __func__, num_of_diag_events_logs);
11588
11589 /* Free any previous allocation */
11590 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053011591 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053011592
11593 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053011594 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053011595 sizeof(uint32_t));
11596 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011597 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011598 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011599 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011600 }
11601 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
11602
11603 /* Prepare the send buffer */
11604 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11605 (num_of_diag_events_logs * sizeof(uint32_t));
11606
11607 buf = wmi_buf_alloc(wmi_handle, buf_len);
11608 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011609 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11610 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053011611 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011612 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011613 }
11614
11615 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11616 buf_ptr = (uint8_t *) cmd;
11617
11618 WMITLV_SET_HDR(&cmd->tlv_header,
11619 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11620 WMITLV_GET_STRUCT_TLVLEN(
11621 wmi_diag_event_log_config_fixed_param));
11622
11623 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
11624
11625 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11626
11627 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11628 (num_of_diag_events_logs * sizeof(uint32_t)));
11629
11630 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11631
11632 /* Populate the events */
11633 for (i = 0; i < num_of_diag_events_logs; i++) {
11634 /* Low freq (0) - Enable (1) the event
11635 * High freq (1) - Disable (0) the event
11636 */
11637 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
11638 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
11639 /* Set the event ID */
11640 WMI_DIAG_ID_SET(cmd_args[i],
11641 WMI_DIAG_ID_GET(evt_args[i]));
11642 /* Set the type */
11643 WMI_DIAG_TYPE_SET(cmd_args[i],
11644 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053011645 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053011646 wmi_handle->events_logs_list[i] = evt_args[i];
11647 }
11648
11649 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
11650 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011651 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011652 __func__);
11653 wmi_buf_free(buf);
11654 /* Not clearing events_logs_list, though wmi cmd failed.
11655 * Host can still have this list
11656 */
Govind Singh67922e82016-04-01 16:48:57 +053011657 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011658 }
11659
11660 return 0;
11661}
11662
11663/**
11664 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
11665 * @wmi_handle: wmi handle
11666 * @start_log: Start logging related parameters
11667 *
11668 * Send the command to the FW based on which specific logging of diag
11669 * event/log id can be started/stopped
11670 *
11671 * Return: None
11672 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011673static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011674 struct wmi_wifi_start_log *start_log)
11675{
11676 wmi_diag_event_log_config_fixed_param *cmd;
11677 wmi_buf_t buf;
11678 uint8_t *buf_ptr;
11679 uint32_t len, count, log_level, i;
11680 uint32_t *cmd_args;
11681 uint32_t total_len;
11682 count = 0;
11683
11684 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011685 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053011686 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011687 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011688 }
11689 /* total_len stores the number of events where BITS 17 and 18 are set.
11690 * i.e., events of high frequency (17) and for extended debugging (18)
11691 */
11692 total_len = 0;
11693 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11694 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
11695 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
11696 total_len++;
11697 }
11698
11699 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11700 (total_len * sizeof(uint32_t));
11701
11702 buf = wmi_buf_alloc(wmi_handle, len);
11703 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011704 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011705 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011706 }
11707 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11708 buf_ptr = (uint8_t *) cmd;
11709
11710 WMITLV_SET_HDR(&cmd->tlv_header,
11711 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11712 WMITLV_GET_STRUCT_TLVLEN(
11713 wmi_diag_event_log_config_fixed_param));
11714
11715 cmd->num_of_diag_events_logs = total_len;
11716
11717 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11718
11719 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11720 (total_len * sizeof(uint32_t)));
11721
11722 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11723
Govind Singh224a7312016-06-21 14:33:26 +053011724 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053011725 log_level = 1;
11726 else
11727 log_level = 0;
11728
Govind Singhb53420c2016-03-09 14:32:57 +053011729 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053011730 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11731 uint32_t val = wmi_handle->events_logs_list[i];
11732 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
11733 (WMI_DIAG_EXT_FEATURE_GET(val))) {
11734
11735 WMI_DIAG_ID_SET(cmd_args[count],
11736 WMI_DIAG_ID_GET(val));
11737 WMI_DIAG_TYPE_SET(cmd_args[count],
11738 WMI_DIAG_TYPE_GET(val));
11739 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
11740 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053011741 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053011742 count++;
11743 }
11744 }
11745
11746 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11747 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011748 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011749 __func__);
11750 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011751 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011752 }
11753
Govind Singhb53420c2016-03-09 14:32:57 +053011754 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011755}
11756
11757/**
11758 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
11759 * @wmi_handle: WMI handle
11760 *
11761 * This function is used to send the flush command to the FW,
11762 * that will flush the fw logs that are residue in the FW
11763 *
11764 * Return: None
11765 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011766static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053011767{
11768 wmi_debug_mesg_flush_fixed_param *cmd;
11769 wmi_buf_t buf;
11770 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053011771 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011772
11773 buf = wmi_buf_alloc(wmi_handle, len);
11774 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011775 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011776 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011777 }
11778
11779 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
11780 WMITLV_SET_HDR(&cmd->tlv_header,
11781 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
11782 WMITLV_GET_STRUCT_TLVLEN(
11783 wmi_debug_mesg_flush_fixed_param));
11784 cmd->reserved0 = 0;
11785
11786 ret = wmi_unified_cmd_send(wmi_handle,
11787 buf,
11788 len,
11789 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011790 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011791 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053011792 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011793 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011794 }
Govind Singhb53420c2016-03-09 14:32:57 +053011795 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053011796
Govind Singh67922e82016-04-01 16:48:57 +053011797 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011798}
11799
11800/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011801 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011802 * @wmi_handle: wmi handle
11803 * @msg: PCL structure containing the PCL and the number of channels
11804 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011805 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053011806 * firmware. The DBS Manager is the consumer of this information in the WLAN
11807 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
11808 * to migrate to a new channel without host driver involvement. An example of
11809 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
11810 * manage the channel selection without firmware involvement.
11811 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011812 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
11813 * channel list. The weights corresponds to the channels sent in
11814 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
11815 * weightage compared to the non PCL channels.
11816 *
Govind Singha4836fd2016-03-07 16:45:38 +053011817 * Return: Success if the cmd is sent successfully to the firmware
11818 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011819static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011820 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053011821{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011822 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011823 wmi_buf_t buf;
11824 uint8_t *buf_ptr;
11825 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011826 uint32_t chan_len;
11827
11828 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053011829
11830 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011831 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053011832
11833 buf = wmi_buf_alloc(wmi_handle, len);
11834 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011835 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11836 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011837 }
11838
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011839 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011840 buf_ptr = (uint8_t *) cmd;
11841 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011842 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
11843 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053011844
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011845 cmd->pdev_id = WMI_PDEV_ID_SOC;
11846 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053011847 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011848
11849 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053011850 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011851 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053011852 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011853 for (i = 0; i < chan_len ; i++) {
11854 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053011855 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011856 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053011857 }
11858 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053011859 WMI_PDEV_SET_PCL_CMDID)) {
11860 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011861 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011862 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011863 }
Govind Singhb53420c2016-03-09 14:32:57 +053011864 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011865}
11866
11867/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011868 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011869 * @wmi_handle: wmi handle
11870 * @msg: Structure containing the following parameters
11871 *
11872 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
11873 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
11874 *
11875 * Provides notification to the WLAN firmware that host driver is requesting a
11876 * HardWare (HW) Mode change. This command is needed to support iHelium in the
11877 * configurations that include the Dual Band Simultaneous (DBS) feature.
11878 *
11879 * Return: Success if the cmd is sent successfully to the firmware
11880 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011881static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011882 uint32_t hw_mode_index)
11883{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011884 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011885 wmi_buf_t buf;
11886 uint32_t len;
11887
11888 len = sizeof(*cmd);
11889
11890 buf = wmi_buf_alloc(wmi_handle, len);
11891 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011892 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11893 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011894 }
11895
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011896 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011897 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011898 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
11899 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
11900
11901 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011902 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053011903 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053011904
11905 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053011906 WMI_PDEV_SET_HW_MODE_CMDID)) {
11907 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011908 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011909 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011910 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011911 }
11912
Govind Singhb53420c2016-03-09 14:32:57 +053011913 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011914}
11915
11916/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011917 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053011918 * @wmi_handle: wmi handle
11919 * @msg: Dual MAC config parameters
11920 *
11921 * Configures WLAN firmware with the dual MAC features
11922 *
Govind Singhb53420c2016-03-09 14:32:57 +053011923 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053011924 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011925static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011926QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011927 struct wmi_dual_mac_config *msg)
11928{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011929 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053011930 wmi_buf_t buf;
11931 uint32_t len;
11932
11933 len = sizeof(*cmd);
11934
11935 buf = wmi_buf_alloc(wmi_handle, len);
11936 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011937 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11938 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011939 }
11940
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011941 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011942 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011943 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053011944 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011945 wmi_pdev_set_mac_config_cmd_fixed_param));
11946
11947 cmd->pdev_id = WMI_PDEV_ID_SOC;
Govind Singha4836fd2016-03-07 16:45:38 +053011948 cmd->concurrent_scan_config_bits = msg->scan_config;
11949 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053011950 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053011951 __func__, msg->scan_config, msg->fw_mode_config);
11952
11953 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053011954 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
11955 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053011956 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053011957 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053011958 }
Govind Singhb53420c2016-03-09 14:32:57 +053011959 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011960}
11961
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053011962#ifdef BIG_ENDIAN_HOST
11963/**
11964* fips_conv_data_be() - LE to BE conversion of FIPS ev data
11965* @param data_len - data length
11966* @param data - pointer to data
11967*
11968* Return: QDF_STATUS - success or error status
11969*/
11970static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
11971 struct fips_params *param)
11972{
11973 unsigned char *key_unaligned, *data_unaligned;
11974 int c;
11975 u_int8_t *key_aligned = NULL;
11976 u_int8_t *data_aligned = NULL;
11977
11978 /* Assigning unaligned space to copy the key */
11979 key_unaligned = qdf_mem_malloc(
11980 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
11981 data_unaligned = qdf_mem_malloc(
11982 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
11983
11984 /* Checking if kmalloc is succesful to allocate space */
11985 if (key_unaligned == NULL)
11986 return QDF_STATUS_SUCCESS;
11987 /* Checking if space is aligned */
11988 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
11989 /* align to 4 */
11990 key_aligned =
11991 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
11992 FIPS_ALIGN);
11993 } else {
11994 key_aligned = (u_int8_t *)key_unaligned;
11995 }
11996
11997 /* memset and copy content from key to key aligned */
11998 OS_MEMSET(key_aligned, 0, param->key_len);
11999 OS_MEMCPY(key_aligned, param->key, param->key_len);
12000
12001 /* print a hexdump for host debug */
12002 print_hex_dump(KERN_DEBUG,
12003 "\t Aligned and Copied Key:@@@@ ",
12004 DUMP_PREFIX_NONE,
12005 16, 1, key_aligned, param->key_len, true);
12006
12007 /* Checking if kmalloc is succesful to allocate space */
12008 if (data_unaligned == NULL)
12009 return QDF_STATUS_SUCCESS;
12010 /* Checking of space is aligned */
12011 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12012 /* align to 4 */
12013 data_aligned =
12014 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12015 FIPS_ALIGN);
12016 } else {
12017 data_aligned = (u_int8_t *)data_unaligned;
12018 }
12019
12020 /* memset and copy content from data to data aligned */
12021 OS_MEMSET(data_aligned, 0, param->data_len);
12022 OS_MEMCPY(data_aligned, param->data, param->data_len);
12023
12024 /* print a hexdump for host debug */
12025 print_hex_dump(KERN_DEBUG,
12026 "\t Properly Aligned and Copied Data:@@@@ ",
12027 DUMP_PREFIX_NONE,
12028 16, 1, data_aligned, param->data_len, true);
12029
12030 /* converting to little Endian both key_aligned and
12031 * data_aligned*/
12032 for (c = 0; c < param->key_len/4; c++) {
12033 *((u_int32_t *)key_aligned+c) =
12034 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12035 }
12036 for (c = 0; c < param->data_len/4; c++) {
12037 *((u_int32_t *)data_aligned+c) =
12038 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12039 }
12040
12041 /* update endian data to key and data vectors */
12042 OS_MEMCPY(param->key, key_aligned, param->key_len);
12043 OS_MEMCPY(param->data, data_aligned, param->data_len);
12044
12045 /* clean up allocated spaces */
12046 qdf_mem_free(key_unaligned);
12047 key_unaligned = NULL;
12048 key_aligned = NULL;
12049
12050 qdf_mem_free(data_unaligned);
12051 data_unaligned = NULL;
12052 data_aligned = NULL;
12053
12054 return QDF_STATUS_SUCCESS;
12055}
12056#else
12057/**
12058* fips_align_data_be() - DUMMY for LE platform
12059*
12060* Return: QDF_STATUS - success
12061*/
12062static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12063 struct fips_params *param)
12064{
12065 return QDF_STATUS_SUCCESS;
12066}
12067#endif
12068
12069
12070/**
12071 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12072 * @wmi_handle: wmi handle
12073 * @param: pointer to hold pdev fips param
12074 *
12075 * Return: 0 for success or error code
12076 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012077static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012078send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12079 struct fips_params *param)
12080{
12081 wmi_pdev_fips_cmd_fixed_param *cmd;
12082 wmi_buf_t buf;
12083 uint8_t *buf_ptr;
12084 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12085 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12086
12087 /* Length TLV placeholder for array of bytes */
12088 len += WMI_TLV_HDR_SIZE;
12089 if (param->data_len)
12090 len += (param->data_len*sizeof(uint8_t));
12091
12092 /*
12093 * Data length must be multiples of 16 bytes - checked against 0xF -
12094 * and must be less than WMI_SVC_MSG_SIZE - static size of
12095 * wmi_pdev_fips_cmd structure
12096 */
12097
12098 /* do sanity on the input */
12099 if (!(((param->data_len & 0xF) == 0) &&
12100 ((param->data_len > 0) &&
12101 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12102 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12103 return QDF_STATUS_E_INVAL;
12104 }
12105
12106 buf = wmi_buf_alloc(wmi_handle, len);
12107 if (!buf) {
12108 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12109 return QDF_STATUS_E_FAILURE;
12110 }
12111
12112 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12113 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12114 WMITLV_SET_HDR(&cmd->tlv_header,
12115 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12116 WMITLV_GET_STRUCT_TLVLEN
12117 (wmi_pdev_fips_cmd_fixed_param));
12118
12119 cmd->pdev_id = param->pdev_id;
12120 if (param->key != NULL && param->data != NULL) {
12121 cmd->key_len = param->key_len;
12122 cmd->data_len = param->data_len;
12123 cmd->fips_cmd = !!(param->op);
12124
12125 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12126 return QDF_STATUS_E_FAILURE;
12127
12128 qdf_mem_copy(cmd->key, param->key, param->key_len);
12129
12130 if (param->mode == FIPS_ENGINE_AES_CTR ||
12131 param->mode == FIPS_ENGINE_AES_MIC) {
12132 cmd->mode = param->mode;
12133 } else {
12134 cmd->mode = FIPS_ENGINE_AES_CTR;
12135 }
12136 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12137 cmd->key_len, cmd->data_len);
12138
12139 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12140 cmd->key, cmd->key_len, true);
12141 buf_ptr += sizeof(*cmd);
12142
12143 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12144
12145 buf_ptr += WMI_TLV_HDR_SIZE;
12146 if (param->data_len)
12147 qdf_mem_copy(buf_ptr,
12148 (uint8_t *) param->data, param->data_len);
12149
12150 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12151 16, 1, buf_ptr, cmd->data_len, true);
12152
12153 buf_ptr += param->data_len;
12154
12155 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12156 WMI_PDEV_FIPS_CMDID);
12157 qdf_print("%s return value %d\n", __func__, retval);
12158 } else {
12159 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12160 wmi_buf_free(buf);
12161 retval = -QDF_STATUS_E_BADMSG;
12162 }
12163
12164 return retval;
12165}
12166
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012167#ifdef WLAN_PMO_ENABLE
12168/**
12169 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12170 * @wmi_handle: wmi handle
12171 * @vdev_id: vdev id
12172 * @bitmap: Event bitmap
12173 * @enable: enable/disable
12174 *
12175 * Return: CDF status
12176 */
12177static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12178 uint32_t vdev_id,
12179 uint32_t bitmap,
12180 bool enable)
12181{
12182 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12183 uint16_t len;
12184 wmi_buf_t buf;
12185 int ret;
12186
12187 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12188 buf = wmi_buf_alloc(wmi_handle, len);
12189 if (!buf) {
12190 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12191 return QDF_STATUS_E_NOMEM;
12192 }
12193 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12194 WMITLV_SET_HDR(&cmd->tlv_header,
12195 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12196 WMITLV_GET_STRUCT_TLVLEN
12197 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12198 cmd->vdev_id = vdev_id;
12199 cmd->is_add = enable;
12200 cmd->event_bitmap = bitmap;
12201
12202 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12203 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12204 if (ret) {
12205 WMI_LOGE("Failed to config wow wakeup event");
12206 wmi_buf_free(buf);
12207 return QDF_STATUS_E_FAILURE;
12208 }
12209
12210 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
12211 enable ? "enabled" : "disabled");
12212
12213 return QDF_STATUS_SUCCESS;
12214}
12215
12216/**
12217 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12218 * @wmi_handle: wmi handle
12219 * @vdev_id: vdev id
12220 * @ptrn_id: pattern id
12221 * @ptrn: pattern
12222 * @ptrn_len: pattern length
12223 * @ptrn_offset: pattern offset
12224 * @mask: mask
12225 * @mask_len: mask length
12226 * @user: true for user configured pattern and false for default pattern
12227 * @default_patterns: default patterns
12228 *
12229 * Return: CDF status
12230 */
12231static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12232 uint8_t vdev_id, uint8_t ptrn_id,
12233 const uint8_t *ptrn, uint8_t ptrn_len,
12234 uint8_t ptrn_offset, const uint8_t *mask,
12235 uint8_t mask_len, bool user,
12236 uint8_t default_patterns)
12237{
12238 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12239 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12240 wmi_buf_t buf;
12241 uint8_t *buf_ptr;
12242 int32_t len;
12243 int ret;
12244
12245 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12246 WMI_TLV_HDR_SIZE +
12247 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12248 WMI_TLV_HDR_SIZE +
12249 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12250 WMI_TLV_HDR_SIZE +
12251 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12252 WMI_TLV_HDR_SIZE +
12253 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12254 WMI_TLV_HDR_SIZE +
12255 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12256
12257 buf = wmi_buf_alloc(wmi_handle, len);
12258 if (!buf) {
12259 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12260 return QDF_STATUS_E_NOMEM;
12261 }
12262
12263 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12264 buf_ptr = (uint8_t *) cmd;
12265
12266 WMITLV_SET_HDR(&cmd->tlv_header,
12267 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12268 WMITLV_GET_STRUCT_TLVLEN
12269 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12270 cmd->vdev_id = vdev_id;
12271 cmd->pattern_id = ptrn_id;
12272
12273 cmd->pattern_type = WOW_BITMAP_PATTERN;
12274 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12275
12276 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12277 sizeof(WOW_BITMAP_PATTERN_T));
12278 buf_ptr += WMI_TLV_HDR_SIZE;
12279 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12280
12281 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12282 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12283 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12284
12285 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12286 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12287
12288 bitmap_pattern->pattern_offset = ptrn_offset;
12289 bitmap_pattern->pattern_len = ptrn_len;
12290
12291 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12292 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12293
12294 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12295 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12296
12297 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12298 bitmap_pattern->pattern_id = ptrn_id;
12299
12300 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12301 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12302 bitmap_pattern->pattern_offset, user);
12303 WMI_LOGI("Pattern : ");
12304 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12305 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12306
12307 WMI_LOGI("Mask : ");
12308 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12309 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12310
12311 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12312
12313 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12314 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12315 buf_ptr += WMI_TLV_HDR_SIZE;
12316
12317 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12318 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12319 buf_ptr += WMI_TLV_HDR_SIZE;
12320
12321 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12322 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12323 buf_ptr += WMI_TLV_HDR_SIZE;
12324
12325 /* Fill TLV for pattern_info_timeout but no data. */
12326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12327 buf_ptr += WMI_TLV_HDR_SIZE;
12328
12329 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12330 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12331 buf_ptr += WMI_TLV_HDR_SIZE;
12332 *(A_UINT32 *) buf_ptr = 0;
12333
12334 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12335 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12336 if (ret) {
12337 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12338 wmi_buf_free(buf);
12339 return QDF_STATUS_E_FAILURE;
12340 }
12341
12342 return QDF_STATUS_SUCCESS;
12343}
12344
Govind Singha4836fd2016-03-07 16:45:38 +053012345/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012346 * fill_arp_offload_params_tlv() - Fill ARP offload data
12347 * @wmi_handle: wmi handle
12348 * @offload_req: offload request
12349 * @buf_ptr: buffer pointer
12350 *
12351 * To fill ARP offload data to firmware
12352 * when target goes to wow mode.
12353 *
12354 * Return: None
12355 */
12356static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012357 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012358{
12359
12360 int i;
12361 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012362 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012363
12364 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12365 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12366 *buf_ptr += WMI_TLV_HDR_SIZE;
12367 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12368 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12369 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12370 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12371 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12372
12373 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012374 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012375 /* Copy the target ip addr and flags */
12376 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12377 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012378 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012379 WMI_IPV4_ADDR_LEN);
12380 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012381 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012382 }
12383 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12384 }
12385}
12386
12387#ifdef WLAN_NS_OFFLOAD
12388/**
12389 * fill_ns_offload_params_tlv() - Fill NS offload data
12390 * @wmi|_handle: wmi handle
12391 * @offload_req: offload request
12392 * @buf_ptr: buffer pointer
12393 *
12394 * To fill NS offload data to firmware
12395 * when target goes to wow mode.
12396 *
12397 * Return: None
12398 */
12399static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012400 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012401{
12402
12403 int i;
12404 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012405
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012406 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12407 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12408 *buf_ptr += WMI_TLV_HDR_SIZE;
12409 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
12410 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12411 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12412 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12413 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
12414
12415 /*
12416 * Fill data only for NS offload in the first ARP tuple for LA
12417 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012418 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012419 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12420 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012421 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012422 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012423 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012424 sizeof(WMI_IPV6_ADDR));
12425 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012426 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012427 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012428 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012429 ns_tuple->flags |=
12430 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12431 }
12432 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012433 i, &ns_req->self_ipv6_addr[i],
12434 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012435
12436 /* target MAC is optional, check if it is valid,
12437 * if this is not valid, the target will use the known
12438 * local MAC address rather than the tuple
12439 */
12440 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012441 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012442 &ns_tuple->target_mac);
12443 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12444 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12445 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12446 }
12447 }
12448 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12449 }
12450}
12451
12452
12453/**
12454 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
12455 * @wmi: wmi handle
12456 * @offload_req: offload request
12457 * @buf_ptr: buffer pointer
12458 *
12459 * To fill extended NS offload extended data to firmware
12460 * when target goes to wow mode.
12461 *
12462 * Return: None
12463 */
12464static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012465 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012466{
12467 int i;
12468 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
12469 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012470
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012471 count = ns_req->num_ns_offload_count;
12472 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012473 WMI_MAX_NS_OFFLOADS;
12474
12475 /* Populate extended NS offload tuples */
12476 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12477 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12478 *buf_ptr += WMI_TLV_HDR_SIZE;
12479 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
12480 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12481 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12482 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12483 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
12484
12485 /*
12486 * Fill data only for NS offload in the first ARP tuple for LA
12487 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012488 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012489 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12490 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012491 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012492 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012493 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012494 sizeof(WMI_IPV6_ADDR));
12495 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012496 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012497 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012498 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012499 ns_tuple->flags |=
12500 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12501 }
12502 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012503 i, &ns_req->self_ipv6_addr[i],
12504 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012505
12506 /* target MAC is optional, check if it is valid,
12507 * if this is not valid, the target will use the
12508 * known local MAC address rather than the tuple
12509 */
12510 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012511 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012512 &ns_tuple->target_mac);
12513 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12514 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12515 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12516 }
12517 }
12518 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12519 }
12520}
12521#else
12522static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012523 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012524{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012525}
12526
12527static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012528 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012529{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012530}
12531#endif
12532
12533/**
Govind Singha4836fd2016-03-07 16:45:38 +053012534 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
12535 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012536 * @arp_offload_req: arp offload request
12537 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053012538 * @arp_only: flag
12539 *
12540 * To configure ARP NS off load data to firmware
12541 * when target goes to wow mode.
12542 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012543 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053012544 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012545static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012546 struct pmo_arp_offload_params *arp_offload_req,
12547 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053012548 uint8_t vdev_id)
12549{
Govind Singha4836fd2016-03-07 16:45:38 +053012550 int32_t res;
12551 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012552 A_UINT8 *buf_ptr;
12553 wmi_buf_t buf;
12554 int32_t len;
12555 uint32_t count = 0, num_ns_ext_tuples = 0;
12556
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012557 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053012558
Govind Singha4836fd2016-03-07 16:45:38 +053012559 /*
12560 * TLV place holder size for array of NS tuples
12561 * TLV place holder size for array of ARP tuples
12562 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012563 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
12564 WMI_TLV_HDR_SIZE +
12565 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
12566 WMI_TLV_HDR_SIZE +
12567 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053012568
12569 /*
12570 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
12571 * extra length for extended NS offload tuples which follows ARP offload
12572 * tuples. Host needs to fill this structure in following format:
12573 * 2 NS ofload tuples
12574 * 2 ARP offload tuples
12575 * N numbers of extended NS offload tuples if HDD has given more than
12576 * 2 NS offload addresses
12577 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012578 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053012579 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012580 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
12581 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053012582 }
12583
12584 buf = wmi_buf_alloc(wmi_handle, len);
12585 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012586 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053012587 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012588 }
12589
12590 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
12591 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
12592 WMITLV_SET_HDR(&cmd->tlv_header,
12593 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
12594 WMITLV_GET_STRUCT_TLVLEN
12595 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
12596 cmd->flags = 0;
12597 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012598 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053012599
Govind Singhb53420c2016-03-09 14:32:57 +053012600 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053012601
Govind Singha4836fd2016-03-07 16:45:38 +053012602 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012603 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
12604 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
12605 if (num_ns_ext_tuples)
12606 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053012607
12608 res = wmi_unified_cmd_send(wmi_handle, buf, len,
12609 WMI_SET_ARP_NS_OFFLOAD_CMDID);
12610 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053012611 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053012612 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012613 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012614 }
12615
Govind Singhb53420c2016-03-09 14:32:57 +053012616 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012617}
12618
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012619/**
12620 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
12621 * @wmi_handle: wmi handle
12622 * @vdev_id: vdev id
12623 * @action: true for enable else false
12624 *
12625 * To enable enhance multicast offload to firmware
12626 * when target goes to wow mode.
12627 *
12628 * Return: QDF Status
12629 */
12630
12631static
12632QDF_STATUS send_enable_enhance_multicast_offload_tlv(
12633 wmi_unified_t wmi_handle,
12634 uint8_t vdev_id, bool action)
12635{
12636 QDF_STATUS status;
12637 wmi_buf_t buf;
12638 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
12639
12640 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12641 if (!buf) {
12642 WMI_LOGE("Failed to allocate buffer to send set key cmd");
12643 return QDF_STATUS_E_NOMEM;
12644 }
12645
12646 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
12647 wmi_buf_data(buf);
12648
12649 WMITLV_SET_HDR(&cmd->tlv_header,
12650 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
12651 WMITLV_GET_STRUCT_TLVLEN(
12652 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
12653
12654 cmd->vdev_id = vdev_id;
12655 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
12656 ENHANCED_MCAST_FILTER_ENABLED);
12657 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
12658 __func__, action, vdev_id);
12659 status = wmi_unified_cmd_send(wmi_handle, buf,
12660 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
12661 if (status != QDF_STATUS_SUCCESS) {
12662 qdf_nbuf_free(buf);
12663 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
12664 __func__);
12665 }
12666
12667 return status;
12668}
12669
12670/**
12671 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
12672 * @wmi_handle: wmi handle
12673 * @param evt_buf: pointer to event buffer
12674 * @param hdr: Pointer to hold header
12675 * @param bufp: Pointer to hold pointer to rx param buffer
12676 *
12677 * Return: QDF_STATUS_SUCCESS for success or error code
12678 */
12679static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
12680 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
12681{
12682 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
12683 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
12684
12685 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
12686 if (!param_buf) {
12687 WMI_LOGE("gtk param_buf is NULL");
12688 return QDF_STATUS_E_INVAL;
12689 }
12690
12691 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
12692 WMI_LOGE("Invalid length for GTK status");
12693 return QDF_STATUS_E_INVAL;
12694 }
12695
12696 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
12697 param_buf->fixed_param;
12698 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
12699 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
12700 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
12701 qdf_mem_copy(&gtk_rsp_param->replay_counter,
12702 &fixed_param->replay_counter,
12703 GTK_REPLAY_COUNTER_BYTES);
12704
12705 return QDF_STATUS_SUCCESS;
12706
12707}
12708
12709#ifdef FEATURE_WLAN_RA_FILTERING
12710/**
12711 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
12712 * @wmi_handle: wmi handle
12713 * @vdev_id: vdev id
12714 *
12715 * Return: CDF status
12716 */
12717static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
12718 uint8_t vdev_id, uint8_t default_pattern,
12719 uint16_t rate_limit_interval)
12720{
12721
12722 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12723 wmi_buf_t buf;
12724 uint8_t *buf_ptr;
12725 int32_t len;
12726 int ret;
12727
12728 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12729 WMI_TLV_HDR_SIZE +
12730 0 * sizeof(WOW_BITMAP_PATTERN_T) +
12731 WMI_TLV_HDR_SIZE +
12732 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12733 WMI_TLV_HDR_SIZE +
12734 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12735 WMI_TLV_HDR_SIZE +
12736 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12737 WMI_TLV_HDR_SIZE +
12738 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12739
12740 buf = wmi_buf_alloc(wmi_handle, len);
12741 if (!buf) {
12742 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12743 return QDF_STATUS_E_NOMEM;
12744 }
12745
12746 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12747 buf_ptr = (uint8_t *) cmd;
12748
12749 WMITLV_SET_HDR(&cmd->tlv_header,
12750 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12751 WMITLV_GET_STRUCT_TLVLEN
12752 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12753 cmd->vdev_id = vdev_id;
12754 cmd->pattern_id = default_pattern,
12755 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
12756 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12757
12758 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
12759 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12760 buf_ptr += WMI_TLV_HDR_SIZE;
12761
12762 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12763 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12764 buf_ptr += WMI_TLV_HDR_SIZE;
12765
12766 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12767 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12768 buf_ptr += WMI_TLV_HDR_SIZE;
12769
12770 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12771 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12772 buf_ptr += WMI_TLV_HDR_SIZE;
12773
12774 /* Fill TLV for pattern_info_timeout but no data. */
12775 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12776 buf_ptr += WMI_TLV_HDR_SIZE;
12777
12778 /* Fill TLV for ra_ratelimit_interval. */
12779 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
12780 buf_ptr += WMI_TLV_HDR_SIZE;
12781
12782 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
12783
12784 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
12785 rate_limit_interval, vdev_id);
12786
12787 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12788 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12789 if (ret) {
12790 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
12791 wmi_buf_free(buf);
12792 return QDF_STATUS_E_FAILURE;
12793 }
12794
12795 return QDF_STATUS_SUCCESS;
12796
12797}
12798#endif /* FEATURE_WLAN_RA_FILTERING */
12799
12800/**
12801 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
12802 * @wmi_handle: wmi handle
12803 * @vdev_id: vdev id
12804 * @multicastAddr: mcast address
12805 * @clearList: clear list flag
12806 *
12807 * Return: QDF_STATUS_SUCCESS for success or error code
12808 */
12809static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
12810 uint8_t vdev_id,
12811 struct qdf_mac_addr multicast_addr,
12812 bool clearList)
12813{
12814 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
12815 wmi_buf_t buf;
12816 int err;
12817
12818 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12819 if (!buf) {
12820 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
12821 return QDF_STATUS_E_NOMEM;
12822 }
12823
12824 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
12825 qdf_mem_zero(cmd, sizeof(*cmd));
12826
12827 WMITLV_SET_HDR(&cmd->tlv_header,
12828 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
12829 WMITLV_GET_STRUCT_TLVLEN
12830 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
12831 cmd->action =
12832 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
12833 cmd->vdev_id = vdev_id;
12834 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
12835
12836 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
12837 cmd->action, vdev_id, clearList, multicast_addr.bytes);
12838
12839 err = wmi_unified_cmd_send(wmi_handle, buf,
12840 sizeof(*cmd),
12841 WMI_SET_MCASTBCAST_FILTER_CMDID);
12842 if (err) {
12843 WMI_LOGE("Failed to send set_param cmd");
12844 wmi_buf_free(buf);
12845 return QDF_STATUS_E_FAILURE;
12846 }
12847
12848 return QDF_STATUS_SUCCESS;
12849}
12850
12851/**
12852 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
12853 * @wmi_handle: wmi handle
12854 * @vdev_id: vdev id
12855 * @params: GTK offload parameters
12856 *
12857 * Return: CDF status
12858 */
12859static
12860QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
12861 struct pmo_gtk_req *params,
12862 bool enable_offload,
12863 uint32_t gtk_offload_opcode)
12864{
12865 int len;
12866 wmi_buf_t buf;
12867 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12868 QDF_STATUS status = QDF_STATUS_SUCCESS;
12869
12870 WMI_LOGD("%s Enter", __func__);
12871
12872 len = sizeof(*cmd);
12873
12874 /* alloc wmi buffer */
12875 buf = wmi_buf_alloc(wmi_handle, len);
12876 if (!buf) {
12877 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12878 status = QDF_STATUS_E_NOMEM;
12879 goto out;
12880 }
12881
12882 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12883 WMITLV_SET_HDR(&cmd->tlv_header,
12884 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12885 WMITLV_GET_STRUCT_TLVLEN
12886 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12887
12888 cmd->vdev_id = vdev_id;
12889
12890 /* Request target to enable GTK offload */
12891 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
12892 cmd->flags = gtk_offload_opcode;
12893
12894 /* Copy the keys and replay counter */
12895 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
12896 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
12897 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
12898 GTK_REPLAY_COUNTER_BYTES);
12899 } else {
12900 cmd->flags = gtk_offload_opcode;
12901 }
12902
12903 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
12904
12905 /* send the wmi command */
12906 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12907 WMI_GTK_OFFLOAD_CMDID)) {
12908 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
12909 wmi_buf_free(buf);
12910 status = QDF_STATUS_E_FAILURE;
12911 }
12912
12913out:
12914 WMI_LOGD("%s Exit", __func__);
12915 return status;
12916}
12917
12918/**
12919 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
12920 * @wmi_handle: wmi handle
12921 * @params: GTK offload params
12922 *
12923 * Return: CDF status
12924 */
12925static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
12926 wmi_unified_t wmi_handle,
12927 uint8_t vdev_id,
12928 uint64_t offload_req_opcode)
12929{
12930 int len;
12931 wmi_buf_t buf;
12932 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
12933 QDF_STATUS status = QDF_STATUS_SUCCESS;
12934
12935 len = sizeof(*cmd);
12936
12937 /* alloc wmi buffer */
12938 buf = wmi_buf_alloc(wmi_handle, len);
12939 if (!buf) {
12940 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
12941 status = QDF_STATUS_E_NOMEM;
12942 goto out;
12943 }
12944
12945 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
12946 WMITLV_SET_HDR(&cmd->tlv_header,
12947 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
12948 WMITLV_GET_STRUCT_TLVLEN
12949 (WMI_GTK_OFFLOAD_CMD_fixed_param));
12950
12951 /* Request for GTK offload status */
12952 cmd->flags = offload_req_opcode;
12953 cmd->vdev_id = vdev_id;
12954
12955 /* send the wmi command */
12956 if (wmi_unified_cmd_send(wmi_handle, buf, len,
12957 WMI_GTK_OFFLOAD_CMDID)) {
12958 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
12959 wmi_buf_free(buf);
12960 status = QDF_STATUS_E_FAILURE;
12961 }
12962
12963out:
12964 return status;
12965}
12966
12967/**
12968 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
12969 * @wmi_handle: wmi handler
12970 * @action_params: pointer to action_params
12971 *
12972 * Return: 0 for success, otherwise appropriate error code
12973 */
12974static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
12975 struct pmo_action_wakeup_set_params *action_params)
12976{
12977 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
12978 wmi_buf_t buf;
12979 int i;
12980 int32_t err;
12981
12982 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12983 if (!buf) {
12984 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
12985 return QDF_STATUS_E_NOMEM;
12986 }
12987 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
12988 WMITLV_SET_HDR(&cmd->tlv_header,
12989 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
12990 WMITLV_GET_STRUCT_TLVLEN(
12991 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
12992
12993 cmd->vdev_id = action_params->vdev_id;
12994 cmd->operation = action_params->operation;
12995
12996 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
12997 cmd->action_category_map[i] =
12998 action_params->action_category_map[i];
12999
13000 err = wmi_unified_cmd_send(wmi_handle, buf,
13001 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13002 if (err) {
13003 WMI_LOGE("Failed to send ap_ps_egap cmd");
13004 wmi_buf_free(buf);
13005 return QDF_STATUS_E_FAILURE;
13006 }
13007
13008 return QDF_STATUS_SUCCESS;
13009}
13010
13011#ifdef FEATURE_WLAN_LPHB
13012
13013/**
13014 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13015 * @wmi_handle: wmi handle
13016 * @lphb_conf_req: configuration info
13017 *
13018 * Return: CDF status
13019 */
13020static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13021 wmi_hb_set_enable_cmd_fixed_param *params)
13022{
13023 QDF_STATUS status;
13024 wmi_buf_t buf = NULL;
13025 uint8_t *buf_ptr;
13026 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13027 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13028
13029
13030 buf = wmi_buf_alloc(wmi_handle, len);
13031 if (!buf) {
13032 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13033 return QDF_STATUS_E_NOMEM;
13034 }
13035
13036 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13037 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13038 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13039 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13040 WMITLV_GET_STRUCT_TLVLEN
13041 (wmi_hb_set_enable_cmd_fixed_param));
13042
13043 /* fill in values */
13044 hb_enable_fp->vdev_id = params->session;
13045 hb_enable_fp->enable = params->enable;
13046 hb_enable_fp->item = params->item;
13047 hb_enable_fp->session = params->session;
13048
13049 status = wmi_unified_cmd_send(wmi_handle, buf,
13050 len, WMI_HB_SET_ENABLE_CMDID);
13051 if (QDF_IS_STATUS_ERROR(status)) {
13052 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13053 status);
13054 wmi_buf_free(buf);
13055 }
13056
13057 return status;
13058}
13059
13060/**
13061 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13062 * @wmi_handle: wmi handle
13063 * @lphb_conf_req: lphb config request
13064 *
13065 * Return: CDF status
13066 */
13067static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13068 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13069{
13070 QDF_STATUS status;
13071 wmi_buf_t buf = NULL;
13072 uint8_t *buf_ptr;
13073 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13074 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13075
13076 buf = wmi_buf_alloc(wmi_handle, len);
13077 if (!buf) {
13078 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13079 return QDF_STATUS_E_NOMEM;
13080 }
13081
13082 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13083 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13084 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13085 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13086 WMITLV_GET_STRUCT_TLVLEN
13087 (wmi_hb_set_tcp_params_cmd_fixed_param));
13088
13089 /* fill in values */
13090 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13091 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13092 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13093 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13094 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13095 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13096 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13097 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13098 hb_tcp_params_fp->session = lphb_conf_req->session;
13099 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13100 &lphb_conf_req->gateway_mac,
13101 sizeof(hb_tcp_params_fp->gateway_mac));
13102
13103 status = wmi_unified_cmd_send(wmi_handle, buf,
13104 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13105 if (QDF_IS_STATUS_ERROR(status)) {
13106 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13107 status);
13108 wmi_buf_free(buf);
13109 }
13110
13111 return status;
13112}
13113
13114/**
13115 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13116 * @wmi_handle: wmi handle
13117 * @lphb_conf_req: lphb config request
13118 *
13119 * Return: CDF status
13120 */
13121static
13122QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13123 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13124{
13125 QDF_STATUS status;
13126 wmi_buf_t buf = NULL;
13127 uint8_t *buf_ptr;
13128 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13129 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13130
13131 buf = wmi_buf_alloc(wmi_handle, len);
13132 if (!buf) {
13133 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13134 return QDF_STATUS_E_NOMEM;
13135 }
13136
13137 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13138 hb_tcp_filter_fp =
13139 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13140 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13141 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13142 WMITLV_GET_STRUCT_TLVLEN
13143 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13144
13145 /* fill in values */
13146 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13147 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13148 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13149 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13150 memcpy((void *)&hb_tcp_filter_fp->filter,
13151 (void *)&g_hb_tcp_filter_fp->filter,
13152 WMI_WLAN_HB_MAX_FILTER_SIZE);
13153
13154 status = wmi_unified_cmd_send(wmi_handle, buf,
13155 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13156 if (QDF_IS_STATUS_ERROR(status)) {
13157 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13158 status);
13159 wmi_buf_free(buf);
13160 }
13161
13162 return status;
13163}
13164
13165/**
13166 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13167 * @wmi_handle: wmi handle
13168 * @lphb_conf_req: lphb config request
13169 *
13170 * Return: CDF status
13171 */
13172static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13173 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13174{
13175 QDF_STATUS status;
13176 wmi_buf_t buf = NULL;
13177 uint8_t *buf_ptr;
13178 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13179 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13180
13181 buf = wmi_buf_alloc(wmi_handle, len);
13182 if (!buf) {
13183 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13184 return QDF_STATUS_E_NOMEM;
13185 }
13186
13187 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13188 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13189 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13190 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13191 WMITLV_GET_STRUCT_TLVLEN
13192 (wmi_hb_set_udp_params_cmd_fixed_param));
13193
13194 /* fill in values */
13195 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13196 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13197 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13198 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13199 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13200 hb_udp_params_fp->interval = lphb_conf_req->interval;
13201 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13202 hb_udp_params_fp->session = lphb_conf_req->session;
13203 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13204 &lphb_conf_req->gateway_mac,
13205 sizeof(lphb_conf_req->gateway_mac));
13206
13207 status = wmi_unified_cmd_send(wmi_handle, buf,
13208 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13209 if (QDF_IS_STATUS_ERROR(status)) {
13210 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13211 status);
13212 wmi_buf_free(buf);
13213 }
13214
13215 return status;
13216}
13217
13218/**
13219 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13220 * @wmi_handle: wmi handle
13221 * @lphb_conf_req: lphb config request
13222 *
13223 * Return: CDF status
13224 */
13225static
13226QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13227 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13228{
13229 QDF_STATUS status;
13230 wmi_buf_t buf = NULL;
13231 uint8_t *buf_ptr;
13232 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13233 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13234
13235 buf = wmi_buf_alloc(wmi_handle, len);
13236 if (!buf) {
13237 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13238 return QDF_STATUS_E_NOMEM;
13239 }
13240
13241 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13242 hb_udp_filter_fp =
13243 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13244 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13245 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13246 WMITLV_GET_STRUCT_TLVLEN
13247 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13248
13249 /* fill in values */
13250 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13251 hb_udp_filter_fp->length = lphb_conf_req->length;
13252 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13253 hb_udp_filter_fp->session = lphb_conf_req->session;
13254 memcpy((void *)&hb_udp_filter_fp->filter,
13255 (void *)&lphb_conf_req->filter,
13256 WMI_WLAN_HB_MAX_FILTER_SIZE);
13257
13258 status = wmi_unified_cmd_send(wmi_handle, buf,
13259 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13260 if (QDF_IS_STATUS_ERROR(status)) {
13261 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13262 status);
13263 wmi_buf_free(buf);
13264 }
13265
13266 return status;
13267}
13268#endif /* FEATURE_WLAN_LPHB */
13269#endif /* End of WLAN_PMO_ENABLE */
13270
Sathish Kumarfd347372017-02-13 12:29:09 +053013271static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013272 uint8_t vdev_id, bool enable)
13273{
13274 int32_t res;
13275 wmi_hw_data_filter_cmd_fixed_param *cmd;
13276 A_UINT8 *buf_ptr;
13277 wmi_buf_t buf;
13278 int32_t len;
13279
13280 /*
13281 * TLV place holder size for array of ARP tuples
13282 */
13283 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
13284
13285 buf = wmi_buf_alloc(wmi_handle, len);
13286 if (!buf) {
13287 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13288 return QDF_STATUS_E_NOMEM;
13289 }
13290
13291 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13292 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
13293 WMITLV_SET_HDR(&cmd->tlv_header,
13294 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13295 WMITLV_GET_STRUCT_TLVLEN
13296 (wmi_hw_data_filter_cmd_fixed_param));
13297 cmd->vdev_id = vdev_id;
13298 cmd->enable = enable;
13299 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
13300
13301 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
13302
13303 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13304 WMI_HW_DATA_FILTER_CMDID);
13305 if (res) {
13306 WMI_LOGE("Failed to enable ARP NDP/NSffload");
13307 wmi_buf_free(buf);
13308 return QDF_STATUS_E_FAILURE;
13309 }
13310
13311 return QDF_STATUS_SUCCESS;
13312}
13313
Govind Singha4836fd2016-03-07 16:45:38 +053013314/**
13315 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
13316 * @wmi_handle: wmi handle
13317 * @request: SSID hotlist set request
13318 *
Govind Singhb53420c2016-03-09 14:32:57 +053013319 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053013320 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013321static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053013322send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
13323 struct ssid_hotlist_request_params *request)
13324{
13325 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
13326 wmi_buf_t wmi_buf;
13327 uint32_t len;
13328 uint32_t array_size;
13329 uint8_t *buf_ptr;
13330
13331 /* length of fixed portion */
13332 len = sizeof(*cmd);
13333
13334 /* length of variable portion */
13335 array_size =
13336 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
13337 len += WMI_TLV_HDR_SIZE + array_size;
13338
13339 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13340 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013341 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13342 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013343 }
13344
13345 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
13346 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
13347 buf_ptr;
13348 WMITLV_SET_HDR
13349 (&cmd->tlv_header,
13350 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
13351 WMITLV_GET_STRUCT_TLVLEN
13352 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
13353
13354 cmd->request_id = request->request_id;
13355 cmd->requestor_id = 0;
13356 cmd->vdev_id = request->session_id;
13357 cmd->table_id = 0;
13358 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
13359 cmd->total_entries = request->ssid_count;
13360 cmd->num_entries_in_page = request->ssid_count;
13361 cmd->first_entry_index = 0;
13362
13363 buf_ptr += sizeof(*cmd);
13364 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
13365
13366 if (request->ssid_count) {
13367 wmi_extscan_hotlist_ssid_entry *entry;
13368 int i;
13369
13370 buf_ptr += WMI_TLV_HDR_SIZE;
13371 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
13372 for (i = 0; i < request->ssid_count; i++) {
13373 WMITLV_SET_HDR
13374 (entry,
13375 WMITLV_TAG_ARRAY_STRUC,
13376 WMITLV_GET_STRUCT_TLVLEN
13377 (wmi_extscan_hotlist_ssid_entry));
13378 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053013379 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053013380 request->ssids[i].ssid.mac_ssid,
13381 request->ssids[i].ssid.length);
13382 entry->band = request->ssids[i].band;
13383 entry->min_rssi = request->ssids[i].rssi_low;
13384 entry->max_rssi = request->ssids[i].rssi_high;
13385 entry++;
13386 }
13387 cmd->mode = WMI_EXTSCAN_MODE_START;
13388 } else {
13389 cmd->mode = WMI_EXTSCAN_MODE_STOP;
13390 }
13391
13392 if (wmi_unified_cmd_send
13393 (wmi_handle, wmi_buf, len,
13394 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013395 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013396 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013397 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013398 }
13399
Govind Singhb53420c2016-03-09 14:32:57 +053013400 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013401}
13402
13403/**
13404 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
13405 * @wmi_handle: wmi handle
13406 * @vdev_id: vdev id
13407 *
13408 * This function sends roam synch complete event to fw.
13409 *
13410 * Return: CDF STATUS
13411 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013412static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013413 uint8_t vdev_id)
13414{
13415 wmi_roam_synch_complete_fixed_param *cmd;
13416 wmi_buf_t wmi_buf;
13417 uint8_t *buf_ptr;
13418 uint16_t len;
13419 len = sizeof(wmi_roam_synch_complete_fixed_param);
13420
13421 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13422 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013423 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13424 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013425 }
13426 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
13427 buf_ptr = (uint8_t *) cmd;
13428 WMITLV_SET_HDR(&cmd->tlv_header,
13429 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
13430 WMITLV_GET_STRUCT_TLVLEN
13431 (wmi_roam_synch_complete_fixed_param));
13432 cmd->vdev_id = vdev_id;
13433 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13434 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013435 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053013436 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013437 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013438 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013439 }
13440
Govind Singhb53420c2016-03-09 14:32:57 +053013441 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013442}
13443
13444/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053013445 * send_fw_test_cmd_tlv() - send fw test command to fw.
13446 * @wmi_handle: wmi handle
13447 * @wmi_fwtest: fw test command
13448 *
13449 * This function sends fw test command to fw.
13450 *
13451 * Return: CDF STATUS
13452 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013453static
Anurag Chouhan459e0152016-07-22 20:19:54 +053013454QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
13455 struct set_fwtest_params *wmi_fwtest)
13456{
13457 wmi_fwtest_set_param_cmd_fixed_param *cmd;
13458 wmi_buf_t wmi_buf;
13459 uint16_t len;
13460
13461 len = sizeof(*cmd);
13462
13463 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13464 if (!wmi_buf) {
13465 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13466 return QDF_STATUS_E_NOMEM;
13467 }
13468
13469 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
13470 WMITLV_SET_HDR(&cmd->tlv_header,
13471 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
13472 WMITLV_GET_STRUCT_TLVLEN(
13473 wmi_fwtest_set_param_cmd_fixed_param));
13474 cmd->param_id = wmi_fwtest->arg;
13475 cmd->param_value = wmi_fwtest->value;
13476
13477 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13478 WMI_FWTEST_CMDID)) {
13479 WMI_LOGP("%s: failed to send fw test command", __func__);
13480 qdf_nbuf_free(wmi_buf);
13481 return QDF_STATUS_E_FAILURE;
13482 }
13483
13484 return QDF_STATUS_SUCCESS;
13485}
13486
13487/**
Govind Singha4836fd2016-03-07 16:45:38 +053013488 * send_unit_test_cmd_tlv() - send unit test command to fw.
13489 * @wmi_handle: wmi handle
13490 * @wmi_utest: unit test command
13491 *
13492 * This function send unit test command to fw.
13493 *
13494 * Return: CDF STATUS
13495 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013496static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013497 struct wmi_unit_test_cmd *wmi_utest)
13498{
13499 wmi_unit_test_cmd_fixed_param *cmd;
13500 wmi_buf_t wmi_buf;
13501 uint8_t *buf_ptr;
13502 int i;
13503 uint16_t len, args_tlv_len;
13504 A_UINT32 *unit_test_cmd_args;
13505
13506 args_tlv_len =
13507 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
13508 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
13509
13510 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13511 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013512 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13513 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013514 }
13515
13516 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
13517 buf_ptr = (uint8_t *) cmd;
13518 WMITLV_SET_HDR(&cmd->tlv_header,
13519 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
13520 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
13521 cmd->vdev_id = wmi_utest->vdev_id;
13522 cmd->module_id = wmi_utest->module_id;
13523 cmd->num_args = wmi_utest->num_args;
13524 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
13525 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13526 (wmi_utest->num_args * sizeof(uint32_t)));
13527 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013528 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053013529 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
13530 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013531 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013532 }
13533 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13534 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013535 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013536 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013537 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013538 }
13539
Govind Singhb53420c2016-03-09 14:32:57 +053013540 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013541}
13542
13543/**
13544 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
13545 * @wmi_handle: wma handle
13546 * @roaminvoke: roam invoke command
13547 *
13548 * Send roam invoke command to fw for fastreassoc.
13549 *
13550 * Return: CDF STATUS
13551 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013552static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013553 struct wmi_roam_invoke_cmd *roaminvoke,
13554 uint32_t ch_hz)
13555{
13556 wmi_roam_invoke_cmd_fixed_param *cmd;
13557 wmi_buf_t wmi_buf;
13558 u_int8_t *buf_ptr;
13559 u_int16_t len, args_tlv_len;
13560 A_UINT32 *channel_list;
13561 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080013562 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053013563
13564 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080013565 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
13566 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
13567 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013568 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
13569 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13570 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013571 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13572 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013573 }
13574
13575 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
13576 buf_ptr = (u_int8_t *) cmd;
13577 WMITLV_SET_HDR(&cmd->tlv_header,
13578 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
13579 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
13580 cmd->vdev_id = roaminvoke->vdev_id;
13581 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080013582
13583 if (roaminvoke->frame_len)
13584 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
13585 else
13586 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
13587
Govind Singha4836fd2016-03-07 16:45:38 +053013588 cmd->roam_ap_sel_mode = 0;
13589 cmd->roam_delay = 0;
13590 cmd->num_chan = 1;
13591 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080013592 /* packing 1 beacon/probe_rsp frame with WMI cmd */
13593 cmd->num_buf = 1;
13594
Govind Singha4836fd2016-03-07 16:45:38 +053013595 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
13596 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13597 (sizeof(u_int32_t)));
13598 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
13599 *channel_list = ch_hz;
13600 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
13601 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
13602 (sizeof(wmi_mac_addr)));
13603 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
13604 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080013605
13606 /* move to next tlv i.e. bcn_prb_buf_list */
13607 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
13608
13609 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
13610 sizeof(wmi_tlv_buf_len_param));
13611
13612 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
13613 buf_len_tlv->buf_len = roaminvoke->frame_len;
13614
13615 /* move to next tlv i.e. bcn_prb_frm */
13616 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
13617 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
13618 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
13619
13620 /* copy frame after the header */
13621 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
13622 roaminvoke->frame_buf,
13623 roaminvoke->frame_len);
13624
13625 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
13626 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
13627 buf_ptr + WMI_TLV_HDR_SIZE,
13628 roaminvoke->frame_len);
13629
Govind Singha4836fd2016-03-07 16:45:38 +053013630 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13631 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013632 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013633 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013634 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013635 }
13636
Govind Singhb53420c2016-03-09 14:32:57 +053013637 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013638}
13639
13640/**
13641 * send_roam_scan_offload_cmd_tlv() - set roam offload command
13642 * @wmi_handle: wmi handle
13643 * @command: command
13644 * @vdev_id: vdev id
13645 *
13646 * This function set roam offload command to fw.
13647 *
13648 * Return: CDF status
13649 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013650static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013651 uint32_t command, uint32_t vdev_id)
13652{
Govind Singh67922e82016-04-01 16:48:57 +053013653 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013654 wmi_roam_scan_cmd_fixed_param *cmd_fp;
13655 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013656 int len;
13657 uint8_t *buf_ptr;
13658
13659 len = sizeof(wmi_roam_scan_cmd_fixed_param);
13660 buf = wmi_buf_alloc(wmi_handle, len);
13661 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013662 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13663 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013664 }
13665
13666 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13667
13668 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
13669 WMITLV_SET_HDR(&cmd_fp->tlv_header,
13670 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
13671 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
13672 cmd_fp->vdev_id = vdev_id;
13673 cmd_fp->command_arg = command;
13674
13675 status = wmi_unified_cmd_send(wmi_handle, buf,
13676 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053013677 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013678 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013679 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013680 goto error;
13681 }
13682
Govind Singhb53420c2016-03-09 14:32:57 +053013683 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
13684 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013685
13686error:
13687 wmi_buf_free(buf);
13688
Govind Singh67922e82016-04-01 16:48:57 +053013689 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013690}
13691
13692/**
13693 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
13694 * @wmi_handle: wmi handle
13695 * @ap_profile_p: ap profile
13696 * @vdev_id: vdev id
13697 *
13698 * Send WMI_ROAM_AP_PROFILE to firmware
13699 *
13700 * Return: CDF status
13701 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013702static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013703 wmi_ap_profile *ap_profile_p,
13704 uint32_t vdev_id)
13705{
Govind Singha4836fd2016-03-07 16:45:38 +053013706 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013707 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013708 int len;
13709 uint8_t *buf_ptr;
13710 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
13711
13712 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
13713
13714 buf = wmi_buf_alloc(wmi_handle, len);
13715 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013716 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13717 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013718 }
13719
13720 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13721 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
13722 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
13723 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
13724 WMITLV_GET_STRUCT_TLVLEN
13725 (wmi_roam_ap_profile_fixed_param));
13726 /* fill in threshold values */
13727 roam_ap_profile_fp->vdev_id = vdev_id;
13728 roam_ap_profile_fp->id = 0;
13729 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
13730
Govind Singhb53420c2016-03-09 14:32:57 +053013731 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053013732 WMITLV_SET_HDR(buf_ptr,
13733 WMITLV_TAG_STRUC_wmi_ap_profile,
13734 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
13735 status = wmi_unified_cmd_send(wmi_handle, buf,
13736 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053013737 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013738 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013739 status);
Govind Singh67922e82016-04-01 16:48:57 +053013740 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053013741 }
13742
Govind Singhb53420c2016-03-09 14:32:57 +053013743 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053013744
Govind Singh67922e82016-04-01 16:48:57 +053013745 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013746}
13747
13748/**
13749 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
13750 * @wmi_handle: wmi handle
13751 * @scan_period: scan period
13752 * @scan_age: scan age
13753 * @vdev_id: vdev id
13754 *
13755 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
13756 *
13757 * Return: CDF status
13758 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013759static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013760 uint32_t scan_period,
13761 uint32_t scan_age,
13762 uint32_t vdev_id)
13763{
Govind Singh67922e82016-04-01 16:48:57 +053013764 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013765 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013766 int len;
13767 uint8_t *buf_ptr;
13768 wmi_roam_scan_period_fixed_param *scan_period_fp;
13769
13770 /* Send scan period values */
13771 len = sizeof(wmi_roam_scan_period_fixed_param);
13772 buf = wmi_buf_alloc(wmi_handle, len);
13773 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013774 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13775 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013776 }
13777
13778 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13779 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
13780 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
13781 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
13782 WMITLV_GET_STRUCT_TLVLEN
13783 (wmi_roam_scan_period_fixed_param));
13784 /* fill in scan period values */
13785 scan_period_fp->vdev_id = vdev_id;
13786 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
13787 scan_period_fp->roam_scan_age = scan_age;
13788
13789 status = wmi_unified_cmd_send(wmi_handle, buf,
13790 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053013791 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013792 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013793 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013794 goto error;
13795 }
13796
Govind Singhb53420c2016-03-09 14:32:57 +053013797 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053013798 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053013799 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013800error:
13801 wmi_buf_free(buf);
13802
Govind Singh67922e82016-04-01 16:48:57 +053013803 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013804}
13805
13806/**
13807 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
13808 * @wmi_handle: wmi handle
13809 * @chan_count: channel count
13810 * @chan_list: channel list
13811 * @list_type: list type
13812 * @vdev_id: vdev id
13813 *
13814 * Set roam offload channel list.
13815 *
13816 * Return: CDF status
13817 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013818static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013819 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070013820 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053013821 uint8_t list_type, uint32_t vdev_id)
13822{
Govind Singha4836fd2016-03-07 16:45:38 +053013823 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013824 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013825 int len, list_tlv_len;
13826 int i;
13827 uint8_t *buf_ptr;
13828 wmi_roam_chan_list_fixed_param *chan_list_fp;
13829 A_UINT32 *roam_chan_list_array;
13830
13831 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053013832 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053013833 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053013834 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053013835 }
13836 /* Channel list is a table of 2 TLV's */
13837 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
13838 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
13839 buf = wmi_buf_alloc(wmi_handle, len);
13840 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013841 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13842 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013843 }
13844
13845 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13846 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
13847 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
13848 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
13849 WMITLV_GET_STRUCT_TLVLEN
13850 (wmi_roam_chan_list_fixed_param));
13851 chan_list_fp->vdev_id = vdev_id;
13852 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053013853 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053013854 /* external app is controlling channel list */
13855 chan_list_fp->chan_list_type =
13856 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
13857 } else {
13858 /* umac supplied occupied channel list in LFR */
13859 chan_list_fp->chan_list_type =
13860 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
13861 }
13862
13863 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
13864 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13865 (chan_list_fp->num_chan * sizeof(uint32_t)));
13866 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013867 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053013868 for (i = 0; ((i < chan_list_fp->num_chan) &&
13869 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
13870 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013871 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013872 }
13873
13874 status = wmi_unified_cmd_send(wmi_handle, buf,
13875 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053013876 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013877 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053013878 status);
Govind Singha4836fd2016-03-07 16:45:38 +053013879 goto error;
13880 }
13881
Govind Singhb53420c2016-03-09 14:32:57 +053013882 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
13883 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013884error:
13885 wmi_buf_free(buf);
13886
Govind Singh67922e82016-04-01 16:48:57 +053013887 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053013888}
13889
13890/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013891 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
13892 * @wmi_handle: wmi handle
13893 * @req_buf: per roam config buffer
13894 *
13895 * Return: QDF status
13896 */
13897static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
13898 struct wmi_per_roam_config_req *req_buf)
13899{
13900 wmi_buf_t buf = NULL;
13901 QDF_STATUS status;
13902 int len;
13903 uint8_t *buf_ptr;
13904 wmi_roam_per_config_fixed_param *wmi_per_config;
13905
13906 len = sizeof(wmi_roam_per_config_fixed_param);
13907 buf = wmi_buf_alloc(wmi_handle, len);
13908 if (!buf) {
13909 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13910 return QDF_STATUS_E_NOMEM;
13911 }
13912
13913 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13914 wmi_per_config =
13915 (wmi_roam_per_config_fixed_param *) buf_ptr;
13916 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
13917 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
13918 WMITLV_GET_STRUCT_TLVLEN
13919 (wmi_roam_per_config_fixed_param));
13920
13921 /* fill in per roam config values */
13922 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013923
13924 wmi_per_config->enable = req_buf->per_config.enable;
13925 wmi_per_config->high_rate_thresh =
13926 (req_buf->per_config.tx_high_rate_thresh << 16) |
13927 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
13928 wmi_per_config->low_rate_thresh =
13929 (req_buf->per_config.tx_low_rate_thresh << 16) |
13930 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
13931 wmi_per_config->pkt_err_rate_thresh_pct =
13932 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
13933 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
13934 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053013935 wmi_per_config->pkt_err_rate_mon_time =
13936 (req_buf->per_config.tx_per_mon_time << 16) |
13937 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053013938
13939 /* Send per roam config parameters */
13940 status = wmi_unified_cmd_send(wmi_handle, buf,
13941 len, WMI_ROAM_PER_CONFIG_CMDID);
13942 if (QDF_IS_STATUS_ERROR(status)) {
13943 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
13944 status);
13945 wmi_buf_free(buf);
13946 return status;
13947 }
13948
13949 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
13950 req_buf->per_config.enable, req_buf->vdev_id);
13951 return QDF_STATUS_SUCCESS;
13952}
13953
13954/**
Govind Singha4836fd2016-03-07 16:45:38 +053013955 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
13956 * @wmi_handle: wmi handle
13957 * @rssi_change_thresh: RSSI Change threshold
13958 * @bcn_rssi_weight: beacon RSSI weight
13959 * @vdev_id: vdev id
13960 *
13961 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
13962 *
13963 * Return: CDF status
13964 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013965static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013966 uint32_t vdev_id,
13967 int32_t rssi_change_thresh,
13968 uint32_t bcn_rssi_weight,
13969 uint32_t hirssi_delay_btw_scans)
13970{
Govind Singha4836fd2016-03-07 16:45:38 +053013971 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053013972 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013973 int len;
13974 uint8_t *buf_ptr;
13975 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
13976
13977 /* Send rssi change parameters */
13978 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
13979 buf = wmi_buf_alloc(wmi_handle, len);
13980 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013981 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13982 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013983 }
13984
13985 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13986 rssi_change_fp =
13987 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
13988 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
13989 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
13990 WMITLV_GET_STRUCT_TLVLEN
13991 (wmi_roam_scan_rssi_change_threshold_fixed_param));
13992 /* fill in rssi change threshold (hysteresis) values */
13993 rssi_change_fp->vdev_id = vdev_id;
13994 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
13995 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
13996 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
13997
13998 status = wmi_unified_cmd_send(wmi_handle, buf,
13999 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014000 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014001 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014002 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014003 goto error;
14004 }
14005
Govind Singhb53420c2016-03-09 14:32:57 +053014006 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014007 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014008 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14009 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014010error:
14011 wmi_buf_free(buf);
14012
Govind Singh67922e82016-04-01 16:48:57 +053014013 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014014}
14015
14016/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14017 * @wmi_handle: wmi handle.
14018 * @cmd: size of command structure.
14019 * @per_entry_size: per entry size.
14020 *
14021 * This utility function calculates how many hotlist entries can
14022 * fit in one page.
14023 *
14024 * Return: number of entries
14025 */
14026static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14027 size_t cmd_size,
14028 size_t per_entry_size)
14029{
14030 uint32_t avail_space = 0;
14031 int num_entries = 0;
14032 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14033
14034 /* Calculate number of hotlist entries that can
14035 * be passed in wma message request.
14036 */
14037 avail_space = max_msg_len - cmd_size;
14038 num_entries = avail_space / per_entry_size;
14039 return num_entries;
14040}
14041
14042/**
14043 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14044 * @wmi_handle: wmi handle
14045 * @photlist: hotlist command params
14046 * @buf_len: buffer length
14047 *
14048 * This function fills individual elements for hotlist request and
14049 * TLV for bssid entries
14050 *
14051 * Return: CDF Status.
14052 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014053static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014054 struct ext_scan_setbssi_hotlist_params *
14055 photlist, int *buf_len)
14056{
14057 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14058 wmi_extscan_hotlist_entry *dest_hotlist;
14059 struct ap_threshold_params *src_ap = photlist->ap;
14060 wmi_buf_t buf;
14061 uint8_t *buf_ptr;
14062
14063 int j, index = 0;
14064 int cmd_len = 0;
14065 int num_entries;
14066 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014067 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014068 int len = sizeof(*cmd);
14069
14070 len += WMI_TLV_HDR_SIZE;
14071 cmd_len = len;
14072
14073 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14074 cmd_len,
14075 sizeof(*dest_hotlist));
14076 /* setbssid hotlist expects the bssid list
14077 * to be non zero value
14078 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014079 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014080 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014081 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014082 }
14083
14084 /* Split the hot list entry pages and send multiple command
14085 * requests if the buffer reaches the maximum request size
14086 */
14087 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014088 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014089 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14090 buf = wmi_buf_alloc(wmi_handle, len);
14091 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014092 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14093 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014094 }
14095 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14096 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14097 buf_ptr;
14098 WMITLV_SET_HDR(&cmd->tlv_header,
14099 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14100 WMITLV_GET_STRUCT_TLVLEN
14101 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14102
14103 /* Multiple requests are sent until the num_entries_in_page
14104 * matches the total_entries
14105 */
14106 cmd->request_id = photlist->requestId;
14107 cmd->vdev_id = photlist->sessionId;
14108 cmd->total_entries = numap;
14109 cmd->mode = 1;
14110 cmd->num_entries_in_page = min_entries;
14111 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14112 cmd->first_entry_index = index;
14113
Govind Singhb53420c2016-03-09 14:32:57 +053014114 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014115 __func__, cmd->vdev_id, cmd->total_entries,
14116 cmd->num_entries_in_page,
14117 cmd->lost_ap_scan_count);
14118
14119 buf_ptr += sizeof(*cmd);
14120 WMITLV_SET_HDR(buf_ptr,
14121 WMITLV_TAG_ARRAY_STRUC,
14122 min_entries * sizeof(wmi_extscan_hotlist_entry));
14123 dest_hotlist = (wmi_extscan_hotlist_entry *)
14124 (buf_ptr + WMI_TLV_HDR_SIZE);
14125
14126 /* Populate bssid, channel info and rssi
14127 * for the bssid's that are sent as hotlists.
14128 */
14129 for (j = 0; j < min_entries; j++) {
14130 WMITLV_SET_HDR(dest_hotlist,
14131 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14132 WMITLV_GET_STRUCT_TLVLEN
14133 (wmi_extscan_hotlist_entry));
14134
14135 dest_hotlist->min_rssi = src_ap->low;
14136 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14137 &dest_hotlist->bssid);
14138
Govind Singhb53420c2016-03-09 14:32:57 +053014139 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014140 __func__, dest_hotlist->channel,
14141 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014142 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014143 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14144 __func__, dest_hotlist->bssid.mac_addr31to0,
14145 dest_hotlist->bssid.mac_addr47to32);
14146 dest_hotlist++;
14147 src_ap++;
14148 }
14149 buf_ptr += WMI_TLV_HDR_SIZE +
14150 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14151
14152 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14153 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014154 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014155 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014156 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014157 }
14158 index = index + min_entries;
14159 num_entries = numap - min_entries;
14160 len = cmd_len;
14161 }
Govind Singhb53420c2016-03-09 14:32:57 +053014162 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014163}
14164
Govind Singhbca3b1b2016-05-02 17:59:24 +053014165/**
Dustin Brown4423f632017-01-13 15:24:07 -080014166 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14167 * @wmi_handle: the WMI handle
14168 * @vdev_id: the Id of the vdev to apply the configuration to
14169 * @ucast_mode: the active BPF mode to configure for unicast packets
14170 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14171 * packets
14172 *
14173 * Return: QDF status
14174 */
14175static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14176 uint8_t vdev_id,
14177 enum wmi_host_active_bpf_mode ucast_mode,
14178 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14179{
14180 const WMITLV_TAG_ID tag_id =
14181 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14182 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14183 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14184 QDF_STATUS status;
14185 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14186 wmi_buf_t buf;
14187
14188 WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
14189 vdev_id, ucast_mode, mcast_bcast_mode);
14190
14191 /* allocate command buffer */
14192 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14193 if (!buf) {
14194 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14195 return QDF_STATUS_E_NOMEM;
14196 }
14197
14198 /* set TLV header */
14199 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14200 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14201
14202 /* populate data */
14203 cmd->vdev_id = vdev_id;
14204 cmd->uc_mode = ucast_mode;
14205 cmd->mcbc_mode = mcast_bcast_mode;
14206
14207 /* send to FW */
14208 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14209 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14210 if (QDF_IS_STATUS_ERROR(status)) {
14211 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14212 status);
14213 wmi_buf_free(buf);
14214 return status;
14215 }
14216
14217 WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
14218
14219 return QDF_STATUS_SUCCESS;
14220}
14221
14222/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014223 * send_power_dbg_cmd_tlv() - send power debug commands
14224 * @wmi_handle: wmi handle
14225 * @param: wmi power debug parameter
14226 *
14227 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14228 *
14229 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14230 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014231static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14232 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014233{
14234 wmi_buf_t buf = NULL;
14235 QDF_STATUS status;
14236 int len, args_tlv_len;
14237 uint8_t *buf_ptr;
14238 uint8_t i;
14239 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14240 uint32_t *cmd_args;
14241
14242 /* Prepare and send power debug cmd parameters */
14243 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14244 len = sizeof(*cmd) + args_tlv_len;
14245 buf = wmi_buf_alloc(wmi_handle, len);
14246 if (!buf) {
14247 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14248 return QDF_STATUS_E_NOMEM;
14249 }
14250
14251 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14252 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
14253 WMITLV_SET_HDR(&cmd->tlv_header,
14254 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
14255 WMITLV_GET_STRUCT_TLVLEN
14256 (wmi_pdev_wal_power_debug_cmd_fixed_param));
14257
14258 cmd->pdev_id = param->pdev_id;
14259 cmd->module_id = param->module_id;
14260 cmd->num_args = param->num_args;
14261 buf_ptr += sizeof(*cmd);
14262 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14263 (param->num_args * sizeof(uint32_t)));
14264 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
14265 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
14266 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14267 cmd_args[i] = param->args[i];
14268 WMI_LOGI("%d,", param->args[i]);
14269 }
14270
14271 status = wmi_unified_cmd_send(wmi_handle, buf,
14272 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
14273 if (QDF_IS_STATUS_ERROR(status)) {
14274 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
14275 status);
14276 goto error;
14277 }
14278
14279 return QDF_STATUS_SUCCESS;
14280error:
14281 wmi_buf_free(buf);
14282
14283 return status;
14284}
14285
Kiran Venkatappa26117052016-12-23 19:58:54 +053014286/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
14287 * @buf_ptr: pointer to current position in init command buffer
14288 * @len: pointer to length. This will be updated with current lenght of cmd
14289 * @param: point host parameters for init command
14290 *
14291 * Return: Updated pointer of buf_ptr.
14292 */
14293static inline uint8_t *copy_hw_mode_in_init_cmd(uint8_t *buf_ptr,
14294 int *len, struct wmi_init_cmd_param *param)
14295{
14296 uint16_t idx;
14297
14298 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
14299 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
14300 wmi_pdev_band_to_mac *band_to_mac;
14301
14302 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
14303 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
14304 sizeof(wmi_resource_config) +
14305 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
14306 sizeof(wlan_host_memory_chunk)));
14307
14308 WMITLV_SET_HDR(&hw_mode->tlv_header,
14309 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
14310 (WMITLV_GET_STRUCT_TLVLEN
14311 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
14312
14313 hw_mode->hw_mode_index = param->hw_mode_id;
14314 hw_mode->num_band_to_mac = param->num_band_to_mac;
14315
14316 buf_ptr = (uint8_t *) (hw_mode + 1);
14317 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
14318 WMI_TLV_HDR_SIZE);
14319 for (idx = 0; idx < param->num_band_to_mac; idx++) {
14320 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
14321 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
14322 WMITLV_GET_STRUCT_TLVLEN
14323 (wmi_pdev_band_to_mac));
14324 band_to_mac[idx].pdev_id =
14325 param->band_to_mac[idx].pdev_id;
14326 band_to_mac[idx].start_freq =
14327 param->band_to_mac[idx].start_freq;
14328 band_to_mac[idx].end_freq =
14329 param->band_to_mac[idx].end_freq;
14330 }
14331 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14332 (param->num_band_to_mac *
14333 sizeof(wmi_pdev_band_to_mac)) +
14334 WMI_TLV_HDR_SIZE;
14335
14336 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14337 (param->num_band_to_mac *
14338 sizeof(wmi_pdev_band_to_mac)));
14339 }
14340
14341 return buf_ptr;
14342}
14343
Govind Singhe7f2f342016-05-23 12:12:52 +053014344/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014345 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
14346 * @wmi_handle: wmi handle
14347 * @param: wmi multiple vdev restart req param
14348 *
14349 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
14350 *
14351 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14352 */
14353static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
14354 wmi_unified_t wmi_handle,
14355 struct multiple_vdev_restart_params *param)
14356{
14357 wmi_buf_t buf;
14358 QDF_STATUS qdf_status;
14359 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
14360 int i;
14361 uint8_t *buf_ptr;
14362 uint32_t *vdev_ids;
14363 wmi_channel *chan_info;
14364 struct channel_param *tchan_info;
14365 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
14366
14367 len += sizeof(wmi_channel);
14368 if (param->num_vdevs)
14369 len += sizeof(uint32_t) * param->num_vdevs;
14370
14371 buf = wmi_buf_alloc(wmi_handle, len);
14372 if (!buf) {
14373 WMI_LOGE("Failed to allocate memory\n");
14374 qdf_status = QDF_STATUS_E_NOMEM;
14375 goto end;
14376 }
14377
14378 buf_ptr = (uint8_t *)wmi_buf_data(buf);
14379 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
14380 buf_ptr;
14381
14382 WMITLV_SET_HDR(&cmd->tlv_header,
14383 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
14384 WMITLV_GET_STRUCT_TLVLEN
14385 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
14386 cmd->pdev_id = param->pdev_id;
14387 cmd->requestor_id = param->requestor_id;
14388 cmd->disable_hw_ack = param->disable_hw_ack;
14389 cmd->cac_duration_ms = param->cac_duration_ms;
14390 cmd->num_vdevs = param->num_vdevs;
14391
14392 buf_ptr += sizeof(*cmd);
14393
14394 WMITLV_SET_HDR(buf_ptr,
14395 WMITLV_TAG_ARRAY_UINT32,
14396 sizeof(A_UINT32) * param->num_vdevs);
14397 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
14398 for (i = 0; i < param->num_vdevs; i++) {
14399 vdev_ids[i] = param->vdev_ids[i];
14400 }
14401
14402 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
14403
14404 WMITLV_SET_HDR(buf_ptr,
14405 WMITLV_TAG_STRUC_wmi_channel,
14406 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053014407 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053014408 tchan_info = &(param->ch_param);
14409 chan_info->mhz = tchan_info->mhz;
14410 chan_info->band_center_freq1 = tchan_info->cfreq1;
14411 chan_info->band_center_freq2 = tchan_info->cfreq2;
14412 if (tchan_info->is_chan_passive)
14413 WMI_SET_CHANNEL_FLAG(chan_info,
14414 WMI_CHAN_FLAG_PASSIVE);
14415 if (tchan_info->allow_vht)
14416 WMI_SET_CHANNEL_FLAG(chan_info,
14417 WMI_CHAN_FLAG_ALLOW_VHT);
14418 else if (tchan_info->allow_ht)
14419 WMI_SET_CHANNEL_FLAG(chan_info,
14420 WMI_CHAN_FLAG_ALLOW_HT);
14421 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
14422 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
14423 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
14424 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
14425 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
14426 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
14427
14428 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
14429 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
14430
14431 if (QDF_IS_STATUS_ERROR(qdf_status)) {
14432 WMI_LOGE("%s: Failed to send\n", __func__);
14433 wmi_buf_free(buf);
14434 }
14435
14436end:
14437 return qdf_status;
14438}
14439
14440/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080014441 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
14442 * @wmi_handle: wmi handle
14443 * @pdev_id: pdev id
14444 *
14445 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
14446 *
14447 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14448 */
14449static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
14450 uint32_t pdev_id)
14451{
14452 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
14453 wmi_buf_t buf;
14454 uint16_t len;
14455 QDF_STATUS ret;
14456
14457 len = sizeof(*cmd);
14458 buf = wmi_buf_alloc(wmi_handle, len);
14459
14460 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
14461
14462 if (!buf) {
14463 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14464 return QDF_STATUS_E_NOMEM;
14465 }
14466
14467 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
14468 wmi_buf_data(buf);
14469
14470 WMITLV_SET_HDR(&cmd->tlv_header,
14471 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
14472 WMITLV_GET_STRUCT_TLVLEN(
14473 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
14474
14475 cmd->pdev_id = pdev_id;
14476 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14477 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
14478 if (QDF_IS_STATUS_ERROR(ret)) {
14479 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
14480 __func__, ret, pdev_id);
14481 wmi_buf_free(buf);
14482 return QDF_STATUS_E_FAILURE;
14483 }
14484
14485 return QDF_STATUS_SUCCESS;
14486}
14487
14488/**
14489 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
14490 * @wmi_handle: wmi handle
14491 * @pdev_id: pdev id
14492 *
14493 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
14494 *
14495 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14496 */
14497static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
14498 uint32_t pdev_id)
14499{
14500 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
14501 wmi_buf_t buf;
14502 uint16_t len;
14503 QDF_STATUS ret;
14504
14505 len = sizeof(*cmd);
14506 buf = wmi_buf_alloc(wmi_handle, len);
14507
14508 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
14509
14510 if (!buf) {
14511 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14512 return QDF_STATUS_E_NOMEM;
14513 }
14514
14515 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
14516 wmi_buf_data(buf);
14517
14518 WMITLV_SET_HDR(&cmd->tlv_header,
14519 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
14520 WMITLV_GET_STRUCT_TLVLEN(
14521 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
14522
14523 cmd->pdev_id = pdev_id;
14524 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14525 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
14526 if (QDF_IS_STATUS_ERROR(ret)) {
14527 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
14528 __func__, ret, pdev_id);
14529 wmi_buf_free(buf);
14530 return QDF_STATUS_E_FAILURE;
14531 }
14532
14533 return QDF_STATUS_SUCCESS;
14534}
14535
14536/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014537 * init_cmd_send_tlv() - send initialization cmd to fw
14538 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014539 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053014540 *
14541 * Return: QDF_STATUS_SUCCESS for success or error code
14542 */
14543static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053014544 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053014545{
14546 wmi_buf_t buf;
14547 wmi_init_cmd_fixed_param *cmd;
14548 wmi_abi_version my_vers;
14549 int num_whitelist;
14550 uint8_t *buf_ptr;
14551 wmi_resource_config *resource_cfg;
14552 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053014553 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053014554 uint16_t idx;
14555 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053014556 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053014557
Kiran Venkatappa26117052016-12-23 19:58:54 +053014558 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
14559 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053014560 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053014561
14562 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
14563 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14564 WMI_TLV_HDR_SIZE +
14565 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
14566
14567 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053014568 if (!buf) {
14569 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14570 return QDF_STATUS_E_FAILURE;
14571 }
14572
14573 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14574 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
14575 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
14576
14577 host_mem_chunks = (wlan_host_memory_chunk *)
14578 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
14579 + WMI_TLV_HDR_SIZE);
14580
14581 WMITLV_SET_HDR(&cmd->tlv_header,
14582 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
14583 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
14584
Kiran Venkatappa26117052016-12-23 19:58:54 +053014585 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053014586 WMITLV_SET_HDR(&resource_cfg->tlv_header,
14587 WMITLV_TAG_STRUC_wmi_resource_config,
14588 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
14589
Kiran Venkatappa26117052016-12-23 19:58:54 +053014590 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053014591 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
14592 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
14593 WMITLV_GET_STRUCT_TLVLEN
14594 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053014595 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
14596 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
14597 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014598 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
14599 idx, host_mem_chunks[idx].size,
14600 host_mem_chunks[idx].ptr);
14601 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053014602 cmd->num_host_mem_chunks = param->num_mem_chunks;
14603 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
14604
Govind Singhe7f2f342016-05-23 12:12:52 +053014605 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
14606 WMITLV_TAG_ARRAY_STRUC,
14607 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053014608 param->num_mem_chunks));
14609
14610 /* Fill hw mode id config */
14611 buf_ptr = copy_hw_mode_in_init_cmd(buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053014612
14613 num_whitelist = sizeof(version_whitelist) /
14614 sizeof(wmi_whitelist_version_info);
14615 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
14616 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
14617 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
14618 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
14619 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
14620 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
14621
Govind Singh87542482016-06-08 19:40:11 +053014622#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014623 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
14624 &my_vers,
14625 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
14626 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053014627#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053014628 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
14629 __func__,
14630 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
14631 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
14632 cmd->host_abi_vers.abi_version_ns_0,
14633 cmd->host_abi_vers.abi_version_ns_1,
14634 cmd->host_abi_vers.abi_version_ns_2,
14635 cmd->host_abi_vers.abi_version_ns_3);
14636
14637 /* Save version sent from host -
14638 * Will be used to check ready event
14639 */
Govind Singh87542482016-06-08 19:40:11 +053014640#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014641 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
14642 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053014643#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053014644 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
14645 if (QDF_IS_STATUS_ERROR(ret)) {
14646 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
14647 ret);
14648 wmi_buf_free(buf);
14649 }
14650 return ret;
14651
Govind Singhe7f2f342016-05-23 12:12:52 +053014652}
14653
14654/**
14655 * save_service_bitmap_tlv() - save service bitmap
14656 * @wmi_handle: wmi handle
14657 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080014658 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053014659 *
14660 * Return: None
14661 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014662#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014663static
Rajeev Kumar77901472017-02-12 02:12:17 -080014664void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
14665 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053014666{
14667 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14668 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14669
14670 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
14671 param_buf->wmi_service_bitmap,
14672 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080014673
14674 if (bitmap_buf)
14675 qdf_mem_copy(bitmap_buf,
14676 param_buf->wmi_service_bitmap,
14677 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053014678}
14679#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014680static
Rajeev Kumar77901472017-02-12 02:12:17 -080014681void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
14682 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053014683{
Rajeev Kumar77901472017-02-12 02:12:17 -080014684 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14685 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053014686
Rajeev Kumar77901472017-02-12 02:12:17 -080014687 if (bitmap_buf)
14688 qdf_mem_copy(bitmap_buf,
14689 param_buf->wmi_service_bitmap,
14690 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
14691}
Govind Singhe7f2f342016-05-23 12:12:52 +053014692#endif
14693
14694/**
14695 * is_service_enabled_tlv() - Check if service enabled
14696 * @param wmi_handle: wmi handle
14697 * @param service_id: service identifier
14698 *
14699 * Return: 1 enabled, 0 disabled
14700 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053014701#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014702static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
14703 uint32_t service_id)
14704{
14705 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
14706 service_id);
14707}
14708#else
14709static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
14710 uint32_t service_id)
14711{
14712 return false;
14713}
14714#endif
14715
14716/**
14717 * extract_service_ready_tlv() - extract service ready event
14718 * @wmi_handle: wmi handle
14719 * @param evt_buf: pointer to received event buffer
14720 * @param cap: pointer to hold target capability information extracted from even
14721 *
14722 * Return: QDF_STATUS_SUCCESS for success or error code
14723 */
14724static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014725 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053014726{
14727 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14728 wmi_service_ready_event_fixed_param *ev;
14729
14730
14731 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14732
14733 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14734 if (!ev) {
14735 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14736 return QDF_STATUS_E_FAILURE;
14737 }
14738
14739 cap->phy_capability = ev->phy_capability;
14740 cap->max_frag_entry = ev->max_frag_entry;
14741 cap->num_rf_chains = ev->num_rf_chains;
14742 cap->ht_cap_info = ev->ht_cap_info;
14743 cap->vht_cap_info = ev->vht_cap_info;
14744 cap->vht_supp_mcs = ev->vht_supp_mcs;
14745 cap->hw_min_tx_power = ev->hw_min_tx_power;
14746 cap->hw_max_tx_power = ev->hw_max_tx_power;
14747 cap->sys_cap_info = ev->sys_cap_info;
14748 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
14749 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
14750 cap->max_num_scan_channels = ev->max_num_scan_channels;
14751 cap->max_supported_macs = ev->max_supported_macs;
14752 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
14753 cap->txrx_chainmask = ev->txrx_chainmask;
14754 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
14755 cap->num_msdu_desc = ev->num_msdu_desc;
14756
14757 return QDF_STATUS_SUCCESS;
14758}
14759
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014760/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
14761 * to host internal WMI_HOST_REGDMN_MODE values.
14762 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
14763 * host currently. Add this in the future if required.
14764 * 11AX (Phase II) : 11ax related values are not currently
14765 * advertised separately by FW. As part of phase II regulatory bring-up,
14766 * finalize the advertisement mechanism.
14767 * @target_wireless_mode: target wireless mode received in message
14768 *
14769 * Return: returns the host internal wireless mode.
14770 */
14771static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
14772{
14773
14774 uint32_t wireless_modes = 0;
14775
14776 if (target_wireless_mode & REGDMN_MODE_11A)
14777 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
14778
14779 if (target_wireless_mode & REGDMN_MODE_TURBO)
14780 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
14781
14782 if (target_wireless_mode & REGDMN_MODE_11B)
14783 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
14784
14785 if (target_wireless_mode & REGDMN_MODE_PUREG)
14786 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
14787
14788 if (target_wireless_mode & REGDMN_MODE_11G)
14789 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
14790
14791 if (target_wireless_mode & REGDMN_MODE_108G)
14792 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
14793
14794 if (target_wireless_mode & REGDMN_MODE_108A)
14795 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
14796
14797 if (target_wireless_mode & REGDMN_MODE_XR)
14798 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
14799
14800 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
14801 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
14802
14803 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
14804 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
14805
14806 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
14807 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
14808
14809 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
14810 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
14811
14812 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
14813 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
14814
14815 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
14816 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
14817
14818 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
14819 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
14820
14821 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
14822 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
14823
14824 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
14825 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
14826
14827 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
14828 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
14829
14830 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
14831 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
14832
14833 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
14834 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
14835
14836 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
14837 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
14838
14839 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
14840 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
14841
14842 return wireless_modes;
14843}
14844
Govind Singhe7f2f342016-05-23 12:12:52 +053014845/**
14846 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
14847 * @wmi_handle: wmi handle
14848 * @param evt_buf: Pointer to event buffer
14849 * @param cap: pointer to hold HAL reg capabilities
14850 *
14851 * Return: QDF_STATUS_SUCCESS for success or error code
14852 */
14853static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080014854 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053014855{
14856 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14857
14858 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14859
14860 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
14861 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080014862 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053014863
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053014864 cap->wireless_modes = convert_wireless_modes_tlv(
14865 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053014866
Govind Singhe7f2f342016-05-23 12:12:52 +053014867 return QDF_STATUS_SUCCESS;
14868}
14869
14870/**
14871 * extract_host_mem_req_tlv() - Extract host memory request event
14872 * @wmi_handle: wmi handle
14873 * @param evt_buf: pointer to event buffer
14874 * @param num_entries: pointer to hold number of entries requested
14875 *
14876 * Return: Number of entries requested
14877 */
14878static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
14879 void *evt_buf, uint8_t *num_entries)
14880{
14881 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14882 wmi_service_ready_event_fixed_param *ev;
14883
14884 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14885
14886 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14887 if (!ev) {
14888 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14889 return NULL;
14890 }
14891
14892 *num_entries = ev->num_mem_reqs;
14893
14894 return (host_mem_req *)param_buf->mem_reqs;
14895}
14896
14897/**
14898 * save_fw_version_in_service_ready_tlv() - Save fw version in service
14899 * ready function
14900 * @wmi_handle: wmi handle
14901 * @param evt_buf: pointer to event buffer
14902 *
14903 * Return: QDF_STATUS_SUCCESS for success or error code
14904 */
14905static QDF_STATUS
14906save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
14907{
14908 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
14909 wmi_service_ready_event_fixed_param *ev;
14910
14911
14912 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
14913
14914 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
14915 if (!ev) {
14916 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14917 return QDF_STATUS_E_FAILURE;
14918 }
14919
Govind Singh87542482016-06-08 19:40:11 +053014920#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014921 /*Save fw version from service ready message */
14922 /*This will be used while sending INIT message */
14923 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
14924 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053014925#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053014926 return QDF_STATUS_SUCCESS;
14927}
14928
14929/**
14930 * ready_extract_init_status_tlv() - Extract init status from ready event
14931 * @wmi_handle: wmi handle
14932 * @param evt_buf: Pointer to event buffer
14933 *
14934 * Return: ready status
14935 */
14936static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
14937 void *evt_buf)
14938{
14939 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
14940 wmi_ready_event_fixed_param *ev = NULL;
14941
14942
14943 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
14944 ev = param_buf->fixed_param;
14945
14946 qdf_print("%s:%d\n", __func__, ev->status);
14947
14948 return ev->status;
14949}
14950
14951/**
14952 * ready_extract_mac_addr_tlv() - extract mac address from ready event
14953 * @wmi_handle: wmi handle
14954 * @param evt_buf: pointer to event buffer
14955 * @param macaddr: Pointer to hold MAC address
14956 *
14957 * Return: QDF_STATUS_SUCCESS for success or error code
14958 */
14959static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
14960 void *evt_buf, uint8_t *macaddr)
14961{
14962 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
14963 wmi_ready_event_fixed_param *ev = NULL;
14964
14965
14966 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
14967 ev = param_buf->fixed_param;
14968
14969 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
14970
14971 return QDF_STATUS_SUCCESS;
14972}
14973
14974/**
14975 * extract_dbglog_data_len_tlv() - extract debuglog data length
14976 * @wmi_handle: wmi handle
14977 * @param evt_buf: pointer to event buffer
14978 *
14979 * Return: length
14980 */
14981static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080014982 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053014983{
14984 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
14985
14986 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
14987
14988 *len = param_buf->num_bufp;
14989
14990 return param_buf->bufp;
14991}
14992
14993/**
14994 * extract_vdev_start_resp_tlv() - extract vdev start response
14995 * @wmi_handle: wmi handle
14996 * @param evt_buf: pointer to event buffer
14997 * @param vdev_rsp: Pointer to hold vdev response
14998 *
14999 * Return: QDF_STATUS_SUCCESS for success or error code
15000 */
15001static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15002 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15003{
15004 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15005 wmi_vdev_start_response_event_fixed_param *ev;
15006
15007 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15008 if (!param_buf) {
15009 qdf_print("Invalid start response event buffer\n");
15010 return QDF_STATUS_E_INVAL;
15011 }
15012
15013 ev = param_buf->fixed_param;
15014 if (!ev) {
15015 qdf_print("Invalid start response event buffer\n");
15016 return QDF_STATUS_E_INVAL;
15017 }
15018
15019 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15020
15021 vdev_rsp->vdev_id = ev->vdev_id;
15022 vdev_rsp->requestor_id = ev->requestor_id;
15023 vdev_rsp->resp_type = ev->resp_type;
15024 vdev_rsp->status = ev->status;
15025 vdev_rsp->chain_mask = ev->chain_mask;
15026 vdev_rsp->smps_mode = ev->smps_mode;
15027 vdev_rsp->mac_id = ev->mac_id;
15028 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15029 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15030
15031 return QDF_STATUS_SUCCESS;
15032}
15033
15034/**
15035 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
15036 * @wmi_handle: wmi handle
15037 * @param evt_buf: pointer to event buffer
15038 * @param vdev_map: Pointer to hold vdev map
15039 * @param tbttoffset_list: Pointer to tbtt offset list
15040 *
15041 * Return: QDF_STATUS_SUCCESS for success or error code
15042 */
15043static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
15044 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
15045{
15046 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15047 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15048
15049 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15050 if (!param_buf) {
15051 qdf_print("Invalid tbtt update event buffer\n");
15052 return QDF_STATUS_E_INVAL;
15053 }
15054 tbtt_offset_event = param_buf->fixed_param;
15055
15056 *vdev_map = tbtt_offset_event->vdev_map;
15057 *tbttoffset_list = param_buf->tbttoffset_list;
15058
15059 return QDF_STATUS_SUCCESS;
15060}
15061
15062/**
15063 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15064 * @wmi_handle: wmi handle
15065 * @param evt_buf: pointer to event buffer
15066 * @param hdr: Pointer to hold header
15067 * @param bufp: Pointer to hold pointer to rx param buffer
15068 *
15069 * Return: QDF_STATUS_SUCCESS for success or error code
15070 */
15071static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015072 void *evt_buf, struct mgmt_rx_event_params *hdr,
15073 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015074{
15075 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15076 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15077
15078 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15079 if (!param_tlvs) {
15080 WMI_LOGE("Get NULL point message from FW");
15081 return QDF_STATUS_E_INVAL;
15082 }
15083
15084 ev_hdr = param_tlvs->hdr;
15085 if (!hdr) {
15086 WMI_LOGE("Rx event is NULL");
15087 return QDF_STATUS_E_INVAL;
15088 }
15089
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053015090 hdr->pdev_id = ev_hdr->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053015091
15092 hdr->channel = ev_hdr->channel;
15093 hdr->snr = ev_hdr->snr;
15094 hdr->rate = ev_hdr->rate;
15095 hdr->phy_mode = ev_hdr->phy_mode;
15096 hdr->buf_len = ev_hdr->buf_len;
15097 hdr->status = ev_hdr->status;
15098 hdr->flags = ev_hdr->flags;
15099 hdr->rssi = ev_hdr->rssi;
15100 hdr->tsf_delta = ev_hdr->tsf_delta;
15101 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15102
15103 *bufp = param_tlvs->bufp;
15104
15105 return QDF_STATUS_SUCCESS;
15106}
15107
15108/**
15109 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15110 * @wmi_handle: wmi handle
15111 * @param evt_buf: pointer to event buffer
15112 * @param vdev_id: Pointer to hold vdev identifier
15113 *
15114 * Return: QDF_STATUS_SUCCESS for success or error code
15115 */
15116static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15117 void *evt_buf, uint32_t *vdev_id)
15118{
15119 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15120 wmi_vdev_stopped_event_fixed_param *resp_event;
15121
15122 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15123 if (!param_buf) {
15124 WMI_LOGE("Invalid event buffer");
15125 return QDF_STATUS_E_INVAL;
15126 }
15127 resp_event = param_buf->fixed_param;
15128 *vdev_id = resp_event->vdev_id;
15129
15130 return QDF_STATUS_SUCCESS;
15131}
15132
15133/**
15134 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
15135 * @wmi_handle: wmi handle
15136 * @param evt_buf: pointer to event buffer
15137 * @param param: Pointer to hold roam param
15138 *
15139 * Return: QDF_STATUS_SUCCESS for success or error code
15140 */
15141static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
15142 void *evt_buf, wmi_host_roam_event *param)
15143{
15144 WMI_ROAM_EVENTID_param_tlvs *param_buf;
15145 wmi_roam_event_fixed_param *evt;
15146
15147 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
15148 if (!param_buf) {
15149 WMI_LOGE("Invalid roam event buffer");
15150 return QDF_STATUS_E_INVAL;
15151 }
15152
15153 evt = param_buf->fixed_param;
15154 qdf_mem_zero(param, sizeof(*param));
15155
15156 param->vdev_id = evt->vdev_id;
15157 param->reason = evt->reason;
15158 param->rssi = evt->rssi;
15159
15160 return QDF_STATUS_SUCCESS;
15161}
15162
15163/**
15164 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
15165 * @wmi_handle: wmi handle
15166 * @param evt_buf: pointer to event buffer
15167 * @param param: Pointer to hold vdev scan param
15168 *
15169 * Return: QDF_STATUS_SUCCESS for success or error code
15170 */
15171static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015172 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015173{
15174 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
15175 wmi_scan_event_fixed_param *evt = NULL;
15176
15177 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
15178 evt = param_buf->fixed_param;
15179
15180 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015181
Govind Singhe7f2f342016-05-23 12:12:52 +053015182 switch (evt->event) {
15183 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015184 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015185 break;
15186 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015187 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015188 break;
15189 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015190 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015191 break;
15192 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015193 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015194 break;
15195 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015196 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015197 break;
15198 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015199 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015200 break;
15201 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015202 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015203 break;
15204 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015205 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015206 break;
15207 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015208 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015209 break;
15210 case WMI_SCAN_EVENT_MAX:
15211 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015212 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015213 break;
15214 };
15215
15216 switch (evt->reason) {
15217 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015218 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015219 break;
15220 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015221 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015222 break;
15223 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015224 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015225 break;
15226 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015227 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015228 break;
15229 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015230 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015231 break;
15232 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015233 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015234 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015235 case WMI_SCAN_REASON_SUSPENDED:
15236 param->reason = SCAN_REASON_SUSPENDED;
15237 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015238 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015239 param->reason = SCAN_REASON_MAX;
15240 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015241 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015242 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015243 break;
15244 };
15245
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015246 param->chan_freq = evt->channel_freq;
15247 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053015248 param->scan_id = evt->scan_id;
15249 param->vdev_id = evt->vdev_id;
15250
15251 return QDF_STATUS_SUCCESS;
15252}
15253
15254/**
15255 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
15256 * @wmi_handle: wmi handle
15257 * @param evt_buf: pointer to event buffer
15258 * @param param: Pointer to hold MGMT TX completion params
15259 *
15260 * Return: QDF_STATUS_SUCCESS for success or error code
15261 */
15262static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
15263 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
15264{
15265 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
15266 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
15267
15268 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
15269 evt_buf;
15270 if (!param_buf) {
15271 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
15272 return QDF_STATUS_E_INVAL;
15273 }
15274 cmpl_params = param_buf->fixed_param;
15275
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053015276 param->pdev_id = cmpl_params->pdev_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053015277 param->desc_id = cmpl_params->desc_id;
15278 param->status = cmpl_params->status;
15279
15280 return QDF_STATUS_SUCCESS;
15281}
15282
15283/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015284 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
15285 * status tlv
15286 * @wmi_handle: wmi handle
15287 * @param evt_buf: pointer to event buffer
15288 * @param param: Pointer to hold csa switch count status event param
15289 *
15290 * Return: QDF_STATUS_SUCCESS for success or error code
15291 */
15292static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
15293 wmi_unified_t wmi_handle,
15294 void *evt_buf,
15295 struct pdev_csa_switch_count_status *param)
15296{
15297 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
15298 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
15299
15300 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
15301 evt_buf;
15302 if (!param_buf) {
15303 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
15304 return QDF_STATUS_E_INVAL;
15305 }
15306
15307 csa_status = param_buf->fixed_param;
15308
15309 param->pdev_id = csa_status->pdev_id;
15310 param->current_switch_count = csa_status->current_switch_count;
15311 param->num_vdevs = csa_status->num_vdevs;
15312 param->vdev_ids = param_buf->vdev_ids;
15313
15314 return QDF_STATUS_SUCCESS;
15315}
15316
15317/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015318 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
15319 * @wmi_handle: wmi handle
15320 * @param evt_buf: pointer to event buffer
15321 * @param vdev_map: Pointer to hold vdev map
15322 *
15323 * Return: QDF_STATUS_SUCCESS for success or error code
15324 */
15325static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
15326 void *evt_buf, uint32_t *vdev_map)
15327{
15328 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15329 wmi_host_swba_event_fixed_param *swba_event;
15330
15331 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15332 if (!param_buf) {
15333 WMI_LOGE("Invalid swba event buffer");
15334 return QDF_STATUS_E_INVAL;
15335 }
15336 swba_event = param_buf->fixed_param;
15337 *vdev_map = swba_event->vdev_map;
15338
15339 return QDF_STATUS_SUCCESS;
15340}
15341
15342/**
15343 * extract_swba_tim_info_tlv() - extract swba tim info from event
15344 * @wmi_handle: wmi handle
15345 * @param evt_buf: pointer to event buffer
15346 * @param idx: Index to bcn info
15347 * @param tim_info: Pointer to hold tim info
15348 *
15349 * Return: QDF_STATUS_SUCCESS for success or error code
15350 */
15351static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
15352 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
15353{
15354 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15355 wmi_tim_info *tim_info_ev;
15356
15357 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15358 if (!param_buf) {
15359 WMI_LOGE("Invalid swba event buffer");
15360 return QDF_STATUS_E_INVAL;
15361 }
15362
15363 tim_info_ev = &param_buf->tim_info[idx];
15364
15365 tim_info->tim_len = tim_info_ev->tim_len;
15366 tim_info->tim_mcast = tim_info_ev->tim_mcast;
15367 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
15368 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
15369 tim_info->tim_changed = tim_info_ev->tim_changed;
15370 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
15371
15372 return QDF_STATUS_SUCCESS;
15373}
15374
15375/**
15376 * extract_swba_noa_info_tlv() - extract swba NoA information from event
15377 * @wmi_handle: wmi handle
15378 * @param evt_buf: pointer to event buffer
15379 * @param idx: Index to bcn info
15380 * @param p2p_desc: Pointer to hold p2p NoA info
15381 *
15382 * Return: QDF_STATUS_SUCCESS for success or error code
15383 */
15384static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
15385 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
15386{
15387 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15388 wmi_p2p_noa_info *p2p_noa_info;
15389 uint8_t i = 0;
15390
15391 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15392 if (!param_buf) {
15393 WMI_LOGE("Invalid swba event buffer");
15394 return QDF_STATUS_E_INVAL;
15395 }
15396
15397 p2p_noa_info = &param_buf->p2p_noa_info[idx];
15398
15399 p2p_desc->modified = false;
15400 p2p_desc->num_descriptors = 0;
15401 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
15402 p2p_desc->modified = true;
15403 p2p_desc->index =
15404 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
15405 p2p_desc->oppPS =
15406 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
15407 p2p_desc->ctwindow =
15408 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
15409 p2p_desc->num_descriptors =
15410 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
15411 (p2p_noa_info);
15412 for (i = 0; i < p2p_desc->num_descriptors; i++) {
15413 p2p_desc->noa_descriptors[i].type_count =
15414 (uint8_t) p2p_noa_info->noa_descriptors[i].
15415 type_count;
15416 p2p_desc->noa_descriptors[i].duration =
15417 p2p_noa_info->noa_descriptors[i].duration;
15418 p2p_desc->noa_descriptors[i].interval =
15419 p2p_noa_info->noa_descriptors[i].interval;
15420 p2p_desc->noa_descriptors[i].start_time =
15421 p2p_noa_info->noa_descriptors[i].start_time;
15422 }
15423 }
15424
15425 return QDF_STATUS_SUCCESS;
15426}
15427
Wu Gaocd3a8512017-03-13 20:17:34 +080015428#ifdef CONVERGED_P2P_ENABLE
15429/**
15430 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
15431 * @wmi_handle: wmi handle
15432 * @param evt_buf: pointer to event buffer
15433 * @param param: Pointer to hold p2p noa info
15434 *
15435 * Return: QDF_STATUS_SUCCESS for success or error code
15436 */
15437static QDF_STATUS extract_p2p_noa_ev_param_tlv(
15438 wmi_unified_t wmi_handle, void *evt_buf,
15439 struct p2p_noa_info *param)
15440{
15441 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
15442 wmi_p2p_noa_event_fixed_param *fixed_param;
15443 uint8_t i;
15444 wmi_p2p_noa_info *wmi_noa_info;
15445 uint8_t *buf_ptr;
15446 uint32_t descriptors;
15447
15448 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
15449 if (!param_tlvs) {
15450 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
15451 return QDF_STATUS_E_INVAL;
15452 }
15453
15454 if (!param) {
15455 WMI_LOGE("noa information param is null");
15456 return QDF_STATUS_E_INVAL;
15457 }
15458
15459 fixed_param = param_tlvs->fixed_param;
15460 buf_ptr = (uint8_t *) fixed_param;
15461 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
15462 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
15463
15464 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
15465 WMI_LOGE("%s: noa attr is not modified", __func__);
15466 return QDF_STATUS_E_INVAL;
15467 }
15468
15469 param->vdev_id = fixed_param->vdev_id;
15470 param->index =
15471 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
15472 param->opps_ps =
15473 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
15474 param->ct_window =
15475 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
15476 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
15477 param->num_desc = (uint8_t) descriptors;
15478
15479 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
15480 param->index, param->opps_ps, param->ct_window,
15481 param->num_desc);
15482 for (i = 0; i < param->num_desc; i++) {
15483 param->noa_desc[i].type_count =
15484 (uint8_t) wmi_noa_info->noa_descriptors[i].
15485 type_count;
15486 param->noa_desc[i].duration =
15487 wmi_noa_info->noa_descriptors[i].duration;
15488 param->noa_desc[i].interval =
15489 wmi_noa_info->noa_descriptors[i].interval;
15490 param->noa_desc[i].start_time =
15491 wmi_noa_info->noa_descriptors[i].start_time;
15492 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
15493 __func__, i, param->noa_desc[i].type_count,
15494 param->noa_desc[i].duration,
15495 param->noa_desc[i].interval,
15496 param->noa_desc[i].start_time);
15497 }
15498
15499 return QDF_STATUS_SUCCESS;
15500}
15501
15502/**
15503 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
15504 * information from event
15505 * @wmi_handle: wmi handle
15506 * @param evt_buf: pointer to event buffer
15507 * @param param: Pointer to hold p2p lo stop event information
15508 *
15509 * Return: QDF_STATUS_SUCCESS for success or error code
15510 */
15511static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
15512 wmi_unified_t wmi_handle, void *evt_buf,
15513 struct p2p_lo_event *param)
15514{
15515 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
15516 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
15517
15518 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
15519 evt_buf;
15520 if (!param_tlvs) {
15521 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
15522 return QDF_STATUS_E_INVAL;
15523 }
15524
15525 if (!param) {
15526 WMI_LOGE("lo stop event param is null");
15527 return QDF_STATUS_E_INVAL;
15528 }
15529
15530 lo_param = param_tlvs->fixed_param;
15531 param->vdev_id = lo_param->vdev_id;
15532 param->reason_code = lo_param->reason;
15533 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
15534 param->vdev_id, param->reason_code);
15535
15536 return QDF_STATUS_SUCCESS;
15537}
15538#endif /* End of CONVERGED_P2P_ENABLE */
15539
Govind Singhe7f2f342016-05-23 12:12:52 +053015540/**
15541 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
15542 * @wmi_handle: wmi handle
15543 * @param evt_buf: pointer to event buffer
15544 * @param ev: Pointer to hold peer param
15545 *
15546 * Return: QDF_STATUS_SUCCESS for success or error code
15547 */
15548static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
15549 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
15550{
15551 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
15552 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
15553
15554 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
15555 kickout_event = param_buf->fixed_param;
15556
15557 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
15558 ev->peer_macaddr);
15559
15560 ev->reason = kickout_event->reason;
15561 ev->rssi = kickout_event->rssi;
15562
15563 return QDF_STATUS_SUCCESS;
15564}
15565
15566/**
15567 * extract_all_stats_counts_tlv() - extract all stats count from event
15568 * @wmi_handle: wmi handle
15569 * @param evt_buf: pointer to event buffer
15570 * @param stats_param: Pointer to hold stats count
15571 *
15572 * Return: QDF_STATUS_SUCCESS for success or error code
15573 */
15574static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
15575 void *evt_buf, wmi_host_stats_event *stats_param)
15576{
15577 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15578 wmi_stats_event_fixed_param *ev;
15579
15580 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15581
15582 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15583 if (!ev) {
15584 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
15585 return QDF_STATUS_E_FAILURE;
15586 }
15587
15588 switch (ev->stats_id) {
15589 case WMI_REQUEST_PEER_STAT:
15590 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
15591 break;
15592
15593 case WMI_REQUEST_AP_STAT:
15594 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
15595 break;
15596
15597 case WMI_REQUEST_PDEV_STAT:
15598 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
15599 break;
15600
15601 case WMI_REQUEST_VDEV_STAT:
15602 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
15603 break;
15604
15605 case WMI_REQUEST_BCNFLT_STAT:
15606 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
15607 break;
15608
15609 case WMI_REQUEST_VDEV_RATE_STAT:
15610 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
15611 break;
15612
15613 default:
15614 stats_param->stats_id = 0;
15615 break;
15616
15617 }
15618
15619 stats_param->num_pdev_stats = ev->num_pdev_stats;
15620 stats_param->num_pdev_ext_stats = 0;
15621 stats_param->num_vdev_stats = ev->num_vdev_stats;
15622 stats_param->num_peer_stats = ev->num_peer_stats;
15623 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
15624 stats_param->num_chan_stats = ev->num_chan_stats;
15625
15626 return QDF_STATUS_SUCCESS;
15627}
15628
15629/**
15630 * extract_pdev_stats_tlv() - extract pdev stats from event
15631 * @wmi_handle: wmi handle
15632 * @param evt_buf: pointer to event buffer
15633 * @param index: Index into pdev stats
15634 * @param pdev_stats: Pointer to hold pdev stats
15635 *
15636 * Return: QDF_STATUS_SUCCESS for success or error code
15637 */
15638static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
15639 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
15640{
15641 return QDF_STATUS_SUCCESS;
15642}
15643
15644/**
15645 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
15646 * @wmi_handle: wmi handle
15647 * @param evt_buf: pointer to event buffer
15648 * @param index: Index into extended pdev stats
15649 * @param pdev_ext_stats: Pointer to hold extended pdev stats
15650 *
15651 * Return: QDF_STATUS_SUCCESS for success or error code
15652 */
15653static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
15654 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
15655{
15656 return QDF_STATUS_SUCCESS;
15657}
15658
15659/**
15660 * extract_vdev_stats_tlv() - extract vdev stats from event
15661 * @wmi_handle: wmi handle
15662 * @param evt_buf: pointer to event buffer
15663 * @param index: Index into vdev stats
15664 * @param vdev_stats: Pointer to hold vdev stats
15665 *
15666 * Return: QDF_STATUS_SUCCESS for success or error code
15667 */
15668static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
15669 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
15670{
15671 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15672 wmi_stats_event_fixed_param *ev_param;
15673 uint8_t *data;
15674
15675 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15676 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15677 data = (uint8_t *) param_buf->data;
15678
15679 if (index < ev_param->num_vdev_stats) {
15680 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
15681 ((ev_param->num_pdev_stats) *
15682 sizeof(wmi_pdev_stats)) +
15683 (index * sizeof(wmi_vdev_stats)));
15684
15685 vdev_stats->vdev_id = ev->vdev_id;
15686 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
15687 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
15688
15689 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
15690 sizeof(ev->tx_frm_cnt));
15691 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
15692 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
15693 ev->multiple_retry_cnt,
15694 sizeof(ev->multiple_retry_cnt));
15695 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
15696 sizeof(ev->fail_cnt));
15697 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
15698 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
15699 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
15700 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
15701 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
15702 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
15703 sizeof(ev->tx_rate_history));
15704 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
15705 sizeof(ev->bcn_rssi_history));
15706
15707 }
15708
15709 return QDF_STATUS_SUCCESS;
15710}
15711
15712/**
15713 * extract_peer_stats_tlv() - extract peer stats from event
15714 * @wmi_handle: wmi handle
15715 * @param evt_buf: pointer to event buffer
15716 * @param index: Index into peer stats
15717 * @param peer_stats: Pointer to hold peer stats
15718 *
15719 * Return: QDF_STATUS_SUCCESS for success or error code
15720 */
15721static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
15722 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
15723{
15724 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15725 wmi_stats_event_fixed_param *ev_param;
15726 uint8_t *data;
15727
15728 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15729 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15730 data = (uint8_t *) param_buf->data;
15731
15732 if (index < ev_param->num_peer_stats) {
15733 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
15734 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
15735 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
15736 (index * sizeof(wmi_peer_stats)));
15737
15738 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
15739
15740 OS_MEMCPY(&(peer_stats->peer_macaddr),
15741 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
15742
15743 peer_stats->peer_rssi = ev->peer_rssi;
15744 peer_stats->peer_tx_rate = ev->peer_tx_rate;
15745 peer_stats->peer_rx_rate = ev->peer_rx_rate;
15746 }
15747
15748 return QDF_STATUS_SUCCESS;
15749}
15750
15751/**
15752 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
15753 * @wmi_handle: wmi handle
15754 * @param evt_buf: pointer to event buffer
15755 * @param index: Index into bcn fault stats
15756 * @param bcnflt_stats: Pointer to hold bcn fault stats
15757 *
15758 * Return: QDF_STATUS_SUCCESS for success or error code
15759 */
15760static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
15761 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
15762{
15763 return QDF_STATUS_SUCCESS;
15764}
15765
15766/**
15767 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
15768 * @wmi_handle: wmi handle
15769 * @param evt_buf: pointer to event buffer
15770 * @param index: Index into extended peer stats
15771 * @param peer_extd_stats: Pointer to hold extended peer stats
15772 *
15773 * Return: QDF_STATUS_SUCCESS for success or error code
15774 */
15775static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
15776 void *evt_buf, uint32_t index,
15777 wmi_host_peer_extd_stats *peer_extd_stats)
15778{
15779 return QDF_STATUS_SUCCESS;
15780}
15781
15782/**
15783 * extract_chan_stats_tlv() - extract chan stats from event
15784 * @wmi_handle: wmi handle
15785 * @param evt_buf: pointer to event buffer
15786 * @param index: Index into chan stats
15787 * @param vdev_extd_stats: Pointer to hold chan stats
15788 *
15789 * Return: QDF_STATUS_SUCCESS for success or error code
15790 */
15791static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
15792 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
15793{
15794 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
15795 wmi_stats_event_fixed_param *ev_param;
15796 uint8_t *data;
15797
15798 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
15799 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
15800 data = (uint8_t *) param_buf->data;
15801
15802 if (index < ev_param->num_chan_stats) {
15803 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
15804 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
15805 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
15806 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
15807 (index * sizeof(wmi_chan_stats)));
15808
15809
15810 /* Non-TLV doesnt have num_chan_stats */
15811 chan_stats->chan_mhz = ev->chan_mhz;
15812 chan_stats->sampling_period_us = ev->sampling_period_us;
15813 chan_stats->rx_clear_count = ev->rx_clear_count;
15814 chan_stats->tx_duration_us = ev->tx_duration_us;
15815 chan_stats->rx_duration_us = ev->rx_duration_us;
15816 }
15817
15818 return QDF_STATUS_SUCCESS;
15819}
15820
15821/**
15822 * extract_profile_ctx_tlv() - extract profile context from event
15823 * @wmi_handle: wmi handle
15824 * @param evt_buf: pointer to event buffer
15825 * @idx: profile stats index to extract
15826 * @param profile_ctx: Pointer to hold profile context
15827 *
15828 * Return: QDF_STATUS_SUCCESS for success or error code
15829 */
15830static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
15831 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
15832{
15833 return QDF_STATUS_SUCCESS;
15834}
15835
15836/**
15837 * extract_profile_data_tlv() - extract profile data from event
15838 * @wmi_handle: wmi handle
15839 * @param evt_buf: pointer to event buffer
15840 * @param profile_data: Pointer to hold profile data
15841 *
15842 * Return: QDF_STATUS_SUCCESS for success or error code
15843 */
15844static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
15845 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
15846{
15847
15848 return QDF_STATUS_SUCCESS;
15849}
15850
15851/**
15852 * extract_chan_info_event_tlv() - extract chan information from event
15853 * @wmi_handle: wmi handle
15854 * @param evt_buf: pointer to event buffer
15855 * @param chan_info: Pointer to hold chan information
15856 *
15857 * Return: QDF_STATUS_SUCCESS for success or error code
15858 */
15859static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
15860 void *evt_buf, wmi_host_chan_info_event *chan_info)
15861{
15862 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
15863 wmi_chan_info_event_fixed_param *ev;
15864
15865 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
15866
15867 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
15868 if (!ev) {
15869 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
15870 return QDF_STATUS_E_FAILURE;
15871 }
15872
15873 chan_info->err_code = ev->err_code;
15874 chan_info->freq = ev->freq;
15875 chan_info->cmd_flags = ev->cmd_flags;
15876 chan_info->noise_floor = ev->noise_floor;
15877 chan_info->rx_clear_count = ev->rx_clear_count;
15878 chan_info->cycle_count = ev->cycle_count;
15879
15880 return QDF_STATUS_SUCCESS;
15881}
15882
15883/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015884 * extract_pdev_utf_event_tlv() - extract UTF data info from event
15885 * @wmi_handle: WMI handle
15886 * @param evt_buf: Pointer to event buffer
15887 * @param param: Pointer to hold data
15888 *
15889 * Return : QDF_STATUS_SUCCESS for success or error code
15890 */
15891static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
15892 uint8_t *evt_buf,
15893 struct wmi_host_pdev_utf_event *event)
15894{
15895 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
15896
15897 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
15898 event->data = param_buf->data;
15899 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053015900 /* Set pdev_id=1 until FW adds support to include pdev_id */
15901 event->pdev_id = 1;
Sathish Kumar27ee0a32017-01-24 17:51:26 +053015902
15903 return QDF_STATUS_SUCCESS;
15904}
Govind Singhe7f2f342016-05-23 12:12:52 +053015905
Kiran Venkatappa06520822016-08-10 23:55:40 +053015906/**
15907 * extract_service_ready_ext_tlv() - extract basic extended service ready params
15908 * from event
15909 * @wmi_handle: wmi handle
15910 * @param evt_buf: pointer to event buffer
15911 * @param param: Pointer to hold evt buf
15912 *
15913 * Return: QDF_STATUS_SUCCESS for success or error code
15914 */
15915static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015916 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015917{
15918 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
15919 wmi_service_ready_ext_event_fixed_param *ev;
15920 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
15921 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
15922
15923 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15924 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015925 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015926
15927 ev = param_buf->fixed_param;
15928 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015929 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015930
15931 /* Move this to host based bitmap */
15932 param->default_conc_scan_config_bits =
15933 ev->default_conc_scan_config_bits;
15934 param->default_fw_config_bits = ev->default_fw_config_bits;
15935 param->he_cap_info = ev->he_cap_info;
15936 param->mpdu_density = ev->mpdu_density;
15937 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
15938 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
15939
15940 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015941 if (hw_caps)
15942 param->num_hw_modes = hw_caps->num_hw_modes;
15943 else
15944 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015945
15946 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015947 if (reg_caps)
15948 param->num_phy = reg_caps->num_phy;
15949 else
15950 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015951
15952 return QDF_STATUS_SUCCESS;
15953}
15954
15955/**
15956 * extract_hw_mode_cap_service_ready_ext_tlv() -
15957 * extract HW mode cap from service ready event
15958 * @wmi_handle: wmi handle
15959 * @param evt_buf: pointer to event buffer
15960 * @param param: Pointer to hold evt buf
15961 * @param hw_mode_idx: hw mode idx should be less than num_mode
15962 *
15963 * Return: QDF_STATUS_SUCCESS for success or error code
15964 */
15965static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
15966 wmi_unified_t wmi_handle,
15967 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015968 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053015969{
15970 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
15971 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
15972
15973 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
15974 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015975 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015976
15977 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015978 if (!hw_caps)
15979 return QDF_STATUS_E_INVAL;
15980
Kiran Venkatappa06520822016-08-10 23:55:40 +053015981 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053015982 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053015983
15984 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
15985 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
15986
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053015987 param->hw_mode_config_type =
15988 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
15989
Kiran Venkatappa06520822016-08-10 23:55:40 +053015990 return QDF_STATUS_SUCCESS;
15991}
15992
15993/**
15994 * extract_mac_phy_cap_service_ready_ext_tlv() -
15995 * extract MAC phy cap from service ready event
15996 * @wmi_handle: wmi handle
15997 * @param evt_buf: pointer to event buffer
15998 * @param param: Pointer to hold evt buf
15999 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016000 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053016001 *
16002 * Return: QDF_STATUS_SUCCESS for success or error code
16003 */
16004static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
16005 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016006 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016007 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016008{
16009 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016010 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016011 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16012 uint32_t phy_map;
16013 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016014
16015 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16016 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016017 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016018
16019 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016020 if (!hw_caps)
16021 return QDF_STATUS_E_INVAL;
16022
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016023 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
16024 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
16025 break;
16026
16027 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
16028 while (phy_map) {
16029 phy_map >>= 1;
16030 phy_idx++;
16031 }
16032 }
16033
16034 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016035 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016036
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016037 phy_idx += phy_id;
16038 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016039 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016040
16041 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053016042
16043 param->hw_mode_id = mac_phy_caps->hw_mode_id;
16044 param->pdev_id = mac_phy_caps->pdev_id;
16045 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016046 param->supports_11b =
16047 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
16048 param->supports_11g =
16049 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
16050 param->supports_11a =
16051 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
16052 param->supports_11n =
16053 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
16054 param->supports_11ac =
16055 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
16056 param->supports_11ax =
16057 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016058
16059 param->supported_bands = mac_phy_caps->supported_bands;
16060 param->ampdu_density = mac_phy_caps->ampdu_density;
16061 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
16062 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
16063 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
16064 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
16065 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
16066 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
16067 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
16068 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
16069 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
16070 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
16071 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
16072 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
16073 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
16074 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
16075 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
16076 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080016077 qdf_mem_copy(&param->he_cap_phy_info_2G,
16078 &mac_phy_caps->he_cap_phy_info_2G,
16079 sizeof(param->he_cap_phy_info_2G));
16080 qdf_mem_copy(&param->he_cap_phy_info_5G,
16081 &mac_phy_caps->he_cap_phy_info_5G,
16082 sizeof(param->he_cap_phy_info_5G));
16083 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
16084 sizeof(param->he_ppet2G));
16085 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
16086 sizeof(param->he_ppet5G));
Kiran Venkatappa06520822016-08-10 23:55:40 +053016087
16088 return QDF_STATUS_SUCCESS;
16089}
16090
16091/**
16092 * extract_reg_cap_service_ready_ext_tlv() -
16093 * extract REG cap from service ready event
16094 * @wmi_handle: wmi handle
16095 * @param evt_buf: pointer to event buffer
16096 * @param param: Pointer to hold evt buf
16097 * @param phy_idx: phy idx should be less than num_mode
16098 *
16099 * Return: QDF_STATUS_SUCCESS for success or error code
16100 */
16101static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
16102 wmi_unified_t wmi_handle,
16103 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016104 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016105{
16106 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16107 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
16108 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
16109
16110 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16111 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016112 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016113
16114 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016115 if (!reg_caps)
16116 return QDF_STATUS_E_INVAL;
16117
Kiran Venkatappa06520822016-08-10 23:55:40 +053016118 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016119 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016120
16121 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
16122
16123 param->phy_id = ext_reg_cap->phy_id;
16124 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
16125 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
16126 param->regcap1 = ext_reg_cap->regcap1;
16127 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053016128 param->wireless_modes = convert_wireless_modes_tlv(
16129 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016130 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
16131 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
16132 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
16133 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
16134
16135 return QDF_STATUS_SUCCESS;
16136}
16137
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016138/**
16139 * extract_dcs_interference_type_tlv() - extract dcs interference type
16140 * from event
16141 * @wmi_handle: wmi handle
16142 * @param evt_buf: pointer to event buffer
16143 * @param param: Pointer to hold dcs interference param
16144 *
16145 * Return: 0 for success or error code
16146 */
16147static QDF_STATUS extract_dcs_interference_type_tlv(
16148 wmi_unified_t wmi_handle,
16149 void *evt_buf, struct wmi_host_dcs_interference_param *param)
16150{
16151 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16152
16153 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16154 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016155 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016156
16157 param->interference_type = param_buf->fixed_param->interference_type;
16158 param->pdev_id = param_buf->fixed_param->pdev_id;
16159
16160 return QDF_STATUS_SUCCESS;
16161}
16162
16163/*
16164 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
16165 * @wmi_handle: wmi handle
16166 * @param evt_buf: pointer to event buffer
16167 * @param cw_int: Pointer to hold cw interference
16168 *
16169 * Return: 0 for success or error code
16170 */
16171static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
16172 void *evt_buf,
16173 wmi_host_ath_dcs_cw_int *cw_int)
16174{
16175 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16176 wlan_dcs_cw_int *ev;
16177
16178 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16179 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016180 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016181
16182 ev = param_buf->cw_int;
16183
16184 cw_int->channel = ev->channel;
16185
16186 return QDF_STATUS_SUCCESS;
16187}
16188
16189/**
16190 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
16191 * @wmi_handle: wmi handle
16192 * @param evt_buf: pointer to event buffer
16193 * @param wlan_stat: Pointer to hold wlan stats
16194 *
16195 * Return: 0 for success or error code
16196 */
16197static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
16198 void *evt_buf,
16199 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
16200{
16201 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16202 wlan_dcs_im_tgt_stats_t *ev;
16203
16204 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16205 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016206 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016207
16208 ev = param_buf->wlan_stat;
16209 wlan_stat->reg_tsf32 = ev->reg_tsf32;
16210 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
16211 wlan_stat->tx_waste_time = ev->tx_waste_time;
16212 wlan_stat->rx_time = ev->rx_time;
16213 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
16214 wlan_stat->mib_stats.listen_time = ev->listen_time;
16215 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
16216 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
16217 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
16218 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
16219 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
16220 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
16221 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
16222 wlan_stat->chan_nf = ev->chan_nf;
16223 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
16224
16225 return QDF_STATUS_SUCCESS;
16226}
16227
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016228#ifdef BIG_ENDIAN_HOST
16229/**
16230 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
16231 * @param data_len - data length
16232 * @param data - pointer to data
16233 *
16234 * Return: QDF_STATUS - success or error status
16235 */
16236static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
16237{
16238 uint8_t *data_aligned = NULL;
16239 int c;
16240 unsigned char *data_unaligned;
16241
16242 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
16243 FIPS_ALIGN));
16244 /* Assigning unaligned space to copy the data */
16245 /* Checking if kmalloc does succesful allocation */
16246 if (data_unaligned == NULL)
16247 return QDF_STATUS_E_FAILURE;
16248
16249 /* Checking if space is alligned */
16250 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
16251 /* align the data space */
16252 data_aligned =
16253 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
16254 } else {
16255 data_aligned = (u_int8_t *)data_unaligned;
16256 }
16257
16258 /* memset and copy content from data to data aligned */
16259 OS_MEMSET(data_aligned, 0, data_len);
16260 OS_MEMCPY(data_aligned, data, data_len);
16261 /* Endianness to LE */
16262 for (c = 0; c < data_len/4; c++) {
16263 *((u_int32_t *)data_aligned + c) =
16264 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
16265 }
16266
16267 /* Copy content to event->data */
16268 OS_MEMCPY(data, data_aligned, data_len);
16269
16270 /* clean up allocated space */
16271 qdf_mem_free(data_unaligned);
16272 data_aligned = NULL;
16273 data_unaligned = NULL;
16274
16275 /*************************************************************/
16276
16277 return QDF_STATUS_SUCCESS;
16278}
16279#else
16280/**
16281 * fips_conv_data_be() - DUMMY for LE platform
16282 *
16283 * Return: QDF_STATUS - success
16284 */
16285static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
16286{
16287 return QDF_STATUS_SUCCESS;
16288}
16289#endif
16290
16291/**
16292 * extract_fips_event_data_tlv() - extract fips event data
16293 * @wmi_handle: wmi handle
16294 * @param evt_buf: pointer to event buffer
16295 * @param param: pointer FIPS event params
16296 *
16297 * Return: 0 for success or error code
16298 */
16299static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
16300 void *evt_buf, struct wmi_host_fips_event_param *param)
16301{
16302 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
16303 wmi_pdev_fips_event_fixed_param *event;
16304
16305 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
16306 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
16307
16308 if (fips_conv_data_be(event->data_len, param_buf->data) !=
16309 QDF_STATUS_SUCCESS)
16310 return QDF_STATUS_E_FAILURE;
16311
16312 param->data = (uint32_t *)param_buf->data;
16313 param->data_len = event->data_len;
16314 param->error_status = event->error_status;
Kiran Venkatappaaa075142017-03-30 15:22:50 +053016315 param->pdev_id = event->pdev_id;
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016316
16317 return QDF_STATUS_SUCCESS;
16318}
16319
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053016320/*
16321 * extract_peer_delete_response_event_tlv() - extract peer delete response event
16322 * @wmi_handle: wmi handle
16323 * @param evt_buf: pointer to event buffer
16324 * @param vdev_id: Pointer to hold vdev_id
16325 * @param mac_addr: Pointer to hold peer mac address
16326 *
16327 * Return: QDF_STATUS_SUCCESS for success or error code
16328 */
16329static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
16330 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
16331{
16332 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
16333 wmi_peer_delete_resp_event_fixed_param *ev;
16334
16335 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
16336
16337 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
16338 if (!ev) {
16339 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
16340 return QDF_STATUS_E_FAILURE;
16341 }
16342
16343 param->vdev_id = ev->vdev_id;
16344 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
16345 &param->mac_address.bytes[0]);
16346
16347 return QDF_STATUS_SUCCESS;
16348}
16349
Govind Singhecf03cd2016-05-12 12:45:51 +053016350static bool is_management_record_tlv(uint32_t cmd_id)
16351{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053016352 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053016353 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053016354
Govind Singhecf03cd2016-05-12 12:45:51 +053016355 return false;
16356}
16357
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053016358static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
16359{
16360 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
16361
16362 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
16363
16364 switch (set_cmd->param_id) {
16365 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
16366 case WMI_VDEV_PARAM_DTIM_POLICY:
16367 return HTC_TX_PACKET_TAG_AUTO_PM;
16368 default:
16369 break;
16370 }
16371
16372 return 0;
16373}
16374
16375static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
16376{
16377 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
16378
16379 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
16380
16381 switch (ps_cmd->param) {
16382 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
16383 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
16384 case WMI_STA_PS_ENABLE_QPOWER:
16385 return HTC_TX_PACKET_TAG_AUTO_PM;
16386 default:
16387 break;
16388 }
16389
16390 return 0;
16391}
16392
16393static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
16394 uint32_t cmd_id)
16395{
16396 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
16397 return 0;
16398
16399 switch (cmd_id) {
16400 case WMI_VDEV_SET_PARAM_CMDID:
16401 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
16402 case WMI_STA_POWERSAVE_PARAM_CMDID:
16403 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
16404 default:
16405 break;
16406 }
16407
16408 return 0;
16409}
16410
16411static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
16412{
16413 uint16_t tag = 0;
16414
16415 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
16416 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
16417 __func__);
16418 return tag;
16419 }
16420
16421 if (wmi_handle->tag_crash_inject)
16422 tag = HTC_TX_PACKET_TAG_AUTO_PM;
16423
16424 wmi_handle->tag_crash_inject = false;
16425 return tag;
16426}
16427
16428/**
16429 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
16430 * @wmi_handle: WMI handle
16431 * @buf: WMI buffer
16432 * @cmd_id: WMI command Id
16433 *
16434 * Return htc_tx_tag
16435 */
16436static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
16437 wmi_buf_t buf,
16438 uint32_t cmd_id)
16439{
16440 uint16_t htc_tx_tag = 0;
16441
16442 switch (cmd_id) {
16443 case WMI_WOW_ENABLE_CMDID:
16444 case WMI_PDEV_SUSPEND_CMDID:
16445 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
16446 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
16447 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
16448 case WMI_PDEV_RESUME_CMDID:
16449 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
16450 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
16451#ifdef FEATURE_WLAN_D0WOW
16452 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
16453#endif
16454 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
16455 break;
16456 case WMI_FORCE_FW_HANG_CMDID:
16457 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
16458 break;
16459 case WMI_VDEV_SET_PARAM_CMDID:
16460 case WMI_STA_POWERSAVE_PARAM_CMDID:
16461 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
16462 default:
16463 break;
16464 }
16465
16466 return htc_tx_tag;
16467}
16468
Sathish Kumard3ab1002017-02-07 17:10:59 +053016469/**
16470 * extract_channel_hopping_event_tlv() - extract channel hopping param
16471 * from event
16472 * @wmi_handle: wmi handle
16473 * @param evt_buf: pointer to event buffer
16474 * @param ch_hopping: Pointer to hold channel hopping param
16475 *
16476 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16477 */
16478static QDF_STATUS extract_channel_hopping_event_tlv(
16479 wmi_unified_t wmi_handle, void *evt_buf,
16480 wmi_host_pdev_channel_hopping_event *ch_hopping)
16481{
16482 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
16483 wmi_pdev_channel_hopping_event_fixed_param *event;
16484
16485 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
16486 event = (wmi_pdev_channel_hopping_event_fixed_param *)
16487 param_buf->fixed_param;
16488
16489 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
16490 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappaaa075142017-03-30 15:22:50 +053016491 ch_hopping->pdev_id = event->pdev_id;
Sathish Kumard3ab1002017-02-07 17:10:59 +053016492
16493 return QDF_STATUS_SUCCESS;
16494}
16495
16496/**
16497 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
16498 * @wmi_handle: wmi handle
16499 * @param evt_buf: pointer to event buffer
16500 * @param param: Pointer to hold tpc param
16501 *
16502 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16503 */
16504static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
16505 void *evt_buf,
16506 wmi_host_pdev_tpc_event *param)
16507{
16508 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
16509 wmi_pdev_tpc_event_fixed_param *event;
16510
16511 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
16512 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
16513
Kiran Venkatappaaa075142017-03-30 15:22:50 +053016514 param->pdev_id = event->pdev_id;
Sathish Kumard3ab1002017-02-07 17:10:59 +053016515 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
16516
16517 return QDF_STATUS_SUCCESS;
16518}
16519
16520
16521#ifdef BIG_ENDIAN_HOST
16522/**
16523 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
16524 * @param data_len - data length
16525 * @param data - pointer to data
16526 *
16527 * Return: QDF_STATUS - success or error status
16528 */
16529static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
16530{
16531 uint8_t *datap = (uint8_t *)ev;
16532 /* Skip swapping the first word */
16533 datap += sizeof(uint32_t);
16534 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
16535 i++, datap += sizeof(uint32_t)) {
16536 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
16537 }
16538
16539 return QDF_STATUS_SUCCESS;
16540}
16541#else
16542/**
16543 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
16544 * @param data_len - data length
16545 * @param data - pointer to data
16546 *
16547 * Return: QDF_STATUS - success or error status
16548 */
16549static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
16550{
16551 return QDF_STATUS_SUCCESS;
16552}
16553#endif
16554
16555/**
16556 * extract_wds_addr_event_tlv() - extract wds address from event
16557 * @wmi_handle: wmi handle
16558 * @param evt_buf: pointer to event buffer
16559 * @param wds_ev: Pointer to hold wds address
16560 *
16561 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16562 */
16563static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
16564 void *evt_buf,
16565 uint16_t len, wds_addr_event_t *wds_ev)
16566{
16567 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
16568 wmi_wds_addr_event_fixed_param *ev;
16569 int i;
16570
16571 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
16572 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
16573
16574 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
16575 return QDF_STATUS_E_FAILURE;
16576
16577 qdf_mem_copy(wds_ev->event_type, ev->event_type,
16578 sizeof(wds_ev->event_type));
16579 for (i = 0; i < 4; i++) {
16580 wds_ev->peer_mac[i] =
16581 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
16582 wds_ev->dest_mac[i] =
16583 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
16584 }
16585 for (i = 0; i < 2; i++) {
16586 wds_ev->peer_mac[4+i] =
16587 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
16588 wds_ev->dest_mac[4+i] =
16589 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
16590 }
16591 return QDF_STATUS_SUCCESS;
16592}
16593
16594/**
16595 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
16596 * from event
16597 * @wmi_handle: wmi handle
16598 * @param evt_buf: pointer to event buffer
16599 * @param ev: Pointer to hold peer param and ps state
16600 *
16601 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16602 */
16603static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
16604 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
16605{
16606 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
16607 wmi_peer_sta_ps_statechange_event_fixed_param *event;
16608
16609 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
16610 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
16611 param_buf->fixed_param;
16612
16613 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
16614 ev->peer_ps_state = event->peer_ps_state;
16615
16616 return QDF_STATUS_SUCCESS;
16617}
16618
16619/**
16620 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
16621 * @wmi_handle: wmi handle
16622 * @param evt_buf: pointer to event buffer
16623 * @param inst_rssi_resp: Pointer to hold inst rssi response
16624 *
16625 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
16626 */
16627static QDF_STATUS extract_inst_rssi_stats_event_tlv(
16628 wmi_unified_t wmi_handle, void *evt_buf,
16629 wmi_host_inst_stats_resp *inst_rssi_resp)
16630{
16631 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
16632 wmi_inst_rssi_stats_resp_fixed_param *event;
16633
16634 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
16635 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
16636
16637 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
16638 &(event->peer_macaddr), sizeof(wmi_mac_addr));
16639 inst_rssi_resp->iRSSI = event->iRSSI;
16640
16641 return QDF_STATUS_SUCCESS;
16642}
16643
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016644static struct cur_reg_rule
16645*create_reg_rules_from_wmi(uint32_t num_reg_rules,
16646 wmi_regulatory_rule_struct *wmi_reg_rule)
16647{
16648 struct cur_reg_rule *reg_rule_ptr;
16649 uint32_t count;
16650
16651 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
16652
16653 if (NULL == reg_rule_ptr) {
16654 WMI_LOGE("memory allocation failure");
16655 return NULL;
16656 }
16657
16658 for (count = 0; count < num_reg_rules; count++) {
16659 reg_rule_ptr[count].start_freq =
16660 WMI_REG_RULE_START_FREQ_GET(
16661 wmi_reg_rule[count].freq_info);
16662 reg_rule_ptr[count].end_freq =
16663 WMI_REG_RULE_END_FREQ_GET(
16664 wmi_reg_rule[count].freq_info);
16665 reg_rule_ptr[count].max_bw =
16666 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070016667 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016668 reg_rule_ptr[count].reg_power =
16669 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070016670 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016671 reg_rule_ptr[count].flags =
16672 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070016673 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016674 }
16675
16676 return reg_rule_ptr;
16677}
16678
16679static QDF_STATUS extract_reg_chan_list_update_event_tlv(
16680 wmi_unified_t wmi_handle, uint8_t *evt_buf,
16681 struct cur_regulatory_info *reg_info, uint32_t len)
16682{
16683 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
16684 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
16685 wmi_regulatory_rule_struct *wmi_reg_rule;
16686 uint32_t num_2g_reg_rules, num_5g_reg_rules;
16687
16688 WMI_LOGD("processing regulatory channel list");
16689
16690 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
16691 if (!param_buf) {
16692 WMI_LOGE("invalid channel list event buf");
16693 return QDF_STATUS_E_FAILURE;
16694 }
16695
16696 chan_list_event_hdr = param_buf->fixed_param;
16697
16698 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
16699 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
16700 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
16701 REG_ALPHA2_LEN);
16702 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
16703 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
16704 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
16705 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
16706 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
16707 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
16708
16709 num_2g_reg_rules = reg_info->num_2g_reg_rules;
16710 num_5g_reg_rules = reg_info->num_5g_reg_rules;
16711
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016712
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070016713 wmi_reg_rule =
16714 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
16715 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
16716 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053016717 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
16718 wmi_reg_rule);
16719 wmi_reg_rule += num_2g_reg_rules;
16720
16721 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
16722 wmi_reg_rule);
16723
16724 WMI_LOGD("processed regulatory channel list");
16725
16726 return QDF_STATUS_SUCCESS;
16727}
16728
Govind Singh5eb51532016-03-09 11:34:12 +053016729struct wmi_ops tlv_ops = {
16730 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
16731 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
16732 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053016733 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
16734 .send_hidden_ssid_vdev_restart_cmd =
16735 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016736 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
16737 .send_peer_param_cmd = send_peer_param_cmd_tlv,
16738 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016739 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016740 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016741 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070016742 .send_peer_rx_reorder_queue_setup_cmd =
16743 send_peer_rx_reorder_queue_setup_cmd_tlv,
16744 .send_peer_rx_reorder_queue_remove_cmd =
16745 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053016746 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
16747 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
16748 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053016749 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
16750 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
16751 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
16752 .send_suspend_cmd = send_suspend_cmd_tlv,
16753 .send_resume_cmd = send_resume_cmd_tlv,
16754 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
16755 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
16756 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
16757 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
16758 .send_dbglog_cmd = send_dbglog_cmd_tlv,
16759 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
16760 .send_stats_request_cmd = send_stats_request_cmd_tlv,
16761 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
16762 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016763#ifndef CONFIG_MCL
16764 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
16765#endif
Govind Singh5eb51532016-03-09 11:34:12 +053016766 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
16767 .send_scan_start_cmd = send_scan_start_cmd_tlv,
16768 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
16769 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016770 .send_mgmt_cmd = send_mgmt_cmd_tlv,
16771 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
16772 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016773 .send_set_sta_uapsd_auto_trig_cmd =
16774 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053016775 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
16776 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
16777 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080016778#ifdef CONVERGED_P2P_ENABLE
16779 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
16780 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
16781#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053016782 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
16783 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053016784 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
16785 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
16786 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
16787 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
16788 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
16789 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
16790 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016791 .send_ocb_start_timing_advert_cmd =
16792 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053016793 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
16794 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
16795 .send_set_mcc_channel_time_latency_cmd =
16796 send_set_mcc_channel_time_latency_cmd_tlv,
16797 .send_set_mcc_channel_time_quota_cmd =
16798 send_set_mcc_channel_time_quota_cmd_tlv,
16799 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
16800 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053016801 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016802 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
16803 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
16804 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016805 .send_probe_rsp_tmpl_send_cmd =
16806 send_probe_rsp_tmpl_send_cmd_tlv,
16807 .send_p2p_go_set_beacon_ie_cmd =
16808 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053016809 .send_setup_install_key_cmd =
16810 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016811 .send_set_gateway_params_cmd =
16812 send_set_gateway_params_cmd_tlv,
16813 .send_set_rssi_monitoring_cmd =
16814 send_set_rssi_monitoring_cmd_tlv,
16815 .send_scan_probe_setoui_cmd =
16816 send_scan_probe_setoui_cmd_tlv,
16817 .send_reset_passpoint_network_list_cmd =
16818 send_reset_passpoint_network_list_cmd_tlv,
16819 .send_set_passpoint_network_list_cmd =
16820 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053016821 .send_roam_scan_offload_rssi_thresh_cmd =
16822 send_roam_scan_offload_rssi_thresh_cmd_tlv,
16823 .send_roam_scan_filter_cmd =
16824 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053016825 .send_set_epno_network_list_cmd =
16826 send_set_epno_network_list_cmd_tlv,
16827 .send_ipa_offload_control_cmd =
16828 send_ipa_offload_control_cmd_tlv,
16829 .send_extscan_get_capabilities_cmd =
16830 send_extscan_get_capabilities_cmd_tlv,
16831 .send_extscan_get_cached_results_cmd =
16832 send_extscan_get_cached_results_cmd_tlv,
16833 .send_extscan_stop_change_monitor_cmd =
16834 send_extscan_stop_change_monitor_cmd_tlv,
16835 .send_extscan_start_change_monitor_cmd =
16836 send_extscan_start_change_monitor_cmd_tlv,
16837 .send_extscan_stop_hotlist_monitor_cmd =
16838 send_extscan_stop_hotlist_monitor_cmd_tlv,
16839 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
16840 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
16841 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
16842 .send_plm_start_cmd = send_plm_start_cmd_tlv,
16843 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016844#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singh4eacd2b2016-03-07 14:24:22 +053016845 .send_pno_start_cmd = send_pno_start_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016846#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +053016847 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
16848 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
16849 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
16850 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
16851 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016852 .send_snr_request_cmd = send_snr_request_cmd_tlv,
16853 .send_snr_cmd = send_snr_cmd_tlv,
16854 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053016855#ifdef WLAN_PMO_ENABLE
16856 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
16857 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
16858 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
16859 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
16860 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
16861 .send_process_gtk_offload_getinfo_cmd =
16862 send_process_gtk_offload_getinfo_cmd_tlv,
16863 .send_enable_enhance_multicast_offload_cmd =
16864 send_enable_enhance_multicast_offload_tlv,
16865 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
16866#ifdef FEATURE_WLAN_RA_FILTERING
16867 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
16868#endif
16869 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016870 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
16871 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053016872 .send_lphb_config_tcp_pkt_filter_cmd =
16873 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016874 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
16875 .send_lphb_config_udp_pkt_filter_cmd =
16876 send_lphb_config_udp_pkt_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053016877#endif /* End of WLAN_PMO_ENABLE */
16878#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053016879 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
16880 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
16881 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053016882 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
16883 .send_process_update_edca_param_cmd =
16884 send_process_update_edca_param_cmd_tlv,
16885 .send_roam_scan_offload_mode_cmd =
16886 send_roam_scan_offload_mode_cmd_tlv,
16887 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
16888 .send_roam_scan_offload_ap_profile_cmd =
16889 send_roam_scan_offload_ap_profile_cmd_tlv,
16890#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053016891 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
16892 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016893 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
16894 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
16895 .send_dfs_phyerr_filter_offload_en_cmd =
16896 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016897 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
16898 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
16899 .send_del_ts_cmd = send_del_ts_cmd_tlv,
16900 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
16901 .send_add_ts_cmd = send_add_ts_cmd_tlv,
16902 .send_enable_disable_packet_filter_cmd =
16903 send_enable_disable_packet_filter_cmd_tlv,
16904 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016905 .send_process_add_periodic_tx_ptrn_cmd =
16906 send_process_add_periodic_tx_ptrn_cmd_tlv,
16907 .send_process_del_periodic_tx_ptrn_cmd =
16908 send_process_del_periodic_tx_ptrn_cmd_tlv,
16909 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
16910 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
16911 .send_set_app_type2_params_in_fw_cmd =
16912 send_set_app_type2_params_in_fw_cmd_tlv,
16913 .send_set_auto_shutdown_timer_cmd =
16914 send_set_auto_shutdown_timer_cmd_tlv,
16915 .send_nan_req_cmd = send_nan_req_cmd_tlv,
16916 .send_process_dhcpserver_offload_cmd =
16917 send_process_dhcpserver_offload_cmd_tlv,
16918 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
16919 .send_process_ch_avoid_update_cmd =
16920 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053016921 .send_pdev_set_regdomain_cmd =
16922 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053016923 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
16924 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
16925 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
16926 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
16927 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
16928 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053016929#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053016930 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053016931#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053016932 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053016933 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053016934 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053016935 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053016936 .send_set_base_macaddr_indicate_cmd =
16937 send_set_base_macaddr_indicate_cmd_tlv,
16938 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
16939 .send_enable_specific_fw_logs_cmd =
16940 send_enable_specific_fw_logs_cmd_tlv,
16941 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053016942 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053016943 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053016944 .send_pdev_set_dual_mac_config_cmd =
16945 send_pdev_set_dual_mac_config_cmd_tlv,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053016946 .send_enable_broadcast_filter_cmd =
16947 send_enable_broadcast_filter_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053016948 .send_app_type1_params_in_fw_cmd =
16949 send_app_type1_params_in_fw_cmd_tlv,
16950 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
16951 .send_process_roam_synch_complete_cmd =
16952 send_process_roam_synch_complete_cmd_tlv,
16953 .send_unit_test_cmd = send_unit_test_cmd_tlv,
16954 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
16955 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053016956 .send_roam_scan_offload_scan_period_cmd =
16957 send_roam_scan_offload_scan_period_cmd_tlv,
16958 .send_roam_scan_offload_chan_list_cmd =
16959 send_roam_scan_offload_chan_list_cmd_tlv,
16960 .send_roam_scan_offload_rssi_change_cmd =
16961 send_roam_scan_offload_rssi_change_cmd_tlv,
16962 .send_get_buf_extscan_hotlist_cmd =
16963 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080016964 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053016965 .send_adapt_dwelltime_params_cmd =
16966 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053016967 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053016968 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
16969 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
16970 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
16971 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
16972 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
16973 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
16974 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
16975 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
16976 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053016977 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
16978 .send_smart_ant_set_training_info_cmd =
16979 send_smart_ant_set_training_info_cmd_tlv,
16980 .send_smart_ant_set_node_config_cmd =
16981 send_smart_ant_set_node_config_cmd_tlv,
16982 .send_set_atf_cmd = send_set_atf_cmd_tlv,
16983 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
16984 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053016985 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
16986 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
16987 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
16988 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
16989 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
16990 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
16991 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053016992 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
16993 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
16994 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
16995 .send_vdev_spectral_configure_cmd =
16996 send_vdev_spectral_configure_cmd_tlv,
16997 .send_vdev_spectral_enable_cmd =
16998 send_vdev_spectral_enable_cmd_tlv,
16999 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
17000 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017001 .get_target_cap_from_service_ready = extract_service_ready_tlv,
17002 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
17003 .extract_host_mem_req = extract_host_mem_req_tlv,
17004 .save_service_bitmap = save_service_bitmap_tlv,
17005 .is_service_enabled = is_service_enabled_tlv,
17006 .save_fw_version = save_fw_version_in_service_ready_tlv,
17007 .ready_extract_init_status = ready_extract_init_status_tlv,
17008 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
17009 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
17010 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
17011 .extract_tbttoffset_update_params =
17012 extract_tbttoffset_update_params_tlv,
17013 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
17014 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
17015 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
17016 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
17017 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
17018 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
17019 .extract_swba_tim_info = extract_swba_tim_info_tlv,
17020 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080017021#ifdef CONVERGED_P2P_ENABLE
17022 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
17023 .extract_p2p_lo_stop_ev_param =
17024 extract_p2p_lo_stop_ev_param_tlv,
17025#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053017026 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
17027 .extract_all_stats_count = extract_all_stats_counts_tlv,
17028 .extract_pdev_stats = extract_pdev_stats_tlv,
17029 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
17030 .extract_vdev_stats = extract_vdev_stats_tlv,
17031 .extract_peer_stats = extract_peer_stats_tlv,
17032 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
17033 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
17034 .extract_chan_stats = extract_chan_stats_tlv,
17035 .extract_profile_ctx = extract_profile_ctx_tlv,
17036 .extract_profile_data = extract_profile_data_tlv,
17037 .extract_chan_info_event = extract_chan_info_event_tlv,
17038 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053017039 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053017040 .send_encrypt_decrypt_send_cmd =
17041 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080017042 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053017043 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053017044 .send_multiple_vdev_restart_req_cmd =
17045 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053017046 .extract_service_ready_ext = extract_service_ready_ext_tlv,
17047 .extract_hw_mode_cap_service_ready_ext =
17048 extract_hw_mode_cap_service_ready_ext_tlv,
17049 .extract_mac_phy_cap_service_ready_ext =
17050 extract_mac_phy_cap_service_ready_ext_tlv,
17051 .extract_reg_cap_service_ready_ext =
17052 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017053 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017054 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017055 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
17056 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
17057 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017058 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053017059 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017060 .extract_peer_delete_response_event =
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017061 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017062 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053017063 .extract_pdev_csa_switch_count_status =
17064 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053017065 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
17066 .extract_wds_addr_event = extract_wds_addr_event_tlv,
17067 .extract_peer_sta_ps_statechange_ev =
17068 extract_peer_sta_ps_statechange_ev_tlv,
17069 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053017070 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080017071 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
17072 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017073 .extract_reg_chan_list_update_event =
17074 extract_reg_chan_list_update_event_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053017075};
17076
Govind Singhe7f2f342016-05-23 12:12:52 +053017077/**
17078 * populate_tlv_event_id() - populates wmi event ids
17079 *
17080 * @param event_ids: Pointer to hold event ids
17081 * Return: None
17082 */
17083static void populate_tlv_events_id(uint32_t *event_ids)
17084{
17085 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
17086 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
17087 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
17088 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
17089 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
17090 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
17091 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
17092 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
17093 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
17094 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
17095 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
17096 event_ids[wmi_service_ready_ext_event_id] =
17097 WMI_SERVICE_READY_EXT_EVENTID;
17098 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
17099 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
17100 event_ids[wmi_vdev_install_key_complete_event_id] =
17101 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
17102 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
17103 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
17104
17105 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
17106 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
17107 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
17108 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
17109 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
17110 event_ids[wmi_peer_estimated_linkspeed_event_id] =
17111 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
17112 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017113 event_ids[wmi_peer_delete_response_event_id] =
17114 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017115 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
17116 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
17117 event_ids[wmi_tbttoffset_update_event_id] =
17118 WMI_TBTTOFFSET_UPDATE_EVENTID;
17119 event_ids[wmi_offload_bcn_tx_status_event_id] =
17120 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
17121 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
17122 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
17123 event_ids[wmi_mgmt_tx_completion_event_id] =
17124 WMI_MGMT_TX_COMPLETION_EVENTID;
17125
17126 event_ids[wmi_tx_delba_complete_event_id] =
17127 WMI_TX_DELBA_COMPLETE_EVENTID;
17128 event_ids[wmi_tx_addba_complete_event_id] =
17129 WMI_TX_ADDBA_COMPLETE_EVENTID;
17130 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
17131
17132 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
17133
17134 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
17135 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
17136
17137 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
17138
17139 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
17140
17141 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080017142 event_ids[wmi_p2p_lo_stop_event_id] =
17143 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017144 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
17145 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
17146 event_ids[wmi_do_wow_disable_ack_event_id] =
17147 WMI_D0_WOW_DISABLE_ACK_EVENTID;
17148 event_ids[wmi_wow_initial_wakeup_event_id] =
17149 WMI_WOW_INITIAL_WAKEUP_EVENTID;
17150
17151 event_ids[wmi_rtt_meas_report_event_id] =
17152 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
17153 event_ids[wmi_tsf_meas_report_event_id] =
17154 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
17155 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
17156 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
17157 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
17158 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
17159 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
17160 event_ids[wmi_update_fw_mem_dump_event_id] =
17161 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
17162 event_ids[wmi_diag_event_id_log_supported_event_id] =
17163 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
17164 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
17165 event_ids[wmi_nlo_scan_complete_event_id] =
17166 WMI_NLO_SCAN_COMPLETE_EVENTID;
17167 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
17168 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
17169
17170 event_ids[wmi_gtk_offload_status_event_id] =
17171 WMI_GTK_OFFLOAD_STATUS_EVENTID;
17172 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
17173 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
17174 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
17175
17176 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
17177
17178 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
17179
17180 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
17181 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
17182 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
17183 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
17184 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
17185 event_ids[wmi_wlan_profile_data_event_id] =
17186 WMI_WLAN_PROFILE_DATA_EVENTID;
17187 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
17188 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
17189 event_ids[wmi_vdev_get_keepalive_event_id] =
17190 WMI_VDEV_GET_KEEPALIVE_EVENTID;
17191 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
17192
17193 event_ids[wmi_diag_container_event_id] =
17194 WMI_DIAG_DATA_CONTAINER_EVENTID;
17195
17196 event_ids[wmi_host_auto_shutdown_event_id] =
17197 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
17198
17199 event_ids[wmi_update_whal_mib_stats_event_id] =
17200 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
17201
17202 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
17203 event_ids[wmi_update_vdev_rate_stats_event_id] =
17204 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
17205
17206 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
17207
17208 /** Set OCB Sched Response, deprecated */
17209 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
17210
17211 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
17212 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
17213 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
17214
17215 /* GPIO Event */
17216 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
17217 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
17218
17219 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
17220 event_ids[wmi_rfkill_state_change_event_id] =
17221 WMI_RFKILL_STATE_CHANGE_EVENTID;
17222
17223 /* TDLS Event */
17224 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
17225
17226 event_ids[wmi_batch_scan_enabled_event_id] =
17227 WMI_BATCH_SCAN_ENABLED_EVENTID;
17228 event_ids[wmi_batch_scan_result_event_id] =
17229 WMI_BATCH_SCAN_RESULT_EVENTID;
17230 /* OEM Event */
17231 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
17232 event_ids[wmi_oem_meas_report_event_id] =
17233 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
17234 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
17235
17236 /* NAN Event */
17237 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
17238
17239 /* LPI Event */
17240 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
17241 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
17242 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
17243
17244 /* ExtScan events */
17245 event_ids[wmi_extscan_start_stop_event_id] =
17246 WMI_EXTSCAN_START_STOP_EVENTID;
17247 event_ids[wmi_extscan_operation_event_id] =
17248 WMI_EXTSCAN_OPERATION_EVENTID;
17249 event_ids[wmi_extscan_table_usage_event_id] =
17250 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
17251 event_ids[wmi_extscan_cached_results_event_id] =
17252 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
17253 event_ids[wmi_extscan_wlan_change_results_event_id] =
17254 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
17255 event_ids[wmi_extscan_hotlist_match_event_id] =
17256 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
17257 event_ids[wmi_extscan_capabilities_event_id] =
17258 WMI_EXTSCAN_CAPABILITIES_EVENTID;
17259 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
17260 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
17261
17262 /* mDNS offload events */
17263 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
17264
17265 /* SAP Authentication offload events */
17266 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
17267 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
17268
17269 /** Out-of-context-of-bss (OCB) events */
17270 event_ids[wmi_ocb_set_config_resp_event_id] =
17271 WMI_OCB_SET_CONFIG_RESP_EVENTID;
17272 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
17273 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
17274 event_ids[wmi_dcc_get_stats_resp_event_id] =
17275 WMI_DCC_GET_STATS_RESP_EVENTID;
17276 event_ids[wmi_dcc_update_ndl_resp_event_id] =
17277 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
17278 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
17279 /* System-On-Chip events */
17280 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
17281 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
17282 event_ids[wmi_soc_hw_mode_transition_event_id] =
17283 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
17284 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
17285 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053017286 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053017287 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
17288 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017289 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053017290 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
17291 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
17292 event_ids[wmi_peer_sta_ps_statechg_event_id] =
17293 WMI_PEER_STA_PS_STATECHG_EVENTID;
17294 event_ids[wmi_pdev_channel_hopping_event_id] =
17295 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
17296 event_ids[wmi_wds_peer_event_id] = WMI_WDS_PEER_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017297}
17298
Soumya Bhat488092d2017-03-22 14:41:01 +053017299#ifndef CONFIG_MCL
17300/**
17301 * populate_tlv_service() - populates wmi services
17302 *
17303 * @param wmi_service: Pointer to hold wmi_service
17304 * Return: None
17305 */
17306static void populate_tlv_service(uint32_t *wmi_service)
17307{
17308 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
17309 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
17310 wmi_service[wmi_service_roam_scan_offload] =
17311 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
17312 wmi_service[wmi_service_bcn_miss_offload] =
17313 WMI_SERVICE_BCN_MISS_OFFLOAD;
17314 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
17315 wmi_service[wmi_service_sta_advanced_pwrsave] =
17316 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
17317 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
17318 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
17319 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
17320 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
17321 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
17322 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
17323 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
17324 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
17325 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
17326 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
17327 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
17328 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
17329 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
17330 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
17331 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
17332 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
17333 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
17334 wmi_service[wmi_service_packet_power_save] =
17335 WMI_SERVICE_PACKET_POWER_SAVE;
17336 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
17337 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
17338 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
17339 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
17340 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
17341 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
17342 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
17343 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
17344 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
17345 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
17346 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
17347 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
17348 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
17349 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
17350 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
17351 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
17352 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
17353 wmi_service[wmi_service_mcc_bcn_interval_change] =
17354 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
17355 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
17356 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
17357 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
17358 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
17359 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
17360 wmi_service[wmi_service_lte_ant_share_support] =
17361 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
17362 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
17363 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
17364 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
17365 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
17366 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
17367 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
17368 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
17369 wmi_service[wmi_service_bcn_txrate_override] =
17370 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
17371 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
17372 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
17373 wmi_service[wmi_service_estimate_linkspeed] =
17374 WMI_SERVICE_ESTIMATE_LINKSPEED;
17375 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
17376 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
17377 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
17378 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
17379 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
17380 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
17381 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
17382 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
17383 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
17384 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
17385 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
17386 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
17387 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
17388 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
17389 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
17390 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
17391 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
17392 wmi_service[wmi_service_sap_auth_offload] =
17393 WMI_SERVICE_SAP_AUTH_OFFLOAD;
17394 wmi_service[wmi_service_dual_band_simultaneous_support] =
17395 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
17396 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
17397 wmi_service[wmi_service_ap_arpns_offload] =
17398 WMI_SERVICE_AP_ARPNS_OFFLOAD;
17399 wmi_service[wmi_service_per_band_chainmask_support] =
17400 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
17401 wmi_service[wmi_service_packet_filter_offload] =
17402 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
17403 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
17404 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
17405 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
17406 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
17407 wmi_service[wmi_service_multiple_vdev_restart] =
17408 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
17409
17410 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
17411 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
17412 wmi_service[wmi_service_smart_antenna_sw_support] =
17413 WMI_SERVICE_UNAVAILABLE;
17414 wmi_service[wmi_service_smart_antenna_hw_support] =
17415 WMI_SERVICE_UNAVAILABLE;
17416 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
17417 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
17418 wmi_service[wmi_service_atf] = WMI_SERVICE_UNAVAILABLE;
17419 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
17420 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
17421 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
17422 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
17423 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
17424 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
17425 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
17426 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
17427
17428 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
17429 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
17430 wmi_service[wmi_service_periodic_chan_stat_support] =
17431 WMI_SERVICE_UNAVAILABLE;
17432 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
17433 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
17434 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
17435 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
17436 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
17437 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
17438}
17439
Govind Singhe7f2f342016-05-23 12:12:52 +053017440/**
17441 * populate_pdev_param_tlv() - populates pdev params
17442 *
17443 * @param pdev_param: Pointer to hold pdev params
17444 * Return: None
17445 */
17446static void populate_pdev_param_tlv(uint32_t *pdev_param)
17447{
17448 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
17449 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
17450 pdev_param[wmi_pdev_param_txpower_limit2g] =
17451 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
17452 pdev_param[wmi_pdev_param_txpower_limit5g] =
17453 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
17454 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
17455 pdev_param[wmi_pdev_param_beacon_gen_mode] =
17456 WMI_PDEV_PARAM_BEACON_GEN_MODE;
17457 pdev_param[wmi_pdev_param_beacon_tx_mode] =
17458 WMI_PDEV_PARAM_BEACON_TX_MODE;
17459 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
17460 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
17461 pdev_param[wmi_pdev_param_protection_mode] =
17462 WMI_PDEV_PARAM_PROTECTION_MODE;
17463 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
17464 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
17465 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
17466 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
17467 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
17468 pdev_param[wmi_pdev_param_sta_kickout_th] =
17469 WMI_PDEV_PARAM_STA_KICKOUT_TH;
17470 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
17471 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
17472 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
17473 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
17474 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
17475 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
17476 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
17477 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
17478 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
17479 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
17480 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
17481 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
17482 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
17483 pdev_param[wmi_pdev_param_ltr_sleep_override] =
17484 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
17485 pdev_param[wmi_pdev_param_ltr_rx_override] =
17486 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
17487 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
17488 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
17489 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
17490 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
17491 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
17492 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
17493 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
17494 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
17495 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
17496 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
17497 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
17498 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
17499 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
17500 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
17501 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
17502 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
17503 pdev_param[wmi_pdev_param_peer_stats_update_period] =
17504 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
17505 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
17506 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
17507 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
17508 pdev_param[wmi_pdev_param_arp_ac_override] =
17509 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
17510 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
17511 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
17512 pdev_param[wmi_pdev_param_ani_poll_period] =
17513 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
17514 pdev_param[wmi_pdev_param_ani_listen_period] =
17515 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
17516 pdev_param[wmi_pdev_param_ani_ofdm_level] =
17517 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
17518 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
17519 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
17520 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
17521 pdev_param[wmi_pdev_param_idle_ps_config] =
17522 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
17523 pdev_param[wmi_pdev_param_power_gating_sleep] =
17524 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
17525 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
17526 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
17527 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
17528 pdev_param[wmi_pdev_param_hw_rfkill_config] =
17529 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
17530 pdev_param[wmi_pdev_param_low_power_rf_enable] =
17531 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
17532 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
17533 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
17534 pdev_param[wmi_pdev_param_power_collapse_enable] =
17535 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
17536 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
17537 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
17538 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
17539 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
17540 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
17541 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
17542 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
17543 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
17544 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
17545 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
17546 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
17547 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
17548 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
17549 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
17550 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
17551 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
17552 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
17553 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
17554 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
17555 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
17556 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
17557 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
17558 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
17559 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
17560 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
17561 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
17562 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
17563 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
17564 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
17565 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
17566 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
17567 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
17568 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
17569 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
17570 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
17571 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
17572 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
17573 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
17574 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
17575 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
17576 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
17577 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
17578 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
17579 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
17580 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
17581 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
17582 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
17583 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
17584 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
17585 WMI_UNAVAILABLE_PARAM;
17586 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
17587 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
17588 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
17589 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
17590 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
17591 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
17592 pdev_param[wmi_pdev_param_atf_strict_sch] = WMI_UNAVAILABLE_PARAM;
17593 pdev_param[wmi_pdev_param_atf_sched_duration] = WMI_UNAVAILABLE_PARAM;
17594 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
17595 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
17596 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
17597 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
17598 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
17599 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
17600 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
17601 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
17602 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
17603 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
17604 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
17605 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
17606 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
17607 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
17608 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
17609 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
17610 pdev_param[wmi_pdev_param_atf_obss_noise_sch] = WMI_UNAVAILABLE_PARAM;
17611 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
17612 WMI_UNAVAILABLE_PARAM;
17613 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
17614 pdev_param[wmi_pdev_param_atf_dynamic_enable] = WMI_UNAVAILABLE_PARAM;
17615 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
17616 WMI_UNAVAILABLE_PARAM;
17617 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
17618 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
17619 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
17620 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
17621 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
17622 WMI_UNAVAILABLE_PARAM;
17623 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
17624 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
17625 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053017626 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
17627 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017628 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053017629 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
17630 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053017631 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
17632 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
17633 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
17634 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
17635 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
17636 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
17637 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
17638 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
17639 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
17640 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
17641 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
17642 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
17643 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
17644 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
17645 pdev_param[wmi_pdev_param_fast_channel_reset] =
17646 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
17647 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053017648}
17649
17650/**
17651 * populate_vdev_param_tlv() - populates vdev params
17652 *
17653 * @param vdev_param: Pointer to hold vdev params
17654 * Return: None
17655 */
17656static void populate_vdev_param_tlv(uint32_t *vdev_param)
17657{
17658 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
17659 vdev_param[wmi_vdev_param_fragmentation_threshold] =
17660 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
17661 vdev_param[wmi_vdev_param_beacon_interval] =
17662 WMI_VDEV_PARAM_BEACON_INTERVAL;
17663 vdev_param[wmi_vdev_param_listen_interval] =
17664 WMI_VDEV_PARAM_LISTEN_INTERVAL;
17665 vdev_param[wmi_vdev_param_multicast_rate] =
17666 WMI_VDEV_PARAM_MULTICAST_RATE;
17667 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
17668 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
17669 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
17670 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
17671 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
17672 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
17673 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
17674 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
17675 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
17676 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
17677 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
17678 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
17679 vdev_param[wmi_vdev_param_bmiss_count_max] =
17680 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
17681 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
17682 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
17683 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
17684 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
17685 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
17686 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
17687 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
17688 vdev_param[wmi_vdev_param_disable_htprotection] =
17689 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
17690 vdev_param[wmi_vdev_param_sta_quickkickout] =
17691 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
17692 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
17693 vdev_param[wmi_vdev_param_protection_mode] =
17694 WMI_VDEV_PARAM_PROTECTION_MODE;
17695 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
17696 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
17697 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
17698 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
17699 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
17700 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
17701 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
17702 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
17703 vdev_param[wmi_vdev_param_bcast_data_rate] =
17704 WMI_VDEV_PARAM_BCAST_DATA_RATE;
17705 vdev_param[wmi_vdev_param_mcast_data_rate] =
17706 WMI_VDEV_PARAM_MCAST_DATA_RATE;
17707 vdev_param[wmi_vdev_param_mcast_indicate] =
17708 WMI_VDEV_PARAM_MCAST_INDICATE;
17709 vdev_param[wmi_vdev_param_dhcp_indicate] =
17710 WMI_VDEV_PARAM_DHCP_INDICATE;
17711 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
17712 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
17713 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
17714 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
17715 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
17716 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
17717 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
17718 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
17719 vdev_param[wmi_vdev_param_ap_enable_nawds] =
17720 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
17721 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
17722 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
17723 vdev_param[wmi_vdev_param_packet_powersave] =
17724 WMI_VDEV_PARAM_PACKET_POWERSAVE;
17725 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
17726 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
17727 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
17728 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
17729 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
17730 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
17731 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
17732 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
17733 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
17734 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
17735 vdev_param[wmi_vdev_param_early_rx_slop_step] =
17736 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
17737 vdev_param[wmi_vdev_param_early_rx_init_slop] =
17738 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
17739 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
17740 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
17741 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
17742 vdev_param[wmi_vdev_param_snr_num_for_cal] =
17743 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
17744 vdev_param[wmi_vdev_param_roam_fw_offload] =
17745 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
17746 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
17747 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
17748 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
17749 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
17750 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
17751 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
17752 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
17753 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
17754 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
17755 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
17756 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
17757 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
17758 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
17759 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
17760 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
17761 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
17762 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
17763 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
17764 vdev_param[wmi_vdev_param_inactivity_cnt] =
17765 WMI_VDEV_PARAM_INACTIVITY_CNT;
17766 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
17767 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
17768 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
17769 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
17770 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
17771 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
17772 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
17773 vdev_param[wmi_vdev_param_rx_leak_window] =
17774 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
17775 vdev_param[wmi_vdev_param_stats_avg_factor] =
17776 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
17777 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
17778 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
17779 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
17780 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
17781 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
17782 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053017783 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
17784 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053017785 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080017786 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
17787 vdev_param[wmi_vdev_param_he_range_ext_enable] =
17788 WMI_VDEV_PARAM_HE_RANGE_EXT;
17789 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
17790 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053017791 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
17792 vdev_param[wmi_vdev_param_dtim_enable_cts] =
17793 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
17794 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
17795 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
17796 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
17797 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053017798 vdev_param[wmi_vdev_param_mcast2ucast_set] =
17799 WMI_VDEV_PARAM_MCAST2UCAST_SET;
17800 vdev_param[wmi_vdev_param_rc_num_retries] =
17801 WMI_VDEV_PARAM_RC_NUM_RETRIES;
17802 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
17803 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
17804 vdev_param[wmi_vdev_param_rts_fixed_rate] =
17805 WMI_VDEV_PARAM_RTS_FIXED_RATE;
17806 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
17807 vdev_param[wmi_vdev_param_vht80_ratemask] =
17808 WMI_VDEV_PARAM_VHT80_RATEMASK;
17809 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
17810 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
17811 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053017812}
17813#endif
17814
Govind Singh5eb51532016-03-09 11:34:12 +053017815/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017816 * populate_target_defines_tlv() - Populate target defines and params
17817 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053017818 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053017819 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053017820 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053017821#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017822static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053017823{
Govind Singhe7f2f342016-05-23 12:12:52 +053017824 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053017825 populate_pdev_param_tlv(wmi_handle->pdev_param);
17826 populate_vdev_param_tlv(wmi_handle->vdev_param);
17827}
17828#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017829static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
17830{ }
17831#endif
17832
17833/**
17834 * wmi_tlv_attach() - Attach TLV APIs
17835 *
17836 * Return: None
17837 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053017838void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053017839{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053017840 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053017841#ifdef WMI_INTERFACE_EVENT_LOGGING
17842 wmi_handle->log_info.buf_offset_command = 2;
17843 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053017844#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053017845 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017846 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053017847}