blob: 64cc9df79e8c548c6d5a254ce5d2826bc32efcbd [file] [log] [blame]
Govind Singh5eb51532016-03-09 11:34:12 +05301/*
Paul Zhangd19abd82017-01-04 16:45:42 +08002 * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
Govind Singh5eb51532016-03-09 11:34:12 +05303 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Govind Singh5eb51532016-03-09 11:34:12 +053028#include "wmi_unified_api.h"
29#include "wmi.h"
Govind Singh224a7312016-06-21 14:33:26 +053030#include "wmi_version.h"
Govind Singh5eb51532016-03-09 11:34:12 +053031#include "wmi_unified_priv.h"
Govind Singha4836fd2016-03-07 16:45:38 +053032#include "wmi_version_whitelist.h"
Wu Gaocd3a8512017-03-13 20:17:34 +080033#ifdef CONVERGED_P2P_ENABLE
34#include "wlan_p2p_public_struct.h"
35#endif
Abhishek Singh5987b632017-03-03 22:09:07 +053036#include <wlan_utility.h>
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053037
38/* copy_vdev_create_pdev_id() - copy pdev from host params to target command
39 * buffer.
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053040 * @wmi_handle: pointer to wmi_handle
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053041 * @cmd: pointer target vdev create command buffer
42 * @param: pointer host params for vdev create
43 *
44 * Return: None
45 */
46#ifdef CONFIG_MCL
47static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053048 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053049 wmi_vdev_create_cmd_fixed_param * cmd,
50 struct vdev_create_params *param)
51{
52 cmd->pdev_id = WMI_PDEV_ID_SOC;
53}
54#else
55static inline void copy_vdev_create_pdev_id(
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053056 struct wmi_unified *wmi_handle,
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053057 wmi_vdev_create_cmd_fixed_param * cmd,
58 struct vdev_create_params *param)
59{
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053060 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
61 param->pdev_id);
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053062}
63#endif
64
Govind Singh5eb51532016-03-09 11:34:12 +053065/**
66 * send_vdev_create_cmd_tlv() - send VDEV create command to fw
67 * @wmi_handle: wmi handle
68 * @param: pointer to hold vdev create parameter
69 * @macaddr: vdev mac address
70 *
Govind Singhe7f2f342016-05-23 12:12:52 +053071 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +053072 */
Sathish Kumarfd347372017-02-13 12:29:09 +053073static QDF_STATUS send_vdev_create_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +053074 uint8_t macaddr[IEEE80211_ADDR_LEN],
75 struct vdev_create_params *param)
76{
77 wmi_vdev_create_cmd_fixed_param *cmd;
78 wmi_buf_t buf;
79 int32_t len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053080 QDF_STATUS ret;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070081 int num_bands = 2;
82 uint8_t *buf_ptr;
83 wmi_vdev_txrx_streams *txrx_streams;
Govind Singh5eb51532016-03-09 11:34:12 +053084
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070085 len += (num_bands * sizeof(*txrx_streams) + WMI_TLV_HDR_SIZE);
Govind Singh5eb51532016-03-09 11:34:12 +053086 buf = wmi_buf_alloc(wmi_handle, len);
87 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053088 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053089 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +053090 }
91 cmd = (wmi_vdev_create_cmd_fixed_param *) wmi_buf_data(buf);
92 WMITLV_SET_HDR(&cmd->tlv_header,
93 WMITLV_TAG_STRUC_wmi_vdev_create_cmd_fixed_param,
94 WMITLV_GET_STRUCT_TLVLEN
95 (wmi_vdev_create_cmd_fixed_param));
96 cmd->vdev_id = param->if_id;
97 cmd->vdev_type = param->type;
98 cmd->vdev_subtype = param->subtype;
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -070099 cmd->num_cfg_txrx_streams = num_bands;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530100 copy_vdev_create_pdev_id(wmi_handle, cmd, param);
Govind Singh5eb51532016-03-09 11:34:12 +0530101 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->vdev_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +0530102 WMI_LOGD("%s: ID = %d VAP Addr = %02x:%02x:%02x:%02x:%02x:%02x",
Govind Singh5eb51532016-03-09 11:34:12 +0530103 __func__, param->if_id,
104 macaddr[0], macaddr[1], macaddr[2],
105 macaddr[3], macaddr[4], macaddr[5]);
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700106 buf_ptr = (uint8_t *)cmd + sizeof(*cmd);
107 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
108 (num_bands * sizeof(wmi_vdev_txrx_streams)));
109 buf_ptr += WMI_TLV_HDR_SIZE;
110
Govind Singh224a7312016-06-21 14:33:26 +0530111 WMI_LOGD("%s: type %d, subtype %d, nss_2g %d, nss_5g %d", __func__,
Kiran Kumar Lokere51b7a162016-05-02 12:32:27 -0700112 param->type, param->subtype,
113 param->nss_2g, param->nss_5g);
114 txrx_streams = (wmi_vdev_txrx_streams *)buf_ptr;
115 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_2G;
116 txrx_streams->supported_tx_streams = param->nss_2g;
117 txrx_streams->supported_rx_streams = param->nss_2g;
118 WMITLV_SET_HDR(&txrx_streams->tlv_header,
119 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
120 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
121
122 txrx_streams++;
123 txrx_streams->band = WMI_TPC_CHAINMASK_CONFIG_BAND_5G;
124 txrx_streams->supported_tx_streams = param->nss_5g;
125 txrx_streams->supported_rx_streams = param->nss_5g;
126 WMITLV_SET_HDR(&txrx_streams->tlv_header,
127 WMITLV_TAG_STRUC_wmi_vdev_txrx_streams,
128 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_txrx_streams));
Govind Singh5eb51532016-03-09 11:34:12 +0530129 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_VDEV_CREATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530130 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530131 WMI_LOGE("Failed to send WMI_VDEV_CREATE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530132 wmi_buf_free(buf);
133 }
134
135 return ret;
136}
137
138/**
139 * send_vdev_delete_cmd_tlv() - send VDEV delete command to fw
140 * @wmi_handle: wmi handle
141 * @if_id: vdev id
142 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530143 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530144 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530145static QDF_STATUS send_vdev_delete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530146 uint8_t if_id)
147{
148 wmi_vdev_delete_cmd_fixed_param *cmd;
149 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +0530150 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +0530151
152 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
153 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530154 WMI_LOGP("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530155 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530156 }
157
158 cmd = (wmi_vdev_delete_cmd_fixed_param *) wmi_buf_data(buf);
159 WMITLV_SET_HDR(&cmd->tlv_header,
160 WMITLV_TAG_STRUC_wmi_vdev_delete_cmd_fixed_param,
161 WMITLV_GET_STRUCT_TLVLEN
162 (wmi_vdev_delete_cmd_fixed_param));
163 cmd->vdev_id = if_id;
164 ret = wmi_unified_cmd_send(wmi_handle, buf,
165 sizeof(wmi_vdev_delete_cmd_fixed_param),
166 WMI_VDEV_DELETE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530167 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530168 WMI_LOGE("Failed to send WMI_VDEV_DELETE_CMDID");
Govind Singh5eb51532016-03-09 11:34:12 +0530169 wmi_buf_free(buf);
170 }
Govind Singhb53420c2016-03-09 14:32:57 +0530171 WMI_LOGD("%s:vdev id = %d", __func__, if_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530172
173 return ret;
174}
175
176/**
177 * send_vdev_stop_cmd_tlv() - send vdev stop command to fw
178 * @wmi: wmi handle
179 * @vdev_id: vdev id
180 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530181 * Return: QDF_STATUS_SUCCESS for success or erro code
Govind Singh5eb51532016-03-09 11:34:12 +0530182 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530183static QDF_STATUS send_vdev_stop_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530184 uint8_t vdev_id)
185{
186 wmi_vdev_stop_cmd_fixed_param *cmd;
187 wmi_buf_t buf;
188 int32_t len = sizeof(*cmd);
189
190 buf = wmi_buf_alloc(wmi, len);
191 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530192 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530193 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530194 }
195 cmd = (wmi_vdev_stop_cmd_fixed_param *) wmi_buf_data(buf);
196 WMITLV_SET_HDR(&cmd->tlv_header,
197 WMITLV_TAG_STRUC_wmi_vdev_stop_cmd_fixed_param,
198 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_stop_cmd_fixed_param));
199 cmd->vdev_id = vdev_id;
200 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530201 WMI_LOGP("%s: Failed to send vdev stop command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530202 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530203 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530204 }
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +0530205 WMI_LOGD("%s:vdev id = %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530206
207 return 0;
208}
209
210/**
211 * send_vdev_down_cmd_tlv() - send vdev down command to fw
212 * @wmi: wmi handle
213 * @vdev_id: vdev id
214 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530215 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530216 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530217static QDF_STATUS send_vdev_down_cmd_tlv(wmi_unified_t wmi, uint8_t vdev_id)
Govind Singh5eb51532016-03-09 11:34:12 +0530218{
219 wmi_vdev_down_cmd_fixed_param *cmd;
220 wmi_buf_t buf;
221 int32_t len = sizeof(*cmd);
222
223 buf = wmi_buf_alloc(wmi, len);
224 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530225 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530226 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530227 }
228 cmd = (wmi_vdev_down_cmd_fixed_param *) wmi_buf_data(buf);
229 WMITLV_SET_HDR(&cmd->tlv_header,
230 WMITLV_TAG_STRUC_wmi_vdev_down_cmd_fixed_param,
231 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_down_cmd_fixed_param));
232 cmd->vdev_id = vdev_id;
233 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_DOWN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530234 WMI_LOGP("%s: Failed to send vdev down", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530235 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530236 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530237 }
Govind Singhb53420c2016-03-09 14:32:57 +0530238 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530239
240 return 0;
241}
242
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530243#ifdef CONFIG_MCL
244static inline void copy_channel_info(
245 wmi_vdev_start_request_cmd_fixed_param * cmd,
246 wmi_channel *chan,
247 struct vdev_start_params *req)
248{
249 chan->mhz = req->chan_freq;
250
251 WMI_SET_CHANNEL_MODE(chan, req->chan_mode);
252
253 chan->band_center_freq1 = req->band_center_freq1;
254 chan->band_center_freq2 = req->band_center_freq2;
255
256 if (req->is_half_rate)
257 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
258 else if (req->is_quarter_rate)
259 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
260
Naveen Rawat44f2f432016-12-01 12:58:57 -0800261 if (req->is_dfs && req->flag_dfs) {
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530262 WMI_SET_CHANNEL_FLAG(chan, req->flag_dfs);
263 cmd->disable_hw_ack = req->dis_hw_ack;
264 }
265
266 WMI_SET_CHANNEL_REG_POWER(chan, req->max_txpow);
267 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->max_txpow);
268
269}
270#else
271static inline void copy_channel_info(
272 wmi_vdev_start_request_cmd_fixed_param * cmd,
273 wmi_channel *chan,
274 struct vdev_start_params *req)
275{
276 chan->mhz = req->channel.mhz;
277
278 WMI_SET_CHANNEL_MODE(chan, req->channel.phy_mode);
279
280 chan->band_center_freq1 = req->channel.cfreq1;
281 chan->band_center_freq2 = req->channel.cfreq2;
282
283 if (req->channel.half_rate)
284 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
285 else if (req->channel.quarter_rate)
286 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
287
288 if (req->channel.dfs_set) {
Kiran Venkatappaf0b91a82016-11-09 13:59:16 +0530289 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530290 cmd->disable_hw_ack = req->disable_hw_ack;
291 }
292
Krishna Rao0b952ea2017-03-20 13:30:10 +0530293 if (req->channel.dfs_set_cfreq2)
294 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_DFS_CFREQ2);
295
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530296 /* FIXME: Find out min, max and regulatory power levels */
297 WMI_SET_CHANNEL_REG_POWER(chan, req->channel.maxregpower);
298 WMI_SET_CHANNEL_MAX_TX_POWER(chan, req->channel.maxpower);
299
300}
301#endif
Govind Singh5eb51532016-03-09 11:34:12 +0530302/**
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530303 * send_vdev_start_cmd_tlv() - send vdev start request to fw
304 * @wmi_handle: wmi handle
305 * @req: vdev start params
306 *
307 * Return: QDF status
308 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530309static QDF_STATUS send_vdev_start_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530310 struct vdev_start_params *req)
311{
312 wmi_vdev_start_request_cmd_fixed_param *cmd;
313 wmi_buf_t buf;
314 wmi_channel *chan;
315 int32_t len, ret;
316 uint8_t *buf_ptr;
317
318 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
319 buf = wmi_buf_alloc(wmi_handle, len);
320 if (!buf) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530321 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530322 return QDF_STATUS_E_NOMEM;
323 }
324 buf_ptr = (uint8_t *) wmi_buf_data(buf);
325 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
326 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
327 WMITLV_SET_HDR(&cmd->tlv_header,
328 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
329 WMITLV_GET_STRUCT_TLVLEN
330 (wmi_vdev_start_request_cmd_fixed_param));
331 WMITLV_SET_HDR(&chan->tlv_header, WMITLV_TAG_STRUC_wmi_channel,
332 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
333 cmd->vdev_id = req->vdev_id;
334
335 /* Fill channel info */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530336 copy_channel_info(cmd, chan, req);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530337
338 cmd->beacon_interval = req->beacon_intval;
339 cmd->dtim_period = req->dtim_period;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530340
341 if (!req->is_restart) {
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530342 cmd->beacon_interval = req->beacon_intval;
343 cmd->dtim_period = req->dtim_period;
344
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530345 /* Copy the SSID */
346 if (req->ssid.length) {
347 if (req->ssid.length < sizeof(cmd->ssid.ssid))
348 cmd->ssid.ssid_len = req->ssid.length;
349 else
350 cmd->ssid.ssid_len = sizeof(cmd->ssid.ssid);
351 qdf_mem_copy(cmd->ssid.ssid, req->ssid.mac_ssid,
352 cmd->ssid.ssid_len);
353 }
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530354
355 if (req->hidden_ssid)
356 cmd->flags |= WMI_UNIFIED_VDEV_START_HIDDEN_SSID;
357
358 if (req->pmf_enabled)
359 cmd->flags |= WMI_UNIFIED_VDEV_START_PMF_ENABLED;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530360 }
361
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530362 cmd->num_noa_descriptors = req->num_noa_descriptors;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530363 cmd->preferred_rx_streams = req->preferred_rx_streams;
364 cmd->preferred_tx_streams = req->preferred_tx_streams;
Arif Hussaindf0211a2017-03-13 15:42:20 -0700365 cmd->cac_duration_ms = req->cac_duration_ms;
366 cmd->regdomain = req->regdomain;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700367 cmd->he_ops = req->he_ops;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530368
369 buf_ptr = (uint8_t *) (((uintptr_t) cmd) + sizeof(*cmd) +
370 sizeof(wmi_channel));
371 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
372 cmd->num_noa_descriptors *
373 sizeof(wmi_p2p_noa_descriptor));
Naveen Rawat44f2f432016-12-01 12:58:57 -0800374 WMI_LOGA("%s: vdev_id %d freq %d chanmode %d ch_info: 0x%x is_dfs %d "
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530375 "beacon interval %d dtim %d center_chan %d center_freq2 %d "
376 "reg_info_1: 0x%x reg_info_2: 0x%x, req->max_txpow: 0x%x "
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700377 "Tx SS %d, Rx SS %d, cac %d, regd %d, HE ops: %d",
Naveen Rawat44f2f432016-12-01 12:58:57 -0800378 __func__, req->vdev_id, chan->mhz, req->chan_mode, chan->info,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530379 req->is_dfs, req->beacon_intval, cmd->dtim_period,
380 chan->band_center_freq1, chan->band_center_freq2,
381 chan->reg_info_1, chan->reg_info_2, req->max_txpow,
Arif Hussaindf0211a2017-03-13 15:42:20 -0700382 req->preferred_tx_streams, req->preferred_rx_streams,
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -0700383 req->cac_duration_ms, req->regdomain, req->he_ops);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530384
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530385 if (req->is_restart)
386 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
387 WMI_VDEV_RESTART_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530388 else
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530389 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
390 WMI_VDEV_START_REQUEST_CMDID);
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530391 if (ret) {
392 WMI_LOGP("%s: Failed to send vdev start command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530393 wmi_buf_free(buf);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530394 return QDF_STATUS_E_FAILURE;
Siddarth Poddaraa0b9a42016-03-29 15:13:26 +0530395 }
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530396
397 return QDF_STATUS_SUCCESS;
398}
399
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530400/**
401 * send_hidden_ssid_vdev_restart_cmd_tlv() - restart vdev to set hidden ssid
402 * @wmi_handle: wmi handle
403 * @restart_params: vdev restart params
404 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530405 * Return: QDF_STATUS_SUCCESS for success or error code
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530406 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530407static QDF_STATUS send_hidden_ssid_vdev_restart_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530408 struct hidden_ssid_vdev_restart_params *restart_params)
409{
410 wmi_vdev_start_request_cmd_fixed_param *cmd;
411 wmi_buf_t buf;
412 wmi_channel *chan;
413 int32_t len;
414 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +0530415 QDF_STATUS ret = 0;
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530416
417 len = sizeof(*cmd) + sizeof(wmi_channel) + WMI_TLV_HDR_SIZE;
418 buf = wmi_buf_alloc(wmi_handle, len);
419 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +0530420 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530421 return QDF_STATUS_E_NOMEM;
422 }
423 buf_ptr = (uint8_t *) wmi_buf_data(buf);
424 cmd = (wmi_vdev_start_request_cmd_fixed_param *) buf_ptr;
425 chan = (wmi_channel *) (buf_ptr + sizeof(*cmd));
426
427 WMITLV_SET_HDR(&cmd->tlv_header,
428 WMITLV_TAG_STRUC_wmi_vdev_start_request_cmd_fixed_param,
429 WMITLV_GET_STRUCT_TLVLEN
430 (wmi_vdev_start_request_cmd_fixed_param));
431
432 WMITLV_SET_HDR(&chan->tlv_header,
433 WMITLV_TAG_STRUC_wmi_channel,
434 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
435
436 cmd->vdev_id = restart_params->session_id;
437 cmd->ssid.ssid_len = restart_params->ssid_len;
438 qdf_mem_copy(cmd->ssid.ssid,
439 restart_params->ssid,
440 cmd->ssid.ssid_len);
441 cmd->flags = restart_params->flags;
442 cmd->requestor_id = restart_params->requestor_id;
443 cmd->disable_hw_ack = restart_params->disable_hw_ack;
444
445 chan->mhz = restart_params->mhz;
446 chan->band_center_freq1 =
447 restart_params->band_center_freq1;
448 chan->band_center_freq2 =
449 restart_params->band_center_freq2;
450 chan->info = restart_params->info;
451 chan->reg_info_1 = restart_params->reg_info_1;
452 chan->reg_info_2 = restart_params->reg_info_2;
453
454 cmd->num_noa_descriptors = 0;
455 buf_ptr = (uint8_t *) (((uint8_t *) cmd) + sizeof(*cmd) +
456 sizeof(wmi_channel));
457 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
458 cmd->num_noa_descriptors *
459 sizeof(wmi_p2p_noa_descriptor));
460
461 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
462 WMI_VDEV_RESTART_REQUEST_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +0530463 if (QDF_IS_STATUS_ERROR(ret)) {
Himanshu Agarwal0007b762016-03-09 16:49:38 +0530464 wmi_buf_free(buf);
465 return QDF_STATUS_E_FAILURE;
466 }
467 return QDF_STATUS_SUCCESS;
468}
469
470
471/**
Govind Singh5eb51532016-03-09 11:34:12 +0530472 * send_peer_flush_tids_cmd_tlv() - flush peer tids packets in fw
473 * @wmi: wmi handle
474 * @peer_addr: peer mac address
475 * @param: pointer to hold peer flush tid parameter
476 *
477 * Return: 0 for sucess or error code
478 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530479static QDF_STATUS send_peer_flush_tids_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530480 uint8_t peer_addr[IEEE80211_ADDR_LEN],
481 struct peer_flush_params *param)
482{
483 wmi_peer_flush_tids_cmd_fixed_param *cmd;
484 wmi_buf_t buf;
485 int32_t len = sizeof(*cmd);
486
487 buf = wmi_buf_alloc(wmi, len);
488 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530489 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530490 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530491 }
492 cmd = (wmi_peer_flush_tids_cmd_fixed_param *) wmi_buf_data(buf);
493 WMITLV_SET_HDR(&cmd->tlv_header,
494 WMITLV_TAG_STRUC_wmi_peer_flush_tids_cmd_fixed_param,
495 WMITLV_GET_STRUCT_TLVLEN
496 (wmi_peer_flush_tids_cmd_fixed_param));
497 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
498 cmd->peer_tid_bitmap = param->peer_tid_bitmap;
499 cmd->vdev_id = param->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +0530500 WMI_LOGD("%s: peer_addr %pM vdev_id %d and peer bitmap %d", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530501 peer_addr, param->vdev_id,
502 param->peer_tid_bitmap);
503 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_FLUSH_TIDS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530504 WMI_LOGP("%s: Failed to send flush tid command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530505 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530506 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530507 }
508
509 return 0;
510}
511
512/**
513 * send_peer_delete_cmd_tlv() - send PEER delete command to fw
514 * @wmi: wmi handle
515 * @peer_addr: peer mac addr
516 * @vdev_id: vdev id
517 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530518 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530519 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530520static QDF_STATUS send_peer_delete_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530521 uint8_t peer_addr[IEEE80211_ADDR_LEN],
522 uint8_t vdev_id)
523{
524 wmi_peer_delete_cmd_fixed_param *cmd;
525 wmi_buf_t buf;
526 int32_t len = sizeof(*cmd);
527 buf = wmi_buf_alloc(wmi, len);
528 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530529 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530530 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530531 }
532 cmd = (wmi_peer_delete_cmd_fixed_param *) wmi_buf_data(buf);
533 WMITLV_SET_HDR(&cmd->tlv_header,
534 WMITLV_TAG_STRUC_wmi_peer_delete_cmd_fixed_param,
535 WMITLV_GET_STRUCT_TLVLEN
536 (wmi_peer_delete_cmd_fixed_param));
537 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
538 cmd->vdev_id = vdev_id;
539
Orhan K AKYILDIZc8d1c4b2017-01-10 14:32:18 -0800540 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, peer_addr, vdev_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530541 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_DELETE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530542 WMI_LOGP("%s: Failed to send peer delete command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530543 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530544 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530545 }
Govind Singh5eb51532016-03-09 11:34:12 +0530546
547 return 0;
548}
549
550/**
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530551 * convert_host_peer_id_to_target_id_tlv - convert host peer param_id
552 * to target id.
553 * @targ_paramid: Target parameter id to hold the result.
554 * @peer_param_id: host param id.
555 *
556 * Return: QDF_STATUS_SUCCESS for success
557 * QDF_STATUS_E_NOSUPPORT when the param_id in not supported in tareget
558 */
559#ifdef CONFIG_MCL
560static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
561 uint32_t *targ_paramid,
562 uint32_t peer_param_id)
563{
564 *targ_paramid = peer_param_id;
565 return QDF_STATUS_SUCCESS;
566}
567#else
568static QDF_STATUS convert_host_peer_id_to_target_id_tlv(
569 uint32_t *targ_paramid,
570 uint32_t peer_param_id)
571{
572 switch (peer_param_id) {
573 case WMI_HOST_PEER_MIMO_PS_STATE:
574 *targ_paramid = WMI_PEER_MIMO_PS_STATE;
575 break;
576 case WMI_HOST_PEER_AMPDU:
577 *targ_paramid = WMI_PEER_AMPDU;
578 break;
579 case WMI_HOST_PEER_AUTHORIZE:
580 *targ_paramid = WMI_PEER_AUTHORIZE;
581 break;
582 case WMI_HOST_PEER_CHWIDTH:
583 *targ_paramid = WMI_PEER_CHWIDTH;
584 break;
585 case WMI_HOST_PEER_NSS:
586 *targ_paramid = WMI_PEER_NSS;
587 break;
588 case WMI_HOST_PEER_USE_4ADDR:
589 *targ_paramid = WMI_PEER_USE_4ADDR;
590 break;
591 case WMI_HOST_PEER_MEMBERSHIP:
592 *targ_paramid = WMI_PEER_MEMBERSHIP;
593 break;
594 case WMI_HOST_PEER_USERPOS:
595 *targ_paramid = WMI_PEER_USERPOS;
596 break;
597 case WMI_HOST_PEER_CRIT_PROTO_HINT_ENABLED:
598 *targ_paramid = WMI_PEER_CRIT_PROTO_HINT_ENABLED;
599 break;
600 case WMI_HOST_PEER_TX_FAIL_CNT_THR:
601 *targ_paramid = WMI_PEER_TX_FAIL_CNT_THR;
602 break;
603 case WMI_HOST_PEER_SET_HW_RETRY_CTS2S:
604 *targ_paramid = WMI_PEER_SET_HW_RETRY_CTS2S;
605 break;
606 case WMI_HOST_PEER_IBSS_ATIM_WINDOW_LENGTH:
607 *targ_paramid = WMI_PEER_IBSS_ATIM_WINDOW_LENGTH;
608 break;
609 case WMI_HOST_PEER_PHYMODE:
610 *targ_paramid = WMI_PEER_PHYMODE;
611 break;
612 case WMI_HOST_PEER_USE_FIXED_PWR:
613 *targ_paramid = WMI_PEER_USE_FIXED_PWR;
614 break;
615 case WMI_HOST_PEER_PARAM_FIXED_RATE:
616 *targ_paramid = WMI_PEER_PARAM_FIXED_RATE;
617 break;
618 case WMI_HOST_PEER_SET_MU_WHITELIST:
619 *targ_paramid = WMI_PEER_SET_MU_WHITELIST;
620 break;
621 case WMI_HOST_PEER_SET_MAC_TX_RATE:
622 *targ_paramid = WMI_PEER_SET_MAX_TX_RATE;
623 break;
624 case WMI_HOST_PEER_SET_MIN_TX_RATE:
625 *targ_paramid = WMI_PEER_SET_MIN_TX_RATE;
626 break;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +0530627 case WMI_HOST_PEER_SET_DEFAULT_ROUTING:
628 *targ_paramid = WMI_PEER_SET_DEFAULT_ROUTING;
629 break;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530630 default:
631 return QDF_STATUS_E_NOSUPPORT;
632 }
633
634 return QDF_STATUS_SUCCESS;
635}
636#endif
637/**
Govind Singh5eb51532016-03-09 11:34:12 +0530638 * send_peer_param_cmd_tlv() - set peer parameter in fw
Govind Singh2edc80f2016-03-01 15:30:53 +0530639 * @wmi: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +0530640 * @peer_addr: peer mac address
641 * @param : pointer to hold peer set parameter
642 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530643 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530644 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530645static QDF_STATUS send_peer_param_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530646 uint8_t peer_addr[IEEE80211_ADDR_LEN],
647 struct peer_set_params *param)
648{
649 wmi_peer_set_param_cmd_fixed_param *cmd;
650 wmi_buf_t buf;
651 int32_t err;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530652 uint32_t param_id;
653
654 if (convert_host_peer_id_to_target_id_tlv(&param_id,
655 param->param_id) != QDF_STATUS_SUCCESS)
656 return QDF_STATUS_E_NOSUPPORT;
Govind Singh5eb51532016-03-09 11:34:12 +0530657
658 buf = wmi_buf_alloc(wmi, sizeof(*cmd));
659 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530660 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +0530661 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530662 }
663 cmd = (wmi_peer_set_param_cmd_fixed_param *) wmi_buf_data(buf);
664 WMITLV_SET_HDR(&cmd->tlv_header,
665 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
666 WMITLV_GET_STRUCT_TLVLEN
667 (wmi_peer_set_param_cmd_fixed_param));
668 cmd->vdev_id = param->vdev_id;
669 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +0530670 cmd->param_id = param_id;
Govind Singh5eb51532016-03-09 11:34:12 +0530671 cmd->param_value = param->param_value;
672 err = wmi_unified_cmd_send(wmi, buf,
673 sizeof(wmi_peer_set_param_cmd_fixed_param),
674 WMI_PEER_SET_PARAM_CMDID);
675 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +0530676 WMI_LOGE("Failed to send set_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +0530677 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530678 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530679 }
680
681 return 0;
682}
683
684/**
685 * send_vdev_up_cmd_tlv() - send vdev up command in fw
686 * @wmi: wmi handle
687 * @bssid: bssid
688 * @vdev_up_params: pointer to hold vdev up parameter
689 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530690 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530691 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530692static QDF_STATUS send_vdev_up_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530693 uint8_t bssid[IEEE80211_ADDR_LEN],
694 struct vdev_up_params *params)
695{
696 wmi_vdev_up_cmd_fixed_param *cmd;
697 wmi_buf_t buf;
698 int32_t len = sizeof(*cmd);
699
Govind Singhb53420c2016-03-09 14:32:57 +0530700 WMI_LOGD("%s: VDEV_UP", __func__);
701 WMI_LOGD("%s: vdev_id %d aid %d bssid %pM", __func__,
Govind Singh5eb51532016-03-09 11:34:12 +0530702 params->vdev_id, params->assoc_id, bssid);
703 buf = wmi_buf_alloc(wmi, len);
704 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530705 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530706 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530707 }
708 cmd = (wmi_vdev_up_cmd_fixed_param *) wmi_buf_data(buf);
709 WMITLV_SET_HDR(&cmd->tlv_header,
710 WMITLV_TAG_STRUC_wmi_vdev_up_cmd_fixed_param,
711 WMITLV_GET_STRUCT_TLVLEN(wmi_vdev_up_cmd_fixed_param));
712 cmd->vdev_id = params->vdev_id;
713 cmd->vdev_assoc_id = params->assoc_id;
714 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid, &cmd->vdev_bssid);
715 if (wmi_unified_cmd_send(wmi, buf, len, WMI_VDEV_UP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530716 WMI_LOGP("%s: Failed to send vdev up command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530717 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530718 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530719 }
720
721 return 0;
722}
723
724/**
725 * send_peer_create_cmd_tlv() - send peer create command to fw
726 * @wmi: wmi handle
727 * @peer_addr: peer mac address
728 * @peer_type: peer type
729 * @vdev_id: vdev id
730 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530731 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530732 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530733static QDF_STATUS send_peer_create_cmd_tlv(wmi_unified_t wmi,
Govind Singh5eb51532016-03-09 11:34:12 +0530734 struct peer_create_params *param)
735{
736 wmi_peer_create_cmd_fixed_param *cmd;
737 wmi_buf_t buf;
738 int32_t len = sizeof(*cmd);
739
740 buf = wmi_buf_alloc(wmi, len);
741 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530742 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530743 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530744 }
745 cmd = (wmi_peer_create_cmd_fixed_param *) wmi_buf_data(buf);
746 WMITLV_SET_HDR(&cmd->tlv_header,
747 WMITLV_TAG_STRUC_wmi_peer_create_cmd_fixed_param,
748 WMITLV_GET_STRUCT_TLVLEN
749 (wmi_peer_create_cmd_fixed_param));
750 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
751 cmd->peer_type = param->peer_type;
752 cmd->vdev_id = param->vdev_id;
753
754 if (wmi_unified_cmd_send(wmi, buf, len, WMI_PEER_CREATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530755 WMI_LOGP("%s: failed to send WMI_PEER_CREATE_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530756 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530757 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530758 }
Govind Singhb53420c2016-03-09 14:32:57 +0530759 WMI_LOGD("%s: peer_addr %pM vdev_id %d", __func__, param->peer_addr,
Govind Singh5eb51532016-03-09 11:34:12 +0530760 param->vdev_id);
761
762 return 0;
763}
764
765/**
Leo Changeee40872016-09-28 13:43:36 -0700766 * send_peer_rx_reorder_queue_setup_cmd_tlv() - send rx reorder setup
767 * command to fw
768 * @wmi: wmi handle
769 * @rx_reorder_queue_setup_params: Rx reorder queue setup parameters
770 *
771 * Return: 0 for success or error code
772 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700773static
Leo Changeee40872016-09-28 13:43:36 -0700774QDF_STATUS send_peer_rx_reorder_queue_setup_cmd_tlv(wmi_unified_t wmi,
775 struct rx_reorder_queue_setup_params *param)
776{
777 wmi_peer_reorder_queue_setup_cmd_fixed_param *cmd;
778 wmi_buf_t buf;
779 int32_t len = sizeof(*cmd);
780
781 buf = wmi_buf_alloc(wmi, len);
782 if (!buf) {
783 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
784 return QDF_STATUS_E_NOMEM;
785 }
786 cmd = (wmi_peer_reorder_queue_setup_cmd_fixed_param *)wmi_buf_data(buf);
787 WMITLV_SET_HDR(&cmd->tlv_header,
788 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_setup_cmd_fixed_param,
789 WMITLV_GET_STRUCT_TLVLEN
790 (wmi_peer_reorder_queue_setup_cmd_fixed_param));
791 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
792 cmd->vdev_id = param->vdev_id;
793 cmd->tid = param->tid;
794 cmd->queue_ptr_lo = param->hw_qdesc_paddr_lo;
795 cmd->queue_ptr_hi = param->hw_qdesc_paddr_hi;
796 cmd->queue_no = param->queue_no;
797
798 if (wmi_unified_cmd_send(wmi, buf, len,
799 WMI_PEER_REORDER_QUEUE_SETUP_CMDID)) {
800 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_SETUP_CMDID",
801 __func__);
802 qdf_nbuf_free(buf);
803 return QDF_STATUS_E_FAILURE;
804 }
805 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid %d\n", __func__,
806 param->peer_macaddr, param->vdev_id, param->tid);
807
808 return QDF_STATUS_SUCCESS;
809}
810
811/**
812 * send_peer_rx_reorder_queue_remove_cmd_tlv() - send rx reorder remove
813 * command to fw
814 * @wmi: wmi handle
815 * @rx_reorder_queue_remove_params: Rx reorder queue remove parameters
816 *
817 * Return: 0 for success or error code
818 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -0700819static
Leo Changeee40872016-09-28 13:43:36 -0700820QDF_STATUS send_peer_rx_reorder_queue_remove_cmd_tlv(wmi_unified_t wmi,
821 struct rx_reorder_queue_remove_params *param)
822{
823 wmi_peer_reorder_queue_remove_cmd_fixed_param *cmd;
824 wmi_buf_t buf;
825 int32_t len = sizeof(*cmd);
826
827 buf = wmi_buf_alloc(wmi, len);
828 if (!buf) {
829 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
830 return QDF_STATUS_E_NOMEM;
831 }
832 cmd = (wmi_peer_reorder_queue_remove_cmd_fixed_param *)
833 wmi_buf_data(buf);
834 WMITLV_SET_HDR(&cmd->tlv_header,
835 WMITLV_TAG_STRUC_wmi_peer_reorder_queue_remove_cmd_fixed_param,
836 WMITLV_GET_STRUCT_TLVLEN
837 (wmi_peer_reorder_queue_remove_cmd_fixed_param));
838 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr, &cmd->peer_macaddr);
839 cmd->vdev_id = param->vdev_id;
840 cmd->tid_mask = param->peer_tid_bitmap;
841
842 if (wmi_unified_cmd_send(wmi, buf, len,
843 WMI_PEER_REORDER_QUEUE_REMOVE_CMDID)) {
844 WMI_LOGP("%s: fail to send WMI_PEER_REORDER_QUEUE_REMOVE_CMDID",
845 __func__);
846 qdf_nbuf_free(buf);
847 return QDF_STATUS_E_FAILURE;
848 }
849 WMI_LOGD("%s: peer_macaddr %pM vdev_id %d, tid_map %d", __func__,
850 param->peer_macaddr, param->vdev_id, param->peer_tid_bitmap);
851
852 return QDF_STATUS_SUCCESS;
853}
854
855/**
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530856 * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
857 * @wmi_handle: wmi handle
858 * @param: pointer holding peer details
859 *
860 * Return: 0 for success or error code
861 */
862static QDF_STATUS send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
863 struct peer_add_wds_entry_params *param)
864{
865 wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
866 wmi_buf_t buf;
867 int len = sizeof(*cmd);
868
869 buf = wmi_buf_alloc(wmi_handle, len);
870 if (!buf) {
871 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
872 return QDF_STATUS_E_FAILURE;
873 }
874 cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *) wmi_buf_data(buf);
875 WMITLV_SET_HDR(&cmd->tlv_header,
876 WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
877 WMITLV_GET_STRUCT_TLVLEN
878 (wmi_peer_add_wds_entry_cmd_fixed_param));
879 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
880 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
881 cmd->flags = param->flags;
882
883 return wmi_unified_cmd_send(wmi_handle, buf, len,
884 WMI_PEER_ADD_WDS_ENTRY_CMDID);
885}
886
887/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +0530888 * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
Ishank Jainf4b8a7a2017-02-23 22:38:42 +0530889 * @wmi_handle: wmi handle
890 * @param: pointer holding peer details
891 *
892 * Return: 0 for success or error code
893 */
894static QDF_STATUS send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
895 struct peer_del_wds_entry_params *param)
896{
897 wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
898 wmi_buf_t buf;
899 int len = sizeof(*cmd);
900
901 buf = wmi_buf_alloc(wmi_handle, len);
902 if (!buf) {
903 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
904 return QDF_STATUS_E_NOMEM;
905 }
906 cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
907 WMITLV_SET_HDR(&cmd->tlv_header,
908 WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
909 WMITLV_GET_STRUCT_TLVLEN
910 (wmi_peer_remove_wds_entry_cmd_fixed_param));
911 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
912 return wmi_unified_cmd_send(wmi_handle, buf, len,
913 WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
914}
915
916/**
917 * send_peer_update_wds_entry_cmd_non_tlv() - send peer update command to fw
918 * @wmi_handle: wmi handle
919 * @param: pointer holding peer details
920 *
921 * Return: 0 for success or error code
922 */
923static QDF_STATUS send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
924 struct peer_update_wds_entry_params *param)
925{
926 wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
927 wmi_buf_t buf;
928 int len = sizeof(*cmd);
929
930 buf = wmi_buf_alloc(wmi_handle, len);
931 if (!buf) {
932 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
933 return QDF_STATUS_E_NOMEM;
934 }
935
936 /* wmi_buf_alloc returns zeroed command buffer */
937 cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
938 WMITLV_SET_HDR(&cmd->tlv_header,
939 WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
940 WMITLV_GET_STRUCT_TLVLEN
941 (wmi_peer_update_wds_entry_cmd_fixed_param));
942 cmd->flags = (param->flags) ? WMI_WDS_FLAG_STATIC : 0;
943 if (param->wds_macaddr)
944 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->wds_macaddr,
945 &cmd->wds_macaddr);
946 if (param->peer_macaddr)
947 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_macaddr,
948 &cmd->peer_macaddr);
949 return wmi_unified_cmd_send(wmi_handle, buf, len,
950 WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
951}
952
953
954
955/**
Govind Singh5eb51532016-03-09 11:34:12 +0530956 * send_green_ap_ps_cmd_tlv() - enable green ap powersave command
957 * @wmi_handle: wmi handle
958 * @value: value
959 * @mac_id: mac id to have radio context
960 *
Govind Singhe7f2f342016-05-23 12:12:52 +0530961 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +0530962 */
Sathish Kumarfd347372017-02-13 12:29:09 +0530963static QDF_STATUS send_green_ap_ps_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +0530964 uint32_t value, uint8_t mac_id)
965{
966 wmi_pdev_green_ap_ps_enable_cmd_fixed_param *cmd;
967 wmi_buf_t buf;
968 int32_t len = sizeof(*cmd);
969
Govind Singhb53420c2016-03-09 14:32:57 +0530970 WMI_LOGD("Set Green AP PS val %d", value);
Govind Singh5eb51532016-03-09 11:34:12 +0530971
972 buf = wmi_buf_alloc(wmi_handle, len);
973 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +0530974 WMI_LOGP("%s: Green AP PS Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +0530975 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +0530976 }
977
978 cmd = (wmi_pdev_green_ap_ps_enable_cmd_fixed_param *) wmi_buf_data(buf);
979 WMITLV_SET_HDR(&cmd->tlv_header,
980 WMITLV_TAG_STRUC_wmi_pdev_green_ap_ps_enable_cmd_fixed_param,
981 WMITLV_GET_STRUCT_TLVLEN
982 (wmi_pdev_green_ap_ps_enable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +0530983 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +0530984 cmd->enable = value;
985
986 if (wmi_unified_cmd_send(wmi_handle, buf, len,
987 WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +0530988 WMI_LOGE("Set Green AP PS param Failed val %d", value);
Abhishek Singh716c46c2016-05-04 16:24:07 +0530989 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +0530990 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +0530991 }
992
993 return 0;
994}
995
996/**
997 * send_pdev_utf_cmd_tlv() - send utf command to fw
998 * @wmi_handle: wmi handle
999 * @param: pointer to pdev_utf_params
1000 * @mac_id: mac id to have radio context
1001 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301002 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301003 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301004static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301005send_pdev_utf_cmd_tlv(wmi_unified_t wmi_handle,
1006 struct pdev_utf_params *param,
1007 uint8_t mac_id)
1008{
1009 wmi_buf_t buf;
1010 uint8_t *cmd;
Houston Hoffmancdd5eda2016-09-27 23:29:49 -07001011 /* if param->len is 0 no data is sent, return error */
1012 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Govind Singh5eb51532016-03-09 11:34:12 +05301013 static uint8_t msgref = 1;
1014 uint8_t segNumber = 0, segInfo, numSegments;
1015 uint16_t chunk_len, total_bytes;
1016 uint8_t *bufpos;
1017 struct seg_hdr_info segHdrInfo;
1018
1019 bufpos = param->utf_payload;
1020 total_bytes = param->len;
1021 ASSERT(total_bytes / MAX_WMI_UTF_LEN ==
1022 (uint8_t) (total_bytes / MAX_WMI_UTF_LEN));
1023 numSegments = (uint8_t) (total_bytes / MAX_WMI_UTF_LEN);
1024
1025 if (param->len - (numSegments * MAX_WMI_UTF_LEN))
1026 numSegments++;
1027
1028 while (param->len) {
1029 if (param->len > MAX_WMI_UTF_LEN)
1030 chunk_len = MAX_WMI_UTF_LEN; /* MAX messsage */
1031 else
1032 chunk_len = param->len;
1033
1034 buf = wmi_buf_alloc(wmi_handle,
1035 (chunk_len + sizeof(segHdrInfo) +
1036 WMI_TLV_HDR_SIZE));
1037 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301038 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301039 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301040 }
1041
1042 cmd = (uint8_t *) wmi_buf_data(buf);
1043
1044 segHdrInfo.len = total_bytes;
1045 segHdrInfo.msgref = msgref;
1046 segInfo = ((numSegments << 4) & 0xF0) | (segNumber & 0xF);
1047 segHdrInfo.segmentInfo = segInfo;
1048 segHdrInfo.pad = 0;
1049
Govind Singhb53420c2016-03-09 14:32:57 +05301050 WMI_LOGD("%s:segHdrInfo.len = %d, segHdrInfo.msgref = %d,"
Govind Singh5eb51532016-03-09 11:34:12 +05301051 " segHdrInfo.segmentInfo = %d",
1052 __func__, segHdrInfo.len, segHdrInfo.msgref,
1053 segHdrInfo.segmentInfo);
1054
Govind Singhb53420c2016-03-09 14:32:57 +05301055 WMI_LOGD("%s:total_bytes %d segNumber %d totalSegments %d"
Govind Singh5eb51532016-03-09 11:34:12 +05301056 "chunk len %d", __func__, total_bytes, segNumber,
1057 numSegments, chunk_len);
1058
1059 segNumber++;
1060
1061 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
1062 (chunk_len + sizeof(segHdrInfo)));
1063 cmd += WMI_TLV_HDR_SIZE;
1064 memcpy(cmd, &segHdrInfo, sizeof(segHdrInfo)); /* 4 bytes */
1065 memcpy(&cmd[sizeof(segHdrInfo)], bufpos, chunk_len);
1066
1067 ret = wmi_unified_cmd_send(wmi_handle, buf,
1068 (chunk_len + sizeof(segHdrInfo) +
1069 WMI_TLV_HDR_SIZE),
1070 WMI_PDEV_UTF_CMDID);
1071
Govind Singh67922e82016-04-01 16:48:57 +05301072 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301073 WMI_LOGE("Failed to send WMI_PDEV_UTF_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301074 wmi_buf_free(buf);
1075 break;
1076 }
1077
1078 param->len -= chunk_len;
1079 bufpos += chunk_len;
1080 }
1081
1082 msgref++;
1083
1084 return ret;
1085}
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301086#ifdef CONFIG_MCL
1087static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1088 uint32_t host_param)
1089{
1090 return host_param;
1091}
1092#else
1093static inline uint32_t convert_host_pdev_param_tlv(wmi_unified_t wmi_handle,
1094 uint32_t host_param)
1095{
1096 if (host_param < wmi_pdev_param_max)
1097 return wmi_handle->pdev_param[host_param];
Govind Singh5eb51532016-03-09 11:34:12 +05301098
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301099 return WMI_UNAVAILABLE_PARAM;
1100}
1101#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301102/**
1103 * send_pdev_param_cmd_tlv() - set pdev parameters
1104 * @wmi_handle: wmi handle
1105 * @param: pointer to pdev parameter
1106 * @mac_id: radio context
1107 *
1108 * Return: 0 on success, errno on failure
1109 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301110static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301111send_pdev_param_cmd_tlv(wmi_unified_t wmi_handle,
1112 struct pdev_params *param,
1113 uint8_t mac_id)
1114{
Govind Singh67922e82016-04-01 16:48:57 +05301115 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301116 wmi_pdev_set_param_cmd_fixed_param *cmd;
1117 wmi_buf_t buf;
1118 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301119 uint32_t pdev_param;
1120
1121 pdev_param = convert_host_pdev_param_tlv(wmi_handle, param->param_id);
1122 if (pdev_param == WMI_UNAVAILABLE_PARAM) {
1123 WMI_LOGW("%s: Unavailable param %d\n",
1124 __func__, param->param_id);
1125 return QDF_STATUS_E_INVAL;
1126 }
Govind Singh5eb51532016-03-09 11:34:12 +05301127
1128 buf = wmi_buf_alloc(wmi_handle, len);
1129 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301130 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301131 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301132 }
1133 cmd = (wmi_pdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1134 WMITLV_SET_HDR(&cmd->tlv_header,
1135 WMITLV_TAG_STRUC_wmi_pdev_set_param_cmd_fixed_param,
1136 WMITLV_GET_STRUCT_TLVLEN
1137 (wmi_pdev_set_param_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301138 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301139 cmd->param_id = pdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301140 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301141 WMI_LOGD("Setting pdev param = %x, value = %u", param->param_id,
Govind Singh5eb51532016-03-09 11:34:12 +05301142 param->param_value);
1143 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1144 WMI_PDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301145 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301146 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301147 wmi_buf_free(buf);
1148 }
1149 return ret;
1150}
1151
1152/**
1153 * send_suspend_cmd_tlv() - WMI suspend function
1154 * @param wmi_handle : handle to WMI.
1155 * @param param : pointer to hold suspend parameter
1156 * @mac_id: radio context
1157 *
1158 * Return 0 on success and -ve on failure.
1159 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301160static QDF_STATUS send_suspend_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301161 struct suspend_params *param,
1162 uint8_t mac_id)
1163{
1164 wmi_pdev_suspend_cmd_fixed_param *cmd;
1165 wmi_buf_t wmibuf;
1166 uint32_t len = sizeof(*cmd);
1167 int32_t ret;
1168
1169 /*
1170 * send the comand to Target to ignore the
1171 * PCIE reset so as to ensure that Host and target
1172 * states are in sync
1173 */
1174 wmibuf = wmi_buf_alloc(wmi_handle, len);
1175 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301176 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301177
1178 cmd = (wmi_pdev_suspend_cmd_fixed_param *) wmi_buf_data(wmibuf);
1179 WMITLV_SET_HDR(&cmd->tlv_header,
1180 WMITLV_TAG_STRUC_wmi_pdev_suspend_cmd_fixed_param,
1181 WMITLV_GET_STRUCT_TLVLEN
1182 (wmi_pdev_suspend_cmd_fixed_param));
1183 if (param->disable_target_intr)
1184 cmd->suspend_opt = WMI_PDEV_SUSPEND_AND_DISABLE_INTR;
1185 else
1186 cmd->suspend_opt = WMI_PDEV_SUSPEND;
1187 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, len,
1188 WMI_PDEV_SUSPEND_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301189 if (ret) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05301190 wmi_buf_free(wmibuf);
Govind Singhe7f2f342016-05-23 12:12:52 +05301191 WMI_LOGE("Failed to send WMI_PDEV_SUSPEND_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301192 }
1193
1194 return ret;
1195}
1196
1197/**
1198 * send_resume_cmd_tlv() - WMI resume function
1199 * @param wmi_handle : handle to WMI.
1200 * @mac_id: radio context
1201 *
1202 * Return: 0 on success and -ve on failure.
1203 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301204static QDF_STATUS send_resume_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301205 uint8_t mac_id)
1206{
1207 wmi_buf_t wmibuf;
1208 wmi_pdev_resume_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05301209 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301210
1211 wmibuf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1212 if (wmibuf == NULL)
Govind Singh67922e82016-04-01 16:48:57 +05301213 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301214 cmd = (wmi_pdev_resume_cmd_fixed_param *) wmi_buf_data(wmibuf);
1215 WMITLV_SET_HDR(&cmd->tlv_header,
1216 WMITLV_TAG_STRUC_wmi_pdev_resume_cmd_fixed_param,
1217 WMITLV_GET_STRUCT_TLVLEN
1218 (wmi_pdev_resume_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05301219 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(mac_id);
Govind Singh5eb51532016-03-09 11:34:12 +05301220 ret = wmi_unified_cmd_send(wmi_handle, wmibuf, sizeof(*cmd),
1221 WMI_PDEV_RESUME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301222 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301223 WMI_LOGE("Failed to send WMI_PDEV_RESUME_CMDID command");
Govind Singh5eb51532016-03-09 11:34:12 +05301224 wmi_buf_free(wmibuf);
1225 }
1226
1227 return ret;
1228}
1229
1230/**
1231 * send_wow_enable_cmd_tlv() - WMI wow enable function
1232 * @param wmi_handle : handle to WMI.
1233 * @param param : pointer to hold wow enable parameter
1234 * @mac_id: radio context
1235 *
1236 * Return: 0 on success and -ve on failure.
1237 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301238static QDF_STATUS send_wow_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301239 struct wow_cmd_params *param,
1240 uint8_t mac_id)
1241{
1242 wmi_wow_enable_cmd_fixed_param *cmd;
1243 wmi_buf_t buf;
1244 int32_t len;
1245 int32_t ret;
1246
1247 len = sizeof(wmi_wow_enable_cmd_fixed_param);
1248
1249 buf = wmi_buf_alloc(wmi_handle, len);
1250 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301251 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
1252 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301253 }
1254 cmd = (wmi_wow_enable_cmd_fixed_param *) wmi_buf_data(buf);
1255 WMITLV_SET_HDR(&cmd->tlv_header,
1256 WMITLV_TAG_STRUC_wmi_wow_enable_cmd_fixed_param,
1257 WMITLV_GET_STRUCT_TLVLEN
1258 (wmi_wow_enable_cmd_fixed_param));
1259 cmd->enable = param->enable;
1260 if (param->can_suspend_link)
1261 cmd->pause_iface_config = WOW_IFACE_PAUSE_ENABLED;
1262 else
1263 cmd->pause_iface_config = WOW_IFACE_PAUSE_DISABLED;
Dustin Brownfc28c0e2016-11-10 11:25:36 -08001264 cmd->flags = param->flags;
Govind Singh5eb51532016-03-09 11:34:12 +05301265
Govind Singhb53420c2016-03-09 14:32:57 +05301266 WMI_LOGI("suspend type: %s",
Govind Singh5eb51532016-03-09 11:34:12 +05301267 cmd->pause_iface_config == WOW_IFACE_PAUSE_ENABLED ?
1268 "WOW_IFACE_PAUSE_ENABLED" : "WOW_IFACE_PAUSE_DISABLED");
1269
1270 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1271 WMI_WOW_ENABLE_CMDID);
1272 if (ret)
1273 wmi_buf_free(buf);
1274
1275 return ret;
1276}
1277
1278/**
1279 * send_set_ap_ps_param_cmd_tlv() - set ap powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301280 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301281 * @peer_addr: peer mac address
1282 * @param: pointer to ap_ps parameter structure
1283 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301284 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301285 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301286static QDF_STATUS send_set_ap_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301287 uint8_t *peer_addr,
1288 struct ap_ps_params *param)
1289{
1290 wmi_ap_ps_peer_cmd_fixed_param *cmd;
1291 wmi_buf_t buf;
1292 int32_t err;
1293
1294 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1295 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301296 WMI_LOGE("Failed to allocate buffer to send set_ap_ps_param cmd");
Govind Singh67922e82016-04-01 16:48:57 +05301297 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301298 }
1299 cmd = (wmi_ap_ps_peer_cmd_fixed_param *) wmi_buf_data(buf);
1300 WMITLV_SET_HDR(&cmd->tlv_header,
1301 WMITLV_TAG_STRUC_wmi_ap_ps_peer_cmd_fixed_param,
1302 WMITLV_GET_STRUCT_TLVLEN
1303 (wmi_ap_ps_peer_cmd_fixed_param));
1304 cmd->vdev_id = param->vdev_id;
1305 WMI_CHAR_ARRAY_TO_MAC_ADDR(peer_addr, &cmd->peer_macaddr);
1306 cmd->param = param->param;
1307 cmd->value = param->value;
1308 err = wmi_unified_cmd_send(wmi_handle, buf,
1309 sizeof(*cmd), WMI_AP_PS_PEER_PARAM_CMDID);
1310 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05301311 WMI_LOGE("Failed to send set_ap_ps_param cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +05301312 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301313 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301314 }
1315
1316 return 0;
1317}
1318
1319/**
1320 * send_set_sta_ps_param_cmd_tlv() - set sta powersave parameters
Govind Singh2edc80f2016-03-01 15:30:53 +05301321 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301322 * @peer_addr: peer mac address
1323 * @param: pointer to sta_ps parameter structure
1324 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301325 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh5eb51532016-03-09 11:34:12 +05301326 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301327static QDF_STATUS send_set_sta_ps_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301328 struct sta_ps_params *param)
1329{
1330 wmi_sta_powersave_param_cmd_fixed_param *cmd;
1331 wmi_buf_t buf;
1332 int32_t len = sizeof(*cmd);
1333
1334 buf = wmi_buf_alloc(wmi_handle, len);
1335 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301336 WMI_LOGP("%s: Set Sta Ps param Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301337 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301338 }
1339
1340 cmd = (wmi_sta_powersave_param_cmd_fixed_param *) wmi_buf_data(buf);
1341 WMITLV_SET_HDR(&cmd->tlv_header,
1342 WMITLV_TAG_STRUC_wmi_sta_powersave_param_cmd_fixed_param,
1343 WMITLV_GET_STRUCT_TLVLEN
1344 (wmi_sta_powersave_param_cmd_fixed_param));
1345 cmd->vdev_id = param->vdev_id;
1346 cmd->param = param->param;
1347 cmd->value = param->value;
1348
1349 if (wmi_unified_cmd_send(wmi_handle, buf, len,
1350 WMI_STA_POWERSAVE_PARAM_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301351 WMI_LOGE("Set Sta Ps param Failed vdevId %d Param %d val %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301352 param->vdev_id, param->param, param->value);
Abhishek Singh716c46c2016-05-04 16:24:07 +05301353 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05301354 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05301355 }
1356
1357 return 0;
1358}
1359
1360/**
1361 * send_crash_inject_cmd_tlv() - inject fw crash
Govind Singh2edc80f2016-03-01 15:30:53 +05301362 * @wmi_handle: wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +05301363 * @param: ponirt to crash inject paramter structure
1364 *
Govind Singhe7f2f342016-05-23 12:12:52 +05301365 * Return: QDF_STATUS_SUCCESS for success or return error
Govind Singh5eb51532016-03-09 11:34:12 +05301366 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301367static QDF_STATUS send_crash_inject_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301368 struct crash_inject *param)
1369{
1370 int32_t ret = 0;
1371 WMI_FORCE_FW_HANG_CMD_fixed_param *cmd;
1372 uint16_t len = sizeof(*cmd);
1373 wmi_buf_t buf;
1374
1375 buf = wmi_buf_alloc(wmi_handle, len);
1376 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301377 WMI_LOGE("%s: wmi_buf_alloc failed!", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301378 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301379 }
1380
1381 cmd = (WMI_FORCE_FW_HANG_CMD_fixed_param *) wmi_buf_data(buf);
1382 WMITLV_SET_HDR(&cmd->tlv_header,
1383 WMITLV_TAG_STRUC_WMI_FORCE_FW_HANG_CMD_fixed_param,
1384 WMITLV_GET_STRUCT_TLVLEN
1385 (WMI_FORCE_FW_HANG_CMD_fixed_param));
1386 cmd->type = param->type;
1387 cmd->delay_time_ms = param->delay_time_ms;
1388
1389 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1390 WMI_FORCE_FW_HANG_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05301391 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301392 WMI_LOGE("%s: Failed to send set param command, ret = %d",
Govind Singh5eb51532016-03-09 11:34:12 +05301393 __func__, ret);
1394 wmi_buf_free(buf);
1395 }
1396
1397 return ret;
1398}
1399
1400/**
1401 * send_dbglog_cmd_tlv() - set debug log level
1402 * @param wmi_handle : handle to WMI.
1403 * @param param : pointer to hold dbglog level parameter
1404 *
1405 * Return: 0 on success and -ve on failure.
1406 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301407 static QDF_STATUS
Govind Singh5eb51532016-03-09 11:34:12 +05301408send_dbglog_cmd_tlv(wmi_unified_t wmi_handle,
1409 struct dbglog_params *dbglog_param)
1410{
1411 wmi_buf_t buf;
1412 wmi_debug_log_config_cmd_fixed_param *configmsg;
1413 A_STATUS status = A_OK;
1414 int32_t i;
1415 int32_t len;
1416 int8_t *buf_ptr;
1417 int32_t *module_id_bitmap_array; /* Used to fomr the second tlv */
1418
1419 ASSERT(bitmap_len < MAX_MODULE_ID_BITMAP_WORDS);
1420
1421 /* Allocate size for 2 tlvs - including tlv hdr space for second tlv */
1422 len = sizeof(wmi_debug_log_config_cmd_fixed_param) + WMI_TLV_HDR_SIZE +
1423 (sizeof(int32_t) * MAX_MODULE_ID_BITMAP_WORDS);
1424 buf = wmi_buf_alloc(wmi_handle, len);
1425 if (buf == NULL)
1426 return A_NO_MEMORY;
1427
1428 configmsg =
1429 (wmi_debug_log_config_cmd_fixed_param *) (wmi_buf_data(buf));
1430 buf_ptr = (int8_t *) configmsg;
1431 WMITLV_SET_HDR(&configmsg->tlv_header,
1432 WMITLV_TAG_STRUC_wmi_debug_log_config_cmd_fixed_param,
1433 WMITLV_GET_STRUCT_TLVLEN
1434 (wmi_debug_log_config_cmd_fixed_param));
1435 configmsg->dbg_log_param = dbglog_param->param;
1436 configmsg->value = dbglog_param->val;
1437 /* Filling in the data part of second tlv -- should
1438 * follow first tlv _ WMI_TLV_HDR_SIZE */
1439 module_id_bitmap_array = (A_UINT32 *) (buf_ptr +
1440 sizeof
1441 (wmi_debug_log_config_cmd_fixed_param)
1442 + WMI_TLV_HDR_SIZE);
1443 WMITLV_SET_HDR(buf_ptr + sizeof(wmi_debug_log_config_cmd_fixed_param),
1444 WMITLV_TAG_ARRAY_UINT32,
1445 sizeof(A_UINT32) * MAX_MODULE_ID_BITMAP_WORDS);
1446 if (dbglog_param->module_id_bitmap) {
1447 for (i = 0; i < dbglog_param->bitmap_len; ++i) {
1448 module_id_bitmap_array[i] =
1449 dbglog_param->module_id_bitmap[i];
1450 }
1451 }
1452
1453 status = wmi_unified_cmd_send(wmi_handle, buf,
1454 len, WMI_DBGLOG_CFG_CMDID);
1455
1456 if (status != A_OK)
Abhishek Singh716c46c2016-05-04 16:24:07 +05301457 wmi_buf_free(buf);
Govind Singh5eb51532016-03-09 11:34:12 +05301458
1459 return status;
1460}
1461
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301462#ifdef CONFIG_MCL
1463static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1464 uint32_t host_param)
1465{
1466 return host_param;
1467}
1468#else
1469static inline uint32_t convert_host_vdev_param_tlv(wmi_unified_t wmi_handle,
1470 uint32_t host_param)
1471{
1472 if (host_param < wmi_vdev_param_max)
1473 return wmi_handle->vdev_param[host_param];
1474
1475 return WMI_UNAVAILABLE_PARAM;
1476}
1477#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301478/**
1479 * send_vdev_set_param_cmd_tlv() - WMI vdev set parameter function
1480 * @param wmi_handle : handle to WMI.
1481 * @param macaddr : MAC address
1482 * @param param : pointer to hold vdev set parameter
1483 *
1484 * Return: 0 on success and -ve on failure.
1485 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301486static QDF_STATUS send_vdev_set_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301487 struct vdev_set_params *param)
1488{
Govind Singh67922e82016-04-01 16:48:57 +05301489 QDF_STATUS ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301490 wmi_vdev_set_param_cmd_fixed_param *cmd;
1491 wmi_buf_t buf;
1492 uint16_t len = sizeof(*cmd);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301493 uint32_t vdev_param;
1494
1495 vdev_param = convert_host_vdev_param_tlv(wmi_handle, param->param_id);
1496 if (vdev_param == WMI_UNAVAILABLE_PARAM) {
1497 WMI_LOGW("%s:Vdev param %d not available", __func__,
1498 param->param_id);
1499 return QDF_STATUS_E_INVAL;
1500
1501 }
Govind Singh5eb51532016-03-09 11:34:12 +05301502
1503 buf = wmi_buf_alloc(wmi_handle, len);
1504 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301505 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301506 return QDF_STATUS_E_NOMEM;
Govind Singh5eb51532016-03-09 11:34:12 +05301507 }
1508 cmd = (wmi_vdev_set_param_cmd_fixed_param *) wmi_buf_data(buf);
1509 WMITLV_SET_HDR(&cmd->tlv_header,
1510 WMITLV_TAG_STRUC_wmi_vdev_set_param_cmd_fixed_param,
1511 WMITLV_GET_STRUCT_TLVLEN
1512 (wmi_vdev_set_param_cmd_fixed_param));
1513 cmd->vdev_id = param->if_id;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301514 cmd->param_id = vdev_param;
Govind Singh5eb51532016-03-09 11:34:12 +05301515 cmd->param_value = param->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05301516 WMI_LOGD("Setting vdev %d param = %x, value = %u",
Govind Singh5eb51532016-03-09 11:34:12 +05301517 param->if_id, param->param_id, param->param_value);
1518 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1519 WMI_VDEV_SET_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05301520 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05301521 WMI_LOGE("Failed to send set param command ret = %d", ret);
Govind Singh5eb51532016-03-09 11:34:12 +05301522 wmi_buf_free(buf);
1523 }
1524
1525 return ret;
1526}
1527
1528/**
1529 * send_stats_request_cmd_tlv() - WMI request stats function
1530 * @param wmi_handle : handle to WMI.
1531 * @param macaddr : MAC address
1532 * @param param : pointer to hold stats request parameter
1533 *
1534 * Return: 0 on success and -ve on failure.
1535 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301536static QDF_STATUS send_stats_request_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301537 uint8_t macaddr[IEEE80211_ADDR_LEN],
1538 struct stats_request_params *param)
1539{
Govind Singhd3156eb2016-02-26 17:50:39 +05301540 int32_t ret;
1541 wmi_request_stats_cmd_fixed_param *cmd;
1542 wmi_buf_t buf;
1543 uint16_t len = sizeof(wmi_request_stats_cmd_fixed_param);
1544
1545 buf = wmi_buf_alloc(wmi_handle, len);
1546 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301547 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
1548 return -QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301549 }
1550
1551 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
1552 WMITLV_SET_HDR(&cmd->tlv_header,
1553 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
1554 WMITLV_GET_STRUCT_TLVLEN
1555 (wmi_request_stats_cmd_fixed_param));
1556 cmd->stats_id = param->stats_id;
1557 cmd->vdev_id = param->vdev_id;
1558 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
1559 WMI_REQUEST_STATS_CMDID);
1560 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301561 WMI_LOGE("Failed to send status request to fw =%d", ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301562 wmi_buf_free(buf);
1563 }
1564
1565 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05301566}
1567
Govind Singh87542482016-06-08 19:40:11 +05301568#ifdef CONFIG_WIN
1569/**
1570 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1571 * @param wmi_handle : handle to WMI.
1572 * @param macaddr : MAC address
1573 * @param param : pointer to hold stats request parameter
1574 *
1575 * Return: 0 on success and -ve on failure.
1576 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301577static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301578 WMI_HOST_PKTLOG_EVENT PKTLOG_EVENT)
1579{
1580 return 0;
1581}
1582#else
Govind Singh5eb51532016-03-09 11:34:12 +05301583/**
1584 * send_packet_log_enable_cmd_tlv() - WMI request stats function
1585 * @param wmi_handle : handle to WMI.
1586 * @param macaddr : MAC address
1587 * @param param : pointer to hold stats request parameter
1588 *
1589 * Return: 0 on success and -ve on failure.
1590 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301591static QDF_STATUS send_packet_log_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301592 uint8_t macaddr[IEEE80211_ADDR_LEN],
1593 struct packet_enable_params *param)
1594{
1595 return 0;
1596}
Govind Singh87542482016-06-08 19:40:11 +05301597#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301598
Govind Singh87542482016-06-08 19:40:11 +05301599#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05301600/**
1601 * send_beacon_send_cmd_tlv() - WMI beacon send function
1602 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301603 * @param param : pointer to hold beacon send cmd parameter
1604 *
1605 * Return: 0 on success and -ve on failure.
1606 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301607static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301608 struct beacon_params *param)
1609{
Govind Singhd3156eb2016-02-26 17:50:39 +05301610 int32_t ret;
1611 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1612 wmi_bcn_prb_info *bcn_prb_info;
1613 wmi_buf_t wmi_buf;
1614 uint8_t *buf_ptr;
1615 uint32_t wmi_buf_len;
1616
1617 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1618 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1619 param->tmpl_len_aligned;
1620 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1621 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301622 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301623 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301624 }
1625 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1626 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1627 WMITLV_SET_HDR(&cmd->tlv_header,
1628 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1629 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1630 cmd->vdev_id = param->vdev_id;
1631 cmd->tim_ie_offset = param->tim_ie_offset;
1632 cmd->buf_len = param->tmpl_len;
1633 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1634
1635 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1636 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1637 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1638 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1639 bcn_prb_info->caps = 0;
1640 bcn_prb_info->erp = 0;
1641 buf_ptr += sizeof(wmi_bcn_prb_info);
1642
1643 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1644 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05301645 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
Govind Singhd3156eb2016-02-26 17:50:39 +05301646
1647 ret = wmi_unified_cmd_send(wmi_handle,
1648 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1649 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05301650 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05301651 wmi_buf_free(wmi_buf);
1652 }
Govind Singh5eb51532016-03-09 11:34:12 +05301653 return 0;
1654}
Govind Singh87542482016-06-08 19:40:11 +05301655#else
Sathish Kumarfd347372017-02-13 12:29:09 +05301656static QDF_STATUS send_beacon_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301657 struct beacon_params *param)
1658{
Kiran Venkatappa9d59bd62017-04-21 14:42:32 +05301659 QDF_STATUS ret;
1660 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
1661 wmi_buf_t wmi_buf;
1662 qdf_dma_addr_t dma_addr;
1663 uint32_t dtim_flag = 0;
1664
1665 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
1666 if (!wmi_buf) {
1667 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1668 return QDF_STATUS_E_NOMEM;
1669 }
1670 if (param->is_dtim_count_zero) {
1671 dtim_flag |= WMI_BCN_SEND_DTIM_ZERO;
1672 if (param->is_bitctl_reqd) {
1673 /* deliver CAB traffic in next DTIM beacon */
1674 dtim_flag |= WMI_BCN_SEND_DTIM_BITCTL_SET;
1675 }
1676 }
1677 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
1678 WMITLV_SET_HDR(&cmd->tlv_header,
1679 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
1680 WMITLV_GET_STRUCT_TLVLEN
1681 (wmi_bcn_send_from_host_cmd_fixed_param));
1682 cmd->vdev_id = param->vdev_id;
1683 cmd->data_len = qdf_nbuf_len(param->wbuf);
1684 cmd->frame_ctrl = param->frame_ctrl;
1685 cmd->dtim_flag = dtim_flag;
1686 dma_addr = qdf_nbuf_get_frag_paddr(param->wbuf, 0);
1687 cmd->frag_ptr_lo = qdf_get_lower_32_bits(dma_addr);
1688#if defined(HTT_PADDR64)
1689 cmd->frag_ptr_hi = qdf_get_upper_32_bits(dma_addr) & 0x1F;
1690#endif
1691 cmd->bcn_antenna = param->bcn_txant;
1692
1693 ret = wmi_unified_cmd_send(wmi_handle,
1694 wmi_buf, sizeof(*cmd), WMI_PDEV_SEND_BCN_CMDID);
1695 if (ret != QDF_STATUS_SUCCESS) {
1696 WMI_LOGE("%s: Failed to send bcn: %d", __func__, ret);
1697 wmi_buf_free(wmi_buf);
1698 }
1699
1700 return ret;
Govind Singh87542482016-06-08 19:40:11 +05301701}
1702
1703/**
1704 * send_beacon_send_tmpl_cmd_tlv() - WMI beacon send function
1705 * @param wmi_handle : handle to WMI.
1706 * @param param : pointer to hold beacon send cmd parameter
1707 *
1708 * Return: 0 on success and -ve on failure.
1709 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301710static QDF_STATUS send_beacon_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05301711 struct beacon_tmpl_params *param)
1712{
1713 int32_t ret;
1714 wmi_bcn_tmpl_cmd_fixed_param *cmd;
1715 wmi_bcn_prb_info *bcn_prb_info;
1716 wmi_buf_t wmi_buf;
1717 uint8_t *buf_ptr;
1718 uint32_t wmi_buf_len;
1719
Sathish Kumar45e991b2017-02-27 10:35:40 +05301720 WMI_LOGI("%s\n", __func__);
Govind Singh87542482016-06-08 19:40:11 +05301721 wmi_buf_len = sizeof(wmi_bcn_tmpl_cmd_fixed_param) +
1722 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
1723 param->tmpl_len_aligned;
1724 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
1725 if (!wmi_buf) {
1726 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
1727 return QDF_STATUS_E_NOMEM;
1728 }
1729 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
1730 cmd = (wmi_bcn_tmpl_cmd_fixed_param *) buf_ptr;
1731 WMITLV_SET_HDR(&cmd->tlv_header,
1732 WMITLV_TAG_STRUC_wmi_bcn_tmpl_cmd_fixed_param,
1733 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_tmpl_cmd_fixed_param));
1734 cmd->vdev_id = param->vdev_id;
1735 cmd->tim_ie_offset = param->tim_ie_offset;
Sathish Kumar45e991b2017-02-27 10:35:40 +05301736 cmd->csa_switch_count_offset = param->csa_switch_count_offset;
1737 cmd->ext_csa_switch_count_offset = param->ext_csa_switch_count_offset;
Govind Singh87542482016-06-08 19:40:11 +05301738 cmd->buf_len = param->tmpl_len;
1739 buf_ptr += sizeof(wmi_bcn_tmpl_cmd_fixed_param);
1740
1741 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
1742 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
1743 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
1744 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
1745 bcn_prb_info->caps = 0;
1746 bcn_prb_info->erp = 0;
1747 buf_ptr += sizeof(wmi_bcn_prb_info);
1748
1749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->tmpl_len_aligned);
1750 buf_ptr += WMI_TLV_HDR_SIZE;
1751 qdf_mem_copy(buf_ptr, param->frm, param->tmpl_len);
1752
1753 ret = wmi_unified_cmd_send(wmi_handle,
1754 wmi_buf, wmi_buf_len, WMI_BCN_TMPL_CMDID);
1755 if (ret) {
1756 WMI_LOGE("%s: Failed to send bcn tmpl: %d", __func__, ret);
1757 wmi_buf_free(wmi_buf);
1758 }
Sathish Kumar45e991b2017-02-27 10:35:40 +05301759
Govind Singh87542482016-06-08 19:40:11 +05301760 return 0;
1761}
1762#endif
Govind Singh5eb51532016-03-09 11:34:12 +05301763
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301764#ifdef CONFIG_MCL
1765static inline void copy_peer_flags_tlv(
1766 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1767 struct peer_assoc_params *param)
1768{
1769 cmd->peer_flags = param->peer_flags;
1770}
1771#else
1772static inline void copy_peer_flags_tlv(
1773 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1774 struct peer_assoc_params *param)
1775{
1776 /*
1777 * The target only needs a subset of the flags maintained in the host.
1778 * Just populate those flags and send it down
1779 */
1780 cmd->peer_flags = 0;
1781
1782 /*
1783 * Do not enable HT/VHT if WMM/wme is disabled for vap.
1784 */
1785 if (param->is_wme_set) {
1786
1787 if (param->qos_flag)
1788 cmd->peer_flags |= WMI_PEER_QOS;
1789 if (param->apsd_flag)
1790 cmd->peer_flags |= WMI_PEER_APSD;
1791 if (param->ht_flag)
1792 cmd->peer_flags |= WMI_PEER_HT;
1793 if (param->bw_40)
1794 cmd->peer_flags |= WMI_PEER_40MHZ;
1795 if (param->bw_80)
1796 cmd->peer_flags |= WMI_PEER_80MHZ;
1797 if (param->bw_160)
1798 cmd->peer_flags |= WMI_PEER_160MHZ;
1799
1800 /* Typically if STBC is enabled for VHT it should be enabled
1801 * for HT as well
1802 **/
1803 if (param->stbc_flag)
1804 cmd->peer_flags |= WMI_PEER_STBC;
1805
1806 /* Typically if LDPC is enabled for VHT it should be enabled
1807 * for HT as well
1808 **/
1809 if (param->ldpc_flag)
1810 cmd->peer_flags |= WMI_PEER_LDPC;
1811
1812 if (param->static_mimops_flag)
1813 cmd->peer_flags |= WMI_PEER_STATIC_MIMOPS;
1814 if (param->dynamic_mimops_flag)
1815 cmd->peer_flags |= WMI_PEER_DYN_MIMOPS;
1816 if (param->spatial_mux_flag)
1817 cmd->peer_flags |= WMI_PEER_SPATIAL_MUX;
1818 if (param->vht_flag)
1819 cmd->peer_flags |= WMI_PEER_VHT;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001820 if (param->he_flag)
1821 cmd->peer_flags |= WMI_PEER_HE;
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301822 }
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -08001823
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301824 /*
1825 * Suppress authorization for all AUTH modes that need 4-way handshake
1826 * (during re-association).
1827 * Authorization will be done for these modes on key installation.
1828 */
1829 if (param->auth_flag)
1830 cmd->peer_flags |= WMI_PEER_AUTH;
1831 if (param->need_ptk_4_way)
1832 cmd->peer_flags |= WMI_PEER_NEED_PTK_4_WAY;
1833 else
1834 cmd->peer_flags &= ~WMI_PEER_NEED_PTK_4_WAY;
1835 if (param->need_gtk_2_way)
1836 cmd->peer_flags |= WMI_PEER_NEED_GTK_2_WAY;
1837 /* safe mode bypass the 4-way handshake */
1838 if (param->safe_mode_enabled)
1839 cmd->peer_flags &=
1840 ~(WMI_PEER_NEED_PTK_4_WAY | WMI_PEER_NEED_GTK_2_WAY);
1841 /* Disable AMSDU for station transmit, if user configures it */
1842 /* Disable AMSDU for AP transmit to 11n Stations, if user configures
1843 * it
1844 * if (param->amsdu_disable) Add after FW support
1845 **/
1846
1847 /* Target asserts if node is marked HT and all MCS is set to 0.
1848 * Mark the node as non-HT if all the mcs rates are disabled through
1849 * iwpriv
1850 **/
1851 if (param->peer_ht_rates.num_rates == 0)
1852 cmd->peer_flags &= ~WMI_PEER_HT;
1853}
1854#endif
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301855
1856#ifdef CONFIG_MCL
1857static inline void copy_peer_mac_addr_tlv(
1858 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1859 struct peer_assoc_params *param)
1860{
1861 qdf_mem_copy(&cmd->peer_macaddr, &param->peer_macaddr,
1862 sizeof(param->peer_macaddr));
1863}
1864#else
1865static inline void copy_peer_mac_addr_tlv(
1866 wmi_peer_assoc_complete_cmd_fixed_param * cmd,
1867 struct peer_assoc_params *param)
1868{
1869 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_mac, &cmd->peer_macaddr);
1870}
1871#endif
1872
Govind Singh5eb51532016-03-09 11:34:12 +05301873/**
1874 * send_peer_assoc_cmd_tlv() - WMI peer assoc function
1875 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05301876 * @param param : pointer to peer assoc parameter
1877 *
1878 * Return: 0 on success and -ve on failure.
1879 */
Sathish Kumarfd347372017-02-13 12:29:09 +05301880static QDF_STATUS send_peer_assoc_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh5eb51532016-03-09 11:34:12 +05301881 struct peer_assoc_params *param)
1882{
Govind Singhd3156eb2016-02-26 17:50:39 +05301883 wmi_peer_assoc_complete_cmd_fixed_param *cmd;
1884 wmi_vht_rate_set *mcs;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001885 wmi_he_rate_set *he_mcs;
Govind Singhd3156eb2016-02-26 17:50:39 +05301886 wmi_buf_t buf;
1887 int32_t len;
1888 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05301889 QDF_STATUS ret;
Govind Singh3419aea2016-03-28 22:02:42 +05301890 uint32_t peer_legacy_rates_align;
1891 uint32_t peer_ht_rates_align;
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001892 int32_t i;
Govind Singh3419aea2016-03-28 22:02:42 +05301893
1894
1895 peer_legacy_rates_align = wmi_align(param->peer_legacy_rates.num_rates);
1896 peer_ht_rates_align = wmi_align(param->peer_ht_rates.num_rates);
Govind Singhd3156eb2016-02-26 17:50:39 +05301897
1898 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001899 (peer_legacy_rates_align * sizeof(uint8_t)) +
1900 WMI_TLV_HDR_SIZE +
1901 (peer_ht_rates_align * sizeof(uint8_t)) +
1902 sizeof(wmi_vht_rate_set) +
1903 (sizeof(wmi_he_rate_set) * param->peer_he_mcs_count
1904 + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05301905
1906 buf = wmi_buf_alloc(wmi_handle, len);
1907 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05301908 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05301909 return QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05301910 }
1911
1912 buf_ptr = (uint8_t *) wmi_buf_data(buf);
1913 cmd = (wmi_peer_assoc_complete_cmd_fixed_param *) buf_ptr;
1914 WMITLV_SET_HDR(&cmd->tlv_header,
1915 WMITLV_TAG_STRUC_wmi_peer_assoc_complete_cmd_fixed_param,
1916 WMITLV_GET_STRUCT_TLVLEN
1917 (wmi_peer_assoc_complete_cmd_fixed_param));
Govind Singh3419aea2016-03-28 22:02:42 +05301918
Govind Singhd3156eb2016-02-26 17:50:39 +05301919 cmd->vdev_id = param->vdev_id;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301920
Govind Singhd3156eb2016-02-26 17:50:39 +05301921 cmd->peer_new_assoc = param->peer_new_assoc;
1922 cmd->peer_associd = param->peer_associd;
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301923
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05301924 copy_peer_flags_tlv(cmd, param);
Pamidipati, Vijayad16a882016-11-29 01:44:25 +05301925 copy_peer_mac_addr_tlv(cmd, param);
1926
Govind Singhd3156eb2016-02-26 17:50:39 +05301927 cmd->peer_rate_caps = param->peer_rate_caps;
1928 cmd->peer_caps = param->peer_caps;
1929 cmd->peer_listen_intval = param->peer_listen_intval;
1930 cmd->peer_ht_caps = param->peer_ht_caps;
1931 cmd->peer_max_mpdu = param->peer_max_mpdu;
1932 cmd->peer_mpdu_density = param->peer_mpdu_density;
Govind Singhd3156eb2016-02-26 17:50:39 +05301933 cmd->peer_vht_caps = param->peer_vht_caps;
1934 cmd->peer_phymode = param->peer_phymode;
1935
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001936 /* Update 11ax capabilities */
1937 cmd->peer_he_cap_info = param->peer_he_cap_macinfo;
1938 cmd->peer_he_ops = param->peer_he_ops;
Krishna Kumaar Natarajancc9d5032016-09-29 14:20:54 -07001939 qdf_mem_copy(&cmd->peer_he_cap_phy, &param->peer_he_cap_phyinfo,
1940 sizeof(param->peer_he_cap_phyinfo));
1941 qdf_mem_copy(&cmd->peer_ppet, &param->peer_ppet,
1942 sizeof(param->peer_ppet));
1943
Govind Singhd3156eb2016-02-26 17:50:39 +05301944 /* Update peer legacy rate information */
1945 buf_ptr += sizeof(*cmd);
1946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301947 peer_legacy_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301948 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301949 cmd->num_peer_legacy_rates = param->peer_legacy_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301950 qdf_mem_copy(buf_ptr, param->peer_legacy_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301951 param->peer_legacy_rates.num_rates);
1952
1953 /* Update peer HT rate information */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001954 buf_ptr += peer_legacy_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301955 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
Govind Singh3419aea2016-03-28 22:02:42 +05301956 peer_ht_rates_align);
Govind Singhd3156eb2016-02-26 17:50:39 +05301957 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh3419aea2016-03-28 22:02:42 +05301958 cmd->num_peer_ht_rates = param->peer_ht_rates.num_rates;
Govind Singhb53420c2016-03-09 14:32:57 +05301959 qdf_mem_copy(buf_ptr, param->peer_ht_rates.rates,
Govind Singhd3156eb2016-02-26 17:50:39 +05301960 param->peer_ht_rates.num_rates);
1961
1962 /* VHT Rates */
Sandeep Puligillaf358b1a2016-09-26 10:07:19 -07001963 buf_ptr += peer_ht_rates_align;
Govind Singhd3156eb2016-02-26 17:50:39 +05301964 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_STRUC_wmi_vht_rate_set,
1965 WMITLV_GET_STRUCT_TLVLEN(wmi_vht_rate_set));
1966
1967 cmd->peer_nss = param->peer_nss;
Krishna Rao0b952ea2017-03-20 13:30:10 +05301968
1969 /* Update bandwidth-NSS mapping */
1970 cmd->peer_bw_rxnss_override = 0;
1971 cmd->peer_bw_rxnss_override |= param->peer_bw_rxnss_override;
1972
Govind Singhd3156eb2016-02-26 17:50:39 +05301973 mcs = (wmi_vht_rate_set *) buf_ptr;
1974 if (param->vht_capable) {
1975 mcs->rx_max_rate = param->rx_max_rate;
1976 mcs->rx_mcs_set = param->rx_mcs_set;
1977 mcs->tx_max_rate = param->tx_max_rate;
1978 mcs->tx_mcs_set = param->tx_mcs_set;
1979 }
1980
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07001981 /* HE Rates */
1982 cmd->peer_he_mcs = param->peer_he_mcs_count;
1983 buf_ptr += sizeof(wmi_vht_rate_set);
1984 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
1985 (param->peer_he_mcs_count * sizeof(wmi_he_rate_set)));
1986 buf_ptr += WMI_TLV_HDR_SIZE;
1987
1988 /* Loop through the HE rate set */
1989 for (i = 0; i < param->peer_he_mcs_count; i++) {
1990 he_mcs = (wmi_he_rate_set *) buf_ptr;
1991 WMITLV_SET_HDR(he_mcs, WMITLV_TAG_STRUC_wmi_he_rate_set,
1992 WMITLV_GET_STRUCT_TLVLEN(wmi_he_rate_set));
1993
1994 he_mcs->rx_mcs_set = param->peer_he_rx_mcs_set[i];
1995 he_mcs->tx_mcs_set = param->peer_he_tx_mcs_set[i];
1996 WMI_LOGD("%s:HE idx %d RxMCSmap %x TxMCSmap %x ", __func__,
1997 i, he_mcs->rx_mcs_set, he_mcs->tx_mcs_set);
1998 buf_ptr += sizeof(wmi_he_rate_set);
1999 }
2000
2001
Govind Singhb53420c2016-03-09 14:32:57 +05302002 WMI_LOGD("%s: vdev_id %d associd %d peer_flags %x rate_caps %x "
Govind Singhd3156eb2016-02-26 17:50:39 +05302003 "peer_caps %x listen_intval %d ht_caps %x max_mpdu %d "
2004 "nss %d phymode %d peer_mpdu_density %d "
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002005 "cmd->peer_vht_caps %x "
2006 "HE cap_info %x ops %x "
Krishna Rao0b952ea2017-03-20 13:30:10 +05302007 "HE phy %x %x %x "
2008 "peer_bw_rxnss_override %x", __func__,
Govind Singhd3156eb2016-02-26 17:50:39 +05302009 cmd->vdev_id, cmd->peer_associd, cmd->peer_flags,
2010 cmd->peer_rate_caps, cmd->peer_caps,
2011 cmd->peer_listen_intval, cmd->peer_ht_caps,
2012 cmd->peer_max_mpdu, cmd->peer_nss, cmd->peer_phymode,
2013 cmd->peer_mpdu_density,
Kris Muthusamy1cac4b52017-03-28 12:03:50 -07002014 cmd->peer_vht_caps, cmd->peer_he_cap_info,
2015 cmd->peer_he_ops, cmd->peer_he_cap_phy[0],
Krishna Rao0b952ea2017-03-20 13:30:10 +05302016 cmd->peer_he_cap_phy[1], cmd->peer_he_cap_phy[2],
2017 cmd->peer_bw_rxnss_override);
Govind Singhd3156eb2016-02-26 17:50:39 +05302018
2019 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2020 WMI_PEER_ASSOC_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302021 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302022 WMI_LOGP("%s: Failed to send peer assoc command ret = %d",
Govind Singhd3156eb2016-02-26 17:50:39 +05302023 __func__, ret);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302024 wmi_buf_free(buf);
Govind Singhd3156eb2016-02-26 17:50:39 +05302025 }
2026
2027 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302028}
2029
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302030/* copy_scan_notify_events() - Helper routine to copy scan notify events
2031 */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302032static inline void copy_scan_event_cntrl_flags(
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302033 wmi_start_scan_cmd_fixed_param * cmd,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302034 struct scan_req_params *param)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302035{
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302036
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302037 /* Scan events subscription */
2038 if (param->scan_ev_started)
2039 cmd->notify_scan_events |= WMI_SCAN_EVENT_STARTED;
2040 if (param->scan_ev_completed)
2041 cmd->notify_scan_events |= WMI_SCAN_EVENT_COMPLETED;
2042 if (param->scan_ev_bss_chan)
2043 cmd->notify_scan_events |= WMI_SCAN_EVENT_BSS_CHANNEL;
2044 if (param->scan_ev_foreign_chan)
2045 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL;
2046 if (param->scan_ev_dequeued)
2047 cmd->notify_scan_events |= WMI_SCAN_EVENT_DEQUEUED;
2048 if (param->scan_ev_preempted)
2049 cmd->notify_scan_events |= WMI_SCAN_EVENT_PREEMPTED;
2050 if (param->scan_ev_start_failed)
2051 cmd->notify_scan_events |= WMI_SCAN_EVENT_START_FAILED;
2052 if (param->scan_ev_restarted)
2053 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESTARTED;
2054 if (param->scan_ev_foreign_chn_exit)
2055 cmd->notify_scan_events |= WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT;
2056 if (param->scan_ev_suspended)
2057 cmd->notify_scan_events |= WMI_SCAN_EVENT_SUSPENDED;
2058 if (param->scan_ev_resumed)
2059 cmd->notify_scan_events |= WMI_SCAN_EVENT_RESUMED;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302060
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302061 /** Set scan control flags */
2062 cmd->scan_ctrl_flags = 0;
2063 if (param->scan_f_passive)
2064 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_PASSIVE;
2065 if (param->scan_f_strict_passive_pch)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302066 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_STRICT_PASSIVE_ON_PCHN;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302067 if (param->scan_f_promisc_mode)
2068 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROMISCOUS;
2069 if (param->scan_f_capture_phy_err)
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302070 cmd->scan_ctrl_flags |= WMI_SCAN_CAPTURE_PHY_ERROR;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302071 if (param->scan_f_half_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302072 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_HALF_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302073 if (param->scan_f_quarter_rate)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302074 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_QUARTER_RATE_SUPPORT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302075 if (param->scan_f_cck_rates)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302076 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302077 if (param->scan_f_ofdm_rates)
2078 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_OFDM_RATES;
2079 if (param->scan_f_chan_stat_evnt)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302080 cmd->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302081 if (param->scan_f_filter_prb_req)
2082 cmd->scan_ctrl_flags |= WMI_SCAN_FILTER_PROBE_REQ;
2083 if (param->scan_f_bcast_probe)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302084 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_BCAST_PROBE_REQ;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302085 if (param->scan_f_offchan_mgmt_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302086 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_MGMT_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302087 if (param->scan_f_offchan_data_tx)
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302088 cmd->scan_ctrl_flags |= WMI_SCAN_OFFCHAN_DATA_TX;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302089 if (param->scan_f_force_active_dfs_chn)
2090 cmd->scan_ctrl_flags |= WMI_SCAN_FLAG_FORCE_ACTIVE_ON_DFS;
2091 if (param->scan_f_add_tpc_ie_in_probe)
2092 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_TPC_IE_IN_PROBE_REQ;
2093 if (param->scan_f_add_ds_ie_in_probe)
2094 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
2095 if (param->scan_f_add_spoofed_mac_in_probe)
2096 cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ;
2097 if (param->scan_f_add_rand_seq_in_probe)
2098 cmd->scan_ctrl_flags |= WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
2099 if (param->scan_f_en_ie_whitelist_in_probe)
2100 cmd->scan_ctrl_flags |=
2101 WMI_SCAN_ENABLE_IE_WHTELIST_IN_PROBE_REQ;
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302102
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302103 /* for adaptive scan mode using 3 bits (21 - 23 bits) */
2104 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
2105 param->adaptive_dwell_time_mode);
2106}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302107
2108/* scan_copy_ie_buffer() - Copy scan ie_data */
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302109static inline void scan_copy_ie_buffer(uint8_t *buf_ptr,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302110 struct scan_req_params *params)
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302111{
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302112 qdf_mem_copy(buf_ptr, params->extraie.ptr, params->extraie.len);
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302113}
Gurumoorthi Gnanasambandhaneb60ce02017-02-07 15:25:18 +05302114
Anish Natarajdd855152017-03-20 12:49:08 +05302115/*
2116 * get_pdev_wmi_handle() - Helper func to derive pdev wmi handle from vdev_id
2117 * @param wmi_handle : Handle to WMI
2118 * @param vdev_id : vdev identifier
2119 *
2120 * Return : void *
2121 */
2122static inline void *get_pdev_wmi_handle(wmi_unified_t wmi_handle, uint8_t vdev_id)
2123{
2124 struct wlan_objmgr_vdev *vdev = NULL;
2125 struct wlan_objmgr_pdev *pdev = NULL;
2126 uint8_t pdev_id = 0;
2127
2128 vdev = wlan_objmgr_get_vdev_by_id_from_psoc(
2129 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
2130 vdev_id, WLAN_SCAN_ID);
2131 if (vdev) {
2132 wlan_objmgr_vdev_release_ref(vdev, WLAN_SCAN_ID);
2133 pdev = wlan_vdev_get_pdev(vdev);
2134 if (pdev)
2135 pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
2136 else {
2137 qdf_print("%s : Invalid PDEV, forcing pdev_id to 0\n", __func__);
2138 }
2139 } else {
2140 qdf_print("%s : Invalid VDEV, forcing pdev_id to 0\n", __func__);
2141 }
2142
2143 return wmi_unified_get_pdev_handle(wmi_handle->soc, pdev_id);
2144}
2145
Govind Singh5eb51532016-03-09 11:34:12 +05302146/**
2147 * send_scan_start_cmd_tlv() - WMI scan start function
2148 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302149 * @param param : pointer to hold scan start cmd parameter
2150 *
2151 * Return: 0 on success and -ve on failure.
2152 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302153static QDF_STATUS send_scan_start_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302154 struct scan_req_params *params)
Govind Singh5eb51532016-03-09 11:34:12 +05302155{
Govind Singhd3156eb2016-02-26 17:50:39 +05302156 int32_t ret = 0;
2157 int32_t i;
2158 wmi_buf_t wmi_buf;
2159 wmi_start_scan_cmd_fixed_param *cmd;
2160 uint8_t *buf_ptr;
2161 uint32_t *tmp_ptr;
2162 wmi_ssid *ssid = NULL;
2163 wmi_mac_addr *bssid;
2164 int len = sizeof(*cmd);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302165 uint8_t extraie_len_with_pad = 0;
Govind Singhd3156eb2016-02-26 17:50:39 +05302166
2167 /* Length TLV placeholder for array of uint32_t */
2168 len += WMI_TLV_HDR_SIZE;
2169 /* calculate the length of buffer required */
2170 if (params->num_chan)
2171 len += params->num_chan * sizeof(uint32_t);
2172
2173 /* Length TLV placeholder for array of wmi_ssid structures */
2174 len += WMI_TLV_HDR_SIZE;
2175 if (params->num_ssids)
2176 len += params->num_ssids * sizeof(wmi_ssid);
2177
2178 /* Length TLV placeholder for array of wmi_mac_addr structures */
2179 len += WMI_TLV_HDR_SIZE;
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302180 if (params->num_bssid)
2181 len += sizeof(wmi_mac_addr) * params->num_bssid;
Govind Singhd3156eb2016-02-26 17:50:39 +05302182
2183 /* Length TLV placeholder for array of bytes */
2184 len += WMI_TLV_HDR_SIZE;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302185 if (params->extraie.len)
2186 extraie_len_with_pad =
2187 roundup(params->extraie.len, sizeof(uint32_t));
2188 len += extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302189
2190 /* Allocate the memory */
2191 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2192 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302193 WMI_LOGP("%s: failed to allocate memory for start scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302194 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05302195 return QDF_STATUS_E_FAILURE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302196 }
2197 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
2198 cmd = (wmi_start_scan_cmd_fixed_param *) buf_ptr;
2199 WMITLV_SET_HDR(&cmd->tlv_header,
2200 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
2201 WMITLV_GET_STRUCT_TLVLEN
2202 (wmi_start_scan_cmd_fixed_param));
2203
2204 cmd->scan_id = params->scan_id;
2205 cmd->scan_req_id = params->scan_req_id;
2206 cmd->vdev_id = params->vdev_id;
2207 cmd->scan_priority = params->scan_priority;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302208
2209 copy_scan_event_cntrl_flags(cmd, params);
2210
Govind Singhd3156eb2016-02-26 17:50:39 +05302211 cmd->dwell_time_active = params->dwell_time_active;
2212 cmd->dwell_time_passive = params->dwell_time_passive;
2213 cmd->min_rest_time = params->min_rest_time;
2214 cmd->max_rest_time = params->max_rest_time;
2215 cmd->repeat_probe_time = params->repeat_probe_time;
2216 cmd->probe_spacing_time = params->probe_spacing_time;
2217 cmd->idle_time = params->idle_time;
2218 cmd->max_scan_time = params->max_scan_time;
2219 cmd->probe_delay = params->probe_delay;
Govind Singhd3156eb2016-02-26 17:50:39 +05302220 cmd->burst_duration = params->burst_duration;
2221 cmd->num_chan = params->num_chan;
2222 cmd->num_bssid = params->num_bssid;
2223 cmd->num_ssids = params->num_ssids;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302224 cmd->ie_len = params->extraie.len;
Govind Singhd3156eb2016-02-26 17:50:39 +05302225 cmd->n_probes = params->n_probes;
2226 buf_ptr += sizeof(*cmd);
2227 tmp_ptr = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
2228 for (i = 0; i < params->num_chan; ++i)
2229 tmp_ptr[i] = params->chan_list[i];
2230
2231 WMITLV_SET_HDR(buf_ptr,
2232 WMITLV_TAG_ARRAY_UINT32,
2233 (params->num_chan * sizeof(uint32_t)));
2234 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_chan * sizeof(uint32_t));
Govind Singh4eacd2b2016-03-07 14:24:22 +05302235 if (params->num_ssids > WMI_SCAN_MAX_NUM_SSID) {
Govind Singhb53420c2016-03-09 14:32:57 +05302236 WMI_LOGE("Invalid value for numSsid");
Govind Singhd3156eb2016-02-26 17:50:39 +05302237 goto error;
2238 }
2239
2240 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2241 (params->num_ssids * sizeof(wmi_ssid)));
2242
2243 if (params->num_ssids) {
2244 ssid = (wmi_ssid *) (buf_ptr + WMI_TLV_HDR_SIZE);
2245 for (i = 0; i < params->num_ssids; ++i) {
2246 ssid->ssid_len = params->ssid[i].length;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302247 qdf_mem_copy(ssid->ssid, params->ssid[i].ssid,
Govind Singhd3156eb2016-02-26 17:50:39 +05302248 params->ssid[i].length);
2249 ssid++;
2250 }
2251 }
2252 buf_ptr += WMI_TLV_HDR_SIZE + (params->num_ssids * sizeof(wmi_ssid));
2253
2254 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
2255 (params->num_bssid * sizeof(wmi_mac_addr)));
2256 bssid = (wmi_mac_addr *) (buf_ptr + WMI_TLV_HDR_SIZE);
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302257
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302258 if (params->num_bssid) {
2259 for (i = 0; i < params->num_bssid; ++i) {
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302260 WMI_CHAR_ARRAY_TO_MAC_ADDR(
2261 &params->bssid_list[i].bytes[0], bssid);
Kiran Venkatappa3c4f6a22016-11-07 23:23:56 +05302262 bssid++;
2263 }
2264 }
Govind Singhd3156eb2016-02-26 17:50:39 +05302265
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302266 buf_ptr += WMI_TLV_HDR_SIZE +
2267 (params->num_bssid * sizeof(wmi_mac_addr));
2268
2269 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, extraie_len_with_pad);
2270 if (params->extraie.len)
2271 scan_copy_ie_buffer(buf_ptr + WMI_TLV_HDR_SIZE,
2272 params);
2273
2274 buf_ptr += WMI_TLV_HDR_SIZE + extraie_len_with_pad;
Govind Singhd3156eb2016-02-26 17:50:39 +05302275
Anish Natarajdd855152017-03-20 12:49:08 +05302276 ret = wmi_unified_cmd_send(
2277 get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302278 len, WMI_START_SCAN_CMDID);
2279 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302280 WMI_LOGE("%s: Failed to start scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302281 wmi_buf_free(wmi_buf);
2282 }
2283 return ret;
2284error:
Abhishek Singh716c46c2016-05-04 16:24:07 +05302285 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302286 return QDF_STATUS_E_FAILURE;
Govind Singh5eb51532016-03-09 11:34:12 +05302287}
2288
2289/**
2290 * send_scan_stop_cmd_tlv() - WMI scan start function
2291 * @param wmi_handle : handle to WMI.
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302292 * @param param : pointer to hold scan cancel cmd parameter
Govind Singh5eb51532016-03-09 11:34:12 +05302293 *
2294 * Return: 0 on success and -ve on failure.
2295 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302296static QDF_STATUS send_scan_stop_cmd_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302297 struct scan_cancel_param *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302298{
Govind Singhd3156eb2016-02-26 17:50:39 +05302299 wmi_stop_scan_cmd_fixed_param *cmd;
2300 int ret;
2301 int len = sizeof(*cmd);
2302 wmi_buf_t wmi_buf;
2303
2304 /* Allocate the memory */
2305 wmi_buf = wmi_buf_alloc(wmi_handle, len);
2306 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302307 WMI_LOGP("%s: failed to allocate memory for stop scan cmd",
Govind Singhd3156eb2016-02-26 17:50:39 +05302308 __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302309 ret = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302310 goto error;
2311 }
2312
2313 cmd = (wmi_stop_scan_cmd_fixed_param *) wmi_buf_data(wmi_buf);
2314 WMITLV_SET_HDR(&cmd->tlv_header,
2315 WMITLV_TAG_STRUC_wmi_stop_scan_cmd_fixed_param,
2316 WMITLV_GET_STRUCT_TLVLEN(wmi_stop_scan_cmd_fixed_param));
2317 cmd->vdev_id = param->vdev_id;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302318 cmd->requestor = param->requester;
Govind Singhd3156eb2016-02-26 17:50:39 +05302319 cmd->scan_id = param->scan_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302320 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2321 param->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302322 /* stop the scan with the corresponding scan_id */
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302323 if (param->req_type == WLAN_SCAN_CANCEL_PDEV_ALL) {
2324 /* Cancelling all scans */
2325 cmd->req_type = WMI_SCAN_STOP_ALL;
2326 } else if (param->req_type == WLAN_SCAN_CANCEL_VDEV_ALL) {
2327 /* Cancelling VAP scans */
2328 cmd->req_type = WMI_SCN_STOP_VAP_ALL;
2329 } else if (param->req_type == WLAN_SCAN_CANCEL_SINGLE) {
2330 /* Cancelling specific scan */
2331 cmd->req_type = WMI_SCAN_STOP_ONE;
Anish Natarajdd855152017-03-20 12:49:08 +05302332 } else {
2333 WMI_LOGE("%s: Invalid Command : ", __func__);
2334 wmi_buf_free(wmi_buf);
2335 return QDF_STATUS_E_INVAL;
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +05302336 }
2337
Anish Natarajdd855152017-03-20 12:49:08 +05302338 ret = wmi_unified_cmd_send(get_pdev_wmi_handle(wmi_handle, cmd->vdev_id), wmi_buf,
Govind Singhd3156eb2016-02-26 17:50:39 +05302339 len, WMI_STOP_SCAN_CMDID);
2340 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05302341 WMI_LOGE("%s: Failed to send stop scan: %d", __func__, ret);
Govind Singhd3156eb2016-02-26 17:50:39 +05302342 wmi_buf_free(wmi_buf);
2343 }
2344
2345error:
2346 return ret;
Govind Singh5eb51532016-03-09 11:34:12 +05302347}
2348
Govind Singh87542482016-06-08 19:40:11 +05302349#ifdef CONFIG_MCL
Govind Singh5eb51532016-03-09 11:34:12 +05302350/**
2351 * send_scan_chan_list_cmd_tlv() - WMI scan channel list function
2352 * @param wmi_handle : handle to WMI.
Govind Singh5eb51532016-03-09 11:34:12 +05302353 * @param param : pointer to hold scan channel list parameter
2354 *
2355 * Return: 0 on success and -ve on failure.
2356 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302357static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302358 struct scan_chan_list_params *chan_list)
2359{
2360 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302361 QDF_STATUS qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302362 wmi_scan_chan_list_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05302363 int i;
Govind Singhd3156eb2016-02-26 17:50:39 +05302364 uint8_t *buf_ptr;
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302365 wmi_channel_param *chan_info, *tchan_info;
Govind Singhd3156eb2016-02-26 17:50:39 +05302366 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
2367
2368 len += sizeof(wmi_channel) * chan_list->num_scan_chans;
2369 buf = wmi_buf_alloc(wmi_handle, len);
2370 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302371 WMI_LOGE("Failed to allocate memory");
2372 qdf_status = QDF_STATUS_E_NOMEM;
Govind Singhd3156eb2016-02-26 17:50:39 +05302373 goto end;
2374 }
2375
2376 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2377 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2378 WMITLV_SET_HDR(&cmd->tlv_header,
2379 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2380 WMITLV_GET_STRUCT_TLVLEN
2381 (wmi_scan_chan_list_cmd_fixed_param));
2382
Govind Singhb53420c2016-03-09 14:32:57 +05302383 WMI_LOGD("no of channels = %d, len = %d", chan_list->num_scan_chans, len);
Govind Singhd3156eb2016-02-26 17:50:39 +05302384
2385 cmd->num_scan_chans = chan_list->num_scan_chans;
2386 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2387 WMITLV_TAG_ARRAY_STRUC,
2388 sizeof(wmi_channel) * chan_list->num_scan_chans);
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +05302389 chan_info = (wmi_channel_param *)
2390 (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
Govind Singhd3156eb2016-02-26 17:50:39 +05302391 tchan_info = chan_list->chan_info;
2392
2393 for (i = 0; i < chan_list->num_scan_chans; ++i) {
2394 WMITLV_SET_HDR(&chan_info->tlv_header,
2395 WMITLV_TAG_STRUC_wmi_channel,
2396 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2397 chan_info->mhz = tchan_info->mhz;
2398 chan_info->band_center_freq1 =
2399 tchan_info->band_center_freq1;
2400 chan_info->band_center_freq2 =
2401 tchan_info->band_center_freq2;
2402 chan_info->info = tchan_info->info;
2403 chan_info->reg_info_1 = tchan_info->reg_info_1;
2404 chan_info->reg_info_2 = tchan_info->reg_info_2;
Govind Singhb53420c2016-03-09 14:32:57 +05302405 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
Govind Singhd3156eb2016-02-26 17:50:39 +05302406
2407 /*TODO: Set WMI_SET_CHANNEL_MIN_POWER */
2408 /*TODO: Set WMI_SET_CHANNEL_ANTENNA_MAX */
2409 /*TODO: WMI_SET_CHANNEL_REG_CLASSID */
2410 tchan_info++;
2411 chan_info++;
2412 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302413 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2414 chan_list->pdev_id);
Govind Singhd3156eb2016-02-26 17:50:39 +05302415
Anish Natarajdd855152017-03-20 12:49:08 +05302416 qdf_status = wmi_unified_cmd_send(wmi_handle,
2417 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singhd3156eb2016-02-26 17:50:39 +05302418
Govind Singh67922e82016-04-01 16:48:57 +05302419 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302420 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
Govind Singhd3156eb2016-02-26 17:50:39 +05302421 wmi_buf_free(buf);
2422 }
Govind Singh67922e82016-04-01 16:48:57 +05302423
Govind Singhd3156eb2016-02-26 17:50:39 +05302424end:
Govind Singhb53420c2016-03-09 14:32:57 +05302425 return qdf_status;
Govind Singhd3156eb2016-02-26 17:50:39 +05302426}
Govind Singh87542482016-06-08 19:40:11 +05302427#else
Sathish Kumarfd347372017-02-13 12:29:09 +05302428static QDF_STATUS send_scan_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh87542482016-06-08 19:40:11 +05302429 struct scan_chan_list_params *chan_list)
2430{
2431 wmi_buf_t buf;
2432 QDF_STATUS qdf_status;
2433 wmi_scan_chan_list_cmd_fixed_param *cmd;
2434 int i;
2435 uint8_t *buf_ptr;
2436 wmi_channel *chan_info;
2437 struct channel_param *tchan_info;
2438 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
Govind Singhd3156eb2016-02-26 17:50:39 +05302439
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302440 len += sizeof(wmi_channel) * chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302441 buf = wmi_buf_alloc(wmi_handle, len);
2442 if (!buf) {
2443 WMI_LOGE("Failed to allocate memory");
2444 qdf_status = QDF_STATUS_E_NOMEM;
2445 goto end;
2446 }
2447
2448 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2449 cmd = (wmi_scan_chan_list_cmd_fixed_param *) buf_ptr;
2450 WMITLV_SET_HDR(&cmd->tlv_header,
2451 WMITLV_TAG_STRUC_wmi_scan_chan_list_cmd_fixed_param,
2452 WMITLV_GET_STRUCT_TLVLEN
2453 (wmi_scan_chan_list_cmd_fixed_param));
2454
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302455 WMI_LOGD("no of channels = %d, len = %d", chan_list->nallchans, len);
Govind Singh87542482016-06-08 19:40:11 +05302456
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302457 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2458 chan_list->pdev_id);
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302459 cmd->num_scan_chans = chan_list->nallchans;
Govind Singh87542482016-06-08 19:40:11 +05302460 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_scan_chan_list_cmd_fixed_param)),
2461 WMITLV_TAG_ARRAY_STRUC,
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302462 sizeof(wmi_channel) * chan_list->nallchans);
Govind Singh87542482016-06-08 19:40:11 +05302463 chan_info = (wmi_channel *) (buf_ptr + sizeof(*cmd) + WMI_TLV_HDR_SIZE);
2464 tchan_info = &(chan_list->ch_param[0]);
2465
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302466 for (i = 0; i < chan_list->nallchans; ++i) {
Govind Singh87542482016-06-08 19:40:11 +05302467 WMITLV_SET_HDR(&chan_info->tlv_header,
2468 WMITLV_TAG_STRUC_wmi_channel,
2469 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
2470 chan_info->mhz = tchan_info->mhz;
2471 chan_info->band_center_freq1 =
2472 tchan_info->cfreq1;
2473 chan_info->band_center_freq2 =
2474 tchan_info->cfreq2;
2475
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +05302476 if (tchan_info->is_chan_passive)
2477 WMI_SET_CHANNEL_FLAG(chan_info,
2478 WMI_CHAN_FLAG_PASSIVE);
2479
2480 if (tchan_info->allow_vht)
2481 WMI_SET_CHANNEL_FLAG(chan_info,
2482 WMI_CHAN_FLAG_ALLOW_VHT);
2483 else if (tchan_info->allow_ht)
2484 WMI_SET_CHANNEL_FLAG(chan_info,
2485 WMI_CHAN_FLAG_ALLOW_HT);
2486 WMI_SET_CHANNEL_MODE(chan_info,
2487 tchan_info->phy_mode);
2488
2489 /* Add tchan_info->half_rate and tchan_info->quarter_rate later
2490 * after FW support
2491 */
2492
2493 /* also fill in power information */
2494 WMI_SET_CHANNEL_MIN_POWER(chan_info,
2495 tchan_info->minpower);
2496 WMI_SET_CHANNEL_MAX_POWER(chan_info,
2497 tchan_info->maxpower);
2498 WMI_SET_CHANNEL_REG_POWER(chan_info,
2499 tchan_info->maxregpower);
2500 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info,
2501 tchan_info->antennamax);
2502 WMI_SET_CHANNEL_REG_CLASSID(chan_info,
2503 tchan_info->reg_class_id);
2504
Govind Singh87542482016-06-08 19:40:11 +05302505 WMI_LOGD("chan[%d] = %u", i, chan_info->mhz);
2506
Govind Singh87542482016-06-08 19:40:11 +05302507 tchan_info++;
2508 chan_info++;
2509 }
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05302510 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
2511 chan_list->pdev_id);
Govind Singh87542482016-06-08 19:40:11 +05302512
Anish Natarajdd855152017-03-20 12:49:08 +05302513 qdf_status = wmi_unified_cmd_send(
2514 wmi_handle,
2515 buf, len, WMI_SCAN_CHAN_LIST_CMDID);
Govind Singh87542482016-06-08 19:40:11 +05302516
2517 if (QDF_IS_STATUS_ERROR(qdf_status)) {
2518 WMI_LOGE("Failed to send WMI_SCAN_CHAN_LIST_CMDID");
2519 wmi_buf_free(buf);
2520 }
2521
2522end:
2523 return qdf_status;
2524}
2525#endif
Govind Singhd3156eb2016-02-26 17:50:39 +05302526/**
2527 * send_mgmt_cmd_tlv() - WMI scan start function
2528 * @wmi_handle : handle to WMI.
2529 * @param : pointer to hold mgmt cmd parameter
2530 *
2531 * Return: 0 on success and -ve on failure.
2532 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302533static QDF_STATUS send_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singhd3156eb2016-02-26 17:50:39 +05302534 struct wmi_mgmt_params *param)
Govind Singh5eb51532016-03-09 11:34:12 +05302535{
Govind Singh427ee5a2016-02-26 18:09:36 +05302536 wmi_buf_t buf;
2537 wmi_mgmt_tx_send_cmd_fixed_param *cmd;
2538 int32_t cmd_len;
2539 uint64_t dma_addr;
Govind Singhb53420c2016-03-09 14:32:57 +05302540 void *qdf_ctx = param->qdf_ctx;
Govind Singh427ee5a2016-02-26 18:09:36 +05302541 uint8_t *bufp;
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302542 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302543 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ? param->frm_len :
2544 mgmt_tx_dl_frm_len;
2545
2546 cmd_len = sizeof(wmi_mgmt_tx_send_cmd_fixed_param) +
2547 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2548
2549 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2550 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302551 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2552 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302553 }
2554
2555 cmd = (wmi_mgmt_tx_send_cmd_fixed_param *)wmi_buf_data(buf);
2556 bufp = (uint8_t *) cmd;
2557 WMITLV_SET_HDR(&cmd->tlv_header,
2558 WMITLV_TAG_STRUC_wmi_mgmt_tx_send_cmd_fixed_param,
2559 WMITLV_GET_STRUCT_TLVLEN
2560 (wmi_mgmt_tx_send_cmd_fixed_param));
2561
2562 cmd->vdev_id = param->vdev_id;
2563
Govind Singh224a7312016-06-21 14:33:26 +05302564 cmd->desc_id = param->desc_id;
Govind Singh427ee5a2016-02-26 18:09:36 +05302565 cmd->chanfreq = param->chanfreq;
2566 bufp += sizeof(wmi_mgmt_tx_send_cmd_fixed_param);
2567 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2568 sizeof(uint32_t)));
2569 bufp += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05302570 qdf_mem_copy(bufp, param->pdata, bufp_len);
Himanshu Agarwale3d13742017-04-04 12:36:33 +05302571
2572 status = qdf_nbuf_map_single(qdf_ctx, param->tx_frame,
2573 QDF_DMA_TO_DEVICE);
2574 if (status != QDF_STATUS_SUCCESS) {
2575 WMI_LOGE("%s: wmi buf map failed", __func__);
2576 goto err1;
2577 }
2578
Govind Singhb53420c2016-03-09 14:32:57 +05302579 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
Govind Singh427ee5a2016-02-26 18:09:36 +05302580 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
Orhan K AKYILDIZ271641f2017-01-29 15:17:12 -08002581#if defined(HTT_PADDR64)
Govind Singh427ee5a2016-02-26 18:09:36 +05302582 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2583#endif
2584 cmd->frame_len = param->frm_len;
2585 cmd->buf_len = bufp_len;
2586
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002587 wmi_mgmt_cmd_record(wmi_handle, WMI_MGMT_TX_SEND_CMDID,
Sandeep Puligilla828a45f2016-07-19 13:20:57 -07002588 bufp, cmd->vdev_id, cmd->chanfreq);
Sandeep Puligillab74958d2016-06-13 15:42:55 -07002589
Govind Singh427ee5a2016-02-26 18:09:36 +05302590 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2591 WMI_MGMT_TX_SEND_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302592 WMI_LOGE("%s: Failed to send mgmt Tx", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302593 goto err1;
2594 }
Govind Singhb53420c2016-03-09 14:32:57 +05302595 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05302596
2597err1:
2598 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05302599 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302600}
2601
2602/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +05302603 * send_offchan_data_tx_send_cmd_tlv() - Send off-chan tx data
2604 * @wmi_handle : handle to WMI.
2605 * @param : pointer to offchan data tx cmd parameter
2606 *
2607 * Return: QDF_STATUS_SUCCESS on success and error on failure.
2608 */
2609static QDF_STATUS send_offchan_data_tx_cmd_tlv(wmi_unified_t wmi_handle,
2610 struct wmi_offchan_data_tx_params *param)
2611{
2612 wmi_buf_t buf;
2613 wmi_offchan_data_tx_send_cmd_fixed_param *cmd;
2614 int32_t cmd_len;
2615 uint64_t dma_addr;
2616 void *qdf_ctx = param->qdf_ctx;
2617 uint8_t *bufp;
2618 int32_t bufp_len = (param->frm_len < mgmt_tx_dl_frm_len) ?
2619 param->frm_len : mgmt_tx_dl_frm_len;
2620
2621 cmd_len = sizeof(wmi_offchan_data_tx_send_cmd_fixed_param) +
2622 WMI_TLV_HDR_SIZE + roundup(bufp_len, sizeof(uint32_t));
2623
2624 buf = wmi_buf_alloc(wmi_handle, cmd_len);
2625 if (!buf) {
2626 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
2627 return QDF_STATUS_E_NOMEM;
2628 }
2629
2630 cmd = (wmi_offchan_data_tx_send_cmd_fixed_param *) wmi_buf_data(buf);
2631 bufp = (uint8_t *) cmd;
2632 WMITLV_SET_HDR(&cmd->tlv_header,
2633 WMITLV_TAG_STRUC_wmi_offchan_data_tx_send_cmd_fixed_param,
2634 WMITLV_GET_STRUCT_TLVLEN
2635 (wmi_offchan_data_tx_send_cmd_fixed_param));
2636
2637 cmd->vdev_id = param->vdev_id;
2638
2639 cmd->desc_id = param->desc_id;
2640 cmd->chanfreq = param->chanfreq;
2641 bufp += sizeof(wmi_offchan_data_tx_send_cmd_fixed_param);
2642 WMITLV_SET_HDR(bufp, WMITLV_TAG_ARRAY_BYTE, roundup(bufp_len,
2643 sizeof(uint32_t)));
2644 bufp += WMI_TLV_HDR_SIZE;
2645 qdf_mem_copy(bufp, param->pdata, bufp_len);
2646 qdf_nbuf_map_single(qdf_ctx, param->tx_frame, QDF_DMA_TO_DEVICE);
2647 dma_addr = qdf_nbuf_get_frag_paddr(param->tx_frame, 0);
2648 cmd->paddr_lo = (uint32_t)(dma_addr & 0xffffffff);
2649#if defined(HTT_PADDR64)
2650 cmd->paddr_hi = (uint32_t)((dma_addr >> 32) & 0x1F);
2651#endif
2652 cmd->frame_len = param->frm_len;
2653 cmd->buf_len = bufp_len;
2654
2655 wmi_mgmt_cmd_record(wmi_handle, WMI_OFFCHAN_DATA_TX_SEND_CMDID,
2656 bufp, cmd->vdev_id, cmd->chanfreq);
2657
2658 if (wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
2659 WMI_OFFCHAN_DATA_TX_SEND_CMDID)) {
2660 WMI_LOGE("%s: Failed to offchan data Tx", __func__);
2661 wmi_buf_free(buf);
2662 return QDF_STATUS_E_FAILURE;
2663 }
2664
2665 return QDF_STATUS_SUCCESS;
2666}
2667
2668/**
Govind Singh427ee5a2016-02-26 18:09:36 +05302669 * send_modem_power_state_cmd_tlv() - set modem power state to fw
2670 * @wmi_handle: wmi handle
2671 * @param_value: parameter value
2672 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302673 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh427ee5a2016-02-26 18:09:36 +05302674 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302675static QDF_STATUS send_modem_power_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302676 uint32_t param_value)
2677{
Govind Singh67922e82016-04-01 16:48:57 +05302678 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302679 wmi_modem_power_state_cmd_param *cmd;
2680 wmi_buf_t buf;
2681 uint16_t len = sizeof(*cmd);
2682
2683 buf = wmi_buf_alloc(wmi_handle, len);
2684 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302685 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302686 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302687 }
2688 cmd = (wmi_modem_power_state_cmd_param *) wmi_buf_data(buf);
2689 WMITLV_SET_HDR(&cmd->tlv_header,
2690 WMITLV_TAG_STRUC_wmi_modem_power_state_cmd_param,
2691 WMITLV_GET_STRUCT_TLVLEN
2692 (wmi_modem_power_state_cmd_param));
2693 cmd->modem_power_state = param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05302694 WMI_LOGD("%s: Setting cmd->modem_power_state = %u", __func__,
Govind Singh427ee5a2016-02-26 18:09:36 +05302695 param_value);
2696 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2697 WMI_MODEM_POWER_STATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302698 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302699 WMI_LOGE("Failed to send notify cmd ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302700 wmi_buf_free(buf);
2701 }
Govind Singh67922e82016-04-01 16:48:57 +05302702
Govind Singh427ee5a2016-02-26 18:09:36 +05302703 return ret;
2704}
2705
2706/**
2707 * send_set_sta_ps_mode_cmd_tlv() - set sta powersave mode in fw
2708 * @wmi_handle: wmi handle
2709 * @vdev_id: vdev id
2710 * @val: value
2711 *
Govind Singhe7f2f342016-05-23 12:12:52 +05302712 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302713 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302714static QDF_STATUS send_set_sta_ps_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302715 uint32_t vdev_id, uint8_t val)
2716{
2717 wmi_sta_powersave_mode_cmd_fixed_param *cmd;
2718 wmi_buf_t buf;
2719 int32_t len = sizeof(*cmd);
2720
Govind Singhb53420c2016-03-09 14:32:57 +05302721 WMI_LOGD("Set Sta Mode Ps vdevId %d val %d", vdev_id, val);
Govind Singh427ee5a2016-02-26 18:09:36 +05302722
2723 buf = wmi_buf_alloc(wmi_handle, len);
2724 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302725 WMI_LOGP("%s: Set Sta Mode Ps Mem Alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302726 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302727 }
2728 cmd = (wmi_sta_powersave_mode_cmd_fixed_param *) wmi_buf_data(buf);
2729 WMITLV_SET_HDR(&cmd->tlv_header,
2730 WMITLV_TAG_STRUC_wmi_sta_powersave_mode_cmd_fixed_param,
2731 WMITLV_GET_STRUCT_TLVLEN
2732 (wmi_sta_powersave_mode_cmd_fixed_param));
2733 cmd->vdev_id = vdev_id;
2734 if (val)
2735 cmd->sta_ps_mode = WMI_STA_PS_MODE_ENABLED;
2736 else
2737 cmd->sta_ps_mode = WMI_STA_PS_MODE_DISABLED;
2738
2739 if (wmi_unified_cmd_send(wmi_handle, buf, len,
2740 WMI_STA_POWERSAVE_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302741 WMI_LOGE("Set Sta Mode Ps Failed vdevId %d val %d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302742 vdev_id, val);
Abhishek Singh716c46c2016-05-04 16:24:07 +05302743 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05302744 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302745 }
Govind Singh5eb51532016-03-09 11:34:12 +05302746 return 0;
2747}
2748
Govind Singh427ee5a2016-02-26 18:09:36 +05302749/**
2750 * send_set_mimops_cmd_tlv() - set MIMO powersave
2751 * @wmi_handle: wmi handle
2752 * @vdev_id: vdev id
2753 * @value: value
2754 *
Govind Singhb53420c2016-03-09 14:32:57 +05302755 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302756 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302757static QDF_STATUS send_set_mimops_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302758 uint8_t vdev_id, int value)
2759{
Govind Singh67922e82016-04-01 16:48:57 +05302760 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302761 wmi_sta_smps_force_mode_cmd_fixed_param *cmd;
2762 wmi_buf_t buf;
2763 uint16_t len = sizeof(*cmd);
2764
2765 buf = wmi_buf_alloc(wmi_handle, len);
2766 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302767 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302768 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302769 }
2770 cmd = (wmi_sta_smps_force_mode_cmd_fixed_param *) wmi_buf_data(buf);
2771 WMITLV_SET_HDR(&cmd->tlv_header,
2772 WMITLV_TAG_STRUC_wmi_sta_smps_force_mode_cmd_fixed_param,
2773 WMITLV_GET_STRUCT_TLVLEN
2774 (wmi_sta_smps_force_mode_cmd_fixed_param));
2775
2776 cmd->vdev_id = vdev_id;
2777
Houston Hoffmanb5168052016-04-14 02:18:01 -07002778 /* WMI_SMPS_FORCED_MODE values do not directly map
2779 * to SM power save values defined in the specification.
2780 * Make sure to send the right mapping.
2781 */
Govind Singh427ee5a2016-02-26 18:09:36 +05302782 switch (value) {
2783 case 0:
2784 cmd->forced_mode = WMI_SMPS_FORCED_MODE_NONE;
2785 break;
2786 case 1:
2787 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DISABLED;
2788 break;
2789 case 2:
2790 cmd->forced_mode = WMI_SMPS_FORCED_MODE_STATIC;
2791 break;
2792 case 3:
2793 cmd->forced_mode = WMI_SMPS_FORCED_MODE_DYNAMIC;
2794 break;
2795 default:
Govind Singhb53420c2016-03-09 14:32:57 +05302796 WMI_LOGE("%s:INVALID Mimo PS CONFIG", __func__);
2797 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302798 }
2799
Govind Singhb53420c2016-03-09 14:32:57 +05302800 WMI_LOGD("Setting vdev %d value = %u", vdev_id, value);
Govind Singh427ee5a2016-02-26 18:09:36 +05302801
2802 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2803 WMI_STA_SMPS_FORCE_MODE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302804 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302805 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302806 wmi_buf_free(buf);
2807 }
2808
2809 return ret;
2810}
2811
2812/**
2813 * send_set_smps_params_cmd_tlv() - set smps params
2814 * @wmi_handle: wmi handle
2815 * @vdev_id: vdev id
2816 * @value: value
2817 *
Govind Singhb53420c2016-03-09 14:32:57 +05302818 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05302819 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302820static QDF_STATUS send_set_smps_params_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh427ee5a2016-02-26 18:09:36 +05302821 int value)
2822{
Govind Singh67922e82016-04-01 16:48:57 +05302823 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05302824 wmi_sta_smps_param_cmd_fixed_param *cmd;
2825 wmi_buf_t buf;
2826 uint16_t len = sizeof(*cmd);
2827
2828 buf = wmi_buf_alloc(wmi_handle, len);
2829 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302830 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05302831 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05302832 }
2833 cmd = (wmi_sta_smps_param_cmd_fixed_param *) wmi_buf_data(buf);
2834 WMITLV_SET_HDR(&cmd->tlv_header,
2835 WMITLV_TAG_STRUC_wmi_sta_smps_param_cmd_fixed_param,
2836 WMITLV_GET_STRUCT_TLVLEN
2837 (wmi_sta_smps_param_cmd_fixed_param));
2838
2839 cmd->vdev_id = vdev_id;
2840 cmd->value = value & WMI_SMPS_MASK_LOWER_16BITS;
2841 cmd->param =
2842 (value >> WMI_SMPS_PARAM_VALUE_S) & WMI_SMPS_MASK_UPPER_3BITS;
2843
Govind Singhb53420c2016-03-09 14:32:57 +05302844 WMI_LOGD("Setting vdev %d value = %x param %x", vdev_id, cmd->value,
Govind Singh427ee5a2016-02-26 18:09:36 +05302845 cmd->param);
2846
2847 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
2848 WMI_STA_SMPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302849 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302850 WMI_LOGE("Failed to send set Mimo PS ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05302851 wmi_buf_free(buf);
2852 }
2853
2854 return ret;
2855}
2856
2857/**
2858 * send_set_p2pgo_noa_req_cmd_tlv() - send p2p go noa request to fw
2859 * @wmi_handle: wmi handle
2860 * @noa: p2p power save parameters
2861 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302862 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302863 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302864static QDF_STATUS send_set_p2pgo_noa_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302865 struct p2p_ps_params *noa)
2866{
2867 wmi_p2p_set_noa_cmd_fixed_param *cmd;
2868 wmi_p2p_noa_descriptor *noa_discriptor;
2869 wmi_buf_t buf;
2870 uint8_t *buf_ptr;
2871 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05302872 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302873 uint32_t duration;
2874
Govind Singhb53420c2016-03-09 14:32:57 +05302875 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302876 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + sizeof(*noa_discriptor);
2877 buf = wmi_buf_alloc(wmi_handle, len);
2878 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302879 WMI_LOGE("Failed to allocate memory");
2880 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302881 goto end;
2882 }
2883
2884 buf_ptr = (uint8_t *) wmi_buf_data(buf);
2885 cmd = (wmi_p2p_set_noa_cmd_fixed_param *) buf_ptr;
2886 WMITLV_SET_HDR(&cmd->tlv_header,
2887 WMITLV_TAG_STRUC_wmi_p2p_set_noa_cmd_fixed_param,
2888 WMITLV_GET_STRUCT_TLVLEN
2889 (wmi_p2p_set_noa_cmd_fixed_param));
2890 duration = (noa->count == 1) ? noa->single_noa_duration : noa->duration;
2891 cmd->vdev_id = noa->session_id;
2892 cmd->enable = (duration) ? true : false;
2893 cmd->num_noa = 1;
2894
2895 WMITLV_SET_HDR((buf_ptr + sizeof(wmi_p2p_set_noa_cmd_fixed_param)),
2896 WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_p2p_noa_descriptor));
2897 noa_discriptor = (wmi_p2p_noa_descriptor *) (buf_ptr +
2898 sizeof
2899 (wmi_p2p_set_noa_cmd_fixed_param)
2900 + WMI_TLV_HDR_SIZE);
2901 WMITLV_SET_HDR(&noa_discriptor->tlv_header,
2902 WMITLV_TAG_STRUC_wmi_p2p_noa_descriptor,
2903 WMITLV_GET_STRUCT_TLVLEN(wmi_p2p_noa_descriptor));
2904 noa_discriptor->type_count = noa->count;
2905 noa_discriptor->duration = duration;
2906 noa_discriptor->interval = noa->interval;
2907 noa_discriptor->start_time = 0;
2908
Govind Singhb53420c2016-03-09 14:32:57 +05302909 WMI_LOGI("SET P2P GO NOA:vdev_id:%d count:%d duration:%d interval:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302910 cmd->vdev_id, noa->count, noa_discriptor->duration,
2911 noa->interval);
2912 status = wmi_unified_cmd_send(wmi_handle, buf, len,
2913 WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302914 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302915 WMI_LOGE("Failed to send WMI_FWTEST_P2P_SET_NOA_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302916 wmi_buf_free(buf);
2917 }
2918
2919end:
Govind Singhb53420c2016-03-09 14:32:57 +05302920 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302921 return status;
2922}
2923
2924
2925/**
2926 * send_set_p2pgo_oppps_req_cmd_tlv() - send p2p go opp power save request to fw
2927 * @wmi_handle: wmi handle
2928 * @noa: p2p opp power save parameters
2929 *
Govind Singh2edc80f2016-03-01 15:30:53 +05302930 * Return: CDF status
Govind Singh427ee5a2016-02-26 18:09:36 +05302931 */
Sathish Kumarfd347372017-02-13 12:29:09 +05302932static QDF_STATUS send_set_p2pgo_oppps_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05302933 struct p2p_ps_params *oppps)
2934{
2935 wmi_p2p_set_oppps_cmd_fixed_param *cmd;
2936 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05302937 QDF_STATUS status;
Govind Singh427ee5a2016-02-26 18:09:36 +05302938
Govind Singhb53420c2016-03-09 14:32:57 +05302939 WMI_LOGD("%s: Enter", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302940 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
2941 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05302942 WMI_LOGE("Failed to allocate memory");
2943 status = QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05302944 goto end;
2945 }
2946
2947 cmd = (wmi_p2p_set_oppps_cmd_fixed_param *) wmi_buf_data(buf);
2948 WMITLV_SET_HDR(&cmd->tlv_header,
2949 WMITLV_TAG_STRUC_wmi_p2p_set_oppps_cmd_fixed_param,
2950 WMITLV_GET_STRUCT_TLVLEN
2951 (wmi_p2p_set_oppps_cmd_fixed_param));
2952 cmd->vdev_id = oppps->session_id;
2953 if (oppps->ctwindow)
2954 WMI_UNIFIED_OPPPS_ATTR_ENABLED_SET(cmd);
2955
2956 WMI_UNIFIED_OPPPS_ATTR_CTWIN_SET(cmd, oppps->ctwindow);
Govind Singhb53420c2016-03-09 14:32:57 +05302957 WMI_LOGI("SET P2P GO OPPPS:vdev_id:%d ctwindow:%d",
Govind Singh427ee5a2016-02-26 18:09:36 +05302958 cmd->vdev_id, oppps->ctwindow);
2959 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
2960 WMI_P2P_SET_OPPPS_PARAM_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05302961 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05302962 WMI_LOGE("Failed to send WMI_P2P_SET_OPPPS_PARAM_CMDID");
Govind Singh427ee5a2016-02-26 18:09:36 +05302963 wmi_buf_free(buf);
2964 }
2965
2966end:
Govind Singhb53420c2016-03-09 14:32:57 +05302967 WMI_LOGD("%s: Exit", __func__);
Govind Singh427ee5a2016-02-26 18:09:36 +05302968 return status;
2969}
2970
Wu Gaocd3a8512017-03-13 20:17:34 +08002971#ifdef CONVERGED_P2P_ENABLE
2972/**
2973 * send_p2p_lo_start_cmd_tlv() - send p2p lo start request to fw
2974 * @wmi_handle: wmi handle
2975 * @param: p2p listen offload start parameters
2976 *
2977 * Return: QDF status
2978 */
2979static QDF_STATUS send_p2p_lo_start_cmd_tlv(wmi_unified_t wmi_handle,
2980 struct p2p_lo_start *param)
2981{
2982 wmi_buf_t buf;
2983 wmi_p2p_lo_start_cmd_fixed_param *cmd;
2984 int32_t len = sizeof(*cmd);
2985 uint8_t *buf_ptr;
2986 QDF_STATUS status;
2987 int device_types_len_aligned;
2988 int probe_resp_len_aligned;
2989
2990 if (!param) {
2991 WMI_LOGE("lo start param is null");
2992 return QDF_STATUS_E_INVAL;
2993 }
2994
2995 WMI_LOGD("%s: vdev_id:%d", __func__, param->vdev_id);
2996
2997 device_types_len_aligned =
2998 qdf_roundup(param->dev_types_len,
2999 sizeof(A_UINT32));
3000 probe_resp_len_aligned =
3001 qdf_roundup(param->probe_resp_len,
3002 sizeof(A_UINT32));
3003
3004 len += 2 * WMI_TLV_HDR_SIZE + device_types_len_aligned +
3005 probe_resp_len_aligned;
3006
3007 buf = wmi_buf_alloc(wmi_handle, len);
3008 if (!buf) {
3009 WMI_LOGE("%s: Failed to allocate memory for p2p lo start",
3010 __func__);
3011 return QDF_STATUS_E_NOMEM;
3012 }
3013
3014 cmd = (wmi_p2p_lo_start_cmd_fixed_param *)wmi_buf_data(buf);
3015 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3016
3017 WMITLV_SET_HDR(&cmd->tlv_header,
3018 WMITLV_TAG_STRUC_wmi_p2p_lo_start_cmd_fixed_param,
3019 WMITLV_GET_STRUCT_TLVLEN(
3020 wmi_p2p_lo_start_cmd_fixed_param));
3021
3022 cmd->vdev_id = param->vdev_id;
3023 cmd->ctl_flags = param->ctl_flags;
3024 cmd->channel = param->freq;
3025 cmd->period = param->period;
3026 cmd->interval = param->interval;
3027 cmd->count = param->count;
3028 cmd->device_types_len = param->dev_types_len;
3029 cmd->prob_resp_len = param->probe_resp_len;
3030
3031 buf_ptr += sizeof(wmi_p2p_lo_start_cmd_fixed_param);
3032 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3033 device_types_len_aligned);
3034 buf_ptr += WMI_TLV_HDR_SIZE;
3035 qdf_mem_copy(buf_ptr, param->device_types,
3036 param->dev_types_len);
3037
3038 buf_ptr += device_types_len_aligned;
3039 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3040 probe_resp_len_aligned);
3041 buf_ptr += WMI_TLV_HDR_SIZE;
3042 qdf_mem_copy(buf_ptr, param->probe_resp_tmplt,
3043 param->probe_resp_len);
3044
3045 WMI_LOGD("%s: Sending WMI_P2P_LO_START command, channel=%d, period=%d, interval=%d, count=%d", __func__,
3046 cmd->channel, cmd->period, cmd->interval, cmd->count);
3047
3048 status = wmi_unified_cmd_send(wmi_handle,
3049 buf, len,
3050 WMI_P2P_LISTEN_OFFLOAD_START_CMDID);
3051 if (status != QDF_STATUS_SUCCESS) {
3052 WMI_LOGE("%s: Failed to send p2p lo start: %d",
3053 __func__, status);
3054 wmi_buf_free(buf);
3055 return status;
3056 }
3057
3058 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_START", __func__);
3059
3060 return QDF_STATUS_SUCCESS;
3061}
3062
3063/**
3064 * send_p2p_lo_stop_cmd_tlv() - send p2p lo stop request to fw
3065 * @wmi_handle: wmi handle
3066 * @param: p2p listen offload stop parameters
3067 *
3068 * Return: QDF status
3069 */
3070static QDF_STATUS send_p2p_lo_stop_cmd_tlv(wmi_unified_t wmi_handle,
3071 uint8_t vdev_id)
3072{
3073 wmi_buf_t buf;
3074 wmi_p2p_lo_stop_cmd_fixed_param *cmd;
3075 int32_t len;
3076 QDF_STATUS status;
3077
3078 WMI_LOGD("%s: vdev_id:%d", __func__, vdev_id);
3079
3080 len = sizeof(*cmd);
3081 buf = wmi_buf_alloc(wmi_handle, len);
3082 if (!buf) {
3083 qdf_print("%s: Failed to allocate memory for p2p lo stop",
3084 __func__);
3085 return QDF_STATUS_E_NOMEM;
3086 }
3087 cmd = (wmi_p2p_lo_stop_cmd_fixed_param *)wmi_buf_data(buf);
3088
3089 WMITLV_SET_HDR(&cmd->tlv_header,
3090 WMITLV_TAG_STRUC_wmi_p2p_lo_stop_cmd_fixed_param,
3091 WMITLV_GET_STRUCT_TLVLEN(
3092 wmi_p2p_lo_stop_cmd_fixed_param));
3093
3094 cmd->vdev_id = vdev_id;
3095
3096 WMI_LOGD("%s: Sending WMI_P2P_LO_STOP command", __func__);
3097
3098 status = wmi_unified_cmd_send(wmi_handle,
3099 buf, len,
3100 WMI_P2P_LISTEN_OFFLOAD_STOP_CMDID);
3101 if (status != QDF_STATUS_SUCCESS) {
3102 WMI_LOGE("%s: Failed to send p2p lo stop: %d",
3103 __func__, status);
3104 wmi_buf_free(buf);
3105 return status;
3106 }
3107
3108 WMI_LOGD("%s: Successfully sent WMI_P2P_LO_STOP", __func__);
3109
3110 return QDF_STATUS_SUCCESS;
3111}
3112#endif /* End of CONVERGED_P2P_ENABLE */
3113
Govind Singh427ee5a2016-02-26 18:09:36 +05303114/**
3115 * send_get_temperature_cmd_tlv() - get pdev temperature req
3116 * @wmi_handle: wmi handle
3117 *
Govind Singhb53420c2016-03-09 14:32:57 +05303118 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303119 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303120static QDF_STATUS send_get_temperature_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh427ee5a2016-02-26 18:09:36 +05303121{
3122 wmi_pdev_get_temperature_cmd_fixed_param *cmd;
3123 wmi_buf_t wmi_buf;
3124 uint32_t len = sizeof(wmi_pdev_get_temperature_cmd_fixed_param);
3125 uint8_t *buf_ptr;
3126
3127 if (!wmi_handle) {
Govind Singhb53420c2016-03-09 14:32:57 +05303128 WMI_LOGE(FL("WMI is closed, can not issue cmd"));
3129 return QDF_STATUS_E_INVAL;
Govind Singh427ee5a2016-02-26 18:09:36 +05303130 }
3131
3132 wmi_buf = wmi_buf_alloc(wmi_handle, len);
3133 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303134 WMI_LOGE(FL("wmi_buf_alloc failed"));
3135 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303136 }
3137
3138 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
3139
3140 cmd = (wmi_pdev_get_temperature_cmd_fixed_param *) buf_ptr;
3141 WMITLV_SET_HDR(&cmd->tlv_header,
3142 WMITLV_TAG_STRUC_wmi_pdev_get_temperature_cmd_fixed_param,
3143 WMITLV_GET_STRUCT_TLVLEN
3144 (wmi_pdev_get_temperature_cmd_fixed_param));
3145
3146 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
3147 WMI_PDEV_GET_TEMPERATURE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303148 WMI_LOGE(FL("failed to send get temperature command"));
Govind Singh427ee5a2016-02-26 18:09:36 +05303149 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303150 return QDF_STATUS_E_FAILURE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303151 }
Govind Singh2edc80f2016-03-01 15:30:53 +05303152
Govind Singhb53420c2016-03-09 14:32:57 +05303153 return QDF_STATUS_SUCCESS;
Govind Singh427ee5a2016-02-26 18:09:36 +05303154}
3155
3156/**
3157 * send_set_sta_uapsd_auto_trig_cmd_tlv() - set uapsd auto trigger command
3158 * @wmi_handle: wmi handle
3159 * @vdevid: vdev id
3160 * @peer_addr: peer mac address
3161 * @auto_triggerparam: auto trigger parameters
3162 * @num_ac: number of access category
3163 *
3164 * This function sets the trigger
3165 * uapsd params such as service interval, delay interval
3166 * and suspend interval which will be used by the firmware
3167 * to send trigger frames periodically when there is no
3168 * traffic on the transmit side.
3169 *
Govind Singhe7f2f342016-05-23 12:12:52 +05303170 * Return: QDF_STATUS_SUCCESS for success or error code.
Govind Singh427ee5a2016-02-26 18:09:36 +05303171 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303172static QDF_STATUS send_set_sta_uapsd_auto_trig_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh427ee5a2016-02-26 18:09:36 +05303173 struct sta_uapsd_trig_params *param)
3174{
3175 wmi_sta_uapsd_auto_trig_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05303176 QDF_STATUS ret;
Govind Singh427ee5a2016-02-26 18:09:36 +05303177 uint32_t param_len = param->num_ac * sizeof(wmi_sta_uapsd_auto_trig_param);
3178 uint32_t cmd_len = sizeof(*cmd) + param_len + WMI_TLV_HDR_SIZE;
3179 uint32_t i;
3180 wmi_buf_t buf;
3181 uint8_t *buf_ptr;
Frank Liu3d5e9992017-03-15 17:51:43 +08003182 struct sta_uapsd_params *uapsd_param;
3183 wmi_sta_uapsd_auto_trig_param *trig_param;
Govind Singh427ee5a2016-02-26 18:09:36 +05303184
3185 buf = wmi_buf_alloc(wmi_handle, cmd_len);
3186 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303187 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05303188 return QDF_STATUS_E_NOMEM;
Govind Singh427ee5a2016-02-26 18:09:36 +05303189 }
3190
3191 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3192 cmd = (wmi_sta_uapsd_auto_trig_cmd_fixed_param *) buf_ptr;
3193 WMITLV_SET_HDR(&cmd->tlv_header,
3194 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_cmd_fixed_param,
3195 WMITLV_GET_STRUCT_TLVLEN
3196 (wmi_sta_uapsd_auto_trig_cmd_fixed_param));
3197 cmd->vdev_id = param->vdevid;
3198 cmd->num_ac = param->num_ac;
3199 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
3200
3201 /* TLV indicating array of structures to follow */
3202 buf_ptr += sizeof(*cmd);
3203 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, param_len);
3204
3205 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh427ee5a2016-02-26 18:09:36 +05303206
3207 /*
3208 * Update tag and length for uapsd auto trigger params (this will take
3209 * care of updating tag and length if it is not pre-filled by caller).
3210 */
Frank Liu3d5e9992017-03-15 17:51:43 +08003211 uapsd_param = (struct sta_uapsd_params *)param->auto_triggerparam;
3212 trig_param = (wmi_sta_uapsd_auto_trig_param *)buf_ptr;
Govind Singh427ee5a2016-02-26 18:09:36 +05303213 for (i = 0; i < param->num_ac; i++) {
3214 WMITLV_SET_HDR((buf_ptr +
3215 (i * sizeof(wmi_sta_uapsd_auto_trig_param))),
3216 WMITLV_TAG_STRUC_wmi_sta_uapsd_auto_trig_param,
3217 WMITLV_GET_STRUCT_TLVLEN
3218 (wmi_sta_uapsd_auto_trig_param));
Frank Liu3d5e9992017-03-15 17:51:43 +08003219 trig_param->wmm_ac = uapsd_param->wmm_ac;
3220 trig_param->user_priority = uapsd_param->user_priority;
3221 trig_param->service_interval = uapsd_param->service_interval;
3222 trig_param->suspend_interval = uapsd_param->suspend_interval;
3223 trig_param->delay_interval = uapsd_param->delay_interval;
3224 trig_param++;
3225 uapsd_param++;
Govind Singh427ee5a2016-02-26 18:09:36 +05303226 }
3227
3228 ret = wmi_unified_cmd_send(wmi_handle, buf, cmd_len,
3229 WMI_STA_UAPSD_AUTO_TRIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303230 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303231 WMI_LOGE("Failed to send set uapsd param ret = %d", ret);
Govind Singh427ee5a2016-02-26 18:09:36 +05303232 wmi_buf_free(buf);
3233 }
Govind Singh17a9cfa2016-03-01 15:54:59 +05303234
Govind Singh427ee5a2016-02-26 18:09:36 +05303235 return ret;
3236}
3237
Govind Singh2edc80f2016-03-01 15:30:53 +05303238/**
3239 * send_ocb_set_utc_time_cmd() - send the UTC time to the firmware
3240 * @wmi_handle: pointer to the wmi handle
3241 * @utc: pointer to the UTC time struct
3242 *
3243 * Return: 0 on succes
3244 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303245static QDF_STATUS send_ocb_set_utc_time_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303246 struct ocb_utc_param *utc)
3247{
Govind Singh67922e82016-04-01 16:48:57 +05303248 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303249 wmi_ocb_set_utc_time_cmd_fixed_param *cmd;
3250 uint8_t *buf_ptr;
3251 uint32_t len, i;
3252 wmi_buf_t buf;
3253
3254 len = sizeof(*cmd);
3255 buf = wmi_buf_alloc(wmi_handle, len);
3256 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303257 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303258 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303259 }
3260
3261 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3262 cmd = (wmi_ocb_set_utc_time_cmd_fixed_param *)buf_ptr;
3263 WMITLV_SET_HDR(&cmd->tlv_header,
3264 WMITLV_TAG_STRUC_wmi_ocb_set_utc_time_cmd_fixed_param,
3265 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_utc_time_cmd_fixed_param));
3266 cmd->vdev_id = utc->vdev_id;
3267
3268 for (i = 0; i < SIZE_UTC_TIME; i++)
3269 WMI_UTC_TIME_SET(cmd, i, utc->utc_time[i]);
3270
3271 for (i = 0; i < SIZE_UTC_TIME_ERROR; i++)
3272 WMI_TIME_ERROR_SET(cmd, i, utc->time_error[i]);
3273
3274 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3275 WMI_OCB_SET_UTC_TIME_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303276 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303277 WMI_LOGE(FL("Failed to set OCB UTC time"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303278 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303279 }
3280
Govind Singh67922e82016-04-01 16:48:57 +05303281 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303282}
3283
3284/**
3285 * send_ocb_start_timing_advert_cmd_tlv() - start sending the timing advertisement
3286 * frames on a channel
3287 * @wmi_handle: pointer to the wmi handle
3288 * @timing_advert: pointer to the timing advertisement struct
3289 *
3290 * Return: 0 on succes
3291 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303292static QDF_STATUS send_ocb_start_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303293 struct ocb_timing_advert_param *timing_advert)
3294{
Govind Singh67922e82016-04-01 16:48:57 +05303295 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303296 wmi_ocb_start_timing_advert_cmd_fixed_param *cmd;
3297 uint8_t *buf_ptr;
3298 uint32_t len, len_template;
3299 wmi_buf_t buf;
3300
3301 len = sizeof(*cmd) +
3302 WMI_TLV_HDR_SIZE;
3303
3304 len_template = timing_advert->template_length;
3305 /* Add padding to the template if needed */
3306 if (len_template % 4 != 0)
3307 len_template += 4 - (len_template % 4);
3308 len += len_template;
3309
3310 buf = wmi_buf_alloc(wmi_handle, len);
3311 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303312 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303313 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303314 }
3315
3316 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3317 cmd = (wmi_ocb_start_timing_advert_cmd_fixed_param *)buf_ptr;
3318 WMITLV_SET_HDR(&cmd->tlv_header,
3319 WMITLV_TAG_STRUC_wmi_ocb_start_timing_advert_cmd_fixed_param,
3320 WMITLV_GET_STRUCT_TLVLEN(
3321 wmi_ocb_start_timing_advert_cmd_fixed_param));
3322 cmd->vdev_id = timing_advert->vdev_id;
3323 cmd->repeat_rate = timing_advert->repeat_rate;
3324 cmd->channel_freq = timing_advert->chan_freq;
3325 cmd->timestamp_offset = timing_advert->timestamp_offset;
3326 cmd->time_value_offset = timing_advert->time_value_offset;
3327 cmd->timing_advert_template_length = timing_advert->template_length;
3328 buf_ptr += sizeof(*cmd);
3329
3330 /* Add the timing advert template */
3331 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3332 len_template);
Govind Singhb53420c2016-03-09 14:32:57 +05303333 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
Govind Singh2edc80f2016-03-01 15:30:53 +05303334 (uint8_t *)timing_advert->template_value,
3335 timing_advert->template_length);
3336
3337 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3338 WMI_OCB_START_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303339 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303340 WMI_LOGE(FL("Failed to start OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303341 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303342 }
3343
Govind Singh67922e82016-04-01 16:48:57 +05303344 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303345}
3346
3347/**
3348 * send_ocb_stop_timing_advert_cmd_tlv() - stop sending the timing advertisement frames
3349 * on a channel
3350 * @wmi_handle: pointer to the wmi handle
3351 * @timing_advert: pointer to the timing advertisement struct
3352 *
3353 * Return: 0 on succes
3354 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303355static QDF_STATUS send_ocb_stop_timing_advert_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303356 struct ocb_timing_advert_param *timing_advert)
3357{
Govind Singh67922e82016-04-01 16:48:57 +05303358 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303359 wmi_ocb_stop_timing_advert_cmd_fixed_param *cmd;
3360 uint8_t *buf_ptr;
3361 uint32_t len;
3362 wmi_buf_t buf;
3363
3364 len = sizeof(*cmd);
3365 buf = wmi_buf_alloc(wmi_handle, len);
3366 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303367 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303368 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303369 }
3370
3371 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3372 cmd = (wmi_ocb_stop_timing_advert_cmd_fixed_param *)buf_ptr;
3373 WMITLV_SET_HDR(&cmd->tlv_header,
3374 WMITLV_TAG_STRUC_wmi_ocb_stop_timing_advert_cmd_fixed_param,
3375 WMITLV_GET_STRUCT_TLVLEN(
3376 wmi_ocb_stop_timing_advert_cmd_fixed_param));
3377 cmd->vdev_id = timing_advert->vdev_id;
3378 cmd->channel_freq = timing_advert->chan_freq;
3379
3380 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3381 WMI_OCB_STOP_TIMING_ADVERT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303382 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303383 WMI_LOGE(FL("Failed to stop OCB timing advert"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303384 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303385 }
3386
Govind Singh67922e82016-04-01 16:48:57 +05303387 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303388}
3389
3390/**
3391 * send_ocb_get_tsf_timer_cmd_tlv() - get ocb tsf timer val
3392 * @wmi_handle: pointer to the wmi handle
3393 * @request: pointer to the request
3394 *
3395 * Return: 0 on succes
3396 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303397static QDF_STATUS send_ocb_get_tsf_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303398 uint8_t vdev_id)
3399{
Govind Singhb53420c2016-03-09 14:32:57 +05303400 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303401 wmi_ocb_get_tsf_timer_cmd_fixed_param *cmd;
3402 uint8_t *buf_ptr;
3403 wmi_buf_t buf;
3404 int32_t len;
3405
3406 len = sizeof(*cmd);
3407 buf = wmi_buf_alloc(wmi_handle, len);
3408 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303409 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303410 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303411 }
3412 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3413
3414 cmd = (wmi_ocb_get_tsf_timer_cmd_fixed_param *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303415 qdf_mem_zero(cmd, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303416 WMITLV_SET_HDR(&cmd->tlv_header,
3417 WMITLV_TAG_STRUC_wmi_ocb_get_tsf_timer_cmd_fixed_param,
3418 WMITLV_GET_STRUCT_TLVLEN(
3419 wmi_ocb_get_tsf_timer_cmd_fixed_param));
3420 cmd->vdev_id = vdev_id;
3421
3422 /* Send the WMI command */
3423 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3424 WMI_OCB_GET_TSF_TIMER_CMDID);
3425 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303426 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303427 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303428 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303429 }
3430
Govind Singh67922e82016-04-01 16:48:57 +05303431 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303432}
3433
3434/**
3435 * send_dcc_get_stats_cmd_tlv() - get the DCC channel stats
3436 * @wmi_handle: pointer to the wmi handle
3437 * @get_stats_param: pointer to the dcc stats
3438 *
3439 * Return: 0 on succes
3440 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303441static QDF_STATUS send_dcc_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303442 struct dcc_get_stats_param *get_stats_param)
3443{
Govind Singh67922e82016-04-01 16:48:57 +05303444 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303445 wmi_dcc_get_stats_cmd_fixed_param *cmd;
3446 wmi_dcc_channel_stats_request *channel_stats_array;
3447 wmi_buf_t buf;
3448 uint8_t *buf_ptr;
3449 uint32_t len;
3450 uint32_t i;
3451
3452 /* Validate the input */
3453 if (get_stats_param->request_array_len !=
3454 get_stats_param->channel_count * sizeof(*channel_stats_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303455 WMI_LOGE(FL("Invalid parameter"));
Govind Singh67922e82016-04-01 16:48:57 +05303456 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303457 }
3458
3459 /* Allocate memory for the WMI command */
3460 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
3461 get_stats_param->request_array_len;
3462
3463 buf = wmi_buf_alloc(wmi_handle, len);
3464 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303465 WMI_LOGE(FL("wmi_buf_alloc failed"));
3466 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303467 }
3468
3469 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303470 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303471
3472 /* Populate the WMI command */
3473 cmd = (wmi_dcc_get_stats_cmd_fixed_param *)buf_ptr;
3474 buf_ptr += sizeof(*cmd);
3475
3476 WMITLV_SET_HDR(&cmd->tlv_header,
3477 WMITLV_TAG_STRUC_wmi_dcc_get_stats_cmd_fixed_param,
3478 WMITLV_GET_STRUCT_TLVLEN(
3479 wmi_dcc_get_stats_cmd_fixed_param));
3480 cmd->vdev_id = get_stats_param->vdev_id;
3481 cmd->num_channels = get_stats_param->channel_count;
3482
3483 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3484 get_stats_param->request_array_len);
3485 buf_ptr += WMI_TLV_HDR_SIZE;
3486
3487 channel_stats_array = (wmi_dcc_channel_stats_request *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303488 qdf_mem_copy(channel_stats_array, get_stats_param->request_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303489 get_stats_param->request_array_len);
3490 for (i = 0; i < cmd->num_channels; i++)
3491 WMITLV_SET_HDR(&channel_stats_array[i].tlv_header,
3492 WMITLV_TAG_STRUC_wmi_dcc_channel_stats_request,
3493 WMITLV_GET_STRUCT_TLVLEN(
3494 wmi_dcc_channel_stats_request));
3495
3496 /* Send the WMI command */
3497 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3498 WMI_DCC_GET_STATS_CMDID);
3499
Govind Singh67922e82016-04-01 16:48:57 +05303500 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303501 WMI_LOGE(FL("Failed to send WMI message: %d"), ret);
Govind Singh2edc80f2016-03-01 15:30:53 +05303502 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303503 }
3504
Govind Singh67922e82016-04-01 16:48:57 +05303505 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303506}
3507
3508/**
3509 * send_dcc_clear_stats_cmd_tlv() - command to clear the DCC stats
3510 * @wmi_handle: pointer to the wmi handle
3511 * @vdev_id: vdev id
3512 * @dcc_stats_bitmap: dcc status bitmap
3513 *
3514 * Return: 0 on succes
3515 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303516static QDF_STATUS send_dcc_clear_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303517 uint32_t vdev_id, uint32_t dcc_stats_bitmap)
3518{
Govind Singh67922e82016-04-01 16:48:57 +05303519 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303520 wmi_dcc_clear_stats_cmd_fixed_param *cmd;
3521 wmi_buf_t buf;
3522 uint8_t *buf_ptr;
3523 uint32_t len;
3524
3525 /* Allocate memory for the WMI command */
3526 len = sizeof(*cmd);
3527
3528 buf = wmi_buf_alloc(wmi_handle, len);
3529 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303530 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303531 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303532 }
3533
3534 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303535 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303536
3537 /* Populate the WMI command */
3538 cmd = (wmi_dcc_clear_stats_cmd_fixed_param *)buf_ptr;
3539
3540 WMITLV_SET_HDR(&cmd->tlv_header,
3541 WMITLV_TAG_STRUC_wmi_dcc_clear_stats_cmd_fixed_param,
3542 WMITLV_GET_STRUCT_TLVLEN(
3543 wmi_dcc_clear_stats_cmd_fixed_param));
3544 cmd->vdev_id = vdev_id;
3545 cmd->dcc_stats_bitmap = dcc_stats_bitmap;
3546
3547 /* Send the WMI command */
3548 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3549 WMI_DCC_CLEAR_STATS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303550 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303551 WMI_LOGE(FL("Failed to send the WMI command"));
Govind Singh2edc80f2016-03-01 15:30:53 +05303552 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303553 }
3554
Govind Singh67922e82016-04-01 16:48:57 +05303555 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303556}
3557
3558/**
3559 * send_dcc_update_ndl_cmd_tlv() - command to update the NDL data
3560 * @wmi_handle: pointer to the wmi handle
3561 * @update_ndl_param: pointer to the request parameters
3562 *
3563 * Return: 0 on success
3564 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303565static QDF_STATUS send_dcc_update_ndl_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303566 struct dcc_update_ndl_param *update_ndl_param)
3567{
Govind Singhb53420c2016-03-09 14:32:57 +05303568 QDF_STATUS qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303569 wmi_dcc_update_ndl_cmd_fixed_param *cmd;
3570 wmi_dcc_ndl_chan *ndl_chan_array;
3571 wmi_dcc_ndl_active_state_config *ndl_active_state_array;
3572 uint32_t active_state_count;
3573 wmi_buf_t buf;
3574 uint8_t *buf_ptr;
3575 uint32_t len;
3576 uint32_t i;
3577
3578 /* validate the input */
3579 if (update_ndl_param->dcc_ndl_chan_list_len !=
3580 update_ndl_param->channel_count * sizeof(*ndl_chan_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303581 WMI_LOGE(FL("Invalid parameter"));
3582 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303583 }
3584 active_state_count = 0;
3585 ndl_chan_array = update_ndl_param->dcc_ndl_chan_list;
3586 for (i = 0; i < update_ndl_param->channel_count; i++)
3587 active_state_count +=
3588 WMI_NDL_NUM_ACTIVE_STATE_GET(&ndl_chan_array[i]);
3589 if (update_ndl_param->dcc_ndl_active_state_list_len !=
3590 active_state_count * sizeof(*ndl_active_state_array)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303591 WMI_LOGE(FL("Invalid parameter"));
3592 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303593 }
3594
3595 /* Allocate memory for the WMI command */
3596 len = sizeof(*cmd) +
3597 WMI_TLV_HDR_SIZE + update_ndl_param->dcc_ndl_chan_list_len +
3598 WMI_TLV_HDR_SIZE +
3599 update_ndl_param->dcc_ndl_active_state_list_len;
3600
3601 buf = wmi_buf_alloc(wmi_handle, len);
3602 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303603 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303604 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303605 }
3606
3607 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303608 qdf_mem_zero(buf_ptr, len);
Govind Singh2edc80f2016-03-01 15:30:53 +05303609
3610 /* Populate the WMI command */
3611 cmd = (wmi_dcc_update_ndl_cmd_fixed_param *)buf_ptr;
3612 buf_ptr += sizeof(*cmd);
3613
3614 WMITLV_SET_HDR(&cmd->tlv_header,
3615 WMITLV_TAG_STRUC_wmi_dcc_update_ndl_cmd_fixed_param,
3616 WMITLV_GET_STRUCT_TLVLEN(
3617 wmi_dcc_update_ndl_cmd_fixed_param));
3618 cmd->vdev_id = update_ndl_param->vdev_id;
3619 cmd->num_channel = update_ndl_param->channel_count;
3620
3621 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3622 update_ndl_param->dcc_ndl_chan_list_len);
3623 buf_ptr += WMI_TLV_HDR_SIZE;
3624
3625 ndl_chan_array = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303626 qdf_mem_copy(ndl_chan_array, update_ndl_param->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303627 update_ndl_param->dcc_ndl_chan_list_len);
3628 for (i = 0; i < cmd->num_channel; i++)
3629 WMITLV_SET_HDR(&ndl_chan_array[i].tlv_header,
3630 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3631 WMITLV_GET_STRUCT_TLVLEN(
3632 wmi_dcc_ndl_chan));
3633 buf_ptr += update_ndl_param->dcc_ndl_chan_list_len;
3634
3635 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3636 update_ndl_param->dcc_ndl_active_state_list_len);
3637 buf_ptr += WMI_TLV_HDR_SIZE;
3638
3639 ndl_active_state_array = (wmi_dcc_ndl_active_state_config *) buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303640 qdf_mem_copy(ndl_active_state_array,
Govind Singh2edc80f2016-03-01 15:30:53 +05303641 update_ndl_param->dcc_ndl_active_state_list,
3642 update_ndl_param->dcc_ndl_active_state_list_len);
3643 for (i = 0; i < active_state_count; i++) {
3644 WMITLV_SET_HDR(&ndl_active_state_array[i].tlv_header,
3645 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3646 WMITLV_GET_STRUCT_TLVLEN(
3647 wmi_dcc_ndl_active_state_config));
3648 }
3649 buf_ptr += update_ndl_param->dcc_ndl_active_state_list_len;
3650
3651 /* Send the WMI command */
Govind Singhb53420c2016-03-09 14:32:57 +05303652 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh2edc80f2016-03-01 15:30:53 +05303653 WMI_DCC_UPDATE_NDL_CMDID);
3654 /* If there is an error, set the completion event */
Govind Singh67922e82016-04-01 16:48:57 +05303655 if (QDF_IS_STATUS_ERROR(qdf_status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303656 WMI_LOGE(FL("Failed to send WMI message: %d"), qdf_status);
Govind Singh2edc80f2016-03-01 15:30:53 +05303657 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303658 }
3659
Govind Singh67922e82016-04-01 16:48:57 +05303660 return qdf_status;
Govind Singh2edc80f2016-03-01 15:30:53 +05303661}
3662
3663/**
3664 * send_ocb_set_config_cmd_tlv() - send the OCB config to the FW
3665 * @wmi_handle: pointer to the wmi handle
3666 * @config: the OCB configuration
3667 *
3668 * Return: 0 on success
3669 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303670static QDF_STATUS send_ocb_set_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh2edc80f2016-03-01 15:30:53 +05303671 struct ocb_config_param *config, uint32_t *ch_mhz)
3672{
Govind Singh67922e82016-04-01 16:48:57 +05303673 QDF_STATUS ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303674 wmi_ocb_set_config_cmd_fixed_param *cmd;
3675 wmi_channel *chan;
3676 wmi_ocb_channel *ocb_chan;
3677 wmi_qos_parameter *qos_param;
3678 wmi_dcc_ndl_chan *ndl_chan;
3679 wmi_dcc_ndl_active_state_config *ndl_active_config;
3680 wmi_ocb_schedule_element *sched_elem;
3681 uint8_t *buf_ptr;
3682 wmi_buf_t buf;
3683 int32_t len;
3684 int32_t i, j, active_state_count;
3685
3686 /*
3687 * Validate the dcc_ndl_chan_list_len and count the number of active
3688 * states. Validate dcc_ndl_active_state_list_len.
3689 */
3690 active_state_count = 0;
3691 if (config->dcc_ndl_chan_list_len) {
3692 if (!config->dcc_ndl_chan_list ||
3693 config->dcc_ndl_chan_list_len !=
3694 config->channel_count * sizeof(wmi_dcc_ndl_chan)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303695 WMI_LOGE(FL("NDL channel is invalid. List len: %d"),
Govind Singh2edc80f2016-03-01 15:30:53 +05303696 config->dcc_ndl_chan_list_len);
Govind Singh67922e82016-04-01 16:48:57 +05303697 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303698 }
3699
3700 for (i = 0, ndl_chan = config->dcc_ndl_chan_list;
3701 i < config->channel_count; ++i, ++ndl_chan)
3702 active_state_count +=
3703 WMI_NDL_NUM_ACTIVE_STATE_GET(ndl_chan);
3704
3705 if (active_state_count) {
3706 if (!config->dcc_ndl_active_state_list ||
3707 config->dcc_ndl_active_state_list_len !=
3708 active_state_count *
3709 sizeof(wmi_dcc_ndl_active_state_config)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303710 WMI_LOGE(FL("NDL active state is invalid."));
Govind Singh67922e82016-04-01 16:48:57 +05303711 return QDF_STATUS_E_INVAL;
Govind Singh2edc80f2016-03-01 15:30:53 +05303712 }
3713 }
3714 }
3715
3716 len = sizeof(*cmd) +
3717 WMI_TLV_HDR_SIZE + config->channel_count *
3718 sizeof(wmi_channel) +
3719 WMI_TLV_HDR_SIZE + config->channel_count *
3720 sizeof(wmi_ocb_channel) +
3721 WMI_TLV_HDR_SIZE + config->channel_count *
3722 sizeof(wmi_qos_parameter) * WMI_MAX_NUM_AC +
3723 WMI_TLV_HDR_SIZE + config->dcc_ndl_chan_list_len +
3724 WMI_TLV_HDR_SIZE + active_state_count *
3725 sizeof(wmi_dcc_ndl_active_state_config) +
3726 WMI_TLV_HDR_SIZE + config->schedule_size *
3727 sizeof(wmi_ocb_schedule_element);
3728 buf = wmi_buf_alloc(wmi_handle, len);
3729 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303730 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05303731 return QDF_STATUS_E_NOMEM;
Govind Singh2edc80f2016-03-01 15:30:53 +05303732 }
3733
3734 buf_ptr = (uint8_t *)wmi_buf_data(buf);
3735 cmd = (wmi_ocb_set_config_cmd_fixed_param *)buf_ptr;
3736 WMITLV_SET_HDR(&cmd->tlv_header,
3737 WMITLV_TAG_STRUC_wmi_ocb_set_config_cmd_fixed_param,
3738 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_set_config_cmd_fixed_param));
3739 cmd->vdev_id = config->session_id;
3740 cmd->channel_count = config->channel_count;
3741 cmd->schedule_size = config->schedule_size;
3742 cmd->flags = config->flags;
3743 buf_ptr += sizeof(*cmd);
3744
3745 /* Add the wmi_channel info */
3746 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3747 config->channel_count*sizeof(wmi_channel));
3748 buf_ptr += WMI_TLV_HDR_SIZE;
3749 for (i = 0; i < config->channel_count; i++) {
3750 chan = (wmi_channel *)buf_ptr;
3751 WMITLV_SET_HDR(&chan->tlv_header,
3752 WMITLV_TAG_STRUC_wmi_channel,
3753 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
3754 chan->mhz = config->channels[i].chan_freq;
3755 chan->band_center_freq1 = config->channels[i].chan_freq;
3756 chan->band_center_freq2 = 0;
3757 chan->info = 0;
3758
3759 WMI_SET_CHANNEL_MODE(chan, ch_mhz[i]);
3760 WMI_SET_CHANNEL_MAX_POWER(chan, config->channels[i].max_pwr);
3761 WMI_SET_CHANNEL_MIN_POWER(chan, config->channels[i].min_pwr);
3762 WMI_SET_CHANNEL_MAX_TX_POWER(chan, config->channels[i].max_pwr);
3763 WMI_SET_CHANNEL_REG_POWER(chan, config->channels[i].reg_pwr);
3764 WMI_SET_CHANNEL_ANTENNA_MAX(chan,
3765 config->channels[i].antenna_max);
3766
3767 if (config->channels[i].bandwidth < 10)
3768 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_QUARTER_RATE);
3769 else if (config->channels[i].bandwidth < 20)
3770 WMI_SET_CHANNEL_FLAG(chan, WMI_CHAN_FLAG_HALF_RATE);
3771 buf_ptr += sizeof(*chan);
3772 }
3773
3774 /* Add the wmi_ocb_channel info */
3775 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3776 config->channel_count*sizeof(wmi_ocb_channel));
3777 buf_ptr += WMI_TLV_HDR_SIZE;
3778 for (i = 0; i < config->channel_count; i++) {
3779 ocb_chan = (wmi_ocb_channel *)buf_ptr;
3780 WMITLV_SET_HDR(&ocb_chan->tlv_header,
3781 WMITLV_TAG_STRUC_wmi_ocb_channel,
3782 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_channel));
3783 ocb_chan->bandwidth = config->channels[i].bandwidth;
3784 WMI_CHAR_ARRAY_TO_MAC_ADDR(
3785 config->channels[i].mac_address.bytes,
3786 &ocb_chan->mac_address);
3787 buf_ptr += sizeof(*ocb_chan);
3788 }
3789
3790 /* Add the wmi_qos_parameter info */
3791 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3792 config->channel_count * sizeof(wmi_qos_parameter)*WMI_MAX_NUM_AC);
3793 buf_ptr += WMI_TLV_HDR_SIZE;
3794 /* WMI_MAX_NUM_AC parameters for each channel */
3795 for (i = 0; i < config->channel_count; i++) {
3796 for (j = 0; j < WMI_MAX_NUM_AC; j++) {
3797 qos_param = (wmi_qos_parameter *)buf_ptr;
3798 WMITLV_SET_HDR(&qos_param->tlv_header,
3799 WMITLV_TAG_STRUC_wmi_qos_parameter,
3800 WMITLV_GET_STRUCT_TLVLEN(wmi_qos_parameter));
3801 qos_param->aifsn =
3802 config->channels[i].qos_params[j].aifsn;
3803 qos_param->cwmin =
3804 config->channels[i].qos_params[j].cwmin;
3805 qos_param->cwmax =
3806 config->channels[i].qos_params[j].cwmax;
3807 buf_ptr += sizeof(*qos_param);
3808 }
3809 }
3810
3811 /* Add the wmi_dcc_ndl_chan (per channel) */
3812 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3813 config->dcc_ndl_chan_list_len);
3814 buf_ptr += WMI_TLV_HDR_SIZE;
3815 if (config->dcc_ndl_chan_list_len) {
3816 ndl_chan = (wmi_dcc_ndl_chan *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303817 qdf_mem_copy(ndl_chan, config->dcc_ndl_chan_list,
Govind Singh2edc80f2016-03-01 15:30:53 +05303818 config->dcc_ndl_chan_list_len);
3819 for (i = 0; i < config->channel_count; i++)
3820 WMITLV_SET_HDR(&(ndl_chan[i].tlv_header),
3821 WMITLV_TAG_STRUC_wmi_dcc_ndl_chan,
3822 WMITLV_GET_STRUCT_TLVLEN(wmi_dcc_ndl_chan));
3823 buf_ptr += config->dcc_ndl_chan_list_len;
3824 }
3825
3826 /* Add the wmi_dcc_ndl_active_state_config */
3827 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, active_state_count *
3828 sizeof(wmi_dcc_ndl_active_state_config));
3829 buf_ptr += WMI_TLV_HDR_SIZE;
3830 if (active_state_count) {
3831 ndl_active_config = (wmi_dcc_ndl_active_state_config *)buf_ptr;
Govind Singhb53420c2016-03-09 14:32:57 +05303832 qdf_mem_copy(ndl_active_config,
Govind Singh2edc80f2016-03-01 15:30:53 +05303833 config->dcc_ndl_active_state_list,
3834 active_state_count * sizeof(*ndl_active_config));
3835 for (i = 0; i < active_state_count; ++i)
3836 WMITLV_SET_HDR(&(ndl_active_config[i].tlv_header),
3837 WMITLV_TAG_STRUC_wmi_dcc_ndl_active_state_config,
3838 WMITLV_GET_STRUCT_TLVLEN(
3839 wmi_dcc_ndl_active_state_config));
3840 buf_ptr += active_state_count *
3841 sizeof(*ndl_active_config);
3842 }
3843
3844 /* Add the wmi_ocb_schedule_element info */
3845 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
3846 config->schedule_size * sizeof(wmi_ocb_schedule_element));
3847 buf_ptr += WMI_TLV_HDR_SIZE;
3848 for (i = 0; i < config->schedule_size; i++) {
3849 sched_elem = (wmi_ocb_schedule_element *)buf_ptr;
3850 WMITLV_SET_HDR(&sched_elem->tlv_header,
3851 WMITLV_TAG_STRUC_wmi_ocb_schedule_element,
3852 WMITLV_GET_STRUCT_TLVLEN(wmi_ocb_schedule_element));
3853 sched_elem->channel_freq = config->schedule[i].chan_freq;
3854 sched_elem->total_duration = config->schedule[i].total_duration;
3855 sched_elem->guard_interval = config->schedule[i].guard_interval;
3856 buf_ptr += sizeof(*sched_elem);
3857 }
3858
3859
3860 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3861 WMI_OCB_SET_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303862 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303863 WMI_LOGE("Failed to set OCB config");
Govind Singh2edc80f2016-03-01 15:30:53 +05303864 wmi_buf_free(buf);
Govind Singh2edc80f2016-03-01 15:30:53 +05303865 }
3866
Govind Singh67922e82016-04-01 16:48:57 +05303867 return ret;
Govind Singh2edc80f2016-03-01 15:30:53 +05303868}
Govind Singh17a9cfa2016-03-01 15:54:59 +05303869
3870/**
3871 * send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv() -enable/disable mcc scheduler
3872 * @wmi_handle: wmi handle
3873 * @mcc_adaptive_scheduler: enable/disable
3874 *
3875 * This function enable/disable mcc adaptive scheduler in fw.
3876 *
Govind Singhb53420c2016-03-09 14:32:57 +05303877 * Return: QDF_STATUS_SUCCESS for sucess or error code
Govind Singh17a9cfa2016-03-01 15:54:59 +05303878 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303879static QDF_STATUS send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv(
Govind Singh4df47142016-04-16 19:24:23 -07003880 wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler,
3881 uint32_t pdev_id)
Govind Singh17a9cfa2016-03-01 15:54:59 +05303882{
Govind Singh67922e82016-04-01 16:48:57 +05303883 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303884 wmi_buf_t buf = 0;
3885 wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *cmd = NULL;
3886 uint16_t len =
3887 sizeof(wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param);
3888
3889 buf = wmi_buf_alloc(wmi_handle, len);
3890 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303891 WMI_LOGP("%s : wmi_buf_alloc failed", __func__);
3892 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303893 }
3894 cmd = (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param *)
3895 wmi_buf_data(buf);
3896
3897 WMITLV_SET_HDR(&cmd->tlv_header,
3898 WMITLV_TAG_STRUC_wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param,
3899 WMITLV_GET_STRUCT_TLVLEN
3900 (wmi_resmgr_adaptive_ocs_enable_disable_cmd_fixed_param));
3901 cmd->enable = mcc_adaptive_scheduler;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05303902 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303903
3904 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3905 WMI_RESMGR_ADAPTIVE_OCS_ENABLE_DISABLE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303906 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303907 WMI_LOGP("%s: Failed to send enable/disable MCC"
Govind Singh17a9cfa2016-03-01 15:54:59 +05303908 " adaptive scheduler command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303909 wmi_buf_free(buf);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303910 }
Govind Singh67922e82016-04-01 16:48:57 +05303911
3912 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303913}
3914
3915/**
3916 * send_set_mcc_channel_time_latency_cmd_tlv() -set MCC channel time latency
3917 * @wmi: wmi handle
3918 * @mcc_channel: mcc channel
3919 * @mcc_channel_time_latency: MCC channel time latency.
3920 *
3921 * Currently used to set time latency for an MCC vdev/adapter using operating
3922 * channel of it and channel number. The info is provided run time using
3923 * iwpriv command: iwpriv <wlan0 | p2p0> setMccLatency <latency in ms>.
3924 *
3925 * Return: CDF status
3926 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303927static QDF_STATUS send_set_mcc_channel_time_latency_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05303928 uint32_t mcc_channel_freq, uint32_t mcc_channel_time_latency)
3929{
Govind Singh67922e82016-04-01 16:48:57 +05303930 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303931 wmi_buf_t buf = 0;
3932 wmi_resmgr_set_chan_latency_cmd_fixed_param *cmdTL = NULL;
3933 uint16_t len = 0;
3934 uint8_t *buf_ptr = NULL;
3935 wmi_resmgr_chan_latency chan_latency;
3936 /* Note: we only support MCC time latency for a single channel */
3937 uint32_t num_channels = 1;
3938 uint32_t chan1_freq = mcc_channel_freq;
3939 uint32_t latency_chan1 = mcc_channel_time_latency;
3940
3941
3942 /* If 0ms latency is provided, then FW will set to a default.
3943 * Otherwise, latency must be at least 30ms.
3944 */
3945 if ((latency_chan1 > 0) &&
3946 (latency_chan1 < WMI_MCC_MIN_NON_ZERO_CHANNEL_LATENCY)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303947 WMI_LOGE("%s: Invalid time latency for Channel #1 = %dms "
Govind Singh17a9cfa2016-03-01 15:54:59 +05303948 "Minimum is 30ms (or 0 to use default value by "
3949 "firmware)", __func__, latency_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05303950 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303951 }
3952
3953 /* Set WMI CMD for channel time latency here */
3954 len = sizeof(wmi_resmgr_set_chan_latency_cmd_fixed_param) +
3955 WMI_TLV_HDR_SIZE + /*Place holder for chan_time_latency array */
3956 num_channels * sizeof(wmi_resmgr_chan_latency);
3957 buf = wmi_buf_alloc(wmi_handle, len);
3958 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05303959 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
3960 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303961 }
3962 buf_ptr = (uint8_t *) wmi_buf_data(buf);
3963 cmdTL = (wmi_resmgr_set_chan_latency_cmd_fixed_param *)
3964 wmi_buf_data(buf);
3965 WMITLV_SET_HDR(&cmdTL->tlv_header,
3966 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_latency_cmd_fixed_param,
3967 WMITLV_GET_STRUCT_TLVLEN
3968 (wmi_resmgr_set_chan_latency_cmd_fixed_param));
3969 cmdTL->num_chans = num_channels;
3970 /* Update channel time latency information for home channel(s) */
3971 buf_ptr += sizeof(*cmdTL);
3972 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
3973 num_channels * sizeof(wmi_resmgr_chan_latency));
3974 buf_ptr += WMI_TLV_HDR_SIZE;
3975 chan_latency.chan_mhz = chan1_freq;
3976 chan_latency.latency = latency_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05303977 qdf_mem_copy(buf_ptr, &chan_latency, sizeof(chan_latency));
Govind Singh17a9cfa2016-03-01 15:54:59 +05303978 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
3979 WMI_RESMGR_SET_CHAN_LATENCY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05303980 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05303981 WMI_LOGE("%s: Failed to send MCC Channel Time Latency command",
Govind Singh17a9cfa2016-03-01 15:54:59 +05303982 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05303983 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05303984 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05303985 }
Govind Singh67922e82016-04-01 16:48:57 +05303986
3987 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05303988}
3989
3990/**
3991 * send_set_mcc_channel_time_quota_cmd_tlv() -set MCC channel time quota
3992 * @wmi: wmi handle
3993 * @adapter_1_chan_number: adapter 1 channel number
3994 * @adapter_1_quota: adapter 1 quota
3995 * @adapter_2_chan_number: adapter 2 channel number
3996 *
3997 * Return: CDF status
3998 */
Sathish Kumarfd347372017-02-13 12:29:09 +05303999static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304000 uint32_t adapter_1_chan_freq,
4001 uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq)
4002{
Govind Singh67922e82016-04-01 16:48:57 +05304003 QDF_STATUS ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304004 wmi_buf_t buf = 0;
4005 uint16_t len = 0;
4006 uint8_t *buf_ptr = NULL;
4007 wmi_resmgr_set_chan_time_quota_cmd_fixed_param *cmdTQ = NULL;
4008 wmi_resmgr_chan_time_quota chan_quota;
4009 uint32_t quota_chan1 = adapter_1_quota;
4010 /* Knowing quota of 1st chan., derive quota for 2nd chan. */
4011 uint32_t quota_chan2 = 100 - quota_chan1;
4012 /* Note: setting time quota for MCC requires info for 2 channels */
4013 uint32_t num_channels = 2;
4014 uint32_t chan1_freq = adapter_1_chan_freq;
4015 uint32_t chan2_freq = adapter_2_chan_freq;
4016
Govind Singhb53420c2016-03-09 14:32:57 +05304017 WMI_LOGD("%s: freq1:%dMHz, Quota1:%dms, "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304018 "freq2:%dMHz, Quota2:%dms", __func__,
4019 chan1_freq, quota_chan1, chan2_freq,
4020 quota_chan2);
4021
4022 /*
4023 * Perform sanity check on time quota values provided.
4024 */
4025 if (quota_chan1 < WMI_MCC_MIN_CHANNEL_QUOTA ||
4026 quota_chan1 > WMI_MCC_MAX_CHANNEL_QUOTA) {
Govind Singhb53420c2016-03-09 14:32:57 +05304027 WMI_LOGE("%s: Invalid time quota for Channel #1=%dms. Minimum "
Govind Singh17a9cfa2016-03-01 15:54:59 +05304028 "is 20ms & maximum is 80ms", __func__, quota_chan1);
Govind Singhb53420c2016-03-09 14:32:57 +05304029 return QDF_STATUS_E_INVAL;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304030 }
4031 /* Set WMI CMD for channel time quota here */
4032 len = sizeof(wmi_resmgr_set_chan_time_quota_cmd_fixed_param) +
4033 WMI_TLV_HDR_SIZE + /* Place holder for chan_time_quota array */
4034 num_channels * sizeof(wmi_resmgr_chan_time_quota);
4035 buf = wmi_buf_alloc(wmi_handle, len);
4036 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304037 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
4038 QDF_ASSERT(0);
4039 return QDF_STATUS_E_NOMEM;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304040 }
4041 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4042 cmdTQ = (wmi_resmgr_set_chan_time_quota_cmd_fixed_param *)
4043 wmi_buf_data(buf);
4044 WMITLV_SET_HDR(&cmdTQ->tlv_header,
4045 WMITLV_TAG_STRUC_wmi_resmgr_set_chan_time_quota_cmd_fixed_param,
4046 WMITLV_GET_STRUCT_TLVLEN
4047 (wmi_resmgr_set_chan_time_quota_cmd_fixed_param));
4048 cmdTQ->num_chans = num_channels;
4049
4050 /* Update channel time quota information for home channel(s) */
4051 buf_ptr += sizeof(*cmdTQ);
4052 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4053 num_channels * sizeof(wmi_resmgr_chan_time_quota));
4054 buf_ptr += WMI_TLV_HDR_SIZE;
4055 chan_quota.chan_mhz = chan1_freq;
4056 chan_quota.channel_time_quota = quota_chan1;
Govind Singhb53420c2016-03-09 14:32:57 +05304057 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304058 /* Construct channel and quota record for the 2nd MCC mode. */
4059 buf_ptr += sizeof(chan_quota);
4060 chan_quota.chan_mhz = chan2_freq;
4061 chan_quota.channel_time_quota = quota_chan2;
Govind Singhb53420c2016-03-09 14:32:57 +05304062 qdf_mem_copy(buf_ptr, &chan_quota, sizeof(chan_quota));
Govind Singh17a9cfa2016-03-01 15:54:59 +05304063
4064 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4065 WMI_RESMGR_SET_CHAN_TIME_QUOTA_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304066 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304067 WMI_LOGE("Failed to send MCC Channel Time Quota command");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304068 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304069 QDF_ASSERT(0);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304070 }
Govind Singh67922e82016-04-01 16:48:57 +05304071
4072 return ret;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304073}
4074
4075/**
4076 * send_set_thermal_mgmt_cmd_tlv() - set thermal mgmt command to fw
4077 * @wmi_handle: Pointer to wmi handle
4078 * @thermal_info: Thermal command information
4079 *
4080 * This function sends the thermal management command
4081 * to the firmware
4082 *
Govind Singhb53420c2016-03-09 14:32:57 +05304083 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304084 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304085static QDF_STATUS send_set_thermal_mgmt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304086 struct thermal_cmd_params *thermal_info)
4087{
4088 wmi_thermal_mgmt_cmd_fixed_param *cmd = NULL;
4089 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05304090 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304091 uint32_t len = 0;
4092
4093 len = sizeof(*cmd);
4094
4095 buf = wmi_buf_alloc(wmi_handle, len);
4096 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304097 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4098 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304099 }
4100
4101 cmd = (wmi_thermal_mgmt_cmd_fixed_param *) wmi_buf_data(buf);
4102
4103 WMITLV_SET_HDR(&cmd->tlv_header,
4104 WMITLV_TAG_STRUC_wmi_thermal_mgmt_cmd_fixed_param,
4105 WMITLV_GET_STRUCT_TLVLEN
4106 (wmi_thermal_mgmt_cmd_fixed_param));
4107
4108 cmd->lower_thresh_degreeC = thermal_info->min_temp;
4109 cmd->upper_thresh_degreeC = thermal_info->max_temp;
4110 cmd->enable = thermal_info->thermal_enable;
4111
Govind Singhb53420c2016-03-09 14:32:57 +05304112 WMI_LOGE("TM Sending thermal mgmt cmd: low temp %d, upper temp %d, enabled %d",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304113 cmd->lower_thresh_degreeC, cmd->upper_thresh_degreeC, cmd->enable);
4114
4115 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4116 WMI_THERMAL_MGMT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304117 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304118 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304119 WMI_LOGE("%s:Failed to send thermal mgmt command", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304120 }
4121
Govind Singh67922e82016-04-01 16:48:57 +05304122 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304123}
4124
4125
4126/**
4127 * send_lro_config_cmd_tlv() - process the LRO config command
Govind Singhb53420c2016-03-09 14:32:57 +05304128 * @wmi_handle: Pointer to WMI handle
Govind Singh17a9cfa2016-03-01 15:54:59 +05304129 * @wmi_lro_cmd: Pointer to LRO configuration parameters
4130 *
4131 * This function sends down the LRO configuration parameters to
4132 * the firmware to enable LRO, sets the TCP flags and sets the
4133 * seed values for the toeplitz hash generation
4134 *
Govind Singhb53420c2016-03-09 14:32:57 +05304135 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh17a9cfa2016-03-01 15:54:59 +05304136 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304137static QDF_STATUS send_lro_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh17a9cfa2016-03-01 15:54:59 +05304138 struct wmi_lro_config_cmd_t *wmi_lro_cmd)
4139{
4140 wmi_lro_info_cmd_fixed_param *cmd;
4141 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304142 QDF_STATUS status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304143
4144
4145 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4146 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304147 WMI_LOGE("Failed to allocate buffer to send set key cmd");
4148 return QDF_STATUS_E_FAILURE;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304149 }
4150
4151 cmd = (wmi_lro_info_cmd_fixed_param *) wmi_buf_data(buf);
4152
4153 WMITLV_SET_HDR(&cmd->tlv_header,
4154 WMITLV_TAG_STRUC_wmi_lro_info_cmd_fixed_param,
4155 WMITLV_GET_STRUCT_TLVLEN(wmi_lro_info_cmd_fixed_param));
4156
4157 cmd->lro_enable = wmi_lro_cmd->lro_enable;
4158 WMI_LRO_INFO_TCP_FLAG_VALS_SET(cmd->tcp_flag_u32,
4159 wmi_lro_cmd->tcp_flag);
4160 WMI_LRO_INFO_TCP_FLAGS_MASK_SET(cmd->tcp_flag_u32,
4161 wmi_lro_cmd->tcp_flag_mask);
4162 cmd->toeplitz_hash_ipv4_0_3 =
4163 wmi_lro_cmd->toeplitz_hash_ipv4[0];
4164 cmd->toeplitz_hash_ipv4_4_7 =
4165 wmi_lro_cmd->toeplitz_hash_ipv4[1];
4166 cmd->toeplitz_hash_ipv4_8_11 =
4167 wmi_lro_cmd->toeplitz_hash_ipv4[2];
4168 cmd->toeplitz_hash_ipv4_12_15 =
4169 wmi_lro_cmd->toeplitz_hash_ipv4[3];
4170 cmd->toeplitz_hash_ipv4_16 =
4171 wmi_lro_cmd->toeplitz_hash_ipv4[4];
4172
4173 cmd->toeplitz_hash_ipv6_0_3 =
4174 wmi_lro_cmd->toeplitz_hash_ipv6[0];
4175 cmd->toeplitz_hash_ipv6_4_7 =
4176 wmi_lro_cmd->toeplitz_hash_ipv6[1];
4177 cmd->toeplitz_hash_ipv6_8_11 =
4178 wmi_lro_cmd->toeplitz_hash_ipv6[2];
4179 cmd->toeplitz_hash_ipv6_12_15 =
4180 wmi_lro_cmd->toeplitz_hash_ipv6[3];
4181 cmd->toeplitz_hash_ipv6_16_19 =
4182 wmi_lro_cmd->toeplitz_hash_ipv6[4];
4183 cmd->toeplitz_hash_ipv6_20_23 =
4184 wmi_lro_cmd->toeplitz_hash_ipv6[5];
4185 cmd->toeplitz_hash_ipv6_24_27 =
4186 wmi_lro_cmd->toeplitz_hash_ipv6[6];
4187 cmd->toeplitz_hash_ipv6_28_31 =
4188 wmi_lro_cmd->toeplitz_hash_ipv6[7];
4189 cmd->toeplitz_hash_ipv6_32_35 =
4190 wmi_lro_cmd->toeplitz_hash_ipv6[8];
4191 cmd->toeplitz_hash_ipv6_36_39 =
4192 wmi_lro_cmd->toeplitz_hash_ipv6[9];
4193 cmd->toeplitz_hash_ipv6_40 =
4194 wmi_lro_cmd->toeplitz_hash_ipv6[10];
4195
Govind Singhb53420c2016-03-09 14:32:57 +05304196 WMI_LOGD("WMI_LRO_CONFIG: lro_enable %d, tcp_flag 0x%x",
Govind Singh17a9cfa2016-03-01 15:54:59 +05304197 cmd->lro_enable, cmd->tcp_flag_u32);
4198
4199 status = wmi_unified_cmd_send(wmi_handle, buf,
4200 sizeof(*cmd), WMI_LRO_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304201 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304202 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304203 WMI_LOGE("%s:Failed to send WMI_LRO_CONFIG_CMDID", __func__);
Govind Singh17a9cfa2016-03-01 15:54:59 +05304204 }
4205
Govind Singh67922e82016-04-01 16:48:57 +05304206 return status;
Govind Singh17a9cfa2016-03-01 15:54:59 +05304207}
4208
Govind Singh4eacd2b2016-03-07 14:24:22 +05304209/**
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304210 * send_peer_rate_report_cmd_tlv() - process the peer rate report command
4211 * @wmi_handle: Pointer to wmi handle
4212 * @rate_report_params: Pointer to peer rate report parameters
4213 *
4214 *
4215 * Return: QDF_STATUS_SUCCESS for success otherwise failure
4216 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304217static QDF_STATUS send_peer_rate_report_cmd_tlv(wmi_unified_t wmi_handle,
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304218 struct wmi_peer_rate_report_params *rate_report_params)
4219{
4220 wmi_peer_set_rate_report_condition_fixed_param *cmd = NULL;
4221 wmi_buf_t buf = NULL;
4222 QDF_STATUS status = 0;
4223 uint32_t len = 0;
4224 uint32_t i, j;
4225
4226 len = sizeof(*cmd);
4227
4228 buf = wmi_buf_alloc(wmi_handle, len);
4229 if (!buf) {
4230 WMI_LOGE("Failed to alloc buf to peer_set_condition cmd\n");
4231 return QDF_STATUS_E_FAILURE;
4232 }
4233
4234 cmd = (wmi_peer_set_rate_report_condition_fixed_param *)
4235 wmi_buf_data(buf);
4236
4237 WMITLV_SET_HDR(
4238 &cmd->tlv_header,
4239 WMITLV_TAG_STRUC_wmi_peer_set_rate_report_condition_fixed_param,
4240 WMITLV_GET_STRUCT_TLVLEN(
4241 wmi_peer_set_rate_report_condition_fixed_param));
4242
4243 cmd->enable_rate_report = rate_report_params->rate_report_enable;
4244 cmd->report_backoff_time = rate_report_params->backoff_time;
4245 cmd->report_timer_period = rate_report_params->timer_period;
4246 for (i = 0; i < PEER_RATE_REPORT_COND_MAX_NUM; i++) {
4247 cmd->cond_per_phy[i].val_cond_flags =
4248 rate_report_params->report_per_phy[i].cond_flags;
4249 cmd->cond_per_phy[i].rate_delta.min_delta =
4250 rate_report_params->report_per_phy[i].delta.delta_min;
4251 cmd->cond_per_phy[i].rate_delta.percentage =
4252 rate_report_params->report_per_phy[i].delta.percent;
4253 for (j = 0; j < MAX_NUM_OF_RATE_THRESH; j++) {
4254 cmd->cond_per_phy[i].rate_threshold[j] =
4255 rate_report_params->report_per_phy[i].
4256 report_rate_threshold[j];
4257 }
4258 }
4259
4260 WMI_LOGE("%s enable %d backoff_time %d period %d\n", __func__,
4261 cmd->enable_rate_report,
4262 cmd->report_backoff_time, cmd->report_timer_period);
4263
4264 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4265 WMI_PEER_SET_RATE_REPORT_CONDITION_CMDID);
4266 if (QDF_IS_STATUS_ERROR(status)) {
Abhishek Singh716c46c2016-05-04 16:24:07 +05304267 wmi_buf_free(buf);
Poddar, Siddarth98281c42016-04-28 15:49:11 +05304268 WMI_LOGE("%s:Failed to send peer_set_report_cond command",
4269 __func__);
4270 }
4271 return status;
4272}
4273
4274/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05304275 * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
4276 * @wmi_handle: wmi handle
4277 * @param: bcn ll cmd parameter
4278 *
Govind Singhb53420c2016-03-09 14:32:57 +05304279 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304280 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304281static QDF_STATUS send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304282 wmi_bcn_send_from_host_cmd_fixed_param *param)
4283{
4284 wmi_bcn_send_from_host_cmd_fixed_param *cmd;
4285 wmi_buf_t wmi_buf;
Govind Singhb53420c2016-03-09 14:32:57 +05304286 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304287
4288 wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
4289 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304290 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4291 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304292 }
4293
4294 cmd = (wmi_bcn_send_from_host_cmd_fixed_param *) wmi_buf_data(wmi_buf);
4295 WMITLV_SET_HDR(&cmd->tlv_header,
4296 WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
4297 WMITLV_GET_STRUCT_TLVLEN
4298 (wmi_bcn_send_from_host_cmd_fixed_param));
4299 cmd->vdev_id = param->vdev_id;
4300 cmd->data_len = param->data_len;
4301 cmd->frame_ctrl = param->frame_ctrl;
4302 cmd->frag_ptr = param->frag_ptr;
4303 cmd->dtim_flag = param->dtim_flag;
4304
4305 ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
4306 WMI_PDEV_SEND_BCN_CMDID);
4307
Govind Singh67922e82016-04-01 16:48:57 +05304308 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304309 WMI_LOGE("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
Govind Singh4eacd2b2016-03-07 14:24:22 +05304310 wmi_buf_free(wmi_buf);
4311 }
4312
4313 return ret;
4314}
4315
4316/**
4317 * send_set_sta_sa_query_param_cmd_tlv() - set sta sa query parameters
4318 * @wmi_handle: wmi handle
4319 * @vdev_id: vdev id
4320 * @max_retries: max retries
4321 * @retry_interval: retry interval
4322 * This function sets sta query related parameters in fw.
4323 *
Govind Singhb53420c2016-03-09 14:32:57 +05304324 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh4eacd2b2016-03-07 14:24:22 +05304325 */
4326
Sathish Kumarfd347372017-02-13 12:29:09 +05304327static QDF_STATUS send_set_sta_sa_query_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304328 uint8_t vdev_id, uint32_t max_retries,
4329 uint32_t retry_interval)
4330{
4331 wmi_buf_t buf;
4332 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *cmd;
4333 int len;
4334
4335 len = sizeof(*cmd);
4336 buf = wmi_buf_alloc(wmi_handle, len);
4337 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304338 WMI_LOGE(FL("wmi_buf_alloc failed"));
4339 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304340 }
4341
4342 cmd = (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param *)wmi_buf_data(buf);
4343 WMITLV_SET_HDR(&cmd->tlv_header,
4344 WMITLV_TAG_STRUC_WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param,
4345 WMITLV_GET_STRUCT_TLVLEN
4346 (WMI_PMF_OFFLOAD_SET_SA_QUERY_CMD_fixed_param));
4347
4348
4349 cmd->vdev_id = vdev_id;
4350 cmd->sa_query_max_retry_count = max_retries;
4351 cmd->sa_query_retry_interval = retry_interval;
4352
Govind Singhb53420c2016-03-09 14:32:57 +05304353 WMI_LOGD(FL("STA sa query: vdev_id:%d interval:%u retry count:%d"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304354 vdev_id, retry_interval, max_retries);
4355
4356 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4357 WMI_PMF_OFFLOAD_SET_SA_QUERY_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304358 WMI_LOGE(FL("Failed to offload STA SA Query"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05304359 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304360 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304361 }
4362
Govind Singhb53420c2016-03-09 14:32:57 +05304363 WMI_LOGD(FL("Exit :"));
Govind Singh4eacd2b2016-03-07 14:24:22 +05304364 return 0;
4365}
4366
4367/**
4368 * send_set_sta_keep_alive_cmd_tlv() - set sta keep alive parameters
4369 * @wmi_handle: wmi handle
4370 * @params: sta keep alive parameter
4371 *
4372 * This function sets keep alive related parameters in fw.
4373 *
4374 * Return: CDF status
4375 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304376static QDF_STATUS send_set_sta_keep_alive_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304377 struct sta_params *params)
4378{
4379 wmi_buf_t buf;
4380 WMI_STA_KEEPALIVE_CMD_fixed_param *cmd;
4381 WMI_STA_KEEPALVE_ARP_RESPONSE *arp_rsp;
4382 uint8_t *buf_ptr;
4383 int len;
Govind Singh67922e82016-04-01 16:48:57 +05304384 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304385
Govind Singhb53420c2016-03-09 14:32:57 +05304386 WMI_LOGD("%s: Enter", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304387
Govind Singh4eacd2b2016-03-07 14:24:22 +05304388 len = sizeof(*cmd) + sizeof(*arp_rsp);
4389 buf = wmi_buf_alloc(wmi_handle, len);
4390 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304391 WMI_LOGE("wmi_buf_alloc failed");
4392 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304393 }
4394
4395 cmd = (WMI_STA_KEEPALIVE_CMD_fixed_param *) wmi_buf_data(buf);
4396 buf_ptr = (uint8_t *) cmd;
4397 WMITLV_SET_HDR(&cmd->tlv_header,
4398 WMITLV_TAG_STRUC_WMI_STA_KEEPALIVE_CMD_fixed_param,
4399 WMITLV_GET_STRUCT_TLVLEN
4400 (WMI_STA_KEEPALIVE_CMD_fixed_param));
4401 cmd->interval = params->timeperiod;
4402 cmd->enable = (params->timeperiod) ? 1 : 0;
4403 cmd->vdev_id = params->vdev_id;
Govind Singhb53420c2016-03-09 14:32:57 +05304404 WMI_LOGD("Keep Alive: vdev_id:%d interval:%u method:%d", params->vdev_id,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304405 params->timeperiod, params->method);
4406 arp_rsp = (WMI_STA_KEEPALVE_ARP_RESPONSE *) (buf_ptr + sizeof(*cmd));
4407 WMITLV_SET_HDR(&arp_rsp->tlv_header,
4408 WMITLV_TAG_STRUC_WMI_STA_KEEPALVE_ARP_RESPONSE,
4409 WMITLV_GET_STRUCT_TLVLEN(WMI_STA_KEEPALVE_ARP_RESPONSE));
4410
4411 if (params->method == WMI_KEEP_ALIVE_UNSOLICIT_ARP_RSP) {
4412 if ((NULL == params->hostv4addr) ||
4413 (NULL == params->destv4addr) ||
4414 (NULL == params->destmac)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304415 WMI_LOGE("%s: received null pointer, hostv4addr:%p "
Govind Singh4eacd2b2016-03-07 14:24:22 +05304416 "destv4addr:%p destmac:%p ", __func__,
4417 params->hostv4addr, params->destv4addr, params->destmac);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304418 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304419 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304420 }
4421 cmd->method = WMI_STA_KEEPALIVE_METHOD_UNSOLICITED_ARP_RESPONSE;
Govind Singhb53420c2016-03-09 14:32:57 +05304422 qdf_mem_copy(&arp_rsp->sender_prot_addr, params->hostv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304423 WMI_IPV4_ADDR_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05304424 qdf_mem_copy(&arp_rsp->target_prot_addr, params->destv4addr,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304425 WMI_IPV4_ADDR_LEN);
4426 WMI_CHAR_ARRAY_TO_MAC_ADDR(params->destmac, &arp_rsp->dest_mac_addr);
4427 } else {
4428 cmd->method = WMI_STA_KEEPALIVE_METHOD_NULL_FRAME;
4429 }
4430
Govind Singh67922e82016-04-01 16:48:57 +05304431 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
4432 WMI_STA_KEEPALIVE_CMDID);
4433 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304434 WMI_LOGE("Failed to set KeepAlive");
Abhishek Singh716c46c2016-05-04 16:24:07 +05304435 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304436 }
4437
Govind Singhb53420c2016-03-09 14:32:57 +05304438 WMI_LOGD("%s: Exit", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304439 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304440}
4441
4442/**
4443 * send_vdev_set_gtx_cfg_cmd_tlv() - set GTX params
4444 * @wmi_handle: wmi handle
4445 * @if_id: vdev id
4446 * @gtx_info: GTX config params
4447 *
4448 * This function set GTX related params in firmware.
4449 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304450 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304451 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304452static 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 +05304453 struct wmi_gtx_config *gtx_info)
4454{
4455 wmi_vdev_set_gtx_params_cmd_fixed_param *cmd;
4456 wmi_buf_t buf;
Abhishek Singh716c46c2016-05-04 16:24:07 +05304457 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304458 int len = sizeof(wmi_vdev_set_gtx_params_cmd_fixed_param);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304459
Govind Singh4eacd2b2016-03-07 14:24:22 +05304460 buf = wmi_buf_alloc(wmi_handle, len);
4461 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304462 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304463 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304464 }
4465 cmd = (wmi_vdev_set_gtx_params_cmd_fixed_param *) wmi_buf_data(buf);
4466 WMITLV_SET_HDR(&cmd->tlv_header,
4467 WMITLV_TAG_STRUC_wmi_vdev_set_gtx_params_cmd_fixed_param,
4468 WMITLV_GET_STRUCT_TLVLEN
4469 (wmi_vdev_set_gtx_params_cmd_fixed_param));
4470 cmd->vdev_id = if_id;
4471
4472 cmd->gtxRTMask[0] = gtx_info->gtx_rt_mask[0];
4473 cmd->gtxRTMask[1] = gtx_info->gtx_rt_mask[1];
4474 cmd->userGtxMask = gtx_info->gtx_usrcfg;
4475 cmd->gtxPERThreshold = gtx_info->gtx_threshold;
4476 cmd->gtxPERMargin = gtx_info->gtx_margin;
4477 cmd->gtxTPCstep = gtx_info->gtx_tpcstep;
4478 cmd->gtxTPCMin = gtx_info->gtx_tpcmin;
4479 cmd->gtxBWMask = gtx_info->gtx_bwmask;
4480
Govind Singhb53420c2016-03-09 14:32:57 +05304481 WMI_LOGD("Setting vdev%d GTX values:htmcs 0x%x, vhtmcs 0x%x, usermask 0x%x, \
Govind Singh4eacd2b2016-03-07 14:24:22 +05304482 gtxPERThreshold %d, gtxPERMargin %d, gtxTPCstep %d, gtxTPCMin %d, \
4483 gtxBWMask 0x%x.", if_id, cmd->gtxRTMask[0], cmd->gtxRTMask[1],
4484 cmd->userGtxMask, cmd->gtxPERThreshold, cmd->gtxPERMargin,
4485 cmd->gtxTPCstep, cmd->gtxTPCMin, cmd->gtxBWMask);
4486
Abhishek Singh716c46c2016-05-04 16:24:07 +05304487 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304488 WMI_VDEV_SET_GTX_PARAMS_CMDID);
Abhishek Singh716c46c2016-05-04 16:24:07 +05304489 if (QDF_IS_STATUS_ERROR(ret)) {
4490 WMI_LOGE("Failed to set GTX PARAMS");
4491 wmi_buf_free(buf);
4492 }
4493 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304494}
4495
4496/**
4497 * send_process_update_edca_param_cmd_tlv() - update EDCA params
4498 * @wmi_handle: wmi handle
4499 * @edca_params: edca parameters
4500 *
4501 * This function updates EDCA parameters to the target
4502 *
4503 * Return: CDF Status
4504 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304505static QDF_STATUS send_process_update_edca_param_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304506 uint8_t vdev_id,
4507 wmi_wmm_vparams gwmm_param[WMI_MAX_NUM_AC])
4508{
4509 uint8_t *buf_ptr;
4510 wmi_buf_t buf;
4511 wmi_vdev_set_wmm_params_cmd_fixed_param *cmd;
4512 wmi_wmm_vparams *wmm_param, *twmm_param;
4513 int len = sizeof(*cmd);
4514 int ac;
4515
4516 buf = wmi_buf_alloc(wmi_handle, len);
4517
4518 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304519 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
4520 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304521 }
4522
4523 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4524 cmd = (wmi_vdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
4525 WMITLV_SET_HDR(&cmd->tlv_header,
4526 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4527 WMITLV_GET_STRUCT_TLVLEN
4528 (wmi_vdev_set_wmm_params_cmd_fixed_param));
4529 cmd->vdev_id = vdev_id;
4530
4531 for (ac = 0; ac < WMI_MAX_NUM_AC; ac++) {
4532 wmm_param = (wmi_wmm_vparams *) (&cmd->wmm_params[ac]);
4533 twmm_param = (wmi_wmm_vparams *) (&gwmm_param[ac]);
4534 WMITLV_SET_HDR(&wmm_param->tlv_header,
4535 WMITLV_TAG_STRUC_wmi_vdev_set_wmm_params_cmd_fixed_param,
4536 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_vparams));
4537 wmm_param->cwmin = twmm_param->cwmin;
4538 wmm_param->cwmax = twmm_param->cwmax;
4539 wmm_param->aifs = twmm_param->aifs;
4540 wmm_param->txoplimit = twmm_param->txoplimit;
4541 wmm_param->acm = twmm_param->acm;
4542 wmm_param->no_ack = twmm_param->no_ack;
4543 }
4544
4545 if (wmi_unified_cmd_send(wmi_handle, buf, len,
4546 WMI_VDEV_SET_WMM_PARAMS_CMDID))
4547 goto fail;
4548
Govind Singhb53420c2016-03-09 14:32:57 +05304549 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304550
4551fail:
4552 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05304553 WMI_LOGE("%s: Failed to set WMM Paremeters", __func__);
4554 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304555}
4556
4557/**
4558 * send_probe_rsp_tmpl_send_cmd_tlv() - send probe response template to fw
4559 * @wmi_handle: wmi handle
4560 * @vdev_id: vdev id
4561 * @probe_rsp_info: probe response info
4562 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304563 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304564 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304565static QDF_STATUS send_probe_rsp_tmpl_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304566 uint8_t vdev_id,
4567 struct wmi_probe_resp_params *probe_rsp_info,
4568 uint8_t *frm)
4569{
4570 wmi_prb_tmpl_cmd_fixed_param *cmd;
4571 wmi_bcn_prb_info *bcn_prb_info;
4572 wmi_buf_t wmi_buf;
4573 uint32_t tmpl_len, tmpl_len_aligned, wmi_buf_len;
4574 uint8_t *buf_ptr;
Govind Singh67922e82016-04-01 16:48:57 +05304575 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304576
Govind Singhb53420c2016-03-09 14:32:57 +05304577 WMI_LOGD(FL("Send probe response template for vdev %d"), vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304578
4579 tmpl_len = probe_rsp_info->probeRespTemplateLen;
4580 tmpl_len_aligned = roundup(tmpl_len, sizeof(A_UINT32));
4581
4582 wmi_buf_len = sizeof(wmi_prb_tmpl_cmd_fixed_param) +
4583 sizeof(wmi_bcn_prb_info) + WMI_TLV_HDR_SIZE +
4584 tmpl_len_aligned;
4585
4586 if (wmi_buf_len > WMI_BEACON_TX_BUFFER_SIZE) {
Govind Singhb53420c2016-03-09 14:32:57 +05304587 WMI_LOGE(FL("wmi_buf_len: %d > %d. Can't send wmi cmd"),
Govind Singh4eacd2b2016-03-07 14:24:22 +05304588 wmi_buf_len, WMI_BEACON_TX_BUFFER_SIZE);
Govind Singh67922e82016-04-01 16:48:57 +05304589 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304590 }
4591
4592 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4593 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304594 WMI_LOGE(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05304595 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304596 }
4597
4598 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4599
4600 cmd = (wmi_prb_tmpl_cmd_fixed_param *) buf_ptr;
4601 WMITLV_SET_HDR(&cmd->tlv_header,
4602 WMITLV_TAG_STRUC_wmi_prb_tmpl_cmd_fixed_param,
4603 WMITLV_GET_STRUCT_TLVLEN(wmi_prb_tmpl_cmd_fixed_param));
4604 cmd->vdev_id = vdev_id;
4605 cmd->buf_len = tmpl_len;
4606 buf_ptr += sizeof(wmi_prb_tmpl_cmd_fixed_param);
4607
4608 bcn_prb_info = (wmi_bcn_prb_info *) buf_ptr;
4609 WMITLV_SET_HDR(&bcn_prb_info->tlv_header,
4610 WMITLV_TAG_STRUC_wmi_bcn_prb_info,
4611 WMITLV_GET_STRUCT_TLVLEN(wmi_bcn_prb_info));
4612 bcn_prb_info->caps = 0;
4613 bcn_prb_info->erp = 0;
4614 buf_ptr += sizeof(wmi_bcn_prb_info);
4615
4616 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, tmpl_len_aligned);
4617 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304618 qdf_mem_copy(buf_ptr, frm, tmpl_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304619
4620 ret = wmi_unified_cmd_send(wmi_handle,
4621 wmi_buf, wmi_buf_len, WMI_PRB_TMPL_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304622 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304623 WMI_LOGE(FL("Failed to send PRB RSP tmpl: %d"), ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304624 wmi_buf_free(wmi_buf);
4625 }
4626
4627 return ret;
4628}
4629
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304630#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304631#define WPI_IV_LEN 16
4632
4633/**
4634 * wmi_update_wpi_key_counter() - update WAPI tsc and rsc key counters
4635 *
4636 * @dest_tx: destination address of tsc key counter
4637 * @src_tx: source address of tsc key counter
4638 * @dest_rx: destination address of rsc key counter
4639 * @src_rx: source address of rsc key counter
4640 *
4641 * This function copies WAPI tsc and rsc key counters in the wmi buffer.
4642 *
4643 * Return: None
4644 *
4645 */
4646static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4647 uint8_t *dest_rx, uint8_t *src_rx)
4648{
4649 qdf_mem_copy(dest_tx, src_tx, WPI_IV_LEN);
4650 qdf_mem_copy(dest_rx, src_rx, WPI_IV_LEN);
4651}
4652#else
4653static void wmi_update_wpi_key_counter(uint8_t *dest_tx, uint8_t *src_tx,
4654 uint8_t *dest_rx, uint8_t *src_rx)
4655{
4656 return;
4657}
4658#endif
4659
4660/**
4661 * send_setup_install_key_cmd_tlv() - set key parameters
4662 * @wmi_handle: wmi handle
4663 * @key_params: key parameters
4664 *
4665 * This function fills structure from information
4666 * passed in key_params.
4667 *
4668 * Return: QDF_STATUS_SUCCESS - success
4669 * QDF_STATUS_E_FAILURE - failure
4670 * QDF_STATUS_E_NOMEM - not able to allocate buffer
4671 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304672static QDF_STATUS send_setup_install_key_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304673 struct set_key_params *key_params)
4674{
4675 wmi_vdev_install_key_cmd_fixed_param *cmd;
4676 wmi_buf_t buf;
4677 uint8_t *buf_ptr;
4678 uint32_t len;
4679 uint8_t *key_data;
Govind Singh67922e82016-04-01 16:48:57 +05304680 QDF_STATUS status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304681
4682 len = sizeof(*cmd) + roundup(key_params->key_len, sizeof(uint32_t)) +
4683 WMI_TLV_HDR_SIZE;
4684
4685 buf = wmi_buf_alloc(wmi_handle, len);
4686 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05304687 WMI_LOGE("Failed to allocate buffer to send set key cmd");
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304688 return QDF_STATUS_E_NOMEM;
4689 }
4690
4691 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4692 cmd = (wmi_vdev_install_key_cmd_fixed_param *) buf_ptr;
4693 WMITLV_SET_HDR(&cmd->tlv_header,
4694 WMITLV_TAG_STRUC_wmi_vdev_install_key_cmd_fixed_param,
4695 WMITLV_GET_STRUCT_TLVLEN
4696 (wmi_vdev_install_key_cmd_fixed_param));
4697 cmd->vdev_id = key_params->vdev_id;
4698 cmd->key_ix = key_params->key_idx;
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304699
Nandha Kishore Easwaran0bc57af2016-12-22 19:05:58 +05304700
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304701 WMI_CHAR_ARRAY_TO_MAC_ADDR(key_params->peer_mac, &cmd->peer_macaddr);
4702 cmd->key_flags |= key_params->key_flags;
4703 cmd->key_cipher = key_params->key_cipher;
4704 if ((key_params->key_txmic_len) &&
4705 (key_params->key_rxmic_len)) {
4706 cmd->key_txmic_len = key_params->key_txmic_len;
4707 cmd->key_rxmic_len = key_params->key_rxmic_len;
4708 }
Gurumoorthi Gnanasambandhanbdee3402017-01-10 20:51:02 +05304709#if defined(ATH_SUPPORT_WAPI) || defined(FEATURE_WLAN_WAPI)
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304710 wmi_update_wpi_key_counter(cmd->wpi_key_tsc_counter,
4711 key_params->tx_iv,
4712 cmd->wpi_key_rsc_counter,
4713 key_params->rx_iv);
Govind Singh87542482016-06-08 19:40:11 +05304714#endif
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304715 buf_ptr += sizeof(wmi_vdev_install_key_cmd_fixed_param);
4716 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4717 roundup(key_params->key_len, sizeof(uint32_t)));
4718 key_data = (A_UINT8 *) (buf_ptr + WMI_TLV_HDR_SIZE);
4719 qdf_mem_copy((void *)key_data,
4720 (const void *)key_params->key_data, key_params->key_len);
4721 cmd->key_len = key_params->key_len;
4722
4723 status = wmi_unified_cmd_send(wmi_handle, buf, len,
4724 WMI_VDEV_INSTALL_KEY_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05304725 if (QDF_IS_STATUS_ERROR(status))
Abhishek Singh716c46c2016-05-04 16:24:07 +05304726 wmi_buf_free(buf);
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304727
Govind Singh67922e82016-04-01 16:48:57 +05304728 return status;
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304729}
4730
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304731/**
Manikandan Mohan31a13e22016-12-13 13:14:06 -08004732 * send_sar_limit_cmd_tlv() - send sar limit cmd to fw
4733 * @wmi_handle: wmi handle
4734 * @params: sar limit params
4735 *
4736 * Return: QDF_STATUS_SUCCESS for success or error code
4737 */
4738static QDF_STATUS send_sar_limit_cmd_tlv(wmi_unified_t wmi_handle,
4739 struct sar_limit_cmd_params *sar_limit_params)
4740{
4741 wmi_buf_t buf;
4742 QDF_STATUS qdf_status;
4743 wmi_sar_limits_cmd_fixed_param *cmd;
4744 int i;
4745 uint8_t *buf_ptr;
4746 wmi_sar_limit_cmd_row *wmi_sar_rows_list;
4747 struct sar_limit_cmd_row *sar_rows_list;
4748 uint32_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
4749
4750 len += sizeof(wmi_sar_limit_cmd_row) * sar_limit_params->num_limit_rows;
4751 buf = wmi_buf_alloc(wmi_handle, len);
4752 if (!buf) {
4753 WMI_LOGE("Failed to allocate memory");
4754 qdf_status = QDF_STATUS_E_NOMEM;
4755 goto end;
4756 }
4757
4758 buf_ptr = (uint8_t *) wmi_buf_data(buf);
4759 cmd = (wmi_sar_limits_cmd_fixed_param *) buf_ptr;
4760 WMITLV_SET_HDR(&cmd->tlv_header,
4761 WMITLV_TAG_STRUC_wmi_sar_limits_cmd_fixed_param,
4762 WMITLV_GET_STRUCT_TLVLEN
4763 (wmi_sar_limits_cmd_fixed_param));
4764 cmd->sar_enable = sar_limit_params->sar_enable;
4765 cmd->commit_limits = sar_limit_params->commit_limits;
4766 cmd->num_limit_rows = sar_limit_params->num_limit_rows;
4767
4768 WMI_LOGD("no of sar rows = %d, len = %d",
4769 sar_limit_params->num_limit_rows, len);
4770 buf_ptr += sizeof(*cmd);
4771 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
4772 sizeof(wmi_sar_limit_cmd_row) *
4773 sar_limit_params->num_limit_rows);
4774 if (cmd->num_limit_rows == 0)
4775 goto send_sar_limits;
4776
4777 wmi_sar_rows_list = (wmi_sar_limit_cmd_row *)
4778 (buf_ptr + WMI_TLV_HDR_SIZE);
4779 sar_rows_list = sar_limit_params->sar_limit_row_list;
4780
4781 for (i = 0; i < sar_limit_params->num_limit_rows; i++) {
4782 WMITLV_SET_HDR(&wmi_sar_rows_list->tlv_header,
4783 WMITLV_TAG_STRUC_wmi_sar_limit_cmd_row,
4784 WMITLV_GET_STRUCT_TLVLEN(wmi_sar_limit_cmd_row));
4785 wmi_sar_rows_list->band_id = sar_rows_list->band_id;
4786 wmi_sar_rows_list->chain_id = sar_rows_list->chain_id;
4787 wmi_sar_rows_list->mod_id = sar_rows_list->mod_id;
4788 wmi_sar_rows_list->limit_value = sar_rows_list->limit_value;
4789 wmi_sar_rows_list->validity_bitmap =
4790 sar_rows_list->validity_bitmap;
4791 WMI_LOGD("row %d, band_id = %d, chain_id = %d, mod_id = %d, limit_value = %d, validity_bitmap = %d",
4792 i, wmi_sar_rows_list->band_id,
4793 wmi_sar_rows_list->chain_id,
4794 wmi_sar_rows_list->mod_id,
4795 wmi_sar_rows_list->limit_value,
4796 wmi_sar_rows_list->validity_bitmap);
4797 sar_rows_list++;
4798 wmi_sar_rows_list++;
4799 }
4800send_sar_limits:
4801 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
4802 WMI_SAR_LIMITS_CMDID);
4803
4804 if (QDF_IS_STATUS_ERROR(qdf_status)) {
4805 WMI_LOGE("Failed to send WMI_SAR_LIMITS_CMDID");
4806 wmi_buf_free(buf);
4807 }
4808
4809end:
4810 return qdf_status;
4811}
4812
4813/**
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304814 * send_encrypt_decrypt_send_cmd() - send encrypt/decrypt cmd to fw
4815 * @wmi_handle: wmi handle
4816 * @params: encrypt/decrypt params
4817 *
4818 * Return: QDF_STATUS_SUCCESS for success or error code
4819 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07004820static
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +05304821QDF_STATUS send_encrypt_decrypt_send_cmd_tlv(wmi_unified_t wmi_handle,
4822 struct encrypt_decrypt_req_params *encrypt_decrypt_params)
4823{
4824 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *cmd;
4825 wmi_buf_t wmi_buf;
4826 uint8_t *buf_ptr;
4827 QDF_STATUS ret;
4828 uint32_t len;
4829
4830 WMI_LOGD(FL("Send encrypt decrypt cmd"));
4831
4832 len = sizeof(*cmd) +
4833 roundup(encrypt_decrypt_params->data_len, sizeof(A_UINT32)) +
4834 WMI_TLV_HDR_SIZE;
4835 wmi_buf = wmi_buf_alloc(wmi_handle, len);
4836 if (!wmi_buf) {
4837 WMI_LOGP("%s: failed to allocate memory for encrypt/decrypt msg",
4838 __func__);
4839 return QDF_STATUS_E_NOMEM;
4840 }
4841
4842 buf_ptr = wmi_buf_data(wmi_buf);
4843 cmd = (wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param *)buf_ptr;
4844
4845 WMITLV_SET_HDR(&cmd->tlv_header,
4846 WMITLV_TAG_STRUC_wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param,
4847 WMITLV_GET_STRUCT_TLVLEN(
4848 wmi_vdev_encrypt_decrypt_data_req_cmd_fixed_param));
4849
4850 cmd->vdev_id = encrypt_decrypt_params->vdev_id;
4851 cmd->key_flag = encrypt_decrypt_params->key_flag;
4852 cmd->key_idx = encrypt_decrypt_params->key_idx;
4853 cmd->key_cipher = encrypt_decrypt_params->key_cipher;
4854 cmd->key_len = encrypt_decrypt_params->key_len;
4855 cmd->key_txmic_len = encrypt_decrypt_params->key_txmic_len;
4856 cmd->key_rxmic_len = encrypt_decrypt_params->key_rxmic_len;
4857
4858 qdf_mem_copy(cmd->key_data, encrypt_decrypt_params->key_data,
4859 encrypt_decrypt_params->key_len);
4860
4861 qdf_mem_copy(cmd->mac_hdr, encrypt_decrypt_params->mac_header,
4862 MAX_MAC_HEADER_LEN);
4863
4864 cmd->data_len = encrypt_decrypt_params->data_len;
4865
4866 if (cmd->data_len) {
4867 buf_ptr += sizeof(*cmd);
4868 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
4869 roundup(encrypt_decrypt_params->data_len,
4870 sizeof(A_UINT32)));
4871 buf_ptr += WMI_TLV_HDR_SIZE;
4872 qdf_mem_copy(buf_ptr, encrypt_decrypt_params->data,
4873 encrypt_decrypt_params->data_len);
4874 }
4875
4876 /* This conversion is to facilitate data to FW in little endian */
4877 cmd->pn[5] = encrypt_decrypt_params->pn[0];
4878 cmd->pn[4] = encrypt_decrypt_params->pn[1];
4879 cmd->pn[3] = encrypt_decrypt_params->pn[2];
4880 cmd->pn[2] = encrypt_decrypt_params->pn[3];
4881 cmd->pn[1] = encrypt_decrypt_params->pn[4];
4882 cmd->pn[0] = encrypt_decrypt_params->pn[5];
4883
4884 ret = wmi_unified_cmd_send(wmi_handle,
4885 wmi_buf, len,
4886 WMI_VDEV_ENCRYPT_DECRYPT_DATA_REQ_CMDID);
4887 if (QDF_IS_STATUS_ERROR(ret)) {
4888 WMI_LOGE("Failed to send ENCRYPT DECRYPT cmd: %d", ret);
4889 wmi_buf_free(wmi_buf);
4890 }
4891
4892 return ret;
4893}
4894
4895
Himanshu Agarwal712622f2016-03-09 18:49:18 +05304896
Govind Singh4eacd2b2016-03-07 14:24:22 +05304897/**
4898 * send_p2p_go_set_beacon_ie_cmd_tlv() - set beacon IE for p2p go
4899 * @wmi_handle: wmi handle
4900 * @vdev_id: vdev id
4901 * @p2p_ie: p2p IE
4902 *
Govind Singhe7f2f342016-05-23 12:12:52 +05304903 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05304904 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304905static QDF_STATUS send_p2p_go_set_beacon_ie_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304906 A_UINT32 vdev_id, uint8_t *p2p_ie)
4907{
Govind Singh67922e82016-04-01 16:48:57 +05304908 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304909 wmi_p2p_go_set_beacon_ie_fixed_param *cmd;
4910 wmi_buf_t wmi_buf;
4911 uint32_t ie_len, ie_len_aligned, wmi_buf_len;
4912 uint8_t *buf_ptr;
4913
4914 ie_len = (uint32_t) (p2p_ie[1] + 2);
4915
4916 /* More than one P2P IE may be included in a single frame.
4917 If multiple P2P IEs are present, the complete P2P attribute
4918 data consists of the concatenation of the P2P Attribute
4919 fields of the P2P IEs. The P2P Attributes field of each
4920 P2P IE may be any length up to the maximum (251 octets).
4921 In this case host sends one P2P IE to firmware so the length
4922 should not exceed more than 251 bytes
4923 */
4924 if (ie_len > 251) {
Govind Singhb53420c2016-03-09 14:32:57 +05304925 WMI_LOGE("%s : invalid p2p ie length %u", __func__, ie_len);
Govind Singh67922e82016-04-01 16:48:57 +05304926 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304927 }
4928
4929 ie_len_aligned = roundup(ie_len, sizeof(A_UINT32));
4930
4931 wmi_buf_len =
4932 sizeof(wmi_p2p_go_set_beacon_ie_fixed_param) + ie_len_aligned +
4933 WMI_TLV_HDR_SIZE;
4934
4935 wmi_buf = wmi_buf_alloc(wmi_handle, wmi_buf_len);
4936 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304937 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05304938 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304939 }
4940
4941 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
4942
4943 cmd = (wmi_p2p_go_set_beacon_ie_fixed_param *) buf_ptr;
4944 WMITLV_SET_HDR(&cmd->tlv_header,
4945 WMITLV_TAG_STRUC_wmi_p2p_go_set_beacon_ie_fixed_param,
4946 WMITLV_GET_STRUCT_TLVLEN
4947 (wmi_p2p_go_set_beacon_ie_fixed_param));
4948 cmd->vdev_id = vdev_id;
4949 cmd->ie_buf_len = ie_len;
4950
4951 buf_ptr += sizeof(wmi_p2p_go_set_beacon_ie_fixed_param);
4952 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
4953 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05304954 qdf_mem_copy(buf_ptr, p2p_ie, ie_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304955
Govind Singhb53420c2016-03-09 14:32:57 +05304956 WMI_LOGI("%s: Sending WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304957
4958 ret = wmi_unified_cmd_send(wmi_handle,
4959 wmi_buf, wmi_buf_len,
4960 WMI_P2P_GO_SET_BEACON_IE);
Govind Singh67922e82016-04-01 16:48:57 +05304961 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05304962 WMI_LOGE("Failed to send bcn tmpl: %d", ret);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304963 wmi_buf_free(wmi_buf);
4964 }
4965
Govind Singhb53420c2016-03-09 14:32:57 +05304966 WMI_LOGI("%s: Successfully sent WMI_P2P_GO_SET_BEACON_IE", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05304967 return ret;
4968}
4969
4970/**
4971 * send_set_gateway_params_cmd_tlv() - set gateway parameters
4972 * @wmi_handle: wmi handle
4973 * @req: gateway parameter update request structure
4974 *
4975 * This function reads the incoming @req and fill in the destination
4976 * WMI structure and sends down the gateway configs down to the firmware
4977 *
Govind Singhb53420c2016-03-09 14:32:57 +05304978 * Return: QDF_STATUS
Govind Singh4eacd2b2016-03-07 14:24:22 +05304979 */
Sathish Kumarfd347372017-02-13 12:29:09 +05304980static QDF_STATUS send_set_gateway_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05304981 struct gateway_update_req_param *req)
4982{
4983 wmi_roam_subnet_change_config_fixed_param *cmd;
4984 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05304985 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304986 int len = sizeof(*cmd);
4987
4988 buf = wmi_buf_alloc(wmi_handle, len);
4989 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05304990 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
4991 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05304992 }
4993
4994 cmd = (wmi_roam_subnet_change_config_fixed_param *) wmi_buf_data(buf);
4995 WMITLV_SET_HDR(&cmd->tlv_header,
4996 WMITLV_TAG_STRUC_wmi_roam_subnet_change_config_fixed_param,
4997 WMITLV_GET_STRUCT_TLVLEN(
4998 wmi_roam_subnet_change_config_fixed_param));
4999
5000 cmd->vdev_id = req->session_id;
Govind Singhb53420c2016-03-09 14:32:57 +05305001 qdf_mem_copy(&cmd->inet_gw_ip_v4_addr, req->ipv4_addr,
5002 QDF_IPV4_ADDR_SIZE);
5003 qdf_mem_copy(&cmd->inet_gw_ip_v6_addr, req->ipv6_addr,
5004 QDF_IPV6_ADDR_SIZE);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305005 WMI_CHAR_ARRAY_TO_MAC_ADDR(req->gw_mac_addr.bytes,
5006 &cmd->inet_gw_mac_addr);
5007 cmd->max_retries = req->max_retries;
5008 cmd->timeout = req->timeout;
5009 cmd->num_skip_subnet_change_detection_bssid_list = 0;
5010 cmd->flag = 0;
5011 if (req->ipv4_addr_type)
5012 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP4_ENABLED(cmd->flag);
5013
5014 if (req->ipv6_addr_type)
5015 WMI_SET_ROAM_SUBNET_CHANGE_FLAG_IP6_ENABLED(cmd->flag);
5016
5017 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5018 WMI_ROAM_SUBNET_CHANGE_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305019 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305020 WMI_LOGE("Failed to send gw config parameter to fw, ret: %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305021 ret);
5022 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305023 }
5024
Govind Singh67922e82016-04-01 16:48:57 +05305025 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305026}
5027
5028/**
5029 * send_set_rssi_monitoring_cmd_tlv() - set rssi monitoring
5030 * @wmi_handle: wmi handle
5031 * @req: rssi monitoring request structure
5032 *
5033 * This function reads the incoming @req and fill in the destination
5034 * WMI structure and send down the rssi monitoring configs down to the firmware
5035 *
5036 * Return: 0 on success; error number otherwise
5037 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305038static QDF_STATUS send_set_rssi_monitoring_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305039 struct rssi_monitor_param *req)
5040{
5041 wmi_rssi_breach_monitor_config_fixed_param *cmd;
5042 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05305043 QDF_STATUS ret;
5044 uint32_t len = sizeof(*cmd);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305045
5046 buf = wmi_buf_alloc(wmi_handle, len);
5047 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305048 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
5049 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305050 }
5051
5052 cmd = (wmi_rssi_breach_monitor_config_fixed_param *) wmi_buf_data(buf);
5053 WMITLV_SET_HDR(&cmd->tlv_header,
5054 WMITLV_TAG_STRUC_wmi_rssi_breach_monitor_config_fixed_param,
5055 WMITLV_GET_STRUCT_TLVLEN(
5056 wmi_rssi_breach_monitor_config_fixed_param));
5057
5058 cmd->vdev_id = req->session_id;
5059 cmd->request_id = req->request_id;
5060 cmd->lo_rssi_reenable_hysteresis = 0;
5061 cmd->hi_rssi_reenable_histeresis = 0;
5062 cmd->min_report_interval = 0;
5063 cmd->max_num_report = 1;
5064 if (req->control) {
5065 /* enable one threshold for each min/max */
5066 cmd->enabled_bitmap = 0x09;
5067 cmd->low_rssi_breach_threshold[0] = req->min_rssi;
5068 cmd->hi_rssi_breach_threshold[0] = req->max_rssi;
5069 } else {
5070 cmd->enabled_bitmap = 0;
5071 cmd->low_rssi_breach_threshold[0] = 0;
5072 cmd->hi_rssi_breach_threshold[0] = 0;
5073 }
5074
5075 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5076 WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305077 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305078 WMI_LOGE("Failed to send WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID");
Govind Singh4eacd2b2016-03-07 14:24:22 +05305079 wmi_buf_free(buf);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305080 }
5081
Govind Singhb53420c2016-03-09 14:32:57 +05305082 WMI_LOGI("Sent WMI_RSSI_BREACH_MONITOR_CONFIG_CMDID to FW");
Govind Singh67922e82016-04-01 16:48:57 +05305083 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305084}
5085
5086/**
5087 * send_scan_probe_setoui_cmd_tlv() - set scan probe OUI
5088 * @wmi_handle: wmi handle
5089 * @psetoui: OUI parameters
5090 *
5091 * set scan probe OUI parameters in firmware
5092 *
5093 * Return: CDF status
5094 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305095static QDF_STATUS send_scan_probe_setoui_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305096 struct scan_mac_oui *psetoui)
5097{
5098 wmi_scan_prob_req_oui_cmd_fixed_param *cmd;
5099 wmi_buf_t wmi_buf;
5100 uint32_t len;
5101 uint8_t *buf_ptr;
5102 uint32_t *oui_buf;
5103
5104 len = sizeof(*cmd);
5105 wmi_buf = wmi_buf_alloc(wmi_handle, len);
5106 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305107 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
5108 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305109 }
5110 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
5111 cmd = (wmi_scan_prob_req_oui_cmd_fixed_param *) buf_ptr;
5112 WMITLV_SET_HDR(&cmd->tlv_header,
5113 WMITLV_TAG_STRUC_wmi_scan_prob_req_oui_cmd_fixed_param,
5114 WMITLV_GET_STRUCT_TLVLEN
5115 (wmi_scan_prob_req_oui_cmd_fixed_param));
5116
5117 oui_buf = &cmd->prob_req_oui;
Govind Singhb53420c2016-03-09 14:32:57 +05305118 qdf_mem_zero(oui_buf, sizeof(cmd->prob_req_oui));
Govind Singh4eacd2b2016-03-07 14:24:22 +05305119 *oui_buf = psetoui->oui[0] << 16 | psetoui->oui[1] << 8
5120 | psetoui->oui[2];
Govind Singhb53420c2016-03-09 14:32:57 +05305121 WMI_LOGD("%s: wmi:oui received from hdd %08x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305122 cmd->prob_req_oui);
5123
5124 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
5125 WMI_SCAN_PROB_REQ_OUI_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05305126 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05305127 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305128 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305129 }
Govind Singhb53420c2016-03-09 14:32:57 +05305130 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305131}
5132
5133/**
5134 * send_reset_passpoint_network_list_cmd_tlv() - reset passpoint network list
5135 * @wmi_handle: wmi handle
5136 * @req: passpoint network request structure
5137 *
5138 * This function sends down WMI command with network id set to wildcard id.
5139 * firmware shall clear all the config entries
5140 *
Govind Singhb53420c2016-03-09 14:32:57 +05305141 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305142 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305143static QDF_STATUS send_reset_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305144 struct wifi_passpoint_req_param *req)
5145{
5146 wmi_passpoint_config_cmd_fixed_param *cmd;
5147 wmi_buf_t buf;
5148 uint32_t len;
5149 int ret;
5150
5151 len = sizeof(*cmd);
5152 buf = wmi_buf_alloc(wmi_handle, len);
5153 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305154 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5155 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305156 }
5157
5158 cmd = (wmi_passpoint_config_cmd_fixed_param *) wmi_buf_data(buf);
5159
5160 WMITLV_SET_HDR(&cmd->tlv_header,
5161 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5162 WMITLV_GET_STRUCT_TLVLEN(
5163 wmi_passpoint_config_cmd_fixed_param));
5164 cmd->id = WMI_PASSPOINT_NETWORK_ID_WILDCARD;
5165
5166 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5167 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5168 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305169 WMI_LOGE("%s: Failed to send reset passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305170 __func__);
5171 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305172 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305173 }
5174
Govind Singhb53420c2016-03-09 14:32:57 +05305175 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305176}
5177
5178/**
5179 * send_set_passpoint_network_list_cmd_tlv() - set passpoint network list
5180 * @wmi_handle: wmi handle
5181 * @req: passpoint network request structure
5182 *
5183 * This function reads the incoming @req and fill in the destination
5184 * WMI structure and send down the passpoint configs down to the firmware
5185 *
Govind Singhb53420c2016-03-09 14:32:57 +05305186 * Return: QDF_STATUS enumeration
Govind Singh4eacd2b2016-03-07 14:24:22 +05305187 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305188static QDF_STATUS send_set_passpoint_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305189 struct wifi_passpoint_req_param *req)
5190{
5191 wmi_passpoint_config_cmd_fixed_param *cmd;
5192 u_int8_t i, j, *bytes;
5193 wmi_buf_t buf;
5194 uint32_t len;
5195 int ret;
5196
5197 len = sizeof(*cmd);
5198 for (i = 0; i < req->num_networks; i++) {
5199 buf = wmi_buf_alloc(wmi_handle, len);
5200 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305201 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5202 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305203 }
5204
5205 cmd = (wmi_passpoint_config_cmd_fixed_param *)
5206 wmi_buf_data(buf);
5207
5208 WMITLV_SET_HDR(&cmd->tlv_header,
5209 WMITLV_TAG_STRUC_wmi_passpoint_config_cmd_fixed_param,
5210 WMITLV_GET_STRUCT_TLVLEN(
5211 wmi_passpoint_config_cmd_fixed_param));
5212 cmd->id = req->networks[i].id;
Govind Singhb53420c2016-03-09 14:32:57 +05305213 WMI_LOGD("%s: network id: %u", __func__, cmd->id);
5214 qdf_mem_copy(cmd->realm, req->networks[i].realm,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305215 strlen(req->networks[i].realm) + 1);
Govind Singhb53420c2016-03-09 14:32:57 +05305216 WMI_LOGD("%s: realm: %s", __func__, cmd->realm);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305217 for (j = 0; j < PASSPOINT_ROAMING_CONSORTIUM_ID_NUM; j++) {
5218 bytes = (uint8_t *) &req->networks[i].roaming_consortium_ids[j];
Govind Singhb53420c2016-03-09 14:32:57 +05305219 WMI_LOGD("index: %d rcids: %02x %02x %02x %02x %02x %02x %02x %02x",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305220 j, bytes[0], bytes[1], bytes[2], bytes[3],
5221 bytes[4], bytes[5], bytes[6], bytes[7]);
5222
Govind Singhb53420c2016-03-09 14:32:57 +05305223 qdf_mem_copy(&cmd->roaming_consortium_ids[j],
Govind Singh4eacd2b2016-03-07 14:24:22 +05305224 &req->networks[i].roaming_consortium_ids[j],
5225 PASSPOINT_ROAMING_CONSORTIUM_ID_LEN);
5226 }
Govind Singhb53420c2016-03-09 14:32:57 +05305227 qdf_mem_copy(cmd->plmn, req->networks[i].plmn,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305228 PASSPOINT_PLMN_ID_LEN);
Govind Singhb53420c2016-03-09 14:32:57 +05305229 WMI_LOGD("%s: plmn: %02x:%02x:%02x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305230 cmd->plmn[0], cmd->plmn[1], cmd->plmn[2]);
5231
5232 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
5233 WMI_PASSPOINT_LIST_CONFIG_CMDID);
5234 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05305235 WMI_LOGE("%s: Failed to send set passpoint network list wmi cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305236 __func__);
5237 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05305238 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305239 }
5240 }
5241
Govind Singhb53420c2016-03-09 14:32:57 +05305242 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305243}
5244
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305245/**
5246 * send_roam_scan_offload_mode_cmd_tlv() - send roam scan mode request to fw
5247 * @wmi_handle: wmi handle
5248 * @scan_cmd_fp: start scan command ptr
5249 * @roam_req: roam request param
5250 *
5251 * send WMI_ROAM_SCAN_MODE TLV to firmware. It has a piggyback
5252 * of WMI_ROAM_SCAN_MODE.
5253 *
5254 * Return: QDF status
5255 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305256static QDF_STATUS send_roam_scan_offload_mode_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305257 wmi_start_scan_cmd_fixed_param *
5258 scan_cmd_fp,
5259 struct roam_offload_scan_params *roam_req)
5260{
5261 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305262 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305263 int len;
5264 uint8_t *buf_ptr;
5265 wmi_roam_scan_mode_fixed_param *roam_scan_mode_fp;
Govind Singh67922e82016-04-01 16:48:57 +05305266
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305267#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5268 int auth_mode = roam_req->auth_mode;
5269 wmi_roam_offload_tlv_param *roam_offload_params;
5270 wmi_roam_11i_offload_tlv_param *roam_offload_11i;
5271 wmi_roam_11r_offload_tlv_param *roam_offload_11r;
5272 wmi_roam_ese_offload_tlv_param *roam_offload_ese;
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305273 wmi_tlv_buf_len_param *assoc_ies;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305274#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5275 /* Need to create a buf with roam_scan command at
5276 * front and piggyback with scan command */
5277 len = sizeof(wmi_roam_scan_mode_fixed_param) +
5278#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5279 (2 * WMI_TLV_HDR_SIZE) +
5280#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5281 sizeof(wmi_start_scan_cmd_fixed_param);
5282#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5283 if (roam_req->is_roam_req_valid &&
5284 roam_req->roam_offload_enabled) {
5285 len += sizeof(wmi_roam_offload_tlv_param);
5286 len += WMI_TLV_HDR_SIZE;
5287 if ((auth_mode != WMI_AUTH_NONE) &&
5288 ((auth_mode != WMI_AUTH_OPEN) ||
5289 (auth_mode == WMI_AUTH_OPEN &&
5290 roam_req->mdid.mdie_present) ||
5291 roam_req->is_ese_assoc)) {
5292 len += WMI_TLV_HDR_SIZE;
5293 if (roam_req->is_ese_assoc)
5294 len +=
5295 sizeof(wmi_roam_ese_offload_tlv_param);
5296 else if (auth_mode == WMI_AUTH_FT_RSNA ||
5297 auth_mode == WMI_AUTH_FT_RSNA_PSK ||
5298 (auth_mode == WMI_AUTH_OPEN &&
5299 roam_req->mdid.mdie_present))
5300 len +=
5301 sizeof(wmi_roam_11r_offload_tlv_param);
5302 else
5303 len +=
5304 sizeof(wmi_roam_11i_offload_tlv_param);
5305 } else {
5306 len += WMI_TLV_HDR_SIZE;
5307 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305308
5309 len += (sizeof(*assoc_ies) + (2*WMI_TLV_HDR_SIZE)
5310 + roundup(roam_req->assoc_ie_length,
5311 sizeof(uint32_t)));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305312 } else {
5313 if (roam_req->is_roam_req_valid)
Govind Singhe7f2f342016-05-23 12:12:52 +05305314 WMI_LOGD("%s : roam offload = %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305315 __func__, roam_req->roam_offload_enabled);
5316 else
Govind Singhe7f2f342016-05-23 12:12:52 +05305317 WMI_LOGD("%s : roam_req is NULL", __func__);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305318 len += (4 * WMI_TLV_HDR_SIZE);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305319 }
5320 if (roam_req->is_roam_req_valid &&
5321 roam_req->roam_offload_enabled) {
5322 roam_req->mode = roam_req->mode |
5323 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD;
5324 }
5325#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
5326
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305327 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE
5328 |WMI_ROAM_SCAN_MODE_ROAMOFFLOAD))
5329 len = sizeof(wmi_roam_scan_mode_fixed_param);
5330
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305331 buf = wmi_buf_alloc(wmi_handle, len);
5332 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305333 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305334 return QDF_STATUS_E_NOMEM;
5335 }
5336
5337 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305338
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305339 roam_scan_mode_fp = (wmi_roam_scan_mode_fixed_param *) buf_ptr;
5340 WMITLV_SET_HDR(&roam_scan_mode_fp->tlv_header,
5341 WMITLV_TAG_STRUC_wmi_roam_scan_mode_fixed_param,
5342 WMITLV_GET_STRUCT_TLVLEN
5343 (wmi_roam_scan_mode_fixed_param));
5344
5345 roam_scan_mode_fp->roam_scan_mode = roam_req->mode;
5346 roam_scan_mode_fp->vdev_id = roam_req->vdev_id;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305347 if (roam_req->mode == (WMI_ROAM_SCAN_MODE_NONE |
5348 WMI_ROAM_SCAN_MODE_ROAMOFFLOAD)) {
5349 roam_scan_mode_fp->flags |=
5350 WMI_ROAM_SCAN_MODE_FLAG_REPORT_STATUS;
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305351 goto send_roam_scan_mode_cmd;
Sreelakshmi Konamki400a40d2017-02-24 14:28:34 +05305352 }
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305353
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305354 /* Fill in scan parameters suitable for roaming scan */
5355 buf_ptr += sizeof(wmi_roam_scan_mode_fixed_param);
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305356
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305357 qdf_mem_copy(buf_ptr, scan_cmd_fp,
5358 sizeof(wmi_start_scan_cmd_fixed_param));
5359 /* Ensure there is no additional IEs */
5360 scan_cmd_fp->ie_len = 0;
5361 WMITLV_SET_HDR(buf_ptr,
5362 WMITLV_TAG_STRUC_wmi_start_scan_cmd_fixed_param,
5363 WMITLV_GET_STRUCT_TLVLEN
5364 (wmi_start_scan_cmd_fixed_param));
5365#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5366 buf_ptr += sizeof(wmi_start_scan_cmd_fixed_param);
5367 if (roam_req->is_roam_req_valid && roam_req->roam_offload_enabled) {
5368 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5369 sizeof(wmi_roam_offload_tlv_param));
5370 buf_ptr += WMI_TLV_HDR_SIZE;
5371 roam_offload_params = (wmi_roam_offload_tlv_param *) buf_ptr;
5372 WMITLV_SET_HDR(buf_ptr,
5373 WMITLV_TAG_STRUC_wmi_roam_offload_tlv_param,
5374 WMITLV_GET_STRUCT_TLVLEN
5375 (wmi_roam_offload_tlv_param));
5376 roam_offload_params->prefer_5g = roam_req->prefer_5ghz;
5377 roam_offload_params->rssi_cat_gap = roam_req->roam_rssi_cat_gap;
5378 roam_offload_params->select_5g_margin =
5379 roam_req->select_5ghz_margin;
5380 roam_offload_params->reassoc_failure_timeout =
5381 roam_req->reassoc_failure_timeout;
5382
5383 /* Fill the capabilities */
5384 roam_offload_params->capability =
5385 roam_req->roam_offload_params.capability;
5386 roam_offload_params->ht_caps_info =
5387 roam_req->roam_offload_params.ht_caps_info;
5388 roam_offload_params->ampdu_param =
5389 roam_req->roam_offload_params.ampdu_param;
5390 roam_offload_params->ht_ext_cap =
5391 roam_req->roam_offload_params.ht_ext_cap;
5392 roam_offload_params->ht_txbf =
5393 roam_req->roam_offload_params.ht_txbf;
5394 roam_offload_params->asel_cap =
5395 roam_req->roam_offload_params.asel_cap;
5396 roam_offload_params->qos_caps =
5397 roam_req->roam_offload_params.qos_caps;
Naveen Rawat1dcabaf2016-11-18 17:27:29 -08005398 roam_offload_params->qos_enabled =
5399 roam_req->roam_offload_params.qos_enabled;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305400 roam_offload_params->wmm_caps =
5401 roam_req->roam_offload_params.wmm_caps;
5402 qdf_mem_copy((uint8_t *)roam_offload_params->mcsset,
5403 (uint8_t *)roam_req->roam_offload_params.mcsset,
5404 ROAM_OFFLOAD_NUM_MCS_SET);
5405
5406 buf_ptr += sizeof(wmi_roam_offload_tlv_param);
5407 /* The TLV's are in the order of 11i, 11R, ESE. Hence,
5408 * they are filled in the same order.Depending on the
5409 * authentication type, the other mode TLV's are nullified
5410 * and only headers are filled.*/
5411 if ((auth_mode != WMI_AUTH_NONE) &&
5412 ((auth_mode != WMI_AUTH_OPEN) ||
5413 (auth_mode == WMI_AUTH_OPEN
5414 && roam_req->mdid.mdie_present) ||
5415 roam_req->is_ese_assoc)) {
5416 if (roam_req->is_ese_assoc) {
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));
5422 buf_ptr += WMI_TLV_HDR_SIZE;
5423 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5424 sizeof(wmi_roam_ese_offload_tlv_param));
5425 buf_ptr += WMI_TLV_HDR_SIZE;
5426 roam_offload_ese =
5427 (wmi_roam_ese_offload_tlv_param *) buf_ptr;
5428 qdf_mem_copy(roam_offload_ese->krk,
5429 roam_req->krk,
5430 sizeof(roam_req->krk));
5431 qdf_mem_copy(roam_offload_ese->btk,
5432 roam_req->btk,
5433 sizeof(roam_req->btk));
5434 WMITLV_SET_HDR(&roam_offload_ese->tlv_header,
5435 WMITLV_TAG_STRUC_wmi_roam_ese_offload_tlv_param,
5436 WMITLV_GET_STRUCT_TLVLEN
5437 (wmi_roam_ese_offload_tlv_param));
5438 buf_ptr +=
5439 sizeof(wmi_roam_ese_offload_tlv_param);
5440 } else if (auth_mode == WMI_AUTH_FT_RSNA
5441 || auth_mode == WMI_AUTH_FT_RSNA_PSK
5442 || (auth_mode == WMI_AUTH_OPEN
5443 && roam_req->mdid.mdie_present)) {
5444 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5445 0);
5446 buf_ptr += WMI_TLV_HDR_SIZE;
5447 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5448 sizeof(wmi_roam_11r_offload_tlv_param));
5449 buf_ptr += WMI_TLV_HDR_SIZE;
5450 roam_offload_11r =
5451 (wmi_roam_11r_offload_tlv_param *) buf_ptr;
5452 roam_offload_11r->r0kh_id_len =
5453 roam_req->rokh_id_length;
5454 qdf_mem_copy(roam_offload_11r->r0kh_id,
5455 roam_req->rokh_id,
5456 roam_offload_11r->r0kh_id_len);
5457 qdf_mem_copy(roam_offload_11r->psk_msk,
5458 roam_req->psk_pmk,
5459 sizeof(roam_req->psk_pmk));
5460 roam_offload_11r->psk_msk_len =
5461 roam_req->pmk_len;
5462 roam_offload_11r->mdie_present =
5463 roam_req->mdid.mdie_present;
5464 roam_offload_11r->mdid =
5465 roam_req->mdid.mobility_domain;
5466 if (auth_mode == WMI_AUTH_OPEN) {
5467 /* If FT-Open ensure pmk length
5468 and r0khid len are zero */
5469 roam_offload_11r->r0kh_id_len = 0;
5470 roam_offload_11r->psk_msk_len = 0;
5471 }
5472 WMITLV_SET_HDR(&roam_offload_11r->tlv_header,
5473 WMITLV_TAG_STRUC_wmi_roam_11r_offload_tlv_param,
5474 WMITLV_GET_STRUCT_TLVLEN
5475 (wmi_roam_11r_offload_tlv_param));
5476 buf_ptr +=
5477 sizeof(wmi_roam_11r_offload_tlv_param);
5478 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5479 WMITLV_GET_STRUCT_TLVLEN(0));
5480 buf_ptr += WMI_TLV_HDR_SIZE;
5481 } else {
5482 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5483 sizeof(wmi_roam_11i_offload_tlv_param));
5484 buf_ptr += WMI_TLV_HDR_SIZE;
5485 roam_offload_11i =
5486 (wmi_roam_11i_offload_tlv_param *) buf_ptr;
Deepak Dhamdhere70504a12016-08-22 18:04:00 -07005487 if (roam_req->roam_key_mgmt_offload_enabled &&
5488 roam_req->okc_enabled) {
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305489 WMI_SET_ROAM_OFFLOAD_OKC_ENABLED
5490 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305491 WMI_LOGE("LFR3:OKC Enabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305492 } else {
5493 WMI_SET_ROAM_OFFLOAD_OKC_DISABLED
5494 (roam_offload_11i->flags);
Govind Singhe7f2f342016-05-23 12:12:52 +05305495 WMI_LOGE("LFR3:OKC Disabled");
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305496 }
5497
5498 qdf_mem_copy(roam_offload_11i->pmk,
5499 roam_req->psk_pmk,
5500 sizeof(roam_req->psk_pmk));
5501 roam_offload_11i->pmk_len = roam_req->pmk_len;
5502 WMITLV_SET_HDR(&roam_offload_11i->tlv_header,
5503 WMITLV_TAG_STRUC_wmi_roam_11i_offload_tlv_param,
5504 WMITLV_GET_STRUCT_TLVLEN
5505 (wmi_roam_11i_offload_tlv_param));
5506 buf_ptr +=
5507 sizeof(wmi_roam_11i_offload_tlv_param);
5508 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5509 0);
5510 buf_ptr += WMI_TLV_HDR_SIZE;
5511 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5512 0);
5513 buf_ptr += WMI_TLV_HDR_SIZE;
5514 }
5515 } else {
5516 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5517 WMITLV_GET_STRUCT_TLVLEN(0));
5518 buf_ptr += WMI_TLV_HDR_SIZE;
5519 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5520 WMITLV_GET_STRUCT_TLVLEN(0));
5521 buf_ptr += WMI_TLV_HDR_SIZE;
5522 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5523 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305524 buf_ptr += WMI_TLV_HDR_SIZE;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305525 }
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305526
5527 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5528 sizeof(*assoc_ies));
5529 buf_ptr += WMI_TLV_HDR_SIZE;
5530
5531 assoc_ies = (wmi_tlv_buf_len_param *) buf_ptr;
5532 WMITLV_SET_HDR(&assoc_ies->tlv_header,
5533 WMITLV_TAG_STRUC_wmi_tlv_buf_len_param,
5534 WMITLV_GET_STRUCT_TLVLEN(wmi_tlv_buf_len_param));
5535 assoc_ies->buf_len = roam_req->assoc_ie_length;
5536
5537 buf_ptr += sizeof(*assoc_ies);
5538
5539 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5540 roundup(assoc_ies->buf_len, sizeof(uint32_t)));
5541 buf_ptr += WMI_TLV_HDR_SIZE;
5542
5543 if (assoc_ies->buf_len != 0) {
5544 qdf_mem_copy(buf_ptr, roam_req->assoc_ie,
5545 assoc_ies->buf_len);
5546 }
5547
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305548 } else {
5549 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5550 WMITLV_GET_STRUCT_TLVLEN(0));
5551 buf_ptr += WMI_TLV_HDR_SIZE;
5552 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5553 WMITLV_GET_STRUCT_TLVLEN(0));
5554 buf_ptr += WMI_TLV_HDR_SIZE;
5555 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5556 WMITLV_GET_STRUCT_TLVLEN(0));
5557 buf_ptr += WMI_TLV_HDR_SIZE;
5558 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5559 WMITLV_GET_STRUCT_TLVLEN(0));
Selvaraj, Sridharf36770f2016-07-04 21:40:23 +05305560 buf_ptr += WMI_TLV_HDR_SIZE;
5561 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5562 WMITLV_GET_STRUCT_TLVLEN(0));
5563 buf_ptr += WMI_TLV_HDR_SIZE;
5564 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
5565 WMITLV_GET_STRUCT_TLVLEN(0));
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305566 }
5567#endif /* WLAN_FEATURE_ROAM_OFFLOAD */
Selvaraj, Sridhar1b1fdae2016-10-17 20:36:10 +05305568
5569send_roam_scan_mode_cmd:
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305570 status = wmi_unified_cmd_send(wmi_handle, buf,
5571 len, WMI_ROAM_SCAN_MODE);
Govind Singh67922e82016-04-01 16:48:57 +05305572 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305573 WMI_LOGE(
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305574 "wmi_unified_cmd_send WMI_ROAM_SCAN_MODE returned Error %d",
5575 status);
5576 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305577 }
5578
Govind Singh67922e82016-04-01 16:48:57 +05305579 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305580}
5581
5582
5583/**
5584 * send_roam_scan_offload_rssi_thresh_cmd_tlv() - set scan offload
5585 * rssi threashold
5586 * @wmi_handle: wmi handle
5587 * @roam_req: Roaming request buffer
5588 *
5589 * Send WMI_ROAM_SCAN_RSSI_THRESHOLD TLV to firmware
5590 *
5591 * Return: QDF status
5592 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305593static QDF_STATUS send_roam_scan_offload_rssi_thresh_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305594 struct roam_offload_scan_rssi_params *roam_req)
5595{
5596 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305597 QDF_STATUS status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305598 int len;
5599 uint8_t *buf_ptr;
5600 wmi_roam_scan_rssi_threshold_fixed_param *rssi_threshold_fp;
5601 wmi_roam_scan_extended_threshold_param *ext_thresholds = NULL;
5602 wmi_roam_earlystop_rssi_thres_param *early_stop_thresholds = NULL;
Gupta, Kapil7e652922016-04-12 15:02:00 +05305603 wmi_roam_dense_thres_param *dense_thresholds = NULL;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305604
5605 len = sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5606 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5607 len += sizeof(wmi_roam_scan_extended_threshold_param);
5608 len += WMI_TLV_HDR_SIZE;
5609 len += sizeof(wmi_roam_earlystop_rssi_thres_param);
Gupta, Kapil7e652922016-04-12 15:02:00 +05305610 len += WMI_TLV_HDR_SIZE; /* TLV for dense thresholds*/
5611 len += sizeof(wmi_roam_dense_thres_param);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305612 buf = wmi_buf_alloc(wmi_handle, len);
5613 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305614 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305615 return QDF_STATUS_E_NOMEM;
5616 }
5617
5618 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5619 rssi_threshold_fp =
5620 (wmi_roam_scan_rssi_threshold_fixed_param *) buf_ptr;
5621 WMITLV_SET_HDR(&rssi_threshold_fp->tlv_header,
5622 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_threshold_fixed_param,
5623 WMITLV_GET_STRUCT_TLVLEN
5624 (wmi_roam_scan_rssi_threshold_fixed_param));
5625 /* fill in threshold values */
5626 rssi_threshold_fp->vdev_id = roam_req->session_id;
5627 rssi_threshold_fp->roam_scan_rssi_thresh = roam_req->rssi_thresh;
5628 rssi_threshold_fp->roam_rssi_thresh_diff = roam_req->rssi_thresh_diff;
5629 rssi_threshold_fp->hirssi_scan_max_count =
5630 roam_req->hi_rssi_scan_max_count;
5631 rssi_threshold_fp->hirssi_scan_delta =
5632 roam_req->hi_rssi_scan_rssi_delta;
5633 rssi_threshold_fp->hirssi_upper_bound = roam_req->hi_rssi_scan_rssi_ub;
5634
5635 buf_ptr += sizeof(wmi_roam_scan_rssi_threshold_fixed_param);
5636 WMITLV_SET_HDR(buf_ptr,
5637 WMITLV_TAG_ARRAY_STRUC,
5638 sizeof(wmi_roam_scan_extended_threshold_param));
5639 buf_ptr += WMI_TLV_HDR_SIZE;
5640 ext_thresholds = (wmi_roam_scan_extended_threshold_param *) buf_ptr;
5641
5642 ext_thresholds->penalty_threshold_5g = roam_req->penalty_threshold_5g;
5643 if (roam_req->raise_rssi_thresh_5g >= WMI_NOISE_FLOOR_DBM_DEFAULT)
5644 ext_thresholds->boost_threshold_5g =
5645 roam_req->boost_threshold_5g;
5646
5647 ext_thresholds->boost_algorithm_5g =
5648 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5649 ext_thresholds->boost_factor_5g = roam_req->raise_factor_5g;
5650 ext_thresholds->penalty_algorithm_5g =
5651 WMI_ROAM_5G_BOOST_PENALIZE_ALGO_LINEAR;
5652 ext_thresholds->penalty_factor_5g = roam_req->drop_factor_5g;
5653 ext_thresholds->max_boost_5g = roam_req->max_raise_rssi_5g;
5654 ext_thresholds->max_penalty_5g = roam_req->max_drop_rssi_5g;
5655 ext_thresholds->good_rssi_threshold = roam_req->good_rssi_threshold;
5656
5657 WMITLV_SET_HDR(&ext_thresholds->tlv_header,
5658 WMITLV_TAG_STRUC_wmi_roam_scan_extended_threshold_param,
5659 WMITLV_GET_STRUCT_TLVLEN
5660 (wmi_roam_scan_extended_threshold_param));
5661 buf_ptr += sizeof(wmi_roam_scan_extended_threshold_param);
5662 WMITLV_SET_HDR(buf_ptr,
5663 WMITLV_TAG_ARRAY_STRUC,
5664 sizeof(wmi_roam_earlystop_rssi_thres_param));
5665 buf_ptr += WMI_TLV_HDR_SIZE;
5666 early_stop_thresholds = (wmi_roam_earlystop_rssi_thres_param *) buf_ptr;
5667 early_stop_thresholds->roam_earlystop_thres_min =
5668 roam_req->roam_earlystop_thres_min;
5669 early_stop_thresholds->roam_earlystop_thres_max =
5670 roam_req->roam_earlystop_thres_max;
5671 WMITLV_SET_HDR(&early_stop_thresholds->tlv_header,
5672 WMITLV_TAG_STRUC_wmi_roam_earlystop_rssi_thres_param,
5673 WMITLV_GET_STRUCT_TLVLEN
5674 (wmi_roam_earlystop_rssi_thres_param));
5675
Gupta, Kapil7e652922016-04-12 15:02:00 +05305676 buf_ptr += sizeof(wmi_roam_earlystop_rssi_thres_param);
5677 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5678 sizeof(wmi_roam_dense_thres_param));
5679 buf_ptr += WMI_TLV_HDR_SIZE;
5680 dense_thresholds = (wmi_roam_dense_thres_param *) buf_ptr;
5681 dense_thresholds->roam_dense_rssi_thres_offset =
5682 roam_req->dense_rssi_thresh_offset;
5683 dense_thresholds->roam_dense_min_aps = roam_req->dense_min_aps_cnt;
5684 dense_thresholds->roam_dense_traffic_thres =
5685 roam_req->traffic_threshold;
5686 dense_thresholds->roam_dense_status = roam_req->initial_dense_status;
5687 WMITLV_SET_HDR(&dense_thresholds->tlv_header,
5688 WMITLV_TAG_STRUC_wmi_roam_dense_thres_param,
5689 WMITLV_GET_STRUCT_TLVLEN
5690 (wmi_roam_dense_thres_param));
5691
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305692 status = wmi_unified_cmd_send(wmi_handle, buf,
5693 len, WMI_ROAM_SCAN_RSSI_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +05305694 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305695 WMI_LOGE("cmd WMI_ROAM_SCAN_RSSI_THRESHOLD returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305696 status);
5697 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305698 }
5699
Govind Singh67922e82016-04-01 16:48:57 +05305700 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305701}
5702
5703/**
Gupta, Kapil2e685982016-04-25 19:14:19 +05305704 * send_adapt_dwelltime_params_cmd_tlv() - send wmi cmd of adaptive dwelltime
5705 * configuration params
5706 * @wma_handle: wma handler
5707 * @dwelltime_params: pointer to dwelltime_params
5708 *
5709 * Return: QDF_STATUS_SUCCESS on success and QDF failure reason code for failure
5710 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07005711static
Gupta, Kapil2e685982016-04-25 19:14:19 +05305712QDF_STATUS send_adapt_dwelltime_params_cmd_tlv(wmi_unified_t wmi_handle,
5713 struct wmi_adaptive_dwelltime_params *dwelltime_params)
5714{
5715 wmi_scan_adaptive_dwell_config_fixed_param *dwell_param;
5716 wmi_scan_adaptive_dwell_parameters_tlv *cmd;
5717 wmi_buf_t buf;
5718 uint8_t *buf_ptr;
5719 int32_t err;
5720 int len;
5721
5722 len = sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5723 len += WMI_TLV_HDR_SIZE; /* TLV for ext_thresholds*/
5724 len += sizeof(wmi_scan_adaptive_dwell_parameters_tlv);
5725 buf = wmi_buf_alloc(wmi_handle, len);
5726 if (!buf) {
5727 WMI_LOGE("%s :Failed to allocate buffer to send cmd",
5728 __func__);
5729 return QDF_STATUS_E_NOMEM;
5730 }
5731 buf_ptr = (uint8_t *) wmi_buf_data(buf);
5732 dwell_param = (wmi_scan_adaptive_dwell_config_fixed_param *) buf_ptr;
5733 WMITLV_SET_HDR(&dwell_param->tlv_header,
5734 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_config_fixed_param,
5735 WMITLV_GET_STRUCT_TLVLEN
5736 (wmi_scan_adaptive_dwell_config_fixed_param));
5737
5738 dwell_param->enable = dwelltime_params->is_enabled;
5739 buf_ptr += sizeof(wmi_scan_adaptive_dwell_config_fixed_param);
5740 WMITLV_SET_HDR(buf_ptr,
5741 WMITLV_TAG_ARRAY_STRUC,
5742 sizeof(wmi_scan_adaptive_dwell_parameters_tlv));
5743 buf_ptr += WMI_TLV_HDR_SIZE;
5744
5745 cmd = (wmi_scan_adaptive_dwell_parameters_tlv *) buf_ptr;
5746 WMITLV_SET_HDR(&cmd->tlv_header,
5747 WMITLV_TAG_STRUC_wmi_scan_adaptive_dwell_parameters_tlv,
5748 WMITLV_GET_STRUCT_TLVLEN(
5749 wmi_scan_adaptive_dwell_parameters_tlv));
5750
5751 cmd->default_adaptive_dwell_mode = dwelltime_params->dwelltime_mode;
5752 cmd->adapative_lpf_weight = dwelltime_params->lpf_weight;
5753 cmd->passive_monitor_interval_ms = dwelltime_params->passive_mon_intval;
5754 cmd->wifi_activity_threshold_pct = dwelltime_params->wifi_act_threshold;
5755 err = wmi_unified_cmd_send(wmi_handle, buf,
5756 len, WMI_SCAN_ADAPTIVE_DWELL_CONFIG_CMDID);
5757 if (err) {
5758 WMI_LOGE("Failed to send adapt dwelltime cmd err=%d", err);
5759 wmi_buf_free(buf);
5760 return QDF_STATUS_E_FAILURE;
5761 }
5762
5763 return QDF_STATUS_SUCCESS;
5764}
5765
5766
5767/**
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305768 * send_roam_scan_filter_cmd_tlv() - Filter to be applied while roaming
5769 * @wmi_handle: wmi handle
5770 * @roam_req: Request which contains the filters
5771 *
5772 * There are filters such as whitelist, blacklist and preferred
5773 * list that need to be applied to the scan results to form the
5774 * probable candidates for roaming.
5775 *
5776 * Return: Return success upon succesfully passing the
5777 * parameters to the firmware, otherwise failure.
5778 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305779static QDF_STATUS send_roam_scan_filter_cmd_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305780 struct roam_scan_filter_params *roam_req)
5781{
5782 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +05305783 QDF_STATUS status;
5784 uint32_t i;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305785 uint32_t len;
5786 uint8_t *buf_ptr;
5787 wmi_roam_filter_fixed_param *roam_filter;
5788 uint8_t *bssid_src_ptr = NULL;
5789 wmi_mac_addr *bssid_dst_ptr = NULL;
5790 wmi_ssid *ssid_ptr = NULL;
5791 uint32_t *bssid_preferred_factor_ptr = NULL;
5792
5793 len = sizeof(wmi_roam_filter_fixed_param);
5794 len += WMI_TLV_HDR_SIZE;
5795 len += roam_req->len;
5796
5797 buf = wmi_buf_alloc(wmi_handle, len);
5798 if (!buf) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305799 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305800 return QDF_STATUS_E_NOMEM;
5801 }
5802
5803 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
5804 roam_filter = (wmi_roam_filter_fixed_param *) buf_ptr;
5805 WMITLV_SET_HDR(&roam_filter->tlv_header,
5806 WMITLV_TAG_STRUC_wmi_roam_filter_fixed_param,
5807 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_filter_fixed_param));
5808 /* fill in fixed values */
5809 roam_filter->vdev_id = roam_req->session_id;
5810 roam_filter->flags = 0;
5811 roam_filter->op_bitmap = roam_req->op_bitmap;
5812 roam_filter->num_bssid_black_list = roam_req->num_bssid_black_list;
5813 roam_filter->num_ssid_white_list = roam_req->num_ssid_white_list;
5814 roam_filter->num_bssid_preferred_list =
5815 roam_req->num_bssid_preferred_list;
5816 buf_ptr += sizeof(wmi_roam_filter_fixed_param);
5817
5818 WMITLV_SET_HDR((buf_ptr),
5819 WMITLV_TAG_ARRAY_FIXED_STRUC,
5820 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr)));
5821 bssid_src_ptr = (uint8_t *)&roam_req->bssid_avoid_list;
5822 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5823 for (i = 0; i < roam_req->num_bssid_black_list; i++) {
5824 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr, bssid_dst_ptr);
5825 bssid_src_ptr += ATH_MAC_LEN;
5826 bssid_dst_ptr++;
5827 }
5828 buf_ptr += WMI_TLV_HDR_SIZE +
5829 (roam_req->num_bssid_black_list * sizeof(wmi_mac_addr));
5830 WMITLV_SET_HDR((buf_ptr),
5831 WMITLV_TAG_ARRAY_FIXED_STRUC,
5832 (roam_req->num_ssid_white_list * sizeof(wmi_ssid)));
5833 ssid_ptr = (wmi_ssid *)(buf_ptr + WMI_TLV_HDR_SIZE);
5834 for (i = 0; i < roam_req->num_ssid_white_list; i++) {
5835 qdf_mem_copy(&ssid_ptr->ssid,
5836 &roam_req->ssid_allowed_list[i].mac_ssid,
5837 roam_req->ssid_allowed_list[i].length);
5838 ssid_ptr->ssid_len = roam_req->ssid_allowed_list[i].length;
5839 ssid_ptr++;
5840 }
5841 buf_ptr += WMI_TLV_HDR_SIZE + (roam_req->num_ssid_white_list *
5842 sizeof(wmi_ssid));
5843 WMITLV_SET_HDR((buf_ptr),
5844 WMITLV_TAG_ARRAY_FIXED_STRUC,
5845 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr)));
5846 bssid_src_ptr = (uint8_t *)&roam_req->bssid_favored;
5847 bssid_dst_ptr = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
5848 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5849 WMI_CHAR_ARRAY_TO_MAC_ADDR(bssid_src_ptr,
5850 (wmi_mac_addr *)bssid_dst_ptr);
5851 bssid_src_ptr += ATH_MAC_LEN;
5852 bssid_dst_ptr++;
5853 }
5854 buf_ptr += WMI_TLV_HDR_SIZE +
5855 (roam_req->num_bssid_preferred_list * sizeof(wmi_mac_addr));
5856 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
5857 (roam_req->num_bssid_preferred_list * sizeof(uint32_t)));
5858 bssid_preferred_factor_ptr = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
5859 for (i = 0; i < roam_req->num_bssid_preferred_list; i++) {
5860 *bssid_preferred_factor_ptr =
5861 roam_req->bssid_favored_factor[i];
5862 bssid_preferred_factor_ptr++;
5863 }
5864 buf_ptr += WMI_TLV_HDR_SIZE +
5865 (roam_req->num_bssid_preferred_list * sizeof(uint32_t));
5866
5867 status = wmi_unified_cmd_send(wmi_handle, buf,
5868 len, WMI_ROAM_FILTER_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05305869 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhe7f2f342016-05-23 12:12:52 +05305870 WMI_LOGE("cmd WMI_ROAM_FILTER_CMDID returned Error %d",
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305871 status);
5872 wmi_buf_free(buf);
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305873 }
Govind Singh67922e82016-04-01 16:48:57 +05305874
5875 return status;
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +05305876}
5877
Govind Singh4eacd2b2016-03-07 14:24:22 +05305878/** send_set_epno_network_list_cmd_tlv() - set epno network list
5879 * @wmi_handle: wmi handle
5880 * @req: epno config params request structure
5881 *
5882 * This function reads the incoming epno config request structure
5883 * and constructs the WMI message to the firmware.
5884 *
5885 * Returns: 0 on success, error number otherwise
5886 */
Sathish Kumarfd347372017-02-13 12:29:09 +05305887static QDF_STATUS send_set_epno_network_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05305888 struct wifi_enhanched_pno_params *req)
5889{
5890 wmi_nlo_config_cmd_fixed_param *cmd;
5891 nlo_configured_parameters *nlo_list;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305892 enlo_candidate_score_params *cand_score_params;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305893 u_int8_t i, *buf_ptr;
5894 wmi_buf_t buf;
5895 uint32_t len;
Govind Singh67922e82016-04-01 16:48:57 +05305896 QDF_STATUS ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305897
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305898 /* Fixed Params */
5899 len = sizeof(*cmd);
5900 if (req->num_networks) {
5901 /* TLV place holder for array of structures
5902 * then each nlo_configured_parameters(nlo_list) TLV.
5903 */
5904 len += WMI_TLV_HDR_SIZE;
5905 len += (sizeof(nlo_configured_parameters)
5906 * QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS));
5907 /* TLV for array of uint32 channel_list */
5908 len += WMI_TLV_HDR_SIZE;
5909 /* TLV for nlo_channel_prediction_cfg */
5910 len += WMI_TLV_HDR_SIZE;
5911 /* TLV for candidate score params */
5912 len += sizeof(enlo_candidate_score_params);
5913 }
Govind Singh4eacd2b2016-03-07 14:24:22 +05305914
5915 buf = wmi_buf_alloc(wmi_handle, len);
5916 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05305917 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
5918 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305919 }
5920
5921 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
5922
5923 buf_ptr = (u_int8_t *) cmd;
5924 WMITLV_SET_HDR(&cmd->tlv_header,
5925 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
5926 WMITLV_GET_STRUCT_TLVLEN(
5927 wmi_nlo_config_cmd_fixed_param));
5928 cmd->vdev_id = req->session_id;
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305929
5930 /* set flag to reset if num of networks are 0 */
5931 cmd->flags = (req->num_networks == 0 ?
5932 WMI_NLO_CONFIG_ENLO_RESET : WMI_NLO_CONFIG_ENLO);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305933
5934 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
5935
Govind Singhb53420c2016-03-09 14:32:57 +05305936 cmd->no_of_ssids = QDF_MIN(req->num_networks, WMI_NLO_MAX_SSIDS);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305937 WMI_LOGD("SSID count: %d flags: %d",
5938 cmd->no_of_ssids, cmd->flags);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305939
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305940 /* Fill nlo_config only when num_networks are non zero */
5941 if (cmd->no_of_ssids) {
5942 /* Fill networks */
5943 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
5944 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
5945 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05305946
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305947 nlo_list = (nlo_configured_parameters *) buf_ptr;
5948 for (i = 0; i < cmd->no_of_ssids; i++) {
5949 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
5950 WMITLV_TAG_ARRAY_BYTE,
5951 WMITLV_GET_STRUCT_TLVLEN(
5952 nlo_configured_parameters));
5953 /* Copy ssid and it's length */
5954 nlo_list[i].ssid.valid = true;
5955 nlo_list[i].ssid.ssid.ssid_len =
5956 req->networks[i].ssid.length;
5957 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
5958 req->networks[i].ssid.mac_ssid,
5959 nlo_list[i].ssid.ssid.ssid_len);
5960 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
5961 nlo_list[i].ssid.ssid.ssid_len,
5962 (char *) nlo_list[i].ssid.ssid.ssid,
5963 nlo_list[i].ssid.ssid.ssid_len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05305964
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305965 /* Copy pno flags */
5966 nlo_list[i].bcast_nw_type.valid = true;
5967 nlo_list[i].bcast_nw_type.bcast_nw_type =
5968 req->networks[i].flags;
5969 WMI_LOGD("PNO flags (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05305970 nlo_list[i].bcast_nw_type.bcast_nw_type);
5971
Mukul Sharmabf3bc652016-10-03 15:04:20 +05305972 /* Copy auth bit field */
5973 nlo_list[i].auth_type.valid = true;
5974 nlo_list[i].auth_type.auth_type =
5975 req->networks[i].auth_bit_field;
5976 WMI_LOGD("Auth bit field (%u)",
5977 nlo_list[i].auth_type.auth_type);
5978 }
5979
5980 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
5981 /* Fill the channel list */
5982 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
5983 buf_ptr += WMI_TLV_HDR_SIZE;
5984
5985 /* Fill prediction_param */
5986 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
5987 buf_ptr += WMI_TLV_HDR_SIZE;
5988
5989 /* Fill epno candidate score params */
5990 cand_score_params = (enlo_candidate_score_params *) buf_ptr;
5991 WMITLV_SET_HDR(buf_ptr,
5992 WMITLV_TAG_STRUC_enlo_candidate_score_param,
5993 WMITLV_GET_STRUCT_TLVLEN(enlo_candidate_score_params));
5994 cand_score_params->min5GHz_rssi =
5995 req->min_5ghz_rssi;
5996 cand_score_params->min24GHz_rssi =
5997 req->min_24ghz_rssi;
5998 cand_score_params->initial_score_max =
5999 req->initial_score_max;
6000 cand_score_params->current_connection_bonus =
6001 req->current_connection_bonus;
6002 cand_score_params->same_network_bonus =
6003 req->same_network_bonus;
6004 cand_score_params->secure_bonus =
6005 req->secure_bonus;
6006 cand_score_params->band5GHz_bonus =
6007 req->band_5ghz_bonus;
6008 buf_ptr += sizeof(enlo_candidate_score_params);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306009 }
6010
Govind Singh4eacd2b2016-03-07 14:24:22 +05306011 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306012 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05306013 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306014 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306015 wmi_buf_free(buf);
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306016 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306017 }
6018
Govind Singhb53420c2016-03-09 14:32:57 +05306019 WMI_LOGD("set ePNO list request sent successfully for vdev %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306020 req->session_id);
6021
Govind Singh67922e82016-04-01 16:48:57 +05306022 return ret;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306023}
6024
Mukul Sharmabf3bc652016-10-03 15:04:20 +05306025
Govind Singh4eacd2b2016-03-07 14:24:22 +05306026/** send_ipa_offload_control_cmd_tlv() - ipa offload control parameter
6027 * @wmi_handle: wmi handle
6028 * @ipa_offload: ipa offload control parameter
6029 *
6030 * Returns: 0 on success, error number otherwise
6031 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306032static QDF_STATUS send_ipa_offload_control_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306033 struct ipa_offload_control_params *ipa_offload)
6034{
6035 wmi_ipa_offload_enable_disable_cmd_fixed_param *cmd;
6036 wmi_buf_t wmi_buf;
6037 uint32_t len;
6038 u_int8_t *buf_ptr;
6039
6040 len = sizeof(*cmd);
6041 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6042 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306043 WMI_LOGE("%s: wmi_buf_alloc failed (len=%d)", __func__, len);
6044 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306045 }
6046
Govind Singhb53420c2016-03-09 14:32:57 +05306047 WMI_LOGE("%s: offload_type=%d, enable=%d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306048 ipa_offload->offload_type, ipa_offload->enable);
6049
6050 buf_ptr = (u_int8_t *)wmi_buf_data(wmi_buf);
6051
6052 cmd = (wmi_ipa_offload_enable_disable_cmd_fixed_param *)buf_ptr;
6053 WMITLV_SET_HDR(&cmd->tlv_header,
6054 WMITLV_TAG_STRUCT_wmi_ipa_offload_enable_disable_cmd_fixed_param,
6055 WMITLV_GET_STRUCT_TLVLEN(
6056 wmi_ipa_offload_enable_disable_cmd_fixed_param));
6057
6058 cmd->offload_type = ipa_offload->offload_type;
6059 cmd->vdev_id = ipa_offload->vdev_id;
6060 cmd->enable = ipa_offload->enable;
6061
6062 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6063 WMI_IPA_OFFLOAD_ENABLE_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306064 WMI_LOGE("%s: failed to command", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306065 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306066 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306067 }
6068
Govind Singhb53420c2016-03-09 14:32:57 +05306069 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306070}
6071
6072/**
6073 * send_extscan_get_capabilities_cmd_tlv() - extscan get capabilities
6074 * @wmi_handle: wmi handle
6075 * @pgetcapab: get capabilities params
6076 *
6077 * This function send request to fw to get extscan capabilities.
6078 *
6079 * Return: CDF status
6080 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306081static QDF_STATUS send_extscan_get_capabilities_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306082 struct extscan_capabilities_params *pgetcapab)
6083{
6084 wmi_extscan_get_capabilities_cmd_fixed_param *cmd;
6085 wmi_buf_t wmi_buf;
6086 uint32_t len;
6087 uint8_t *buf_ptr;
6088
6089 len = sizeof(*cmd);
6090 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6091 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306092 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6093 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306094 }
6095 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6096
6097 cmd = (wmi_extscan_get_capabilities_cmd_fixed_param *) buf_ptr;
6098 WMITLV_SET_HDR(&cmd->tlv_header,
6099 WMITLV_TAG_STRUC_wmi_extscan_get_capabilities_cmd_fixed_param,
6100 WMITLV_GET_STRUCT_TLVLEN
6101 (wmi_extscan_get_capabilities_cmd_fixed_param));
6102
6103 cmd->request_id = pgetcapab->request_id;
6104
6105 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6106 WMI_EXTSCAN_GET_CAPABILITIES_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306107 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306108 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306109 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306110 }
Govind Singhb53420c2016-03-09 14:32:57 +05306111 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306112}
6113
6114/**
6115 * send_extscan_get_cached_results_cmd_tlv() - extscan get cached results
6116 * @wmi_handle: wmi handle
6117 * @pcached_results: cached results parameters
6118 *
6119 * This function send request to fw to get cached results.
6120 *
6121 * Return: CDF status
6122 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306123static QDF_STATUS send_extscan_get_cached_results_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306124 struct extscan_cached_result_params *pcached_results)
6125{
6126 wmi_extscan_get_cached_results_cmd_fixed_param *cmd;
6127 wmi_buf_t wmi_buf;
6128 uint32_t len;
6129 uint8_t *buf_ptr;
6130
6131 len = sizeof(*cmd);
6132 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6133 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306134 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6135 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306136 }
6137 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6138
6139 cmd = (wmi_extscan_get_cached_results_cmd_fixed_param *) buf_ptr;
6140 WMITLV_SET_HDR(&cmd->tlv_header,
6141 WMITLV_TAG_STRUC_wmi_extscan_get_cached_results_cmd_fixed_param,
6142 WMITLV_GET_STRUCT_TLVLEN
6143 (wmi_extscan_get_cached_results_cmd_fixed_param));
6144
6145 cmd->request_id = pcached_results->request_id;
6146 cmd->vdev_id = pcached_results->session_id;
6147 cmd->control_flags = pcached_results->flush;
6148
6149 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6150 WMI_EXTSCAN_GET_CACHED_RESULTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306151 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306152 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306153 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306154 }
Govind Singhb53420c2016-03-09 14:32:57 +05306155 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306156}
6157
6158/**
6159 * send_extscan_stop_change_monitor_cmd_tlv() - send stop change monitor cmd
6160 * @wmi_handle: wmi handle
6161 * @reset_req: Reset change request params
6162 *
6163 * This function sends stop change monitor request to fw.
6164 *
6165 * Return: CDF status
6166 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306167static QDF_STATUS send_extscan_stop_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306168 struct extscan_capabilities_reset_params *reset_req)
6169{
6170 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6171 wmi_buf_t wmi_buf;
6172 uint32_t len;
6173 uint8_t *buf_ptr;
6174 int change_list = 0;
6175
6176 len = sizeof(*cmd);
6177
6178 /* reset significant change tlv is set to 0 */
6179 len += WMI_TLV_HDR_SIZE;
6180 len += change_list * sizeof(wmi_extscan_wlan_change_bssid_param);
6181 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6182 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306183 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6184 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306185 }
6186 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6187
6188 cmd = (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6189 buf_ptr;
6190 WMITLV_SET_HDR(&cmd->tlv_header,
6191 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6192 WMITLV_GET_STRUCT_TLVLEN
6193 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6194
6195 cmd->request_id = reset_req->request_id;
6196 cmd->vdev_id = reset_req->session_id;
6197 cmd->mode = 0;
6198
6199 buf_ptr += sizeof(*cmd);
6200 WMITLV_SET_HDR(buf_ptr,
6201 WMITLV_TAG_ARRAY_STRUC,
6202 change_list *
6203 sizeof(wmi_extscan_wlan_change_bssid_param));
6204 buf_ptr += WMI_TLV_HDR_SIZE + (change_list *
6205 sizeof
6206 (wmi_extscan_wlan_change_bssid_param));
6207
6208 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6209 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306210 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306211 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306212 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306213 }
Govind Singhb53420c2016-03-09 14:32:57 +05306214 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306215}
6216
6217/**
6218 * wmi_get_buf_extscan_change_monitor_cmd() - fill change monitor request
6219 * @wmi_handle: wmi handle
6220 * @psigchange: change monitor request params
6221 * @buf: wmi buffer
6222 * @buf_len: buffer length
6223 *
6224 * This function fills elements of change monitor request buffer.
6225 *
6226 * Return: CDF status
6227 */
Govind Singhb53420c2016-03-09 14:32:57 +05306228static QDF_STATUS wmi_get_buf_extscan_change_monitor_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306229 struct extscan_set_sig_changereq_params
6230 *psigchange, wmi_buf_t *buf, int *buf_len)
6231{
6232 wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *cmd;
6233 wmi_extscan_wlan_change_bssid_param *dest_chglist;
6234 uint8_t *buf_ptr;
6235 int j;
6236 int len = sizeof(*cmd);
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006237 uint32_t numap = psigchange->num_ap;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306238 struct ap_threshold_params *src_ap = psigchange->ap;
6239
Srinivas Girigowda4c777b42016-12-07 14:45:34 -08006240 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_SIGNIFICANT_CHANGE_APS)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306241 WMI_LOGE("%s: Invalid number of bssid's", __func__);
6242 return QDF_STATUS_E_INVAL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306243 }
6244 len += WMI_TLV_HDR_SIZE;
6245 len += numap * sizeof(wmi_extscan_wlan_change_bssid_param);
6246
6247 *buf = wmi_buf_alloc(wmi_handle, len);
6248 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306249 WMI_LOGP("%s: failed to allocate memory for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306250 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306251 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306252 }
6253 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6254 cmd =
6255 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param *)
6256 buf_ptr;
6257 WMITLV_SET_HDR(&cmd->tlv_header,
6258 WMITLV_TAG_STRUC_wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param,
6259 WMITLV_GET_STRUCT_TLVLEN
6260 (wmi_extscan_configure_wlan_change_monitor_cmd_fixed_param));
6261
6262 cmd->request_id = psigchange->request_id;
6263 cmd->vdev_id = psigchange->session_id;
6264 cmd->total_entries = numap;
6265 cmd->mode = 1;
6266 cmd->num_entries_in_page = numap;
6267 cmd->lost_ap_scan_count = psigchange->lostap_sample_size;
6268 cmd->max_rssi_samples = psigchange->rssi_sample_size;
6269 cmd->rssi_averaging_samples = psigchange->rssi_sample_size;
6270 cmd->max_out_of_range_count = psigchange->min_breaching;
6271
6272 buf_ptr += sizeof(*cmd);
6273 WMITLV_SET_HDR(buf_ptr,
6274 WMITLV_TAG_ARRAY_STRUC,
6275 numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6276 dest_chglist = (wmi_extscan_wlan_change_bssid_param *)
6277 (buf_ptr + WMI_TLV_HDR_SIZE);
6278
6279 for (j = 0; j < numap; j++) {
6280 WMITLV_SET_HDR(dest_chglist,
6281 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6282 WMITLV_GET_STRUCT_TLVLEN
6283 (wmi_extscan_wlan_change_bssid_param));
6284
6285 dest_chglist->lower_rssi_limit = src_ap->low;
6286 dest_chglist->upper_rssi_limit = src_ap->high;
6287 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
6288 &dest_chglist->bssid);
6289
Govind Singhb53420c2016-03-09 14:32:57 +05306290 WMI_LOGD("%s: min_rssi %d", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306291 dest_chglist->lower_rssi_limit);
6292 dest_chglist++;
6293 src_ap++;
6294 }
6295 buf_ptr += WMI_TLV_HDR_SIZE +
6296 (numap * sizeof(wmi_extscan_wlan_change_bssid_param));
6297 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306298 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306299}
6300
6301/**
6302 * send_extscan_start_change_monitor_cmd_tlv() - send start change monitor cmd
6303 * @wmi_handle: wmi handle
6304 * @psigchange: change monitor request params
6305 *
6306 * This function sends start change monitor request to fw.
6307 *
6308 * Return: CDF status
6309 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306310static QDF_STATUS send_extscan_start_change_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306311 struct extscan_set_sig_changereq_params *
6312 psigchange)
6313{
Govind Singhb53420c2016-03-09 14:32:57 +05306314 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306315 wmi_buf_t buf;
6316 int len;
6317
6318
Govind Singhb53420c2016-03-09 14:32:57 +05306319 qdf_status = wmi_get_buf_extscan_change_monitor_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306320 psigchange, &buf,
6321 &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306322 if (qdf_status != QDF_STATUS_SUCCESS) {
6323 WMI_LOGE("%s: Failed to get buffer for change monitor cmd",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306324 __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306325 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306326 }
6327 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306328 WMI_LOGE("%s: Failed to get buffer", __func__);
6329 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306330 }
6331 if (wmi_unified_cmd_send(wmi_handle, buf, len,
6332 WMI_EXTSCAN_CONFIGURE_WLAN_CHANGE_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306333 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306334 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306335 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306336 }
Govind Singhb53420c2016-03-09 14:32:57 +05306337 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306338}
6339
6340/**
6341 * send_extscan_stop_hotlist_monitor_cmd_tlv() - stop hotlist monitor
6342 * @wmi_handle: wmi handle
6343 * @photlist_reset: hotlist reset params
6344 *
6345 * This function configures hotlist monitor to stop in fw.
6346 *
6347 * Return: CDF status
6348 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306349static QDF_STATUS send_extscan_stop_hotlist_monitor_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306350 struct extscan_bssid_hotlist_reset_params *photlist_reset)
6351{
6352 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd;
6353 wmi_buf_t wmi_buf;
6354 uint32_t len;
6355 uint8_t *buf_ptr;
6356 int hotlist_entries = 0;
6357
6358 len = sizeof(*cmd);
6359
6360 /* reset bssid hotlist with tlv set to 0 */
6361 len += WMI_TLV_HDR_SIZE;
6362 len += hotlist_entries * sizeof(wmi_extscan_hotlist_entry);
6363
6364 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6365 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306366 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6367 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306368 }
6369
6370 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6371 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
6372 buf_ptr;
6373 WMITLV_SET_HDR(&cmd->tlv_header,
6374 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
6375 WMITLV_GET_STRUCT_TLVLEN
6376 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
6377
6378 cmd->request_id = photlist_reset->request_id;
6379 cmd->vdev_id = photlist_reset->session_id;
6380 cmd->mode = 0;
6381
6382 buf_ptr += sizeof(*cmd);
6383 WMITLV_SET_HDR(buf_ptr,
6384 WMITLV_TAG_ARRAY_STRUC,
6385 hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6386 buf_ptr += WMI_TLV_HDR_SIZE +
6387 (hotlist_entries * sizeof(wmi_extscan_hotlist_entry));
6388
6389 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6390 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306391 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306392 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306393 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306394 }
Govind Singhb53420c2016-03-09 14:32:57 +05306395 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306396}
6397
6398/**
6399 * send_stop_extscan_cmd_tlv() - stop extscan command to fw.
6400 * @wmi_handle: wmi handle
6401 * @pstopcmd: stop scan command request params
6402 *
6403 * This function sends stop extscan request to fw.
6404 *
6405 * Return: CDF Status.
6406 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306407static QDF_STATUS send_stop_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306408 struct extscan_stop_req_params *pstopcmd)
6409{
6410 wmi_extscan_stop_cmd_fixed_param *cmd;
6411 wmi_buf_t wmi_buf;
6412 uint32_t len;
6413 uint8_t *buf_ptr;
6414
6415 len = sizeof(*cmd);
6416 wmi_buf = wmi_buf_alloc(wmi_handle, len);
6417 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306418 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
6419 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306420 }
6421 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
6422 cmd = (wmi_extscan_stop_cmd_fixed_param *) buf_ptr;
6423 WMITLV_SET_HDR(&cmd->tlv_header,
6424 WMITLV_TAG_STRUC_wmi_extscan_stop_cmd_fixed_param,
6425 WMITLV_GET_STRUCT_TLVLEN
6426 (wmi_extscan_stop_cmd_fixed_param));
6427
6428 cmd->request_id = pstopcmd->request_id;
6429 cmd->vdev_id = pstopcmd->session_id;
6430
6431 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
6432 WMI_EXTSCAN_STOP_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306433 WMI_LOGE("%s: failed to command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306434 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306435 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306436 }
6437
Govind Singhb53420c2016-03-09 14:32:57 +05306438 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306439}
6440
6441/**
6442 * wmi_get_buf_extscan_start_cmd() - Fill extscan start request
6443 * @wmi_handle: wmi handle
6444 * @pstart: scan command request params
6445 * @buf: event buffer
6446 * @buf_len: length of buffer
6447 *
6448 * This function fills individual elements of extscan request and
6449 * TLV for buckets, channel list.
6450 *
6451 * Return: CDF Status.
6452 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -07006453static
Govind Singhb53420c2016-03-09 14:32:57 +05306454QDF_STATUS wmi_get_buf_extscan_start_cmd(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306455 struct wifi_scan_cmd_req_params *pstart,
6456 wmi_buf_t *buf, int *buf_len)
6457{
6458 wmi_extscan_start_cmd_fixed_param *cmd;
6459 wmi_extscan_bucket *dest_blist;
6460 wmi_extscan_bucket_channel *dest_clist;
6461 struct wifi_scan_bucket_params *src_bucket = pstart->buckets;
6462 struct wifi_scan_channelspec_params *src_channel = src_bucket->channels;
6463 struct wifi_scan_channelspec_params save_channel[WMI_WLAN_EXTSCAN_MAX_CHANNELS];
6464
6465 uint8_t *buf_ptr;
6466 int i, k, count = 0;
6467 int len = sizeof(*cmd);
6468 int nbuckets = pstart->numBuckets;
6469 int nchannels = 0;
6470
6471 /* These TLV's are are NULL by default */
6472 uint32_t ie_len_with_pad = 0;
6473 int num_ssid = 0;
6474 int num_bssid = 0;
6475 int ie_len = 0;
6476
6477 uint32_t base_period = pstart->basePeriod;
6478
6479 /* TLV placeholder for ssid_list (NULL) */
6480 len += WMI_TLV_HDR_SIZE;
6481 len += num_ssid * sizeof(wmi_ssid);
6482
6483 /* TLV placeholder for bssid_list (NULL) */
6484 len += WMI_TLV_HDR_SIZE;
6485 len += num_bssid * sizeof(wmi_mac_addr);
6486
6487 /* TLV placeholder for ie_data (NULL) */
6488 len += WMI_TLV_HDR_SIZE;
6489 len += ie_len * sizeof(uint32_t);
6490
6491 /* TLV placeholder for bucket */
6492 len += WMI_TLV_HDR_SIZE;
6493 len += nbuckets * sizeof(wmi_extscan_bucket);
6494
6495 /* TLV channel placeholder */
6496 len += WMI_TLV_HDR_SIZE;
6497 for (i = 0; i < nbuckets; i++) {
6498 nchannels += src_bucket->numChannels;
6499 src_bucket++;
6500 }
6501
Govind Singhb53420c2016-03-09 14:32:57 +05306502 WMI_LOGD("%s: Total buckets: %d total #of channels is %d",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306503 __func__, nbuckets, nchannels);
6504 len += nchannels * sizeof(wmi_extscan_bucket_channel);
6505 /* Allocate the memory */
6506 *buf = wmi_buf_alloc(wmi_handle, len);
6507 if (!*buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306508 WMI_LOGP("%s: failed to allocate memory"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306509 " for start extscan cmd", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306510 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306511 }
6512 buf_ptr = (uint8_t *) wmi_buf_data(*buf);
6513 cmd = (wmi_extscan_start_cmd_fixed_param *) buf_ptr;
6514 WMITLV_SET_HDR(&cmd->tlv_header,
6515 WMITLV_TAG_STRUC_wmi_extscan_start_cmd_fixed_param,
6516 WMITLV_GET_STRUCT_TLVLEN
6517 (wmi_extscan_start_cmd_fixed_param));
6518
6519 cmd->request_id = pstart->requestId;
6520 cmd->vdev_id = pstart->sessionId;
6521 cmd->base_period = pstart->basePeriod;
6522 cmd->num_buckets = nbuckets;
6523 cmd->configuration_flags = 0;
Govind Singh224a7312016-06-21 14:33:26 +05306524 if (pstart->configuration_flags & WMI_EXTSCAN_LP_EXTENDED_BATCHING)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306525 cmd->configuration_flags |= WMI_EXTSCAN_EXTENDED_BATCHING_EN;
Govind Singhb53420c2016-03-09 14:32:57 +05306526 WMI_LOGI("%s: configuration_flags: 0x%x", __func__,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306527 cmd->configuration_flags);
Govind Singh87542482016-06-08 19:40:11 +05306528#ifdef FEATURE_WLAN_EXTSCAN
Govind Singhb53420c2016-03-09 14:32:57 +05306529 cmd->min_rest_time = WMI_EXTSCAN_REST_TIME;
6530 cmd->max_rest_time = WMI_EXTSCAN_REST_TIME;
Govind Singh87542482016-06-08 19:40:11 +05306531 cmd->max_scan_time = WMI_EXTSCAN_MAX_SCAN_TIME;
6532 cmd->burst_duration = WMI_EXTSCAN_BURST_DURATION;
6533#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05306534 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6535
6536 /* The max dwell time is retrieved from the first channel
6537 * of the first bucket and kept common for all channels.
6538 */
6539 cmd->min_dwell_time_active = pstart->min_dwell_time_active;
6540 cmd->max_dwell_time_active = pstart->max_dwell_time_active;
6541 cmd->min_dwell_time_passive = pstart->min_dwell_time_passive;
6542 cmd->max_dwell_time_passive = pstart->max_dwell_time_passive;
6543 cmd->max_bssids_per_scan_cycle = pstart->maxAPperScan;
6544 cmd->max_table_usage = pstart->report_threshold_percent;
6545 cmd->report_threshold_num_scans = pstart->report_threshold_num_scans;
6546
6547 cmd->repeat_probe_time = cmd->max_dwell_time_active /
Govind Singhb53420c2016-03-09 14:32:57 +05306548 WMI_SCAN_NPROBES_DEFAULT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306549 cmd->probe_delay = 0;
6550 cmd->probe_spacing_time = 0;
6551 cmd->idle_time = 0;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306552 cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
6553 WMI_SCAN_ADD_CCK_RATES |
6554 WMI_SCAN_ADD_OFDM_RATES |
6555 WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
6556 WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
Gupta, Kapil2e685982016-04-25 19:14:19 +05306557 WMI_SCAN_SET_DWELL_MODE(cmd->scan_ctrl_flags,
6558 pstart->extscan_adaptive_dwell_mode);
Kapil Gupta4a95ef22016-09-29 18:07:01 +05306559 cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306560 cmd->num_ssids = 0;
6561 cmd->num_bssid = 0;
6562 cmd->ie_len = 0;
6563 cmd->n_probes = (cmd->repeat_probe_time > 0) ?
6564 cmd->max_dwell_time_active / cmd->repeat_probe_time : 0;
6565
6566 buf_ptr += sizeof(*cmd);
6567 WMITLV_SET_HDR(buf_ptr,
6568 WMITLV_TAG_ARRAY_FIXED_STRUC,
6569 num_ssid * sizeof(wmi_ssid));
6570 buf_ptr += WMI_TLV_HDR_SIZE + (num_ssid * sizeof(wmi_ssid));
6571
6572 WMITLV_SET_HDR(buf_ptr,
6573 WMITLV_TAG_ARRAY_FIXED_STRUC,
6574 num_bssid * sizeof(wmi_mac_addr));
6575 buf_ptr += WMI_TLV_HDR_SIZE + (num_bssid * sizeof(wmi_mac_addr));
6576
6577 ie_len_with_pad = 0;
6578 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
6579 ie_len_with_pad);
6580 buf_ptr += WMI_TLV_HDR_SIZE + ie_len_with_pad;
6581
6582 WMITLV_SET_HDR(buf_ptr,
6583 WMITLV_TAG_ARRAY_STRUC,
6584 nbuckets * sizeof(wmi_extscan_bucket));
6585 dest_blist = (wmi_extscan_bucket *)
6586 (buf_ptr + WMI_TLV_HDR_SIZE);
6587 src_bucket = pstart->buckets;
6588
6589 /* Retrieve scanning information from each bucket and
6590 * channels and send it to the target
6591 */
6592 for (i = 0; i < nbuckets; i++) {
6593 WMITLV_SET_HDR(dest_blist,
6594 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
6595 WMITLV_GET_STRUCT_TLVLEN(wmi_extscan_bucket));
6596
6597 dest_blist->bucket_id = src_bucket->bucket;
6598 dest_blist->base_period_multiplier =
6599 src_bucket->period / base_period;
6600 dest_blist->min_period = src_bucket->period;
6601 dest_blist->max_period = src_bucket->max_period;
6602 dest_blist->exp_backoff = src_bucket->exponent;
6603 dest_blist->exp_max_step_count = src_bucket->step_count;
6604 dest_blist->channel_band = src_bucket->band;
6605 dest_blist->num_channels = src_bucket->numChannels;
6606 dest_blist->notify_extscan_events = 0;
6607
6608 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_EACH_SCAN)
6609 dest_blist->notify_extscan_events =
Deepak Dhamdhere583283c2016-09-02 00:03:12 -07006610 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT |
6611 WMI_EXTSCAN_CYCLE_STARTED_EVENT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306612
6613 if (src_bucket->reportEvents &
6614 WMI_EXTSCAN_REPORT_EVENTS_FULL_RESULTS) {
6615 dest_blist->forwarding_flags =
6616 WMI_EXTSCAN_FORWARD_FRAME_TO_HOST;
6617 dest_blist->notify_extscan_events |=
6618 WMI_EXTSCAN_BUCKET_COMPLETED_EVENT |
6619 WMI_EXTSCAN_CYCLE_STARTED_EVENT |
6620 WMI_EXTSCAN_CYCLE_COMPLETED_EVENT;
6621 } else {
6622 dest_blist->forwarding_flags =
6623 WMI_EXTSCAN_NO_FORWARDING;
6624 }
6625
6626 if (src_bucket->reportEvents & WMI_EXTSCAN_REPORT_EVENTS_NO_BATCH)
6627 dest_blist->configuration_flags = 0;
6628 else
6629 dest_blist->configuration_flags =
6630 WMI_EXTSCAN_BUCKET_CACHE_RESULTS;
6631
Govind Singhb53420c2016-03-09 14:32:57 +05306632 WMI_LOGI("%s: ntfy_extscan_events:%u cfg_flags:%u fwd_flags:%u",
Govind Singh4eacd2b2016-03-07 14:24:22 +05306633 __func__, dest_blist->notify_extscan_events,
6634 dest_blist->configuration_flags,
6635 dest_blist->forwarding_flags);
6636
6637 dest_blist->min_dwell_time_active =
6638 src_bucket->min_dwell_time_active;
6639 dest_blist->max_dwell_time_active =
6640 src_bucket->max_dwell_time_active;
6641 dest_blist->min_dwell_time_passive =
6642 src_bucket->min_dwell_time_passive;
6643 dest_blist->max_dwell_time_passive =
6644 src_bucket->max_dwell_time_passive;
6645 src_channel = src_bucket->channels;
6646
6647 /* save the channel info to later populate
6648 * the channel TLV
6649 */
6650 for (k = 0; k < src_bucket->numChannels; k++) {
6651 save_channel[count++].channel = src_channel->channel;
6652 src_channel++;
6653 }
6654 dest_blist++;
6655 src_bucket++;
6656 }
6657 buf_ptr += WMI_TLV_HDR_SIZE + (nbuckets * sizeof(wmi_extscan_bucket));
6658 WMITLV_SET_HDR(buf_ptr,
6659 WMITLV_TAG_ARRAY_STRUC,
6660 nchannels * sizeof(wmi_extscan_bucket_channel));
6661 dest_clist = (wmi_extscan_bucket_channel *)
6662 (buf_ptr + WMI_TLV_HDR_SIZE);
6663
6664 /* Active or passive scan is based on the bucket dwell time
6665 * and channel specific active,passive scans are not
6666 * supported yet
6667 */
6668 for (i = 0; i < nchannels; i++) {
6669 WMITLV_SET_HDR(dest_clist,
6670 WMITLV_TAG_STRUC_wmi_extscan_bucket_channel_event_fixed_param,
6671 WMITLV_GET_STRUCT_TLVLEN
6672 (wmi_extscan_bucket_channel));
6673 dest_clist->channel = save_channel[i].channel;
6674 dest_clist++;
6675 }
6676 buf_ptr += WMI_TLV_HDR_SIZE +
6677 (nchannels * sizeof(wmi_extscan_bucket_channel));
6678 *buf_len = len;
Govind Singhb53420c2016-03-09 14:32:57 +05306679 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306680}
6681
6682/**
6683 * send_start_extscan_cmd_tlv() - start extscan command to fw.
6684 * @wmi_handle: wmi handle
6685 * @pstart: scan command request params
6686 *
6687 * This function sends start extscan request to fw.
6688 *
6689 * Return: CDF Status.
6690 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306691static QDF_STATUS send_start_extscan_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306692 struct wifi_scan_cmd_req_params *pstart)
6693{
Govind Singhb53420c2016-03-09 14:32:57 +05306694 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306695 wmi_buf_t buf;
6696 int len;
6697
6698 /* Fill individual elements of extscan request and
6699 * TLV for buckets, channel list.
6700 */
Govind Singhb53420c2016-03-09 14:32:57 +05306701 qdf_status = wmi_get_buf_extscan_start_cmd(wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306702 pstart, &buf, &len);
Govind Singhb53420c2016-03-09 14:32:57 +05306703 if (qdf_status != QDF_STATUS_SUCCESS) {
6704 WMI_LOGE("%s: Failed to get buffer for ext scan cmd", __func__);
6705 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306706 }
6707 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306708 WMI_LOGE("%s:Failed to get buffer"
Govind Singh4eacd2b2016-03-07 14:24:22 +05306709 "for current extscan info", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +05306710 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306711 }
6712 if (wmi_unified_cmd_send(wmi_handle, buf,
6713 len, WMI_EXTSCAN_START_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05306714 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05306715 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306716 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306717 }
6718
Govind Singhb53420c2016-03-09 14:32:57 +05306719 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306720}
6721
6722/**
6723 * send_plm_stop_cmd_tlv() - plm stop request
6724 * @wmi_handle: wmi handle
6725 * @plm: plm request parameters
6726 *
6727 * This function request FW to stop PLM.
6728 *
6729 * Return: CDF status
6730 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306731static QDF_STATUS send_plm_stop_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306732 const struct plm_req_params *plm)
6733{
6734 wmi_vdev_plmreq_stop_cmd_fixed_param *cmd;
6735 int32_t len;
6736 wmi_buf_t buf;
6737 uint8_t *buf_ptr;
6738 int ret;
6739
6740 len = sizeof(*cmd);
6741 buf = wmi_buf_alloc(wmi_handle, len);
6742 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306743 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6744 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306745 }
6746
6747 cmd = (wmi_vdev_plmreq_stop_cmd_fixed_param *) wmi_buf_data(buf);
6748
6749 buf_ptr = (uint8_t *) cmd;
6750
6751 WMITLV_SET_HDR(&cmd->tlv_header,
6752 WMITLV_TAG_STRUC_wmi_vdev_plmreq_stop_cmd_fixed_param,
6753 WMITLV_GET_STRUCT_TLVLEN
6754 (wmi_vdev_plmreq_stop_cmd_fixed_param));
6755
6756 cmd->vdev_id = plm->session_id;
6757
6758 cmd->meas_token = plm->meas_token;
Govind Singhb53420c2016-03-09 14:32:57 +05306759 WMI_LOGD("vdev %d meas token %d", cmd->vdev_id, cmd->meas_token);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306760
6761 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6762 WMI_VDEV_PLMREQ_STOP_CMDID);
6763 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306764 WMI_LOGE("%s: Failed to send plm stop wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306765 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306766 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306767 }
6768
Govind Singhb53420c2016-03-09 14:32:57 +05306769 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306770}
6771
6772/**
6773 * send_plm_start_cmd_tlv() - plm start request
6774 * @wmi_handle: wmi handle
6775 * @plm: plm request parameters
6776 *
6777 * This function request FW to start PLM.
6778 *
6779 * Return: CDF status
6780 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306781static QDF_STATUS send_plm_start_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306782 const struct plm_req_params *plm,
6783 uint32_t *gchannel_list)
6784{
6785 wmi_vdev_plmreq_start_cmd_fixed_param *cmd;
6786 uint32_t *channel_list;
6787 int32_t len;
6788 wmi_buf_t buf;
6789 uint8_t *buf_ptr;
6790 uint8_t count;
6791 int ret;
6792
6793 /* TLV place holder for channel_list */
6794 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
6795 len += sizeof(uint32_t) * plm->plm_num_ch;
6796
6797 buf = wmi_buf_alloc(wmi_handle, len);
6798 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306799 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6800 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306801 }
6802 cmd = (wmi_vdev_plmreq_start_cmd_fixed_param *) wmi_buf_data(buf);
6803
6804 buf_ptr = (uint8_t *) cmd;
6805
6806 WMITLV_SET_HDR(&cmd->tlv_header,
6807 WMITLV_TAG_STRUC_wmi_vdev_plmreq_start_cmd_fixed_param,
6808 WMITLV_GET_STRUCT_TLVLEN
6809 (wmi_vdev_plmreq_start_cmd_fixed_param));
6810
6811 cmd->vdev_id = plm->session_id;
6812
6813 cmd->meas_token = plm->meas_token;
6814 cmd->dialog_token = plm->diag_token;
6815 cmd->number_bursts = plm->num_bursts;
Govind Singhb53420c2016-03-09 14:32:57 +05306816 cmd->burst_interval = WMI_SEC_TO_MSEC(plm->burst_int);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306817 cmd->off_duration = plm->meas_duration;
6818 cmd->burst_cycle = plm->burst_len;
6819 cmd->tx_power = plm->desired_tx_pwr;
6820 WMI_CHAR_ARRAY_TO_MAC_ADDR(plm->mac_addr.bytes, &cmd->dest_mac);
6821 cmd->num_chans = plm->plm_num_ch;
6822
6823 buf_ptr += sizeof(wmi_vdev_plmreq_start_cmd_fixed_param);
6824
Govind Singhb53420c2016-03-09 14:32:57 +05306825 WMI_LOGD("vdev : %d measu token : %d", cmd->vdev_id, cmd->meas_token);
6826 WMI_LOGD("dialog_token: %d", cmd->dialog_token);
6827 WMI_LOGD("number_bursts: %d", cmd->number_bursts);
6828 WMI_LOGD("burst_interval: %d", cmd->burst_interval);
6829 WMI_LOGD("off_duration: %d", cmd->off_duration);
6830 WMI_LOGD("burst_cycle: %d", cmd->burst_cycle);
6831 WMI_LOGD("tx_power: %d", cmd->tx_power);
6832 WMI_LOGD("Number of channels : %d", cmd->num_chans);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306833
6834 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
6835 (cmd->num_chans * sizeof(uint32_t)));
6836
6837 buf_ptr += WMI_TLV_HDR_SIZE;
6838 if (cmd->num_chans) {
6839 channel_list = (uint32_t *) buf_ptr;
6840 for (count = 0; count < cmd->num_chans; count++) {
6841 channel_list[count] = plm->plm_ch_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306842 if (channel_list[count] < WMI_NLO_FREQ_THRESH)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306843 channel_list[count] =
6844 gchannel_list[count];
Govind Singhb53420c2016-03-09 14:32:57 +05306845 WMI_LOGD("Ch[%d]: %d MHz", count, channel_list[count]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306846 }
6847 buf_ptr += cmd->num_chans * sizeof(uint32_t);
6848 }
6849
6850 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6851 WMI_VDEV_PLMREQ_START_CMDID);
6852 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306853 WMI_LOGE("%s: Failed to send plm start wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306854 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306855 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306856 }
6857
Govind Singhb53420c2016-03-09 14:32:57 +05306858 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306859}
6860
6861/**
6862 * send_pno_stop_cmd_tlv() - PNO stop request
6863 * @wmi_handle: wmi handle
6864 * @vdev_id: vdev id
6865 *
6866 * This function request FW to stop ongoing PNO operation.
6867 *
6868 * Return: CDF status
6869 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306870static QDF_STATUS send_pno_stop_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306871{
6872 wmi_nlo_config_cmd_fixed_param *cmd;
6873 int32_t len = sizeof(*cmd);
6874 wmi_buf_t buf;
6875 uint8_t *buf_ptr;
6876 int ret;
6877
6878 /*
6879 * TLV place holder for array of structures nlo_configured_parameters
6880 * TLV place holder for array of uint32_t channel_list
6881 * TLV place holder for chnl prediction cfg
6882 */
6883 len += WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6884 buf = wmi_buf_alloc(wmi_handle, len);
6885 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306886 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6887 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306888 }
6889
6890 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6891 buf_ptr = (uint8_t *) cmd;
6892
6893 WMITLV_SET_HDR(&cmd->tlv_header,
6894 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
6895 WMITLV_GET_STRUCT_TLVLEN
6896 (wmi_nlo_config_cmd_fixed_param));
6897
6898 cmd->vdev_id = vdev_id;
6899 cmd->flags = WMI_NLO_CONFIG_STOP;
6900 buf_ptr += sizeof(*cmd);
6901
6902 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6903 buf_ptr += WMI_TLV_HDR_SIZE;
6904
6905 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
6906 buf_ptr += WMI_TLV_HDR_SIZE;
6907
6908 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
6909 buf_ptr += WMI_TLV_HDR_SIZE;
6910
6911
6912 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
6913 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
6914 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05306915 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306916 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05306917 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306918 }
6919
Govind Singhb53420c2016-03-09 14:32:57 +05306920 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306921}
6922
6923/**
Govind Singhccb0c272016-04-01 16:30:08 +05306924 * wmi_set_pno_channel_prediction() - Set PNO channel prediction
6925 * @buf_ptr: Buffer passed by upper layers
6926 * @pno: Buffer to be sent to the firmware
6927 *
6928 * Copy the PNO Channel prediction configuration parameters
6929 * passed by the upper layers to a WMI format TLV and send it
6930 * down to the firmware.
6931 *
6932 * Return: None
6933 */
6934static void wmi_set_pno_channel_prediction(uint8_t *buf_ptr,
6935 struct pno_scan_req_params *pno)
6936{
6937 nlo_channel_prediction_cfg *channel_prediction_cfg =
6938 (nlo_channel_prediction_cfg *) buf_ptr;
6939 WMITLV_SET_HDR(&channel_prediction_cfg->tlv_header,
6940 WMITLV_TAG_ARRAY_BYTE,
6941 WMITLV_GET_STRUCT_TLVLEN(nlo_channel_prediction_cfg));
Govind Singh87542482016-06-08 19:40:11 +05306942#ifdef FEATURE_WLAN_SCAN_PNO
Govind Singhccb0c272016-04-01 16:30:08 +05306943 channel_prediction_cfg->enable = pno->pno_channel_prediction;
6944 channel_prediction_cfg->top_k_num = pno->top_k_num_of_channels;
6945 channel_prediction_cfg->stationary_threshold = pno->stationary_thresh;
6946 channel_prediction_cfg->full_scan_period_ms =
6947 pno->channel_prediction_full_scan;
Govind Singh87542482016-06-08 19:40:11 +05306948#endif
Govind Singhccb0c272016-04-01 16:30:08 +05306949 buf_ptr += sizeof(nlo_channel_prediction_cfg);
6950 WMI_LOGD("enable: %d, top_k_num: %d, stat_thresh: %d, full_scan: %d",
6951 channel_prediction_cfg->enable,
6952 channel_prediction_cfg->top_k_num,
6953 channel_prediction_cfg->stationary_threshold,
6954 channel_prediction_cfg->full_scan_period_ms);
6955}
6956
6957/**
Govind Singh4eacd2b2016-03-07 14:24:22 +05306958 * send_pno_start_cmd_tlv() - PNO start request
6959 * @wmi_handle: wmi handle
6960 * @pno: PNO request
6961 *
6962 * This function request FW to start PNO request.
6963 * Request: CDF status
6964 */
Sathish Kumarfd347372017-02-13 12:29:09 +05306965static QDF_STATUS send_pno_start_cmd_tlv(wmi_unified_t wmi_handle,
Abhishek Singh5987b632017-03-03 22:09:07 +05306966 struct pno_scan_req_params *pno)
Govind Singh4eacd2b2016-03-07 14:24:22 +05306967{
6968 wmi_nlo_config_cmd_fixed_param *cmd;
6969 nlo_configured_parameters *nlo_list;
6970 uint32_t *channel_list;
6971 int32_t len;
6972 wmi_buf_t buf;
6973 uint8_t *buf_ptr;
6974 uint8_t i;
6975 int ret;
6976
6977 /*
6978 * TLV place holder for array nlo_configured_parameters(nlo_list)
6979 * TLV place holder for array of uint32_t channel_list
6980 * TLV place holder for chnnl prediction cfg
6981 */
6982 len = sizeof(*cmd) +
6983 WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE + WMI_TLV_HDR_SIZE;
6984
Abhishek Singh5987b632017-03-03 22:09:07 +05306985 len += sizeof(uint32_t) * QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05306986 WMI_NLO_MAX_CHAN);
6987 len += sizeof(nlo_configured_parameters) *
Abhishek Singh5987b632017-03-03 22:09:07 +05306988 QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singh4eacd2b2016-03-07 14:24:22 +05306989 len += sizeof(nlo_channel_prediction_cfg);
6990
6991 buf = wmi_buf_alloc(wmi_handle, len);
6992 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05306993 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
6994 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05306995 }
6996
6997 cmd = (wmi_nlo_config_cmd_fixed_param *) wmi_buf_data(buf);
6998
6999 buf_ptr = (uint8_t *) cmd;
7000 WMITLV_SET_HDR(&cmd->tlv_header,
7001 WMITLV_TAG_STRUC_wmi_nlo_config_cmd_fixed_param,
7002 WMITLV_GET_STRUCT_TLVLEN
7003 (wmi_nlo_config_cmd_fixed_param));
Abhishek Singh5987b632017-03-03 22:09:07 +05307004 cmd->vdev_id = pno->vdev_id;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307005 cmd->flags = WMI_NLO_CONFIG_START | WMI_NLO_CONFIG_SSID_HIDE_EN;
7006
Govind Singh87542482016-06-08 19:40:11 +05307007#ifdef FEATURE_WLAN_SCAN_PNO
Gupta, Kapil2e685982016-04-25 19:14:19 +05307008 WMI_SCAN_SET_DWELL_MODE(cmd->flags,
Abhishek Singh5987b632017-03-03 22:09:07 +05307009 pno->adaptive_dwell_mode);
Govind Singh87542482016-06-08 19:40:11 +05307010#endif
Govind Singh4eacd2b2016-03-07 14:24:22 +05307011 /* Current FW does not support min-max range for dwell time */
Abhishek Singh5987b632017-03-03 22:09:07 +05307012 cmd->active_dwell_time = pno->active_dwell_time;
7013 cmd->passive_dwell_time = pno->passive_dwell_time;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307014
7015 /* Copy scan interval */
7016 cmd->fast_scan_period = pno->fast_scan_period;
7017 cmd->slow_scan_period = pno->slow_scan_period;
Arif Hussain17ff2032017-03-02 11:56:04 -08007018 cmd->delay_start_time = WMI_SEC_TO_MSEC(pno->delay_start_time);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307019 cmd->fast_scan_max_cycles = pno->fast_scan_max_cycles;
Govind Singhb53420c2016-03-09 14:32:57 +05307020 WMI_LOGD("fast_scan_period: %d msec slow_scan_period: %d msec",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307021 cmd->fast_scan_period, cmd->slow_scan_period);
Govind Singhb53420c2016-03-09 14:32:57 +05307022 WMI_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307023
7024 buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
7025
Abhishek Singh5987b632017-03-03 22:09:07 +05307026 cmd->no_of_ssids = QDF_MIN(pno->networks_cnt, WMI_NLO_MAX_SSIDS);
Govind Singhb53420c2016-03-09 14:32:57 +05307027 WMI_LOGD("SSID count : %d", cmd->no_of_ssids);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307028 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7029 cmd->no_of_ssids * sizeof(nlo_configured_parameters));
7030 buf_ptr += WMI_TLV_HDR_SIZE;
7031
7032 nlo_list = (nlo_configured_parameters *) buf_ptr;
7033 for (i = 0; i < cmd->no_of_ssids; i++) {
7034 WMITLV_SET_HDR(&nlo_list[i].tlv_header,
7035 WMITLV_TAG_ARRAY_BYTE,
7036 WMITLV_GET_STRUCT_TLVLEN
7037 (nlo_configured_parameters));
7038 /* Copy ssid and it's length */
7039 nlo_list[i].ssid.valid = true;
Abhishek Singh5987b632017-03-03 22:09:07 +05307040 nlo_list[i].ssid.ssid.ssid_len =
7041 pno->networks_list[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +05307042 qdf_mem_copy(nlo_list[i].ssid.ssid.ssid,
Abhishek Singh5987b632017-03-03 22:09:07 +05307043 pno->networks_list[i].ssid.ssid,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307044 nlo_list[i].ssid.ssid.ssid_len);
Govind Singhb53420c2016-03-09 14:32:57 +05307045 WMI_LOGD("index: %d ssid: %.*s len: %d", i,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307046 nlo_list[i].ssid.ssid.ssid_len,
7047 (char *)nlo_list[i].ssid.ssid.ssid,
7048 nlo_list[i].ssid.ssid.ssid_len);
7049
7050 /* Copy rssi threshold */
Abhishek Singh5987b632017-03-03 22:09:07 +05307051 if (pno->networks_list[i].rssi_thresh &&
7052 pno->networks_list[i].rssi_thresh >
7053 WMI_RSSI_THOLD_DEFAULT) {
Govind Singh4eacd2b2016-03-07 14:24:22 +05307054 nlo_list[i].rssi_cond.valid = true;
7055 nlo_list[i].rssi_cond.rssi =
Abhishek Singh5987b632017-03-03 22:09:07 +05307056 pno->networks_list[i].rssi_thresh;
Govind Singhb53420c2016-03-09 14:32:57 +05307057 WMI_LOGD("RSSI threshold : %d dBm",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307058 nlo_list[i].rssi_cond.rssi);
7059 }
7060 nlo_list[i].bcast_nw_type.valid = true;
7061 nlo_list[i].bcast_nw_type.bcast_nw_type =
Abhishek Singh5987b632017-03-03 22:09:07 +05307062 pno->networks_list[i].bc_new_type;
Govind Singhb53420c2016-03-09 14:32:57 +05307063 WMI_LOGI("Broadcast NW type (%u)",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307064 nlo_list[i].bcast_nw_type.bcast_nw_type);
7065 }
7066 buf_ptr += cmd->no_of_ssids * sizeof(nlo_configured_parameters);
7067
7068 /* Copy channel info */
Abhishek Singh5987b632017-03-03 22:09:07 +05307069 cmd->num_of_channels = QDF_MIN(pno->networks_list[0].channel_cnt,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307070 WMI_NLO_MAX_CHAN);
Govind Singhb53420c2016-03-09 14:32:57 +05307071 WMI_LOGD("Channel count: %d", cmd->num_of_channels);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307072 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
7073 (cmd->num_of_channels * sizeof(uint32_t)));
7074 buf_ptr += WMI_TLV_HDR_SIZE;
7075
7076 channel_list = (uint32_t *) buf_ptr;
7077 for (i = 0; i < cmd->num_of_channels; i++) {
Abhishek Singh5987b632017-03-03 22:09:07 +05307078 channel_list[i] = pno->networks_list[0].channels[i];
Govind Singh4eacd2b2016-03-07 14:24:22 +05307079
7080 if (channel_list[i] < WMI_NLO_FREQ_THRESH)
Abhishek Singh5987b632017-03-03 22:09:07 +05307081 channel_list[i] =
7082 wlan_chan_to_freq(pno->
7083 networks_list[0].channels[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307084
Govind Singhb53420c2016-03-09 14:32:57 +05307085 WMI_LOGD("Ch[%d]: %d MHz", i, channel_list[i]);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307086 }
7087 buf_ptr += cmd->num_of_channels * sizeof(uint32_t);
7088 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
7089 sizeof(nlo_channel_prediction_cfg));
7090 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhccb0c272016-04-01 16:30:08 +05307091 wmi_set_pno_channel_prediction(buf_ptr, pno);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307092 buf_ptr += WMI_TLV_HDR_SIZE;
7093 /** TODO: Discrete firmware doesn't have command/option to configure
7094 * App IE which comes from wpa_supplicant as of part PNO start request.
7095 */
7096 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7097 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID);
7098 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307099 WMI_LOGE("%s: Failed to send nlo wmi cmd", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307100 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307101 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307102 }
7103
Govind Singhb53420c2016-03-09 14:32:57 +05307104 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307105}
7106
7107/* send_set_ric_req_cmd_tlv() - set ric request element
7108 * @wmi_handle: wmi handle
7109 * @msg: message
7110 * @is_add_ts: is addts required
7111 *
7112 * This function sets ric request element for 11r roaming.
7113 *
7114 * Return: CDF status
7115 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307116static QDF_STATUS send_set_ric_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307117 void *msg, uint8_t is_add_ts)
7118{
7119 wmi_ric_request_fixed_param *cmd;
7120 wmi_ric_tspec *tspec_param;
7121 wmi_buf_t buf;
7122 uint8_t *buf_ptr;
Govind Singh87542482016-06-08 19:40:11 +05307123 struct mac_tspec_ie *ptspecIE = NULL;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307124 int32_t len = sizeof(wmi_ric_request_fixed_param) +
7125 WMI_TLV_HDR_SIZE + sizeof(wmi_ric_tspec);
7126
7127 buf = wmi_buf_alloc(wmi_handle, len);
7128 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307129 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
7130 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307131 }
7132
7133 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7134
7135 cmd = (wmi_ric_request_fixed_param *) buf_ptr;
7136 WMITLV_SET_HDR(&cmd->tlv_header,
7137 WMITLV_TAG_STRUC_wmi_ric_request_fixed_param,
7138 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_request_fixed_param));
7139 if (is_add_ts)
7140 cmd->vdev_id = ((struct add_ts_param *) msg)->sessionId;
7141 else
7142 cmd->vdev_id = ((struct del_ts_params *) msg)->sessionId;
7143 cmd->num_ric_request = 1;
7144 cmd->is_add_ric = is_add_ts;
7145
7146 buf_ptr += sizeof(wmi_ric_request_fixed_param);
7147 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, sizeof(wmi_ric_tspec));
7148
7149 buf_ptr += WMI_TLV_HDR_SIZE;
7150 tspec_param = (wmi_ric_tspec *) buf_ptr;
7151 WMITLV_SET_HDR(&tspec_param->tlv_header,
7152 WMITLV_TAG_STRUC_wmi_ric_tspec,
7153 WMITLV_GET_STRUCT_TLVLEN(wmi_ric_tspec));
7154
7155 if (is_add_ts)
7156 ptspecIE = &(((struct add_ts_param *) msg)->tspec);
Govind Singh87542482016-06-08 19:40:11 +05307157#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Govind Singh4eacd2b2016-03-07 14:24:22 +05307158 else
7159 ptspecIE = &(((struct del_ts_params *) msg)->delTsInfo.tspec);
Govind Singh87542482016-06-08 19:40:11 +05307160#endif
7161 if (ptspecIE) {
7162 /* Fill the tsinfo in the format expected by firmware */
Govind Singh4eacd2b2016-03-07 14:24:22 +05307163#ifndef ANI_LITTLE_BIT_ENDIAN
Govind Singh87542482016-06-08 19:40:11 +05307164 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info) + 1,
7165 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307166#else
Govind Singh87542482016-06-08 19:40:11 +05307167 qdf_mem_copy(((uint8_t *) &tspec_param->ts_info),
7168 ((uint8_t *) &ptspecIE->tsinfo) + 1, 2);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307169#endif /* ANI_LITTLE_BIT_ENDIAN */
7170
Govind Singh87542482016-06-08 19:40:11 +05307171 tspec_param->nominal_msdu_size = ptspecIE->nomMsduSz;
7172 tspec_param->maximum_msdu_size = ptspecIE->maxMsduSz;
7173 tspec_param->min_service_interval = ptspecIE->minSvcInterval;
7174 tspec_param->max_service_interval = ptspecIE->maxSvcInterval;
7175 tspec_param->inactivity_interval = ptspecIE->inactInterval;
7176 tspec_param->suspension_interval = ptspecIE->suspendInterval;
7177 tspec_param->svc_start_time = ptspecIE->svcStartTime;
7178 tspec_param->min_data_rate = ptspecIE->minDataRate;
7179 tspec_param->mean_data_rate = ptspecIE->meanDataRate;
7180 tspec_param->peak_data_rate = ptspecIE->peakDataRate;
7181 tspec_param->max_burst_size = ptspecIE->maxBurstSz;
7182 tspec_param->delay_bound = ptspecIE->delayBound;
7183 tspec_param->min_phy_rate = ptspecIE->minPhyRate;
7184 tspec_param->surplus_bw_allowance = ptspecIE->surplusBw;
7185 tspec_param->medium_time = 0;
7186 }
Govind Singhb53420c2016-03-09 14:32:57 +05307187 WMI_LOGI("%s: Set RIC Req is_add_ts:%d", __func__, is_add_ts);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307188
7189 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7190 WMI_ROAM_SET_RIC_REQUEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307191 WMI_LOGP("%s: Failed to send vdev Set RIC Req command",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307192 __func__);
7193 if (is_add_ts)
7194 ((struct add_ts_param *) msg)->status =
Govind Singhb53420c2016-03-09 14:32:57 +05307195 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05307196 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307197 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307198 }
7199
Govind Singhb53420c2016-03-09 14:32:57 +05307200 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307201}
7202
7203/**
7204 * send_process_ll_stats_clear_cmd_tlv() - clear link layer stats
7205 * @wmi_handle: wmi handle
7206 * @clear_req: ll stats clear request command params
7207 *
Govind Singhb53420c2016-03-09 14:32:57 +05307208 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307209 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307210static QDF_STATUS send_process_ll_stats_clear_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307211 const struct ll_stats_clear_params *clear_req,
7212 uint8_t addr[IEEE80211_ADDR_LEN])
7213{
7214 wmi_clear_link_stats_cmd_fixed_param *cmd;
7215 int32_t len;
7216 wmi_buf_t buf;
7217 uint8_t *buf_ptr;
7218 int ret;
7219
7220 len = sizeof(*cmd);
7221 buf = wmi_buf_alloc(wmi_handle, len);
7222
7223 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307224 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7225 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307226 }
7227
7228 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307229 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307230 cmd = (wmi_clear_link_stats_cmd_fixed_param *) buf_ptr;
7231
7232 WMITLV_SET_HDR(&cmd->tlv_header,
7233 WMITLV_TAG_STRUC_wmi_clear_link_stats_cmd_fixed_param,
7234 WMITLV_GET_STRUCT_TLVLEN
7235 (wmi_clear_link_stats_cmd_fixed_param));
7236
7237 cmd->stop_stats_collection_req = clear_req->stop_req;
7238 cmd->vdev_id = clear_req->sta_id;
7239 cmd->stats_clear_req_mask = clear_req->stats_clear_mask;
7240
7241 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7242 &cmd->peer_macaddr);
7243
Govind Singhb53420c2016-03-09 14:32:57 +05307244 WMI_LOGD("LINK_LAYER_STATS - Clear Request Params");
7245 WMI_LOGD("StopReq : %d", cmd->stop_stats_collection_req);
7246 WMI_LOGD("Vdev Id : %d", cmd->vdev_id);
7247 WMI_LOGD("Clear Stat Mask : %d", cmd->stats_clear_req_mask);
7248 /* WMI_LOGD("Peer MAC Addr : %pM",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307249 cmd->peer_macaddr); */
7250
7251 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7252 WMI_CLEAR_LINK_STATS_CMDID);
7253 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307254 WMI_LOGE("%s: Failed to send clear link stats req", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307255 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307256 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307257 }
7258
Govind Singhb53420c2016-03-09 14:32:57 +05307259 WMI_LOGD("Clear Link Layer Stats request sent successfully");
7260 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307261}
7262
7263/**
7264 * send_process_ll_stats_set_cmd_tlv() - link layer stats set request
7265 * @wmi_handle: wmi handle
7266 * @setReq: ll stats set request command params
7267 *
Govind Singhb53420c2016-03-09 14:32:57 +05307268 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307269 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307270static QDF_STATUS send_process_ll_stats_set_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307271 const struct ll_stats_set_params *set_req)
7272{
7273 wmi_start_link_stats_cmd_fixed_param *cmd;
7274 int32_t len;
7275 wmi_buf_t buf;
7276 uint8_t *buf_ptr;
7277 int ret;
7278
7279 len = sizeof(*cmd);
7280 buf = wmi_buf_alloc(wmi_handle, len);
7281
7282 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307283 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
7284 return QDF_STATUS_E_NOMEM;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307285 }
7286
7287 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307288 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307289 cmd = (wmi_start_link_stats_cmd_fixed_param *) buf_ptr;
7290
7291 WMITLV_SET_HDR(&cmd->tlv_header,
7292 WMITLV_TAG_STRUC_wmi_start_link_stats_cmd_fixed_param,
7293 WMITLV_GET_STRUCT_TLVLEN
7294 (wmi_start_link_stats_cmd_fixed_param));
7295
7296 cmd->mpdu_size_threshold = set_req->mpdu_size_threshold;
7297 cmd->aggressive_statistics_gathering =
7298 set_req->aggressive_statistics_gathering;
7299
Govind Singhb53420c2016-03-09 14:32:57 +05307300 WMI_LOGD("LINK_LAYER_STATS - Start/Set Request Params");
7301 WMI_LOGD("MPDU Size Thresh : %d", cmd->mpdu_size_threshold);
7302 WMI_LOGD("Aggressive Gather: %d", cmd->aggressive_statistics_gathering);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307303
7304 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7305 WMI_START_LINK_STATS_CMDID);
7306 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307307 WMI_LOGE("%s: Failed to send set link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307308 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307309 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307310 }
7311
Govind Singhb53420c2016-03-09 14:32:57 +05307312 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307313}
7314
7315/**
7316 * send_process_ll_stats_get_cmd_tlv() - link layer stats get request
7317 * @wmi_handle:wmi handle
7318 * @get_req:ll stats get request command params
7319 * @addr: mac address
7320 *
Govind Singhb53420c2016-03-09 14:32:57 +05307321 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh4eacd2b2016-03-07 14:24:22 +05307322 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307323static QDF_STATUS send_process_ll_stats_get_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307324 const struct ll_stats_get_params *get_req,
7325 uint8_t addr[IEEE80211_ADDR_LEN])
7326{
7327 wmi_request_link_stats_cmd_fixed_param *cmd;
7328 int32_t len;
7329 wmi_buf_t buf;
7330 uint8_t *buf_ptr;
7331 int ret;
7332
7333 len = sizeof(*cmd);
7334 buf = wmi_buf_alloc(wmi_handle, len);
7335
Himanshu Agarwalac3869b2016-06-30 18:04:14 +05307336 if (!buf) {
7337 WMI_LOGE("%s: buf allocation failed", __func__);
7338 return QDF_STATUS_E_NOMEM;
7339 }
7340
Govind Singh4eacd2b2016-03-07 14:24:22 +05307341 buf_ptr = (uint8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307342 qdf_mem_zero(buf_ptr, len);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307343 cmd = (wmi_request_link_stats_cmd_fixed_param *) buf_ptr;
7344
7345 WMITLV_SET_HDR(&cmd->tlv_header,
7346 WMITLV_TAG_STRUC_wmi_request_link_stats_cmd_fixed_param,
7347 WMITLV_GET_STRUCT_TLVLEN
7348 (wmi_request_link_stats_cmd_fixed_param));
7349
7350 cmd->request_id = get_req->req_id;
7351 cmd->stats_type = get_req->param_id_mask;
7352 cmd->vdev_id = get_req->sta_id;
7353
7354 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr,
7355 &cmd->peer_macaddr);
7356
Govind Singhb53420c2016-03-09 14:32:57 +05307357 WMI_LOGD("LINK_LAYER_STATS - Get Request Params");
Krishna Kumaar Natarajanf6a996c2017-03-10 17:24:55 -08007358 WMI_LOGD("Request ID : %u", cmd->request_id);
7359 WMI_LOGD("Stats Type : %0x", cmd->stats_type);
Govind Singhb53420c2016-03-09 14:32:57 +05307360 WMI_LOGD("Vdev ID : %d", cmd->vdev_id);
7361 WMI_LOGD("Peer MAC Addr : %pM", addr);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307362
7363 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7364 WMI_REQUEST_LINK_STATS_CMDID);
7365 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307366 WMI_LOGE("%s: Failed to send get link stats request", __func__);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307367 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307368 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307369 }
7370
Govind Singhb53420c2016-03-09 14:32:57 +05307371 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307372}
7373
7374/**
7375 * send_get_stats_cmd_tlv() - get stats request
7376 * @wmi_handle: wmi handle
7377 * @get_stats_param: stats params
7378 * @addr: mac address
7379 *
7380 * Return: CDF status
7381 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307382static QDF_STATUS send_get_stats_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh4eacd2b2016-03-07 14:24:22 +05307383 struct pe_stats_req *get_stats_param,
7384 uint8_t addr[IEEE80211_ADDR_LEN])
7385{
7386 wmi_buf_t buf;
7387 wmi_request_stats_cmd_fixed_param *cmd;
7388 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7389
7390 buf = wmi_buf_alloc(wmi_handle, len);
7391 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307392 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7393 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307394 }
7395
7396
7397 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7398 WMITLV_SET_HDR(&cmd->tlv_header,
7399 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7400 WMITLV_GET_STRUCT_TLVLEN
7401 (wmi_request_stats_cmd_fixed_param));
7402 cmd->stats_id =
7403 WMI_REQUEST_PEER_STAT | WMI_REQUEST_PDEV_STAT |
Himanshu Agarwalc9fc2a32016-07-21 14:46:58 +05307404 WMI_REQUEST_VDEV_STAT | WMI_REQUEST_RSSI_PER_CHAIN_STAT;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307405 cmd->vdev_id = get_stats_param->session_id;
7406 WMI_CHAR_ARRAY_TO_MAC_ADDR(addr, &cmd->peer_macaddr);
Govind Singhb53420c2016-03-09 14:32:57 +05307407 WMI_LOGD("STATS REQ VDEV_ID:%d-->", cmd->vdev_id);
Govind Singh4eacd2b2016-03-07 14:24:22 +05307408 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7409 WMI_REQUEST_STATS_CMDID)) {
7410
Govind Singhb53420c2016-03-09 14:32:57 +05307411 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
Govind Singh4eacd2b2016-03-07 14:24:22 +05307412 __func__);
7413 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307414 return QDF_STATUS_E_FAILURE;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307415 }
7416
Govind Singhb53420c2016-03-09 14:32:57 +05307417 return QDF_STATUS_SUCCESS;
Govind Singh4eacd2b2016-03-07 14:24:22 +05307418
7419}
7420
Govind Singh20c5dac2016-03-07 15:33:31 +05307421/**
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +05307422 * send_congestion_cmd_tlv() - send request to fw to get CCA
7423 * @wmi_handle: wmi handle
7424 * @vdev_id: vdev id
7425 *
7426 * Return: CDF status
7427 */
7428static QDF_STATUS send_congestion_cmd_tlv(wmi_unified_t wmi_handle,
7429 A_UINT8 vdev_id)
7430{
7431 wmi_buf_t buf;
7432 wmi_request_stats_cmd_fixed_param *cmd;
7433 uint8_t len;
7434 uint8_t *buf_ptr;
7435
7436 len = sizeof(*cmd);
7437 buf = wmi_buf_alloc(wmi_handle, len);
7438 if (!buf) {
7439 WMI_LOGE("%s: Failed to allocate wmi buffer", __func__);
7440 return QDF_STATUS_E_FAILURE;
7441 }
7442
7443 buf_ptr = wmi_buf_data(buf);
7444 cmd = (wmi_request_stats_cmd_fixed_param *)buf_ptr;
7445 WMITLV_SET_HDR(&cmd->tlv_header,
7446 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7447 WMITLV_GET_STRUCT_TLVLEN
7448 (wmi_request_stats_cmd_fixed_param));
7449
7450 cmd->stats_id = WMI_REQUEST_CONGESTION_STAT;
7451 cmd->vdev_id = vdev_id;
7452 WMI_LOGD("STATS REQ VDEV_ID:%d stats_id %d -->",
7453 cmd->vdev_id, cmd->stats_id);
7454
7455 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7456 WMI_REQUEST_STATS_CMDID)) {
7457 WMI_LOGE("%s: Failed to send WMI_REQUEST_STATS_CMDID",
7458 __func__);
7459 wmi_buf_free(buf);
7460 return QDF_STATUS_E_FAILURE;
7461 }
7462
7463 return QDF_STATUS_SUCCESS;
7464}
7465
7466/**
Govind Singh20c5dac2016-03-07 15:33:31 +05307467 * send_snr_request_cmd_tlv() - send request to fw to get RSSI stats
7468 * @wmi_handle: wmi handle
7469 * @rssi_req: get RSSI request
7470 *
7471 * Return: CDF status
7472 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307473static QDF_STATUS send_snr_request_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05307474{
7475 wmi_buf_t buf;
7476 wmi_request_stats_cmd_fixed_param *cmd;
7477 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7478
7479 buf = wmi_buf_alloc(wmi_handle, len);
7480 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307481 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7482 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307483 }
7484
7485 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7486 WMITLV_SET_HDR(&cmd->tlv_header,
7487 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7488 WMITLV_GET_STRUCT_TLVLEN
7489 (wmi_request_stats_cmd_fixed_param));
7490 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7491 if (wmi_unified_cmd_send
7492 (wmi_handle, buf, len, WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307493 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307494 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307495 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307496 }
7497
Govind Singhb53420c2016-03-09 14:32:57 +05307498 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307499}
7500
7501/**
7502 * send_snr_cmd_tlv() - get RSSI from fw
7503 * @wmi_handle: wmi handle
7504 * @vdev_id: vdev id
7505 *
7506 * Return: CDF status
7507 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307508static QDF_STATUS send_snr_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307509{
7510 wmi_buf_t buf;
7511 wmi_request_stats_cmd_fixed_param *cmd;
7512 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7513
7514 buf = wmi_buf_alloc(wmi_handle, len);
7515 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307516 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7517 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307518 }
7519
7520 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7521 cmd->vdev_id = vdev_id;
7522
7523 WMITLV_SET_HDR(&cmd->tlv_header,
7524 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7525 WMITLV_GET_STRUCT_TLVLEN
7526 (wmi_request_stats_cmd_fixed_param));
7527 cmd->stats_id = WMI_REQUEST_VDEV_STAT;
7528 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7529 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307530 WMI_LOGE("Failed to send host stats request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307531 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307532 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307533 }
7534
Govind Singhb53420c2016-03-09 14:32:57 +05307535 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307536}
7537
7538/**
7539 * send_link_status_req_cmd_tlv() - process link status request from UMAC
7540 * @wmi_handle: wmi handle
7541 * @link_status: get link params
7542 *
7543 * Return: CDF status
7544 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307545static QDF_STATUS send_link_status_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307546 struct link_status_params *link_status)
7547{
7548 wmi_buf_t buf;
7549 wmi_request_stats_cmd_fixed_param *cmd;
7550 uint8_t len = sizeof(wmi_request_stats_cmd_fixed_param);
7551
7552 buf = wmi_buf_alloc(wmi_handle, len);
7553 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307554 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7555 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307556 }
7557
7558 cmd = (wmi_request_stats_cmd_fixed_param *) wmi_buf_data(buf);
7559 WMITLV_SET_HDR(&cmd->tlv_header,
7560 WMITLV_TAG_STRUC_wmi_request_stats_cmd_fixed_param,
7561 WMITLV_GET_STRUCT_TLVLEN
7562 (wmi_request_stats_cmd_fixed_param));
7563 cmd->stats_id = WMI_REQUEST_VDEV_RATE_STAT;
7564 cmd->vdev_id = link_status->session_id;
7565 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7566 WMI_REQUEST_STATS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307567 WMI_LOGE("Failed to send WMI link status request to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05307568 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307569 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307570 }
7571
Govind Singhb53420c2016-03-09 14:32:57 +05307572 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307573}
7574
Govind Singh20c5dac2016-03-07 15:33:31 +05307575/**
7576 * send_process_dhcp_ind_cmd_tlv() - process dhcp indication from SME
7577 * @wmi_handle: wmi handle
7578 * @ta_dhcp_ind: DHCP indication parameter
7579 *
7580 * Return: CDF Status
7581 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307582static QDF_STATUS send_process_dhcp_ind_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307583 wmi_peer_set_param_cmd_fixed_param *ta_dhcp_ind)
7584{
Govind Singh67922e82016-04-01 16:48:57 +05307585 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307586 wmi_buf_t buf = NULL;
7587 uint8_t *buf_ptr;
7588 wmi_peer_set_param_cmd_fixed_param *peer_set_param_fp;
7589 int len = sizeof(wmi_peer_set_param_cmd_fixed_param);
7590
7591
7592 buf = wmi_buf_alloc(wmi_handle, len);
7593 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307594 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
7595 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307596 }
7597
7598 buf_ptr = (uint8_t *) wmi_buf_data(buf);
7599 peer_set_param_fp = (wmi_peer_set_param_cmd_fixed_param *) buf_ptr;
7600 WMITLV_SET_HDR(&peer_set_param_fp->tlv_header,
7601 WMITLV_TAG_STRUC_wmi_peer_set_param_cmd_fixed_param,
7602 WMITLV_GET_STRUCT_TLVLEN
7603 (wmi_peer_set_param_cmd_fixed_param));
7604
7605 /* fill in values */
7606 peer_set_param_fp->vdev_id = ta_dhcp_ind->vdev_id;
7607 peer_set_param_fp->param_id = ta_dhcp_ind->param_id;
7608 peer_set_param_fp->param_value = ta_dhcp_ind->param_value;
Govind Singhb53420c2016-03-09 14:32:57 +05307609 qdf_mem_copy(&peer_set_param_fp->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307610 &ta_dhcp_ind->peer_macaddr,
7611 sizeof(ta_dhcp_ind->peer_macaddr));
7612
7613 status = wmi_unified_cmd_send(wmi_handle, buf,
7614 len, WMI_PEER_SET_PARAM_CMDID);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307615 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307616 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05307617 " returned Error %d", __func__, status);
Govind Singh2d8a88c2016-08-08 19:07:00 +05307618 wmi_buf_free(buf);
7619 }
Govind Singh20c5dac2016-03-07 15:33:31 +05307620
Govind Singh67922e82016-04-01 16:48:57 +05307621 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05307622}
7623
7624/**
7625 * send_get_link_speed_cmd_tlv() -send command to get linkspeed
7626 * @wmi_handle: wmi handle
7627 * @pLinkSpeed: link speed info
7628 *
7629 * Return: CDF status
7630 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307631static QDF_STATUS send_get_link_speed_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307632 wmi_mac_addr peer_macaddr)
7633{
7634 wmi_peer_get_estimated_linkspeed_cmd_fixed_param *cmd;
7635 wmi_buf_t wmi_buf;
7636 uint32_t len;
7637 uint8_t *buf_ptr;
7638
7639 len = sizeof(wmi_peer_get_estimated_linkspeed_cmd_fixed_param);
7640 wmi_buf = wmi_buf_alloc(wmi_handle, len);
7641 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307642 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
7643 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307644 }
7645 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
7646
7647 cmd = (wmi_peer_get_estimated_linkspeed_cmd_fixed_param *) buf_ptr;
7648 WMITLV_SET_HDR(&cmd->tlv_header,
7649 WMITLV_TAG_STRUC_wmi_peer_get_estimated_linkspeed_cmd_fixed_param,
7650 WMITLV_GET_STRUCT_TLVLEN
7651 (wmi_peer_get_estimated_linkspeed_cmd_fixed_param));
7652
7653 /* Copy the peer macaddress to the wma buffer */
Govind Singhb53420c2016-03-09 14:32:57 +05307654 qdf_mem_copy(&cmd->peer_macaddr,
Govind Singh20c5dac2016-03-07 15:33:31 +05307655 &peer_macaddr,
7656 sizeof(peer_macaddr));
7657
7658
7659 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
7660 WMI_PEER_GET_ESTIMATED_LINKSPEED_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307661 WMI_LOGE("%s: failed to send link speed command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307662 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307663 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307664 }
Govind Singhb53420c2016-03-09 14:32:57 +05307665 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307666}
7667
7668/**
7669 * send_egap_conf_params_cmd_tlv() - send wmi cmd of egap configuration params
7670 * @wmi_handle: wmi handler
7671 * @egap_params: pointer to egap_params
7672 *
7673 * Return: 0 for success, otherwise appropriate error code
7674 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307675static QDF_STATUS send_egap_conf_params_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307676 wmi_ap_ps_egap_param_cmd_fixed_param *egap_params)
7677{
7678 wmi_ap_ps_egap_param_cmd_fixed_param *cmd;
7679 wmi_buf_t buf;
7680 int32_t err;
7681
7682 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
7683 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307684 WMI_LOGE("Failed to allocate buffer to send ap_ps_egap cmd");
7685 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307686 }
7687 cmd = (wmi_ap_ps_egap_param_cmd_fixed_param *) wmi_buf_data(buf);
7688 WMITLV_SET_HDR(&cmd->tlv_header,
7689 WMITLV_TAG_STRUC_wmi_ap_ps_egap_param_cmd_fixed_param,
7690 WMITLV_GET_STRUCT_TLVLEN(
7691 wmi_ap_ps_egap_param_cmd_fixed_param));
7692
7693 cmd->enable = egap_params->enable;
7694 cmd->inactivity_time = egap_params->inactivity_time;
7695 cmd->wait_time = egap_params->wait_time;
7696 cmd->flags = egap_params->flags;
7697 err = wmi_unified_cmd_send(wmi_handle, buf,
7698 sizeof(*cmd), WMI_AP_PS_EGAP_PARAM_CMDID);
7699 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +05307700 WMI_LOGE("Failed to send ap_ps_egap cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05307701 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05307702 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307703 }
7704
Govind Singhb53420c2016-03-09 14:32:57 +05307705 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05307706}
7707
7708/**
7709 * send_fw_profiling_cmd_tlv() - send FW profiling cmd to WLAN FW
7710 * @wmi_handl: wmi handle
7711 * @cmd: Profiling command index
7712 * @value1: parameter1 value
7713 * @value2: parameter2 value
7714 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307715 * Return: QDF_STATUS_SUCCESS for success else error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307716 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307717static QDF_STATUS send_fw_profiling_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307718 uint32_t cmd, uint32_t value1, uint32_t value2)
7719{
7720 wmi_buf_t buf;
7721 int32_t len = 0;
7722 int ret;
7723 wmi_wlan_profile_trigger_cmd_fixed_param *prof_trig_cmd;
7724 wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *hist_intvl_cmd;
7725 wmi_wlan_profile_enable_profile_id_cmd_fixed_param *profile_enable_cmd;
7726 wmi_wlan_profile_get_prof_data_cmd_fixed_param *profile_getdata_cmd;
7727
7728 switch (cmd) {
7729 case WMI_WLAN_PROFILE_TRIGGER_CMDID:
7730 len = sizeof(wmi_wlan_profile_trigger_cmd_fixed_param);
7731 buf = wmi_buf_alloc(wmi_handle, len);
7732 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307733 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307734 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307735 }
7736 prof_trig_cmd =
7737 (wmi_wlan_profile_trigger_cmd_fixed_param *)
7738 wmi_buf_data(buf);
7739 WMITLV_SET_HDR(&prof_trig_cmd->tlv_header,
7740 WMITLV_TAG_STRUC_wmi_wlan_profile_trigger_cmd_fixed_param,
7741 WMITLV_GET_STRUCT_TLVLEN
7742 (wmi_wlan_profile_trigger_cmd_fixed_param));
7743 prof_trig_cmd->enable = value1;
7744 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7745 WMI_WLAN_PROFILE_TRIGGER_CMDID);
7746 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307747 WMI_LOGE("PROFILE_TRIGGER cmd Failed with value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307748 value1);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307749 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307750 return ret;
7751 }
7752 break;
7753
7754 case WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID:
7755 len = sizeof(wmi_wlan_profile_get_prof_data_cmd_fixed_param);
7756 buf = wmi_buf_alloc(wmi_handle, len);
7757 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307758 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307759 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307760 }
7761 profile_getdata_cmd =
7762 (wmi_wlan_profile_get_prof_data_cmd_fixed_param *)
7763 wmi_buf_data(buf);
7764 WMITLV_SET_HDR(&profile_getdata_cmd->tlv_header,
7765 WMITLV_TAG_STRUC_wmi_wlan_profile_get_prof_data_cmd_fixed_param,
7766 WMITLV_GET_STRUCT_TLVLEN
7767 (wmi_wlan_profile_get_prof_data_cmd_fixed_param));
7768 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7769 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID);
7770 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307771 WMI_LOGE("PROFILE_DATA cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307772 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307773 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307774 return ret;
7775 }
7776 break;
7777
7778 case WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID:
7779 len = sizeof(wmi_wlan_profile_set_hist_intvl_cmd_fixed_param);
7780 buf = wmi_buf_alloc(wmi_handle, len);
7781 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307782 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307783 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307784 }
7785 hist_intvl_cmd =
7786 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param *)
7787 wmi_buf_data(buf);
7788 WMITLV_SET_HDR(&hist_intvl_cmd->tlv_header,
7789 WMITLV_TAG_STRUC_wmi_wlan_profile_set_hist_intvl_cmd_fixed_param,
7790 WMITLV_GET_STRUCT_TLVLEN
7791 (wmi_wlan_profile_set_hist_intvl_cmd_fixed_param));
7792 hist_intvl_cmd->profile_id = value1;
7793 hist_intvl_cmd->value = value2;
7794 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7795 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID);
7796 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307797 WMI_LOGE("HIST_INTVL cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307798 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307799 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307800 return ret;
7801 }
7802 break;
7803
7804 case WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID:
7805 len =
7806 sizeof(wmi_wlan_profile_enable_profile_id_cmd_fixed_param);
7807 buf = wmi_buf_alloc(wmi_handle, len);
7808 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307809 WMI_LOGP("%s: wmi_buf_alloc Failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307810 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307811 }
7812 profile_enable_cmd =
7813 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param *)
7814 wmi_buf_data(buf);
7815 WMITLV_SET_HDR(&profile_enable_cmd->tlv_header,
7816 WMITLV_TAG_STRUC_wmi_wlan_profile_enable_profile_id_cmd_fixed_param,
7817 WMITLV_GET_STRUCT_TLVLEN
7818 (wmi_wlan_profile_enable_profile_id_cmd_fixed_param));
7819 profile_enable_cmd->profile_id = value1;
7820 profile_enable_cmd->enable = value2;
7821 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
7822 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID);
7823 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05307824 WMI_LOGE("enable cmd Failed for id %d value %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05307825 value1, value2);
Abhishek Singh716c46c2016-05-04 16:24:07 +05307826 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307827 return ret;
7828 }
7829 break;
7830
7831 default:
Govind Singhb53420c2016-03-09 14:32:57 +05307832 WMI_LOGD("%s: invalid profiling command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307833 break;
7834 }
7835
7836 return 0;
7837}
7838
Govind Singh20c5dac2016-03-07 15:33:31 +05307839/**
7840 * send_nat_keepalive_en_cmd_tlv() - enable NAT keepalive filter
7841 * @wmi_handle: wmi handle
7842 * @vdev_id: vdev id
7843 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307844 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307845 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307846static QDF_STATUS send_nat_keepalive_en_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05307847{
7848 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *cmd;
7849 wmi_buf_t buf;
7850 int32_t len = sizeof(*cmd);
7851
Govind Singhb53420c2016-03-09 14:32:57 +05307852 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307853 buf = wmi_buf_alloc(wmi_handle, len);
7854 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307855 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307856 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307857 }
7858 cmd = (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param *)
7859 wmi_buf_data(buf);
7860 WMITLV_SET_HDR(&cmd->tlv_header,
7861 WMITLV_TAG_STRUC_WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param,
7862 WMITLV_GET_STRUCT_TLVLEN
7863 (WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMD_fixed_param));
7864 cmd->vdev_id = vdev_id;
7865 cmd->action = IPSEC_NATKEEPALIVE_FILTER_ENABLE;
7866 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7867 WMI_VDEV_IPSEC_NATKEEPALIVE_FILTER_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307868 WMI_LOGP("%s: Failed to send NAT keepalive enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307869 __func__);
7870 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307871 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307872 }
7873
7874 return 0;
7875}
7876
7877/**
7878 * wmi_unified_csa_offload_enable() - sen CSA offload enable command
7879 * @wmi_handle: wmi handle
7880 * @vdev_id: vdev id
7881 *
Govind Singhe7f2f342016-05-23 12:12:52 +05307882 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05307883 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307884static QDF_STATUS send_csa_offload_enable_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05307885 uint8_t vdev_id)
7886{
7887 wmi_csa_offload_enable_cmd_fixed_param *cmd;
7888 wmi_buf_t buf;
7889 int32_t len = sizeof(*cmd);
7890
Govind Singhb53420c2016-03-09 14:32:57 +05307891 WMI_LOGD("%s: vdev_id %d", __func__, vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05307892 buf = wmi_buf_alloc(wmi_handle, len);
7893 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307894 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05307895 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05307896 }
7897 cmd = (wmi_csa_offload_enable_cmd_fixed_param *) wmi_buf_data(buf);
7898 WMITLV_SET_HDR(&cmd->tlv_header,
7899 WMITLV_TAG_STRUC_wmi_csa_offload_enable_cmd_fixed_param,
7900 WMITLV_GET_STRUCT_TLVLEN
7901 (wmi_csa_offload_enable_cmd_fixed_param));
7902 cmd->vdev_id = vdev_id;
7903 cmd->csa_offload_enable = WMI_CSA_OFFLOAD_ENABLE;
7904 if (wmi_unified_cmd_send(wmi_handle, buf, len,
7905 WMI_CSA_OFFLOAD_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307906 WMI_LOGP("%s: Failed to send CSA offload enable command",
Govind Singh20c5dac2016-03-07 15:33:31 +05307907 __func__);
7908 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05307909 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307910 }
7911
7912 return 0;
7913}
7914
7915/**
7916 * send_start_oem_data_cmd_tlv() - start OEM data request to target
7917 * @wmi_handle: wmi handle
7918 * @startOemDataReq: start request params
7919 *
7920 * Return: CDF status
7921 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307922static QDF_STATUS send_start_oem_data_cmd_tlv(wmi_unified_t wmi_handle,
Krishna Kumaar Natarajanb16bb272016-07-21 15:02:44 -07007923 uint32_t data_len,
Govind Singh20c5dac2016-03-07 15:33:31 +05307924 uint8_t *data)
7925{
7926 wmi_buf_t buf;
7927 uint8_t *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05307928 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307929
7930 buf = wmi_buf_alloc(wmi_handle,
7931 (data_len + WMI_TLV_HDR_SIZE));
7932 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307933 WMI_LOGE(FL("wmi_buf_alloc failed"));
7934 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05307935 }
7936
7937 cmd = (uint8_t *) wmi_buf_data(buf);
7938
7939 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE, data_len);
7940 cmd += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05307941 qdf_mem_copy(cmd, data,
Govind Singh20c5dac2016-03-07 15:33:31 +05307942 data_len);
7943
Govind Singhb53420c2016-03-09 14:32:57 +05307944 WMI_LOGI(FL("Sending OEM Data Request to target, data len %d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05307945 data_len);
7946
7947 ret = wmi_unified_cmd_send(wmi_handle, buf,
7948 (data_len +
7949 WMI_TLV_HDR_SIZE), WMI_OEM_REQ_CMDID);
7950
Govind Singh67922e82016-04-01 16:48:57 +05307951 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05307952 WMI_LOGE(FL(":wmi cmd send failed"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05307953 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05307954 }
7955
Govind Singh67922e82016-04-01 16:48:57 +05307956 return ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307957}
7958
7959/**
7960 * send_dfs_phyerr_filter_offload_en_cmd_tlv() - enable dfs phyerr filter
7961 * @wmi_handle: wmi handle
7962 * @dfs_phyerr_filter_offload: is dfs phyerr filter offload
7963 *
7964 * Send WMI_DFS_PHYERR_FILTER_ENA_CMDID or
7965 * WMI_DFS_PHYERR_FILTER_DIS_CMDID command
7966 * to firmware based on phyerr filtering
7967 * offload status.
7968 *
7969 * Return: 1 success, 0 failure
7970 */
Sathish Kumarfd347372017-02-13 12:29:09 +05307971static QDF_STATUS
Govind Singh20c5dac2016-03-07 15:33:31 +05307972send_dfs_phyerr_filter_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
7973 bool dfs_phyerr_filter_offload)
7974{
7975 wmi_dfs_phyerr_filter_ena_cmd_fixed_param *enable_phyerr_offload_cmd;
7976 wmi_dfs_phyerr_filter_dis_cmd_fixed_param *disable_phyerr_offload_cmd;
7977 wmi_buf_t buf;
7978 uint16_t len;
Govind Singh67922e82016-04-01 16:48:57 +05307979 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05307980
7981
Arif Hussain4ab1c4c2016-06-30 15:57:49 -07007982 if (false == dfs_phyerr_filter_offload) {
Govind Singhb53420c2016-03-09 14:32:57 +05307983 WMI_LOGD("%s:Phyerror Filtering offload is Disabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05307984 __func__);
7985 len = sizeof(*disable_phyerr_offload_cmd);
7986 buf = wmi_buf_alloc(wmi_handle, len);
7987 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05307988 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05307989 return 0;
7990 }
7991 disable_phyerr_offload_cmd =
7992 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param *)
7993 wmi_buf_data(buf);
7994
7995 WMITLV_SET_HDR(&disable_phyerr_offload_cmd->tlv_header,
7996 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_dis_cmd_fixed_param,
7997 WMITLV_GET_STRUCT_TLVLEN
7998 (wmi_dfs_phyerr_filter_dis_cmd_fixed_param));
7999
8000 /*
8001 * Send WMI_DFS_PHYERR_FILTER_DIS_CMDID
8002 * to the firmware to disable the phyerror
8003 * filtering offload.
8004 */
8005 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8006 WMI_DFS_PHYERR_FILTER_DIS_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308007 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308008 WMI_LOGE("%s: Failed to send WMI_DFS_PHYERR_FILTER_DIS_CMDID ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308009 __func__, ret);
8010 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308011 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308012 }
Govind Singhb53420c2016-03-09 14:32:57 +05308013 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_DIS_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308014 __func__);
8015 } else {
Govind Singhb53420c2016-03-09 14:32:57 +05308016 WMI_LOGD("%s:Phyerror Filtering offload is Enabled in ini",
Govind Singh20c5dac2016-03-07 15:33:31 +05308017 __func__);
8018
8019 len = sizeof(*enable_phyerr_offload_cmd);
8020 buf = wmi_buf_alloc(wmi_handle, len);
8021 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308022 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8023 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308024 }
8025
8026 enable_phyerr_offload_cmd =
8027 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param *)
8028 wmi_buf_data(buf);
8029
8030 WMITLV_SET_HDR(&enable_phyerr_offload_cmd->tlv_header,
8031 WMITLV_TAG_STRUC_wmi_dfs_phyerr_filter_ena_cmd_fixed_param,
8032 WMITLV_GET_STRUCT_TLVLEN
8033 (wmi_dfs_phyerr_filter_ena_cmd_fixed_param));
8034
8035 /*
8036 * Send a WMI_DFS_PHYERR_FILTER_ENA_CMDID
8037 * to the firmware to enable the phyerror
8038 * filtering offload.
8039 */
8040 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8041 WMI_DFS_PHYERR_FILTER_ENA_CMDID);
8042
Govind Singh67922e82016-04-01 16:48:57 +05308043 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308044 WMI_LOGE("%s: Failed to send DFS PHYERR CMD ret=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308045 __func__, ret);
8046 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308047 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308048 }
Govind Singhb53420c2016-03-09 14:32:57 +05308049 WMI_LOGD("%s: WMI_DFS_PHYERR_FILTER_ENA_CMDID Send Success",
Govind Singh20c5dac2016-03-07 15:33:31 +05308050 __func__);
8051 }
8052
Govind Singhb53420c2016-03-09 14:32:57 +05308053 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308054}
8055
8056#if !defined(REMOVE_PKT_LOG)
8057/**
8058 * send_pktlog_wmi_send_cmd_tlv() - send pktlog enable/disable command to target
8059 * @wmi_handle: wmi handle
8060 * @pktlog_event: pktlog event
8061 * @cmd_id: pktlog cmd id
8062 *
8063 * Return: CDF status
8064 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308065static QDF_STATUS send_pktlog_wmi_send_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308066 WMI_PKTLOG_EVENT pktlog_event,
Nirav Shah47ec2482016-07-27 19:06:13 +05308067 WMI_CMD_ID cmd_id, uint8_t user_triggered)
Govind Singh20c5dac2016-03-07 15:33:31 +05308068{
8069 WMI_PKTLOG_EVENT PKTLOG_EVENT;
8070 WMI_CMD_ID CMD_ID;
8071 wmi_pdev_pktlog_enable_cmd_fixed_param *cmd;
8072 wmi_pdev_pktlog_disable_cmd_fixed_param *disable_cmd;
8073 int len = 0;
8074 wmi_buf_t buf;
8075
8076 PKTLOG_EVENT = pktlog_event;
8077 CMD_ID = cmd_id;
8078
8079 switch (CMD_ID) {
8080 case WMI_PDEV_PKTLOG_ENABLE_CMDID:
8081 len = sizeof(*cmd);
8082 buf = wmi_buf_alloc(wmi_handle, len);
8083 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308084 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8085 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308086 }
8087 cmd = (wmi_pdev_pktlog_enable_cmd_fixed_param *)
8088 wmi_buf_data(buf);
8089 WMITLV_SET_HDR(&cmd->tlv_header,
8090 WMITLV_TAG_STRUC_wmi_pdev_pktlog_enable_cmd_fixed_param,
8091 WMITLV_GET_STRUCT_TLVLEN
8092 (wmi_pdev_pktlog_enable_cmd_fixed_param));
8093 cmd->evlist = PKTLOG_EVENT;
Nirav Shah47ec2482016-07-27 19:06:13 +05308094 cmd->enable = user_triggered ? WMI_PKTLOG_ENABLE_FORCE
8095 : WMI_PKTLOG_ENABLE_AUTO;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308096 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
8097 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308098 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8099 WMI_PDEV_PKTLOG_ENABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308100 WMI_LOGE("failed to send pktlog enable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308101 goto wmi_send_failed;
8102 }
8103 break;
8104 case WMI_PDEV_PKTLOG_DISABLE_CMDID:
8105 len = sizeof(*disable_cmd);
8106 buf = wmi_buf_alloc(wmi_handle, len);
8107 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308108 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8109 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308110 }
8111 disable_cmd = (wmi_pdev_pktlog_disable_cmd_fixed_param *)
8112 wmi_buf_data(buf);
8113 WMITLV_SET_HDR(&disable_cmd->tlv_header,
8114 WMITLV_TAG_STRUC_wmi_pdev_pktlog_disable_cmd_fixed_param,
8115 WMITLV_GET_STRUCT_TLVLEN
8116 (wmi_pdev_pktlog_disable_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308117 disable_cmd->pdev_id =
8118 wmi_handle->ops->convert_pdev_id_host_to_target(
8119 WMI_HOST_PDEV_ID_SOC);
Govind Singh20c5dac2016-03-07 15:33:31 +05308120 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8121 WMI_PDEV_PKTLOG_DISABLE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308122 WMI_LOGE("failed to send pktlog disable cmdid");
Govind Singh20c5dac2016-03-07 15:33:31 +05308123 goto wmi_send_failed;
8124 }
8125 break;
8126 default:
Govind Singhb53420c2016-03-09 14:32:57 +05308127 WMI_LOGD("%s: invalid PKTLOG command", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308128 break;
8129 }
8130
Govind Singhb53420c2016-03-09 14:32:57 +05308131 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308132
8133wmi_send_failed:
8134 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308135 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308136}
8137#endif /* REMOVE_PKT_LOG */
8138
8139/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308140 * send_wow_delete_pattern_cmd_tlv() - delete wow pattern in target
8141 * @wmi_handle: wmi handle
8142 * @ptrn_id: pattern id
8143 * @vdev_id: vdev id
8144 *
8145 * Return: CDF status
8146 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +05308147static QDF_STATUS send_wow_delete_pattern_cmd_tlv(wmi_unified_t wmi_handle,
8148 uint8_t ptrn_id, uint8_t vdev_id)
Govind Singh20c5dac2016-03-07 15:33:31 +05308149{
8150 WMI_WOW_DEL_PATTERN_CMD_fixed_param *cmd;
8151 wmi_buf_t buf;
8152 int32_t len;
8153 int ret;
8154
8155 len = sizeof(WMI_WOW_DEL_PATTERN_CMD_fixed_param);
8156
8157
8158 buf = wmi_buf_alloc(wmi_handle, len);
8159 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308160 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8161 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308162 }
8163
8164 cmd = (WMI_WOW_DEL_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
8165
8166 WMITLV_SET_HDR(&cmd->tlv_header,
8167 WMITLV_TAG_STRUC_WMI_WOW_DEL_PATTERN_CMD_fixed_param,
8168 WMITLV_GET_STRUCT_TLVLEN(
8169 WMI_WOW_DEL_PATTERN_CMD_fixed_param));
8170 cmd->vdev_id = vdev_id;
8171 cmd->pattern_id = ptrn_id;
8172 cmd->pattern_type = WOW_BITMAP_PATTERN;
8173
Govind Singhb53420c2016-03-09 14:32:57 +05308174 WMI_LOGI("Deleting pattern id: %d vdev id %d in fw",
Govind Singh20c5dac2016-03-07 15:33:31 +05308175 cmd->pattern_id, vdev_id);
8176
8177 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8178 WMI_WOW_DEL_WAKE_PATTERN_CMDID);
8179 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308180 WMI_LOGE("%s: Failed to delete wow ptrn from fw", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308181 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308182 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308183 }
8184
Govind Singhb53420c2016-03-09 14:32:57 +05308185 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308186}
8187
8188/**
8189 * send_host_wakeup_ind_to_fw_cmd_tlv() - send wakeup ind to fw
8190 * @wmi_handle: wmi handle
8191 *
8192 * Sends host wakeup indication to FW. On receiving this indication,
8193 * FW will come out of WOW.
8194 *
8195 * Return: CDF status
8196 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308197static QDF_STATUS send_host_wakeup_ind_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308198{
8199 wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *cmd;
8200 wmi_buf_t buf;
Govind Singhb53420c2016-03-09 14:32:57 +05308201 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308202 int32_t len;
8203 int ret;
8204
8205 len = sizeof(wmi_wow_hostwakeup_from_sleep_cmd_fixed_param);
8206
8207 buf = wmi_buf_alloc(wmi_handle, len);
8208 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308209 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8210 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308211 }
8212
8213 cmd = (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param *)
8214 wmi_buf_data(buf);
8215 WMITLV_SET_HDR(&cmd->tlv_header,
8216 WMITLV_TAG_STRUC_wmi_wow_hostwakeup_from_sleep_cmd_fixed_param,
8217 WMITLV_GET_STRUCT_TLVLEN
8218 (wmi_wow_hostwakeup_from_sleep_cmd_fixed_param));
8219
8220
8221 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8222 WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID);
8223 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308224 WMI_LOGE("Failed to send host wakeup indication to fw");
Govind Singh20c5dac2016-03-07 15:33:31 +05308225 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308226 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308227 }
8228
Govind Singhb53420c2016-03-09 14:32:57 +05308229 return qdf_status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308230}
8231
8232/**
8233 * send_del_ts_cmd_tlv() - send DELTS request to fw
8234 * @wmi_handle: wmi handle
8235 * @msg: delts params
8236 *
8237 * Return: CDF status
8238 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308239static QDF_STATUS send_del_ts_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05308240 uint8_t ac)
8241{
8242 wmi_vdev_wmm_delts_cmd_fixed_param *cmd;
8243 wmi_buf_t buf;
8244 int32_t len = sizeof(*cmd);
8245
8246 buf = wmi_buf_alloc(wmi_handle, len);
8247 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308248 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8249 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308250 }
8251 cmd = (wmi_vdev_wmm_delts_cmd_fixed_param *) wmi_buf_data(buf);
8252 WMITLV_SET_HDR(&cmd->tlv_header,
8253 WMITLV_TAG_STRUC_wmi_vdev_wmm_delts_cmd_fixed_param,
8254 WMITLV_GET_STRUCT_TLVLEN
8255 (wmi_vdev_wmm_delts_cmd_fixed_param));
8256 cmd->vdev_id = vdev_id;
8257 cmd->ac = ac;
8258
Govind Singhb53420c2016-03-09 14:32:57 +05308259 WMI_LOGD("Delts vdev:%d, ac:%d, %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308260 cmd->vdev_id, cmd->ac, __func__, __LINE__);
8261 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8262 WMI_VDEV_WMM_DELTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308263 WMI_LOGP("%s: Failed to send vdev DELTS command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308264 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308265 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308266 }
8267
Govind Singhb53420c2016-03-09 14:32:57 +05308268 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308269}
8270
8271/**
8272 * send_aggr_qos_cmd_tlv() - send aggr qos request to fw
8273 * @wmi_handle: handle to wmi
8274 * @aggr_qos_rsp_msg - combined struct for all ADD_TS requests.
8275 *
Govind Singhb53420c2016-03-09 14:32:57 +05308276 * A function to handle WMI_AGGR_QOS_REQ. This will send out
Govind Singh20c5dac2016-03-07 15:33:31 +05308277 * ADD_TS requestes to firmware in loop for all the ACs with
8278 * active flow.
8279 *
8280 * Return: CDF status
8281 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308282static QDF_STATUS send_aggr_qos_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308283 struct aggr_add_ts_param *aggr_qos_rsp_msg)
8284{
8285 int i = 0;
8286 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8287 wmi_buf_t buf;
8288 int32_t len = sizeof(*cmd);
8289
8290 for (i = 0; i < WMI_QOS_NUM_AC_MAX; i++) {
8291 /* if flow in this AC is active */
8292 if (((1 << i) & aggr_qos_rsp_msg->tspecIdx)) {
8293 /*
8294 * as per implementation of wma_add_ts_req() we
8295 * are not waiting any response from firmware so
8296 * apart from sending ADDTS to firmware just send
8297 * success to upper layers
8298 */
Govind Singhb53420c2016-03-09 14:32:57 +05308299 aggr_qos_rsp_msg->status[i] = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308300
8301 buf = wmi_buf_alloc(wmi_handle, len);
8302 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308303 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8304 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308305 }
8306 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *)
8307 wmi_buf_data(buf);
8308 WMITLV_SET_HDR(&cmd->tlv_header,
8309 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8310 WMITLV_GET_STRUCT_TLVLEN
8311 (wmi_vdev_wmm_addts_cmd_fixed_param));
8312 cmd->vdev_id = aggr_qos_rsp_msg->sessionId;
8313 cmd->ac =
Govind Singh224a7312016-06-21 14:33:26 +05308314 WMI_TID_TO_AC(aggr_qos_rsp_msg->tspec[i].tsinfo.
Govind Singh20c5dac2016-03-07 15:33:31 +05308315 traffic.userPrio);
8316 cmd->medium_time_us =
8317 aggr_qos_rsp_msg->tspec[i].mediumTime * 32;
8318 cmd->downgrade_type = WMM_AC_DOWNGRADE_DEPRIO;
Govind Singhb53420c2016-03-09 14:32:57 +05308319 WMI_LOGD("%s:%d: Addts vdev:%d, ac:%d, mediumTime:%d downgrade_type:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308320 __func__, __LINE__, cmd->vdev_id, cmd->ac,
8321 cmd->medium_time_us, cmd->downgrade_type);
8322 if (wmi_unified_cmd_send
8323 (wmi_handle, buf, len,
8324 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308325 WMI_LOGP("%s: Failed to send vdev ADDTS command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308326 __func__);
8327 aggr_qos_rsp_msg->status[i] =
Govind Singhb53420c2016-03-09 14:32:57 +05308328 QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308329 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308330 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308331 }
8332 }
8333 }
8334
Govind Singhb53420c2016-03-09 14:32:57 +05308335 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308336}
8337
8338/**
8339 * send_add_ts_cmd_tlv() - send ADDTS request to fw
8340 * @wmi_handle: wmi handle
8341 * @msg: ADDTS params
8342 *
8343 * Return: CDF status
8344 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308345static QDF_STATUS send_add_ts_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308346 struct add_ts_param *msg)
8347{
8348 wmi_vdev_wmm_addts_cmd_fixed_param *cmd;
8349 wmi_buf_t buf;
8350 int32_t len = sizeof(*cmd);
8351
Govind Singhb53420c2016-03-09 14:32:57 +05308352 msg->status = QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308353
8354 buf = wmi_buf_alloc(wmi_handle, len);
8355 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308356 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8357 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308358 }
8359 cmd = (wmi_vdev_wmm_addts_cmd_fixed_param *) wmi_buf_data(buf);
8360 WMITLV_SET_HDR(&cmd->tlv_header,
8361 WMITLV_TAG_STRUC_wmi_vdev_wmm_addts_cmd_fixed_param,
8362 WMITLV_GET_STRUCT_TLVLEN
8363 (wmi_vdev_wmm_addts_cmd_fixed_param));
8364 cmd->vdev_id = msg->sme_session_id;
8365 cmd->ac = msg->tspec.tsinfo.traffic.userPrio;
8366 cmd->medium_time_us = msg->tspec.mediumTime * 32;
8367 cmd->downgrade_type = WMM_AC_DOWNGRADE_DROP;
Govind Singhb53420c2016-03-09 14:32:57 +05308368 WMI_LOGD("Addts vdev:%d, ac:%d, mediumTime:%d, downgrade_type:%d %s:%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308369 cmd->vdev_id, cmd->ac, cmd->medium_time_us,
8370 cmd->downgrade_type, __func__, __LINE__);
8371 if (wmi_unified_cmd_send(wmi_handle, buf, len,
8372 WMI_VDEV_WMM_ADDTS_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308373 WMI_LOGP("%s: Failed to send vdev ADDTS command", __func__);
8374 msg->status = QDF_STATUS_E_FAILURE;
Abhishek Singh716c46c2016-05-04 16:24:07 +05308375 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308376 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308377 }
8378
Govind Singhb53420c2016-03-09 14:32:57 +05308379 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308380}
8381
8382/**
Govind Singh20c5dac2016-03-07 15:33:31 +05308383 * send_process_add_periodic_tx_ptrn_cmd_tlv - add periodic tx ptrn
8384 * @wmi_handle: wmi handle
8385 * @pAddPeriodicTxPtrnParams: tx ptrn params
8386 *
8387 * Retrun: CDF status
8388 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308389static QDF_STATUS send_process_add_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308390 struct periodic_tx_pattern *
8391 pAddPeriodicTxPtrnParams,
8392 uint8_t vdev_id)
8393{
8394 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8395 wmi_buf_t wmi_buf;
8396 uint32_t len;
8397 uint8_t *buf_ptr;
8398 uint32_t ptrn_len, ptrn_len_aligned;
8399 int j;
8400
8401 ptrn_len = pAddPeriodicTxPtrnParams->ucPtrnSize;
8402 ptrn_len_aligned = roundup(ptrn_len, sizeof(uint32_t));
8403 len = sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param) +
8404 WMI_TLV_HDR_SIZE + ptrn_len_aligned;
8405
8406 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8407 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308408 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8409 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308410 }
8411
8412 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
8413
8414 cmd = (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *) buf_ptr;
8415 WMITLV_SET_HDR(&cmd->tlv_header,
8416 WMITLV_TAG_STRUC_WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8417 WMITLV_GET_STRUCT_TLVLEN
8418 (WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8419
8420 /* Pass the pattern id to delete for the corresponding vdev id */
8421 cmd->vdev_id = vdev_id;
8422 cmd->pattern_id = pAddPeriodicTxPtrnParams->ucPtrnId;
8423 cmd->timeout = pAddPeriodicTxPtrnParams->usPtrnIntervalMs;
8424 cmd->length = pAddPeriodicTxPtrnParams->ucPtrnSize;
8425
8426 /* Pattern info */
8427 buf_ptr += sizeof(WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8428 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ptrn_len_aligned);
8429 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308430 qdf_mem_copy(buf_ptr, pAddPeriodicTxPtrnParams->ucPattern, ptrn_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308431 for (j = 0; j < pAddPeriodicTxPtrnParams->ucPtrnSize; j++)
Govind Singhb53420c2016-03-09 14:32:57 +05308432 WMI_LOGD("%s: Add Ptrn: %02x", __func__, buf_ptr[j] & 0xff);
Govind Singh20c5dac2016-03-07 15:33:31 +05308433
Govind Singhb53420c2016-03-09 14:32:57 +05308434 WMI_LOGD("%s: Add ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308435 __func__, cmd->pattern_id, cmd->vdev_id);
8436
8437 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8438 WMI_ADD_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308439 WMI_LOGE("%s: failed to add pattern set state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05308440 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308441 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308442 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308443 }
Govind Singhb53420c2016-03-09 14:32:57 +05308444 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308445}
8446
8447/**
8448 * send_process_del_periodic_tx_ptrn_cmd_tlv - del periodic tx ptrn
8449 * @wmi_handle: wmi handle
8450 * @vdev_id: vdev id
8451 * @pattern_id: pattern id
8452 *
8453 * Retrun: CDF status
8454 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308455static QDF_STATUS send_process_del_periodic_tx_ptrn_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308456 uint8_t vdev_id,
8457 uint8_t pattern_id)
8458{
8459 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *cmd;
8460 wmi_buf_t wmi_buf;
8461 uint32_t len =
8462 sizeof(WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param);
8463
8464 wmi_buf = wmi_buf_alloc(wmi_handle, len);
8465 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308466 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
8467 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308468 }
8469
8470 cmd = (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param *)
8471 wmi_buf_data(wmi_buf);
8472 WMITLV_SET_HDR(&cmd->tlv_header,
8473 WMITLV_TAG_STRUC_WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param,
8474 WMITLV_GET_STRUCT_TLVLEN
8475 (WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMD_fixed_param));
8476
8477 /* Pass the pattern id to delete for the corresponding vdev id */
8478 cmd->vdev_id = vdev_id;
8479 cmd->pattern_id = pattern_id;
Govind Singhb53420c2016-03-09 14:32:57 +05308480 WMI_LOGD("%s: Del ptrn id: %d vdev_id: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308481 __func__, cmd->pattern_id, cmd->vdev_id);
8482
8483 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
8484 WMI_DEL_PROACTIVE_ARP_RSP_PATTERN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308485 WMI_LOGE("%s: failed to send del pattern command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308486 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308487 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308488 }
Govind Singhb53420c2016-03-09 14:32:57 +05308489 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308490}
8491
8492/**
8493 * send_stats_ext_req_cmd_tlv() - request ext stats from fw
8494 * @wmi_handle: wmi handle
8495 * @preq: stats ext params
8496 *
8497 * Return: CDF status
8498 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308499static QDF_STATUS send_stats_ext_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308500 struct stats_ext_params *preq)
8501{
Govind Singh67922e82016-04-01 16:48:57 +05308502 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308503 wmi_req_stats_ext_cmd_fixed_param *cmd;
8504 wmi_buf_t buf;
8505 uint16_t len;
8506 uint8_t *buf_ptr;
8507
8508 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + preq->request_data_len;
8509
8510 buf = wmi_buf_alloc(wmi_handle, len);
8511 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308512 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +05308513 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308514 }
8515
8516 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8517 cmd = (wmi_req_stats_ext_cmd_fixed_param *) buf_ptr;
8518
8519 WMITLV_SET_HDR(&cmd->tlv_header,
8520 WMITLV_TAG_STRUC_wmi_req_stats_ext_cmd_fixed_param,
8521 WMITLV_GET_STRUCT_TLVLEN
8522 (wmi_req_stats_ext_cmd_fixed_param));
8523 cmd->vdev_id = preq->vdev_id;
8524 cmd->data_len = preq->request_data_len;
8525
Govind Singhb53420c2016-03-09 14:32:57 +05308526 WMI_LOGD("%s: The data len value is %u and vdev id set is %u ",
Govind Singh20c5dac2016-03-07 15:33:31 +05308527 __func__, preq->request_data_len, preq->vdev_id);
8528
8529 buf_ptr += sizeof(wmi_req_stats_ext_cmd_fixed_param);
8530 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->data_len);
8531
8532 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308533 qdf_mem_copy(buf_ptr, preq->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308534
8535 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8536 WMI_REQUEST_STATS_EXT_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308537 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308538 WMI_LOGE("%s: Failed to send notify cmd ret = %d", __func__,
Govind Singh20c5dac2016-03-07 15:33:31 +05308539 ret);
8540 wmi_buf_free(buf);
8541 }
8542
8543 return ret;
8544}
8545
8546/**
8547 * send_enable_ext_wow_cmd_tlv() - enable ext wow in fw
8548 * @wmi_handle: wmi handle
8549 * @params: ext wow params
8550 *
8551 * Return:0 for success or error code
8552 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308553static QDF_STATUS send_enable_ext_wow_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308554 struct ext_wow_params *params)
8555{
8556 wmi_extwow_enable_cmd_fixed_param *cmd;
8557 wmi_buf_t buf;
8558 int32_t len;
8559 int ret;
8560
8561 len = sizeof(wmi_extwow_enable_cmd_fixed_param);
8562 buf = wmi_buf_alloc(wmi_handle, len);
8563 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308564 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8565 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308566 }
8567
8568 cmd = (wmi_extwow_enable_cmd_fixed_param *) wmi_buf_data(buf);
8569
8570 WMITLV_SET_HDR(&cmd->tlv_header,
8571 WMITLV_TAG_STRUC_wmi_extwow_enable_cmd_fixed_param,
8572 WMITLV_GET_STRUCT_TLVLEN
8573 (wmi_extwow_enable_cmd_fixed_param));
8574
8575 cmd->vdev_id = params->vdev_id;
8576 cmd->type = params->type;
8577 cmd->wakeup_pin_num = params->wakeup_pin_num;
8578
Govind Singhb53420c2016-03-09 14:32:57 +05308579 WMI_LOGD("%s: vdev_id %d type %d Wakeup_pin_num %x",
Govind Singh20c5dac2016-03-07 15:33:31 +05308580 __func__, cmd->vdev_id, cmd->type, cmd->wakeup_pin_num);
8581
8582 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8583 WMI_EXTWOW_ENABLE_CMDID);
8584 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308585 WMI_LOGE("%s: Failed to set EXTWOW Enable", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308586 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308587 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308588 }
8589
Govind Singhb53420c2016-03-09 14:32:57 +05308590 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308591
8592}
8593
8594/**
8595 * send_app_type1_params_in_fw_cmd_tlv() - set app type1 params in fw
8596 * @wmi_handle: wmi handle
8597 * @app_type1_params: app type1 params
8598 *
8599 * Return: CDF status
8600 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308601static QDF_STATUS send_app_type1_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308602 struct app_type1_params *app_type1_params)
8603{
8604 wmi_extwow_set_app_type1_params_cmd_fixed_param *cmd;
8605 wmi_buf_t buf;
8606 int32_t len;
8607 int ret;
8608
8609 len = sizeof(wmi_extwow_set_app_type1_params_cmd_fixed_param);
8610 buf = wmi_buf_alloc(wmi_handle, len);
8611 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308612 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8613 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308614 }
8615
8616 cmd = (wmi_extwow_set_app_type1_params_cmd_fixed_param *)
8617 wmi_buf_data(buf);
8618
8619 WMITLV_SET_HDR(&cmd->tlv_header,
8620 WMITLV_TAG_STRUC_wmi_extwow_set_app_type1_params_cmd_fixed_param,
8621 WMITLV_GET_STRUCT_TLVLEN
8622 (wmi_extwow_set_app_type1_params_cmd_fixed_param));
8623
8624 cmd->vdev_id = app_type1_params->vdev_id;
8625 WMI_CHAR_ARRAY_TO_MAC_ADDR(app_type1_params->wakee_mac_addr.bytes,
8626 &cmd->wakee_mac);
Govind Singhb53420c2016-03-09 14:32:57 +05308627 qdf_mem_copy(cmd->ident, app_type1_params->identification_id, 8);
Govind Singh20c5dac2016-03-07 15:33:31 +05308628 cmd->ident_len = app_type1_params->id_length;
Govind Singhb53420c2016-03-09 14:32:57 +05308629 qdf_mem_copy(cmd->passwd, app_type1_params->password, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308630 cmd->passwd_len = app_type1_params->pass_length;
8631
Govind Singhb53420c2016-03-09 14:32:57 +05308632 WMI_LOGD("%s: vdev_id %d wakee_mac_addr %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308633 "identification_id %.8s id_length %u "
8634 "password %.16s pass_length %u",
8635 __func__, cmd->vdev_id, app_type1_params->wakee_mac_addr.bytes,
8636 cmd->ident, cmd->ident_len, cmd->passwd, cmd->passwd_len);
8637
8638 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8639 WMI_EXTWOW_SET_APP_TYPE1_PARAMS_CMDID);
8640 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308641 WMI_LOGE("%s: Failed to set APP TYPE1 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308642 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308643 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308644 }
8645
Govind Singhb53420c2016-03-09 14:32:57 +05308646 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308647}
8648
8649/**
8650 * send_set_app_type2_params_in_fw_cmd_tlv() - set app type2 params in fw
8651 * @wmi_handle: wmi handle
8652 * @appType2Params: app type2 params
8653 *
8654 * Return: CDF status
8655 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308656static QDF_STATUS send_set_app_type2_params_in_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308657 struct app_type2_params *appType2Params)
8658{
8659 wmi_extwow_set_app_type2_params_cmd_fixed_param *cmd;
8660 wmi_buf_t buf;
8661 int32_t len;
8662 int ret;
8663
8664 len = sizeof(wmi_extwow_set_app_type2_params_cmd_fixed_param);
8665 buf = wmi_buf_alloc(wmi_handle, len);
8666 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308667 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
8668 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308669 }
8670
8671 cmd = (wmi_extwow_set_app_type2_params_cmd_fixed_param *)
8672 wmi_buf_data(buf);
8673
8674 WMITLV_SET_HDR(&cmd->tlv_header,
8675 WMITLV_TAG_STRUC_wmi_extwow_set_app_type2_params_cmd_fixed_param,
8676 WMITLV_GET_STRUCT_TLVLEN
8677 (wmi_extwow_set_app_type2_params_cmd_fixed_param));
8678
8679 cmd->vdev_id = appType2Params->vdev_id;
8680
Govind Singhb53420c2016-03-09 14:32:57 +05308681 qdf_mem_copy(cmd->rc4_key, appType2Params->rc4_key, 16);
Govind Singh20c5dac2016-03-07 15:33:31 +05308682 cmd->rc4_key_len = appType2Params->rc4_key_len;
8683
8684 cmd->ip_id = appType2Params->ip_id;
8685 cmd->ip_device_ip = appType2Params->ip_device_ip;
8686 cmd->ip_server_ip = appType2Params->ip_server_ip;
8687
8688 cmd->tcp_src_port = appType2Params->tcp_src_port;
8689 cmd->tcp_dst_port = appType2Params->tcp_dst_port;
8690 cmd->tcp_seq = appType2Params->tcp_seq;
8691 cmd->tcp_ack_seq = appType2Params->tcp_ack_seq;
8692
8693 cmd->keepalive_init = appType2Params->keepalive_init;
8694 cmd->keepalive_min = appType2Params->keepalive_min;
8695 cmd->keepalive_max = appType2Params->keepalive_max;
8696 cmd->keepalive_inc = appType2Params->keepalive_inc;
8697
8698 WMI_CHAR_ARRAY_TO_MAC_ADDR(appType2Params->gateway_mac.bytes,
8699 &cmd->gateway_mac);
8700 cmd->tcp_tx_timeout_val = appType2Params->tcp_tx_timeout_val;
8701 cmd->tcp_rx_timeout_val = appType2Params->tcp_rx_timeout_val;
8702
Govind Singhb53420c2016-03-09 14:32:57 +05308703 WMI_LOGD("%s: vdev_id %d gateway_mac %pM "
Govind Singh20c5dac2016-03-07 15:33:31 +05308704 "rc4_key %.16s rc4_key_len %u "
8705 "ip_id %x ip_device_ip %x ip_server_ip %x "
8706 "tcp_src_port %u tcp_dst_port %u tcp_seq %u "
8707 "tcp_ack_seq %u keepalive_init %u keepalive_min %u "
8708 "keepalive_max %u keepalive_inc %u "
8709 "tcp_tx_timeout_val %u tcp_rx_timeout_val %u",
8710 __func__, cmd->vdev_id, appType2Params->gateway_mac.bytes,
8711 cmd->rc4_key, cmd->rc4_key_len,
8712 cmd->ip_id, cmd->ip_device_ip, cmd->ip_server_ip,
8713 cmd->tcp_src_port, cmd->tcp_dst_port, cmd->tcp_seq,
8714 cmd->tcp_ack_seq, cmd->keepalive_init, cmd->keepalive_min,
8715 cmd->keepalive_max, cmd->keepalive_inc,
8716 cmd->tcp_tx_timeout_val, cmd->tcp_rx_timeout_val);
8717
8718 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8719 WMI_EXTWOW_SET_APP_TYPE2_PARAMS_CMDID);
8720 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05308721 WMI_LOGE("%s: Failed to set APP TYPE2 PARAMS", __func__);
Govind Singh20c5dac2016-03-07 15:33:31 +05308722 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308723 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308724 }
8725
Govind Singhb53420c2016-03-09 14:32:57 +05308726 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05308727
8728}
8729
8730/**
8731 * send_set_auto_shutdown_timer_cmd_tlv() - sets auto shutdown timer in firmware
8732 * @wmi_handle: wmi handle
8733 * @timer_val: auto shutdown timer value
8734 *
8735 * Return: CDF status
8736 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308737static QDF_STATUS send_set_auto_shutdown_timer_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308738 uint32_t timer_val)
8739{
Govind Singh67922e82016-04-01 16:48:57 +05308740 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308741 wmi_buf_t buf = NULL;
8742 uint8_t *buf_ptr;
8743 wmi_host_auto_shutdown_cfg_cmd_fixed_param *wmi_auto_sh_cmd;
8744 int len = sizeof(wmi_host_auto_shutdown_cfg_cmd_fixed_param);
8745
Govind Singhb53420c2016-03-09 14:32:57 +05308746 WMI_LOGD("%s: Set WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID:TIMER_VAL=%d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308747 __func__, timer_val);
8748
8749 buf = wmi_buf_alloc(wmi_handle, len);
8750 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308751 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8752 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308753 }
8754
8755 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8756 wmi_auto_sh_cmd =
8757 (wmi_host_auto_shutdown_cfg_cmd_fixed_param *) buf_ptr;
8758 wmi_auto_sh_cmd->timer_value = timer_val;
8759
8760 WMITLV_SET_HDR(&wmi_auto_sh_cmd->tlv_header,
8761 WMITLV_TAG_STRUC_wmi_host_auto_shutdown_cfg_cmd_fixed_param,
8762 WMITLV_GET_STRUCT_TLVLEN
8763 (wmi_host_auto_shutdown_cfg_cmd_fixed_param));
8764
8765 status = wmi_unified_cmd_send(wmi_handle, buf,
8766 len, WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308767 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308768 WMI_LOGE("%s: WMI_HOST_AUTO_SHUTDOWN_CFG_CMDID Err %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308769 __func__, status);
8770 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308771 }
8772
Govind Singh67922e82016-04-01 16:48:57 +05308773 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308774}
8775
8776/**
8777 * send_nan_req_cmd_tlv() - to send nan request to target
8778 * @wmi_handle: wmi handle
8779 * @nan_req: request data which will be non-null
8780 *
8781 * Return: CDF status
8782 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308783static QDF_STATUS send_nan_req_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308784 struct nan_req_params *nan_req)
8785{
Govind Singh67922e82016-04-01 16:48:57 +05308786 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05308787 wmi_nan_cmd_param *cmd;
8788 wmi_buf_t buf;
8789 uint16_t len = sizeof(*cmd);
8790 uint16_t nan_data_len, nan_data_len_aligned;
8791 uint8_t *buf_ptr;
8792
8793 /*
8794 * <----- cmd ------------><-- WMI_TLV_HDR_SIZE --><--- data ---->
8795 * +------------+----------+-----------------------+--------------+
8796 * | tlv_header | data_len | WMITLV_TAG_ARRAY_BYTE | nan_req_data |
8797 * +------------+----------+-----------------------+--------------+
8798 */
8799 if (!nan_req) {
Govind Singhb53420c2016-03-09 14:32:57 +05308800 WMI_LOGE("%s:nan req is not valid", __func__);
8801 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308802 }
8803 nan_data_len = nan_req->request_data_len;
8804 nan_data_len_aligned = roundup(nan_req->request_data_len,
8805 sizeof(uint32_t));
8806 len += WMI_TLV_HDR_SIZE + nan_data_len_aligned;
8807 buf = wmi_buf_alloc(wmi_handle, len);
8808 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308809 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
8810 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308811 }
8812 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8813 cmd = (wmi_nan_cmd_param *) buf_ptr;
8814 WMITLV_SET_HDR(&cmd->tlv_header,
8815 WMITLV_TAG_STRUC_wmi_nan_cmd_param,
8816 WMITLV_GET_STRUCT_TLVLEN(wmi_nan_cmd_param));
8817 cmd->data_len = nan_req->request_data_len;
Govind Singhb53420c2016-03-09 14:32:57 +05308818 WMI_LOGD("%s: The data len value is %u",
Govind Singh20c5dac2016-03-07 15:33:31 +05308819 __func__, nan_req->request_data_len);
8820 buf_ptr += sizeof(wmi_nan_cmd_param);
8821 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, nan_data_len_aligned);
8822 buf_ptr += WMI_TLV_HDR_SIZE;
Govind Singhb53420c2016-03-09 14:32:57 +05308823 qdf_mem_copy(buf_ptr, nan_req->request_data, cmd->data_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05308824
8825 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
8826 WMI_NAN_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308827 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308828 WMI_LOGE("%s Failed to send set param command ret = %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308829 __func__, ret);
8830 wmi_buf_free(buf);
8831 }
8832
8833 return ret;
8834}
8835
8836/**
8837 * send_process_dhcpserver_offload_cmd_tlv() - enable DHCP server offload
8838 * @wmi_handle: wmi handle
8839 * @pDhcpSrvOffloadInfo: DHCP server offload info
8840 *
Govind Singhe7f2f342016-05-23 12:12:52 +05308841 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05308842 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308843static QDF_STATUS send_process_dhcpserver_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308844 struct dhcp_offload_info_params *pDhcpSrvOffloadInfo)
8845{
8846 wmi_set_dhcp_server_offload_cmd_fixed_param *cmd;
8847 wmi_buf_t buf;
Govind Singh67922e82016-04-01 16:48:57 +05308848 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308849
8850 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
8851 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308852 WMI_LOGE("Failed to allocate buffer to send "
Govind Singh20c5dac2016-03-07 15:33:31 +05308853 "set_dhcp_server_offload cmd");
Govind Singh67922e82016-04-01 16:48:57 +05308854 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308855 }
8856
8857 cmd = (wmi_set_dhcp_server_offload_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05308858 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singh20c5dac2016-03-07 15:33:31 +05308859
8860 WMITLV_SET_HDR(&cmd->tlv_header,
8861 WMITLV_TAG_STRUC_wmi_set_dhcp_server_offload_cmd_fixed_param,
8862 WMITLV_GET_STRUCT_TLVLEN
8863 (wmi_set_dhcp_server_offload_cmd_fixed_param));
8864 cmd->vdev_id = pDhcpSrvOffloadInfo->vdev_id;
8865 cmd->enable = pDhcpSrvOffloadInfo->dhcpSrvOffloadEnabled;
8866 cmd->num_client = pDhcpSrvOffloadInfo->dhcpClientNum;
8867 cmd->srv_ipv4 = pDhcpSrvOffloadInfo->dhcpSrvIP;
8868 cmd->start_lsb = 0;
Govind Singh67922e82016-04-01 16:48:57 +05308869 status = wmi_unified_cmd_send(wmi_handle, buf,
Govind Singh20c5dac2016-03-07 15:33:31 +05308870 sizeof(*cmd),
8871 WMI_SET_DHCP_SERVER_OFFLOAD_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308872 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308873 WMI_LOGE("Failed to send set_dhcp_server_offload cmd");
Govind Singh20c5dac2016-03-07 15:33:31 +05308874 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +05308875 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05308876 }
Govind Singhb53420c2016-03-09 14:32:57 +05308877 WMI_LOGD("Set dhcp server offload to vdevId %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05308878 pDhcpSrvOffloadInfo->vdev_id);
Govind Singh67922e82016-04-01 16:48:57 +05308879
8880 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308881}
8882
8883/**
8884 * send_set_led_flashing_cmd_tlv() - set led flashing in fw
8885 * @wmi_handle: wmi handle
8886 * @flashing: flashing request
8887 *
8888 * Return: CDF status
8889 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308890static QDF_STATUS send_set_led_flashing_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05308891 struct flashing_req_params *flashing)
8892{
8893 wmi_set_led_flashing_cmd_fixed_param *cmd;
Govind Singh67922e82016-04-01 16:48:57 +05308894 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308895 wmi_buf_t buf;
8896 uint8_t *buf_ptr;
8897 int32_t len = sizeof(wmi_set_led_flashing_cmd_fixed_param);
8898
8899 buf = wmi_buf_alloc(wmi_handle, len);
8900 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308901 WMI_LOGP(FL("wmi_buf_alloc failed"));
Govind Singh67922e82016-04-01 16:48:57 +05308902 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308903 }
8904 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8905 cmd = (wmi_set_led_flashing_cmd_fixed_param *) buf_ptr;
8906 WMITLV_SET_HDR(&cmd->tlv_header,
8907 WMITLV_TAG_STRUC_wmi_set_led_flashing_cmd_fixed_param,
8908 WMITLV_GET_STRUCT_TLVLEN
8909 (wmi_set_led_flashing_cmd_fixed_param));
8910 cmd->pattern_id = flashing->pattern_id;
8911 cmd->led_x0 = flashing->led_x0;
8912 cmd->led_x1 = flashing->led_x1;
8913
8914 status = wmi_unified_cmd_send(wmi_handle, buf, len,
8915 WMI_PDEV_SET_LED_FLASHING_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308916 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308917 WMI_LOGE("%s: wmi_unified_cmd_send WMI_PEER_SET_PARAM_CMD"
Govind Singh20c5dac2016-03-07 15:33:31 +05308918 " returned Error %d", __func__, status);
Abhishek Singh716c46c2016-05-04 16:24:07 +05308919 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308920 }
Govind Singh67922e82016-04-01 16:48:57 +05308921
8922 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308923}
8924
8925/**
8926 * send_process_ch_avoid_update_cmd_tlv() - handles channel avoid update request
8927 * @wmi_handle: wmi handle
8928 * @ch_avoid_update_req: channel avoid update params
8929 *
8930 * Return: CDF status
8931 */
Sathish Kumarfd347372017-02-13 12:29:09 +05308932static QDF_STATUS send_process_ch_avoid_update_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh20c5dac2016-03-07 15:33:31 +05308933{
Govind Singh67922e82016-04-01 16:48:57 +05308934 QDF_STATUS status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308935 wmi_buf_t buf = NULL;
8936 uint8_t *buf_ptr;
8937 wmi_chan_avoid_update_cmd_param *ch_avoid_update_fp;
8938 int len = sizeof(wmi_chan_avoid_update_cmd_param);
8939
8940
8941 buf = wmi_buf_alloc(wmi_handle, len);
8942 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05308943 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
8944 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05308945 }
8946
8947 buf_ptr = (uint8_t *) wmi_buf_data(buf);
8948 ch_avoid_update_fp = (wmi_chan_avoid_update_cmd_param *) buf_ptr;
8949 WMITLV_SET_HDR(&ch_avoid_update_fp->tlv_header,
8950 WMITLV_TAG_STRUC_wmi_chan_avoid_update_cmd_param,
8951 WMITLV_GET_STRUCT_TLVLEN
8952 (wmi_chan_avoid_update_cmd_param));
8953
8954 status = wmi_unified_cmd_send(wmi_handle, buf,
8955 len, WMI_CHAN_AVOID_UPDATE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05308956 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +05308957 WMI_LOGE("wmi_unified_cmd_send"
Govind Singh20c5dac2016-03-07 15:33:31 +05308958 " WMITLV_TABLE_WMI_CHAN_AVOID_UPDATE"
8959 " returned Error %d", status);
8960 wmi_buf_free(buf);
Govind Singh20c5dac2016-03-07 15:33:31 +05308961 }
8962
Govind Singh67922e82016-04-01 16:48:57 +05308963 return status;
Govind Singh20c5dac2016-03-07 15:33:31 +05308964}
8965
8966/**
Kiran Venkatappa36445a72017-02-08 15:02:44 +05308967 * send_pdev_set_regdomain_cmd_tlv() - send set regdomain command to fw
8968 * @wmi_handle: wmi handle
8969 * @param: pointer to pdev regdomain params
8970 *
8971 * Return: 0 for success or error code
8972 */
8973static QDF_STATUS
8974send_pdev_set_regdomain_cmd_tlv(wmi_unified_t wmi_handle,
8975 struct pdev_set_regdomain_params *param)
8976{
8977 wmi_buf_t buf;
8978 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
8979 int32_t len = sizeof(*cmd);
8980
8981
8982 buf = wmi_buf_alloc(wmi_handle, len);
8983 if (!buf) {
8984 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
8985 return QDF_STATUS_E_NOMEM;
8986 }
8987 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
8988 WMITLV_SET_HDR(&cmd->tlv_header,
8989 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
8990 WMITLV_GET_STRUCT_TLVLEN
8991 (wmi_pdev_set_regdomain_cmd_fixed_param));
8992
8993 cmd->reg_domain = param->currentRDinuse;
8994 cmd->reg_domain_2G = param->currentRD2G;
8995 cmd->reg_domain_5G = param->currentRD5G;
8996 cmd->conformance_test_limit_2G = param->ctl_2G;
8997 cmd->conformance_test_limit_5G = param->ctl_5G;
8998 cmd->dfs_domain = param->dfsDomain;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05308999 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9000 param->pdev_id);
Kiran Venkatappa36445a72017-02-08 15:02:44 +05309001
9002 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9003 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
9004 WMI_LOGE("%s: Failed to send pdev set regdomain command",
9005 __func__);
9006 wmi_buf_free(buf);
9007 return QDF_STATUS_E_FAILURE;
9008 }
9009
9010 return QDF_STATUS_SUCCESS;
9011}
9012
9013/**
Govind Singh20c5dac2016-03-07 15:33:31 +05309014 * send_regdomain_info_to_fw_cmd_tlv() - send regdomain info to fw
9015 * @wmi_handle: wmi handle
9016 * @reg_dmn: reg domain
9017 * @regdmn2G: 2G reg domain
9018 * @regdmn5G: 5G reg domain
9019 * @ctl2G: 2G test limit
9020 * @ctl5G: 5G test limit
9021 *
9022 * Return: none
9023 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309024static QDF_STATUS send_regdomain_info_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309025 uint32_t reg_dmn, uint16_t regdmn2G,
9026 uint16_t regdmn5G, int8_t ctl2G,
9027 int8_t ctl5G)
9028{
9029 wmi_buf_t buf;
9030 wmi_pdev_set_regdomain_cmd_fixed_param *cmd;
9031 int32_t len = sizeof(*cmd);
9032
9033
9034 buf = wmi_buf_alloc(wmi_handle, len);
9035 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309036 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
9037 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309038 }
9039 cmd = (wmi_pdev_set_regdomain_cmd_fixed_param *) wmi_buf_data(buf);
9040 WMITLV_SET_HDR(&cmd->tlv_header,
9041 WMITLV_TAG_STRUC_wmi_pdev_set_regdomain_cmd_fixed_param,
9042 WMITLV_GET_STRUCT_TLVLEN
9043 (wmi_pdev_set_regdomain_cmd_fixed_param));
9044 cmd->reg_domain = reg_dmn;
9045 cmd->reg_domain_2G = regdmn2G;
9046 cmd->reg_domain_5G = regdmn5G;
9047 cmd->conformance_test_limit_2G = ctl2G;
9048 cmd->conformance_test_limit_5G = ctl5G;
9049
9050 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9051 WMI_PDEV_SET_REGDOMAIN_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309052 WMI_LOGP("%s: Failed to send pdev set regdomain command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309053 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309054 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309055 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309056 }
9057
Govind Singhb53420c2016-03-09 14:32:57 +05309058 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309059}
9060
9061
9062/**
9063 * send_set_tdls_offchan_mode_cmd_tlv() - set tdls off channel mode
9064 * @wmi_handle: wmi handle
9065 * @chan_switch_params: Pointer to tdls channel switch parameter structure
9066 *
9067 * This function sets tdls off channel mode
9068 *
9069 * Return: 0 on success; Negative errno otherwise
9070 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309071static QDF_STATUS send_set_tdls_offchan_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309072 struct tdls_channel_switch_params *chan_switch_params)
9073{
9074 wmi_tdls_set_offchan_mode_cmd_fixed_param *cmd;
9075 wmi_buf_t wmi_buf;
9076 u_int16_t len = sizeof(wmi_tdls_set_offchan_mode_cmd_fixed_param);
9077
9078 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9079 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309080 WMI_LOGE(FL("wmi_buf_alloc failed"));
9081 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309082 }
9083 cmd = (wmi_tdls_set_offchan_mode_cmd_fixed_param *)
9084 wmi_buf_data(wmi_buf);
9085 WMITLV_SET_HDR(&cmd->tlv_header,
9086 WMITLV_TAG_STRUC_wmi_tdls_set_offchan_mode_cmd_fixed_param,
9087 WMITLV_GET_STRUCT_TLVLEN(
9088 wmi_tdls_set_offchan_mode_cmd_fixed_param));
9089
9090 WMI_CHAR_ARRAY_TO_MAC_ADDR(chan_switch_params->peer_mac_addr,
9091 &cmd->peer_macaddr);
9092 cmd->vdev_id = chan_switch_params->vdev_id;
9093 cmd->offchan_mode = chan_switch_params->tdls_sw_mode;
9094 cmd->is_peer_responder = chan_switch_params->is_responder;
9095 cmd->offchan_num = chan_switch_params->tdls_off_ch;
9096 cmd->offchan_bw_bitmap = chan_switch_params->tdls_off_ch_bw_offset;
9097 cmd->offchan_oper_class = chan_switch_params->oper_class;
9098
Govind Singhb53420c2016-03-09 14:32:57 +05309099 WMI_LOGD(FL("Peer MAC Addr mac_addr31to0: 0x%x, mac_addr47to32: 0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309100 cmd->peer_macaddr.mac_addr31to0,
9101 cmd->peer_macaddr.mac_addr47to32);
9102
Govind Singhb53420c2016-03-09 14:32:57 +05309103 WMI_LOGD(FL(
Govind Singh20c5dac2016-03-07 15:33:31 +05309104 "vdev_id: %d, off channel mode: %d, off channel Num: %d, "
9105 "off channel offset: 0x%x, is_peer_responder: %d, operating class: %d"
9106 ),
9107 cmd->vdev_id,
9108 cmd->offchan_mode,
9109 cmd->offchan_num,
9110 cmd->offchan_bw_bitmap,
9111 cmd->is_peer_responder,
9112 cmd->offchan_oper_class);
9113
9114 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9115 WMI_TDLS_SET_OFFCHAN_MODE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309116 WMI_LOGP(FL("failed to send tdls off chan command"));
Abhishek Singh716c46c2016-05-04 16:24:07 +05309117 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309118 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309119 }
9120
9121
Govind Singhb53420c2016-03-09 14:32:57 +05309122 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309123}
9124
9125/**
9126 * send_update_fw_tdls_state_cmd_tlv() - send enable/disable tdls for a vdev
9127 * @wmi_handle: wmi handle
9128 * @pwmaTdlsparams: TDLS params
9129 *
9130 * Return: 0 for sucess or error code
9131 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309132static QDF_STATUS send_update_fw_tdls_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309133 void *tdls_param, uint8_t tdls_state)
9134{
9135 wmi_tdls_set_state_cmd_fixed_param *cmd;
9136 wmi_buf_t wmi_buf;
9137
9138 struct wmi_tdls_params *wmi_tdls = (struct wmi_tdls_params *) tdls_param;
9139 uint16_t len = sizeof(wmi_tdls_set_state_cmd_fixed_param);
9140
9141 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9142 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309143 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
9144 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309145 }
9146 cmd = (wmi_tdls_set_state_cmd_fixed_param *) wmi_buf_data(wmi_buf);
9147 WMITLV_SET_HDR(&cmd->tlv_header,
9148 WMITLV_TAG_STRUC_wmi_tdls_set_state_cmd_fixed_param,
9149 WMITLV_GET_STRUCT_TLVLEN
9150 (wmi_tdls_set_state_cmd_fixed_param));
9151 cmd->vdev_id = wmi_tdls->vdev_id;
9152 cmd->state = tdls_state;
9153 cmd->notification_interval_ms = wmi_tdls->notification_interval_ms;
9154 cmd->tx_discovery_threshold = wmi_tdls->tx_discovery_threshold;
9155 cmd->tx_teardown_threshold = wmi_tdls->tx_teardown_threshold;
9156 cmd->rssi_teardown_threshold = wmi_tdls->rssi_teardown_threshold;
9157 cmd->rssi_delta = wmi_tdls->rssi_delta;
9158 cmd->tdls_options = wmi_tdls->tdls_options;
9159 cmd->tdls_peer_traffic_ind_window = wmi_tdls->peer_traffic_ind_window;
9160 cmd->tdls_peer_traffic_response_timeout_ms =
9161 wmi_tdls->peer_traffic_response_timeout;
9162 cmd->tdls_puapsd_mask = wmi_tdls->puapsd_mask;
9163 cmd->tdls_puapsd_inactivity_time_ms = wmi_tdls->puapsd_inactivity_time;
9164 cmd->tdls_puapsd_rx_frame_threshold =
9165 wmi_tdls->puapsd_rx_frame_threshold;
9166 cmd->teardown_notification_ms =
9167 wmi_tdls->teardown_notification_ms;
9168 cmd->tdls_peer_kickout_threshold =
9169 wmi_tdls->tdls_peer_kickout_threshold;
9170
Govind Singhb53420c2016-03-09 14:32:57 +05309171 WMI_LOGD("%s: tdls_state: %d, state: %d, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309172 "notification_interval_ms: %d, "
9173 "tx_discovery_threshold: %d, "
9174 "tx_teardown_threshold: %d, "
9175 "rssi_teardown_threshold: %d, "
9176 "rssi_delta: %d, "
9177 "tdls_options: 0x%x, "
9178 "tdls_peer_traffic_ind_window: %d, "
9179 "tdls_peer_traffic_response_timeout: %d, "
9180 "tdls_puapsd_mask: 0x%x, "
9181 "tdls_puapsd_inactivity_time: %d, "
9182 "tdls_puapsd_rx_frame_threshold: %d, "
9183 "teardown_notification_ms: %d, "
9184 "tdls_peer_kickout_threshold: %d",
9185 __func__, tdls_state, cmd->state,
9186 cmd->notification_interval_ms,
9187 cmd->tx_discovery_threshold,
9188 cmd->tx_teardown_threshold,
9189 cmd->rssi_teardown_threshold,
9190 cmd->rssi_delta,
9191 cmd->tdls_options,
9192 cmd->tdls_peer_traffic_ind_window,
9193 cmd->tdls_peer_traffic_response_timeout_ms,
9194 cmd->tdls_puapsd_mask,
9195 cmd->tdls_puapsd_inactivity_time_ms,
9196 cmd->tdls_puapsd_rx_frame_threshold,
9197 cmd->teardown_notification_ms,
9198 cmd->tdls_peer_kickout_threshold);
9199
9200 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9201 WMI_TDLS_SET_STATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309202 WMI_LOGP("%s: failed to send tdls set state command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309203 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309204 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309205 }
Govind Singhb53420c2016-03-09 14:32:57 +05309206 WMI_LOGD("%s: vdev_id %d", __func__, wmi_tdls->vdev_id);
Govind Singh20c5dac2016-03-07 15:33:31 +05309207
Govind Singhb53420c2016-03-09 14:32:57 +05309208 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309209}
9210
9211/**
9212 * send_update_tdls_peer_state_cmd_tlv() - update TDLS peer state
9213 * @wmi_handle: wmi handle
9214 * @peerStateParams: TDLS peer state params
9215 *
Govind Singhe7f2f342016-05-23 12:12:52 +05309216 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singh20c5dac2016-03-07 15:33:31 +05309217 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309218static QDF_STATUS send_update_tdls_peer_state_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309219 struct tdls_peer_state_params *peerStateParams,
9220 uint32_t *ch_mhz)
9221{
9222 wmi_tdls_peer_update_cmd_fixed_param *cmd;
9223 wmi_tdls_peer_capabilities *peer_cap;
9224 wmi_channel *chan_info;
9225 wmi_buf_t wmi_buf;
9226 uint8_t *buf_ptr;
9227 uint32_t i;
9228 int32_t len = sizeof(wmi_tdls_peer_update_cmd_fixed_param) +
9229 sizeof(wmi_tdls_peer_capabilities);
9230
9231
9232 len += WMI_TLV_HDR_SIZE +
9233 sizeof(wmi_channel) * peerStateParams->peerCap.peerChanLen;
9234
9235 wmi_buf = wmi_buf_alloc(wmi_handle, len);
9236 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309237 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
9238 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309239 }
9240
9241 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
9242 cmd = (wmi_tdls_peer_update_cmd_fixed_param *) buf_ptr;
9243 WMITLV_SET_HDR(&cmd->tlv_header,
9244 WMITLV_TAG_STRUC_wmi_tdls_peer_update_cmd_fixed_param,
9245 WMITLV_GET_STRUCT_TLVLEN
9246 (wmi_tdls_peer_update_cmd_fixed_param));
9247
9248 cmd->vdev_id = peerStateParams->vdevId;
9249 WMI_CHAR_ARRAY_TO_MAC_ADDR(peerStateParams->peerMacAddr,
9250 &cmd->peer_macaddr);
9251
9252
9253 cmd->peer_state = peerStateParams->peerState;
9254
Govind Singhb53420c2016-03-09 14:32:57 +05309255 WMI_LOGD("%s: vdev_id: %d, peerStateParams->peerMacAddr: %pM, "
Govind Singh20c5dac2016-03-07 15:33:31 +05309256 "peer_macaddr.mac_addr31to0: 0x%x, "
9257 "peer_macaddr.mac_addr47to32: 0x%x, peer_state: %d",
9258 __func__, cmd->vdev_id, peerStateParams->peerMacAddr,
9259 cmd->peer_macaddr.mac_addr31to0,
9260 cmd->peer_macaddr.mac_addr47to32, cmd->peer_state);
9261
9262 buf_ptr += sizeof(wmi_tdls_peer_update_cmd_fixed_param);
9263 peer_cap = (wmi_tdls_peer_capabilities *) buf_ptr;
9264 WMITLV_SET_HDR(&peer_cap->tlv_header,
9265 WMITLV_TAG_STRUC_wmi_tdls_peer_capabilities,
9266 WMITLV_GET_STRUCT_TLVLEN(wmi_tdls_peer_capabilities));
9267
9268 if ((peerStateParams->peerCap.peerUapsdQueue & 0x08) >> 3)
9269 WMI_SET_TDLS_PEER_VO_UAPSD(peer_cap);
9270 if ((peerStateParams->peerCap.peerUapsdQueue & 0x04) >> 2)
9271 WMI_SET_TDLS_PEER_VI_UAPSD(peer_cap);
9272 if ((peerStateParams->peerCap.peerUapsdQueue & 0x02) >> 1)
9273 WMI_SET_TDLS_PEER_BK_UAPSD(peer_cap);
9274 if (peerStateParams->peerCap.peerUapsdQueue & 0x01)
9275 WMI_SET_TDLS_PEER_BE_UAPSD(peer_cap);
9276
9277 /* Ack and More Data Ack are sent as 0, so no need to set
9278 * but fill SP
9279 */
9280 WMI_SET_TDLS_PEER_SP_UAPSD(peer_cap,
9281 peerStateParams->peerCap.peerMaxSp);
9282
9283 peer_cap->buff_sta_support =
9284 peerStateParams->peerCap.peerBuffStaSupport;
9285 peer_cap->off_chan_support =
9286 peerStateParams->peerCap.peerOffChanSupport;
9287 peer_cap->peer_curr_operclass =
9288 peerStateParams->peerCap.peerCurrOperClass;
9289 /* self curr operclass is not being used and so pass op class for
9290 * preferred off chan in it.
9291 */
9292 peer_cap->self_curr_operclass =
9293 peerStateParams->peerCap.opClassForPrefOffChan;
9294 peer_cap->peer_chan_len = peerStateParams->peerCap.peerChanLen;
9295 peer_cap->peer_operclass_len =
9296 peerStateParams->peerCap.peerOperClassLen;
9297
Govind Singhb53420c2016-03-09 14:32:57 +05309298 WMI_LOGD("%s: peer_operclass_len: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309299 __func__, peer_cap->peer_operclass_len);
9300 for (i = 0; i < WMI_TDLS_MAX_SUPP_OPER_CLASSES; i++) {
9301 peer_cap->peer_operclass[i] =
9302 peerStateParams->peerCap.peerOperClass[i];
Govind Singhb53420c2016-03-09 14:32:57 +05309303 WMI_LOGD("%s: peer_operclass[%d]: %d",
Govind Singh20c5dac2016-03-07 15:33:31 +05309304 __func__, i, peer_cap->peer_operclass[i]);
9305 }
9306
9307 peer_cap->is_peer_responder = peerStateParams->peerCap.isPeerResponder;
9308 peer_cap->pref_offchan_num = peerStateParams->peerCap.prefOffChanNum;
9309 peer_cap->pref_offchan_bw =
9310 peerStateParams->peerCap.prefOffChanBandwidth;
9311
Govind Singhb53420c2016-03-09 14:32:57 +05309312 WMI_LOGD
Govind Singh20c5dac2016-03-07 15:33:31 +05309313 ("%s: peer_qos: 0x%x, buff_sta_support: %d, off_chan_support: %d, "
9314 "peer_curr_operclass: %d, self_curr_operclass: %d, peer_chan_len: "
9315 "%d, peer_operclass_len: %d, is_peer_responder: %d, pref_offchan_num:"
9316 " %d, pref_offchan_bw: %d",
9317 __func__, peer_cap->peer_qos, peer_cap->buff_sta_support,
9318 peer_cap->off_chan_support, peer_cap->peer_curr_operclass,
9319 peer_cap->self_curr_operclass, peer_cap->peer_chan_len,
9320 peer_cap->peer_operclass_len, peer_cap->is_peer_responder,
9321 peer_cap->pref_offchan_num, peer_cap->pref_offchan_bw);
9322
9323 /* next fill variable size array of peer chan info */
9324 buf_ptr += sizeof(wmi_tdls_peer_capabilities);
9325 WMITLV_SET_HDR(buf_ptr,
9326 WMITLV_TAG_ARRAY_STRUC,
9327 sizeof(wmi_channel) *
9328 peerStateParams->peerCap.peerChanLen);
9329 chan_info = (wmi_channel *) (buf_ptr + WMI_TLV_HDR_SIZE);
9330
9331 for (i = 0; i < peerStateParams->peerCap.peerChanLen; ++i) {
9332 WMITLV_SET_HDR(&chan_info->tlv_header,
9333 WMITLV_TAG_STRUC_wmi_channel,
9334 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
9335 chan_info->mhz = ch_mhz[i];
9336 chan_info->band_center_freq1 = chan_info->mhz;
9337 chan_info->band_center_freq2 = 0;
9338
Govind Singhb53420c2016-03-09 14:32:57 +05309339 WMI_LOGD("%s: chan[%d] = %u", __func__, i, chan_info->mhz);
Govind Singh20c5dac2016-03-07 15:33:31 +05309340
9341 if (peerStateParams->peerCap.peerChan[i].dfsSet) {
9342 WMI_SET_CHANNEL_FLAG(chan_info, WMI_CHAN_FLAG_PASSIVE);
Govind Singhb53420c2016-03-09 14:32:57 +05309343 WMI_LOGI("chan[%d] DFS[%d]\n",
Govind Singh20c5dac2016-03-07 15:33:31 +05309344 peerStateParams->peerCap.peerChan[i].chanId,
9345 peerStateParams->peerCap.peerChan[i].dfsSet);
9346 }
9347
9348 if (chan_info->mhz < WMI_2_4_GHZ_MAX_FREQ)
9349 WMI_SET_CHANNEL_MODE(chan_info, MODE_11G);
9350 else
9351 WMI_SET_CHANNEL_MODE(chan_info, MODE_11A);
9352
9353 WMI_SET_CHANNEL_MAX_TX_POWER(chan_info,
9354 peerStateParams->peerCap.
9355 peerChan[i].pwr);
9356
9357 WMI_SET_CHANNEL_REG_POWER(chan_info,
9358 peerStateParams->peerCap.peerChan[i].
9359 pwr);
Govind Singhb53420c2016-03-09 14:32:57 +05309360 WMI_LOGD("Channel TX power[%d] = %u: %d", i, chan_info->mhz,
Govind Singh20c5dac2016-03-07 15:33:31 +05309361 peerStateParams->peerCap.peerChan[i].pwr);
9362
9363 chan_info++;
9364 }
9365
9366 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
9367 WMI_TDLS_PEER_UPDATE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309368 WMI_LOGE("%s: failed to send tdls peer update state command",
Govind Singh20c5dac2016-03-07 15:33:31 +05309369 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +05309370 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309371 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309372 }
9373
9374
Govind Singhb53420c2016-03-09 14:32:57 +05309375 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309376}
9377
9378/*
9379 * send_process_fw_mem_dump_cmd_tlv() - Function to request fw memory dump from
9380 * firmware
9381 * @wmi_handle: Pointer to wmi handle
9382 * @mem_dump_req: Pointer for mem_dump_req
9383 *
9384 * This function sends memory dump request to firmware
9385 *
Govind Singhb53420c2016-03-09 14:32:57 +05309386 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309387 *
9388 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309389static QDF_STATUS send_process_fw_mem_dump_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309390 struct fw_dump_req_param *mem_dump_req)
9391{
9392 wmi_get_fw_mem_dump_fixed_param *cmd;
9393 wmi_fw_mem_dump *dump_params;
Govind Singh224a7312016-06-21 14:33:26 +05309394 struct wmi_fw_dump_seg_req *seg_req;
Govind Singh20c5dac2016-03-07 15:33:31 +05309395 int32_t len;
9396 wmi_buf_t buf;
9397 u_int8_t *buf_ptr;
9398 int ret, loop;
9399
9400 /*
9401 * len = sizeof(fixed param) that includes tlv header +
9402 * tlv header for array of struc +
9403 * sizeof (each struct)
9404 */
9405 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9406 len += mem_dump_req->num_seg * sizeof(wmi_fw_mem_dump);
9407 buf = wmi_buf_alloc(wmi_handle, len);
9408
9409 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309410 WMI_LOGE(FL("Failed allocate wmi buffer"));
9411 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309412 }
9413
9414 buf_ptr = (u_int8_t *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309415 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309416 cmd = (wmi_get_fw_mem_dump_fixed_param *) buf_ptr;
9417
9418 WMITLV_SET_HDR(&cmd->tlv_header,
9419 WMITLV_TAG_STRUC_wmi_get_fw_mem_dump_fixed_param,
9420 WMITLV_GET_STRUCT_TLVLEN(wmi_get_fw_mem_dump_fixed_param));
9421
9422 cmd->request_id = mem_dump_req->request_id;
9423 cmd->num_fw_mem_dump_segs = mem_dump_req->num_seg;
9424
9425 /* TLV indicating array of structures to follow */
9426 buf_ptr += sizeof(wmi_get_fw_mem_dump_fixed_param);
9427 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9428 sizeof(wmi_fw_mem_dump) *
9429 cmd->num_fw_mem_dump_segs);
9430
9431 buf_ptr += WMI_TLV_HDR_SIZE;
9432 dump_params = (wmi_fw_mem_dump *) buf_ptr;
9433
Govind Singhb53420c2016-03-09 14:32:57 +05309434 WMI_LOGI(FL("request_id:%d num_seg:%d"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309435 mem_dump_req->request_id, mem_dump_req->num_seg);
9436 for (loop = 0; loop < cmd->num_fw_mem_dump_segs; loop++) {
Govind Singh224a7312016-06-21 14:33:26 +05309437 seg_req = (struct wmi_fw_dump_seg_req *)
Govind Singh20c5dac2016-03-07 15:33:31 +05309438 ((uint8_t *)(mem_dump_req->segment) +
9439 loop * sizeof(*seg_req));
9440 WMITLV_SET_HDR(&dump_params->tlv_header,
9441 WMITLV_TAG_STRUC_wmi_fw_mem_dump_params,
9442 WMITLV_GET_STRUCT_TLVLEN(wmi_fw_mem_dump));
9443 dump_params->seg_id = seg_req->seg_id;
9444 dump_params->seg_start_addr_lo = seg_req->seg_start_addr_lo;
9445 dump_params->seg_start_addr_hi = seg_req->seg_start_addr_hi;
9446 dump_params->seg_length = seg_req->seg_length;
9447 dump_params->dest_addr_lo = seg_req->dst_addr_lo;
9448 dump_params->dest_addr_hi = seg_req->dst_addr_hi;
Govind Singhb53420c2016-03-09 14:32:57 +05309449 WMI_LOGI(FL("seg_number:%d"), loop);
9450 WMI_LOGI(FL("seg_id:%d start_addr_lo:0x%x start_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309451 dump_params->seg_id, dump_params->seg_start_addr_lo,
9452 dump_params->seg_start_addr_hi);
Govind Singhb53420c2016-03-09 14:32:57 +05309453 WMI_LOGI(FL("seg_length:%d dst_addr_lo:0x%x dst_addr_hi:0x%x"),
Govind Singh20c5dac2016-03-07 15:33:31 +05309454 dump_params->seg_length, dump_params->dest_addr_lo,
9455 dump_params->dest_addr_hi);
9456 dump_params++;
9457 }
9458
9459 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9460 WMI_GET_FW_MEM_DUMP_CMDID);
9461 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +05309462 WMI_LOGE(FL("Failed to send get firmware mem dump request"));
Govind Singh20c5dac2016-03-07 15:33:31 +05309463 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309464 return QDF_STATUS_E_FAILURE;
Govind Singh20c5dac2016-03-07 15:33:31 +05309465 }
9466
Govind Singhb53420c2016-03-09 14:32:57 +05309467 WMI_LOGI(FL("Get firmware mem dump request sent successfully"));
9468 return QDF_STATUS_SUCCESS;
Govind Singh20c5dac2016-03-07 15:33:31 +05309469}
9470
9471/*
9472 * send_process_set_ie_info_cmd_tlv() - Function to send IE info to firmware
9473 * @wmi_handle: Pointer to WMi handle
9474 * @ie_data: Pointer for ie data
9475 *
9476 * This function sends IE information to firmware
9477 *
Govind Singhb53420c2016-03-09 14:32:57 +05309478 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh20c5dac2016-03-07 15:33:31 +05309479 *
9480 */
Sathish Kumarfd347372017-02-13 12:29:09 +05309481static QDF_STATUS send_process_set_ie_info_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh20c5dac2016-03-07 15:33:31 +05309482 struct vdev_ie_info_param *ie_info)
9483{
9484 wmi_vdev_set_ie_cmd_fixed_param *cmd;
9485 wmi_buf_t buf;
9486 uint8_t *buf_ptr;
9487 uint32_t len, ie_len_aligned;
Govind Singh67922e82016-04-01 16:48:57 +05309488 QDF_STATUS ret;
Govind Singh20c5dac2016-03-07 15:33:31 +05309489
9490
9491 ie_len_aligned = roundup(ie_info->length, sizeof(uint32_t));
9492 /* Allocate memory for the WMI command */
9493 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE + ie_len_aligned;
9494
9495 buf = wmi_buf_alloc(wmi_handle, len);
9496 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +05309497 WMI_LOGE(FL("wmi_buf_alloc failed"));
9498 return QDF_STATUS_E_NOMEM;
Govind Singh20c5dac2016-03-07 15:33:31 +05309499 }
9500
9501 buf_ptr = wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +05309502 qdf_mem_zero(buf_ptr, len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309503
9504 /* Populate the WMI command */
9505 cmd = (wmi_vdev_set_ie_cmd_fixed_param *)buf_ptr;
9506
9507 WMITLV_SET_HDR(&cmd->tlv_header,
9508 WMITLV_TAG_STRUC_wmi_vdev_set_ie_cmd_fixed_param,
9509 WMITLV_GET_STRUCT_TLVLEN(
9510 wmi_vdev_set_ie_cmd_fixed_param));
9511 cmd->vdev_id = ie_info->vdev_id;
9512 cmd->ie_id = ie_info->ie_id;
9513 cmd->ie_len = ie_info->length;
Naveen Rawat61be23a2016-08-03 16:41:33 -07009514 cmd->band = ie_info->band;
Govind Singh20c5dac2016-03-07 15:33:31 +05309515
Govind Singhb53420c2016-03-09 14:32:57 +05309516 WMI_LOGD(FL("IE:%d of size:%d sent for vdev:%d"), ie_info->ie_id,
Govind Singh20c5dac2016-03-07 15:33:31 +05309517 ie_info->length, ie_info->vdev_id);
9518
9519 buf_ptr += sizeof(*cmd);
9520 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, ie_len_aligned);
9521 buf_ptr += WMI_TLV_HDR_SIZE;
9522
Govind Singhb53420c2016-03-09 14:32:57 +05309523 qdf_mem_copy(buf_ptr, ie_info->data, cmd->ie_len);
Govind Singh20c5dac2016-03-07 15:33:31 +05309524
9525 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
9526 WMI_VDEV_SET_IE_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +05309527 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +05309528 WMI_LOGE(FL("Failed to send set IE command ret = %d"), ret);
Govind Singh20c5dac2016-03-07 15:33:31 +05309529 wmi_buf_free(buf);
9530 }
9531
9532 return ret;
9533}
9534
Sathish Kumar497bef42017-03-01 14:02:36 +05309535/**
9536 * send_smart_ant_enable_cmd_tlv() - WMI smart ant enable function
9537 *
9538 * @param wmi_handle : handle to WMI.
9539 * @param param : pointer to antenna param
9540 *
9541 * This function sends smart antenna enable command to FW
9542 *
9543 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9544 */
9545static QDF_STATUS send_smart_ant_enable_cmd_tlv(wmi_unified_t wmi_handle,
9546 struct smart_ant_enable_params *param)
9547{
9548 /* Send WMI COMMAND to Enable */
9549 wmi_pdev_smart_ant_enable_cmd_fixed_param *cmd;
9550 wmi_pdev_smart_ant_gpio_handle *gpio_param;
9551 wmi_buf_t buf;
9552 uint8_t *buf_ptr;
9553 int len = 0;
9554 QDF_STATUS ret;
9555 int loop = 0;
9556
9557 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
9558 len += WMI_HAL_MAX_SANTENNA * sizeof(wmi_pdev_smart_ant_gpio_handle);
9559 buf = wmi_buf_alloc(wmi_handle, len);
9560
9561 if (!buf) {
9562 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9563 return QDF_STATUS_E_NOMEM;
9564 }
9565
9566 buf_ptr = wmi_buf_data(buf);
9567 qdf_mem_zero(buf_ptr, len);
9568 cmd = (wmi_pdev_smart_ant_enable_cmd_fixed_param *)buf_ptr;
9569
9570 WMITLV_SET_HDR(&cmd->tlv_header,
9571 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_enable_cmd_fixed_param,
9572 WMITLV_GET_STRUCT_TLVLEN(
9573 wmi_pdev_smart_ant_enable_cmd_fixed_param));
9574
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309575 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9576 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309577 cmd->enable = param->enable;
9578 cmd->mode = param->mode;
9579 cmd->rx_antenna = param->rx_antenna;
9580 cmd->tx_default_antenna = param->rx_antenna;
9581
9582 /* TLV indicating array of structures to follow */
9583 buf_ptr += sizeof(wmi_pdev_smart_ant_enable_cmd_fixed_param);
9584 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
9585 WMI_HAL_MAX_SANTENNA *
9586 sizeof(wmi_pdev_smart_ant_gpio_handle));
9587
9588 buf_ptr += WMI_TLV_HDR_SIZE;
9589 gpio_param = (wmi_pdev_smart_ant_gpio_handle *)buf_ptr;
9590
9591 for (loop = 0; loop < WMI_HAL_MAX_SANTENNA; loop++) {
9592 WMITLV_SET_HDR(&gpio_param->tlv_header,
9593 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_gpio_handle,
9594 WMITLV_GET_STRUCT_TLVLEN(
9595 wmi_pdev_smart_ant_gpio_handle));
9596 if (param->mode == SMART_ANT_MODE_SERIAL) {
9597 if (loop < WMI_HOST_MAX_SERIAL_ANTENNA) {
9598 gpio_param->gpio_pin = param->gpio_pin[loop];
9599 gpio_param->gpio_func = param->gpio_func[loop];
9600 } else {
9601 gpio_param->gpio_pin = 0;
9602 gpio_param->gpio_func = 0;
9603 }
9604 } else if (param->mode == SMART_ANT_MODE_PARALLEL) {
9605 gpio_param->gpio_pin = param->gpio_pin[loop];
9606 gpio_param->gpio_func = param->gpio_func[loop];
9607 }
9608 /* Setting it to 0 for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309609 gpio_param->pdev_id =
9610 wmi_handle->ops->convert_pdev_id_host_to_target(
9611 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309612 gpio_param++;
9613 }
9614
9615 ret = wmi_unified_cmd_send(wmi_handle,
9616 buf,
9617 len,
9618 WMI_PDEV_SMART_ANT_ENABLE_CMDID);
9619
9620 if (ret != 0) {
9621 WMI_LOGE(" %s :WMI Failed\n", __func__);
9622 WMI_LOGE("enable:%d mode:%d rx_antenna: 0x%08x PINS: [%d %d %d %d] Func[%d %d %d %d] cmdstatus=%d\n",
9623 cmd->enable,
9624 cmd->mode,
9625 cmd->rx_antenna,
9626 param->gpio_pin[0], param->gpio_pin[1],
9627 param->gpio_pin[2], param->gpio_pin[3],
9628 param->gpio_func[0], param->gpio_func[1],
9629 param->gpio_func[2], param->gpio_func[3],
9630 ret);
9631 wmi_buf_free(buf);
9632 }
9633
9634 return ret;
9635}
9636
9637/**
9638 * send_smart_ant_set_rx_ant_cmd_tlv() - WMI set rx antenna function
9639 *
9640 * @param wmi_handle : handle to WMI.
9641 * @param param : pointer to rx antenna param
9642 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9643 */
9644static QDF_STATUS send_smart_ant_set_rx_ant_cmd_tlv(wmi_unified_t wmi_handle,
9645 struct smart_ant_rx_ant_params *param)
9646{
9647 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *cmd;
9648 wmi_buf_t buf;
9649 uint8_t *buf_ptr;
9650 uint32_t len;
9651 QDF_STATUS ret;
9652
9653 len = sizeof(*cmd);
9654 buf = wmi_buf_alloc(wmi_handle, len);
9655 WMI_LOGD("%s:\n", __func__);
9656 if (!buf) {
9657 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9658 return QDF_STATUS_E_NOMEM;
9659 }
9660
9661 buf_ptr = wmi_buf_data(buf);
9662 cmd = (wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param *)buf_ptr;
9663 WMITLV_SET_HDR(&cmd->tlv_header,
9664 WMITLV_TAG_STRUC_wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param,
9665 WMITLV_GET_STRUCT_TLVLEN(
9666 wmi_pdev_smart_ant_set_rx_antenna_cmd_fixed_param));
9667 cmd->rx_antenna = param->antenna;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309668 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9669 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309670
9671 ret = wmi_unified_cmd_send(wmi_handle,
9672 buf,
9673 len,
9674 WMI_PDEV_SMART_ANT_SET_RX_ANTENNA_CMDID);
9675
9676 if (ret != 0) {
9677 WMI_LOGE(" %s :WMI Failed\n", __func__);
9678 WMI_LOGE("%s: rx_antenna: 0x%08x cmdstatus=%d\n",
9679 __func__,
9680 cmd->rx_antenna,
9681 ret);
9682 wmi_buf_free(buf);
9683 }
9684
9685 return ret;
9686}
9687
9688/**
9689 * send_set_ctl_table_cmd_tlv() - send ctl table cmd to fw
9690 * @wmi_handle: wmi handle
9691 * @param: pointer to hold ctl table param
9692 *
9693 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9694 */
9695static QDF_STATUS
9696send_set_ctl_table_cmd_tlv(wmi_unified_t wmi_handle,
9697 struct ctl_table_params *param)
9698{
9699 uint16_t len, ctl_tlv_len;
9700 uint8_t *buf_ptr;
9701 wmi_buf_t buf;
9702 wmi_pdev_set_ctl_table_cmd_fixed_param *cmd;
9703 uint32_t *ctl_array;
9704
9705 if (!param->ctl_array)
9706 return QDF_STATUS_E_FAILURE;
9707
9708 if (param->ctl_cmd_len !=
9709 WMI_HOST_NUM_CTLS_2G * WMI_HOST_NUM_BAND_EDGES_2G * 2 +
9710 WMI_HOST_NUM_CTLS_5G * WMI_HOST_NUM_BAND_EDGES_5G * 2) {
9711 qdf_print("CTL array len not correct\n");
9712 return QDF_STATUS_E_FAILURE;
9713 }
9714
9715 ctl_tlv_len = WMI_TLV_HDR_SIZE +
9716 roundup(param->ctl_cmd_len, sizeof(A_UINT32));
9717 len = sizeof(*cmd) + ctl_tlv_len;
9718
9719 buf = wmi_buf_alloc(wmi_handle, len);
9720 if (!buf) {
9721 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9722 return QDF_STATUS_E_FAILURE;
9723 }
9724
9725 buf_ptr = wmi_buf_data(buf);
9726 qdf_mem_zero(buf_ptr, len);
9727
9728 cmd = (wmi_pdev_set_ctl_table_cmd_fixed_param *)buf_ptr;
9729
9730 WMITLV_SET_HDR(&cmd->tlv_header,
9731 WMITLV_TAG_STRUC_wmi_pdev_set_ctl_table_cmd_fixed_param,
9732 WMITLV_GET_STRUCT_TLVLEN(
9733 wmi_pdev_set_ctl_table_cmd_fixed_param));
9734 cmd->ctl_len = param->ctl_cmd_len;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309735 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9736 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309737
9738 buf_ptr += sizeof(*cmd);
9739 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9740 (cmd->ctl_len));
9741 buf_ptr += WMI_TLV_HDR_SIZE;
9742 ctl_array = (uint32_t *)buf_ptr;
9743
9744 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[0], &param->ctl_band,
9745 sizeof(param->ctl_band));
9746 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(&ctl_array[1], param->ctl_array,
9747 param->ctl_cmd_len -
9748 sizeof(param->ctl_band));
9749
9750 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9751 WMI_PDEV_SET_CTL_TABLE_CMDID)) {
9752 WMI_LOGE("%s:Failed to send command\n", __func__);
9753 wmi_buf_free(buf);
9754 return QDF_STATUS_E_FAILURE;
9755 }
9756
9757 return QDF_STATUS_SUCCESS;
9758}
9759
9760/**
9761 * send_set_mimogain_table_cmd_tlv() - send mimogain table cmd to fw
9762 * @wmi_handle: wmi handle
9763 * @param: pointer to hold mimogain table param
9764 *
9765 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9766 */
9767static QDF_STATUS
9768send_set_mimogain_table_cmd_tlv(wmi_unified_t wmi_handle,
9769 struct mimogain_table_params *param)
9770{
9771 uint16_t len, table_tlv_len;
9772 wmi_buf_t buf;
9773 uint8_t *buf_ptr;
9774 wmi_pdev_set_mimogain_table_cmd_fixed_param *cmd;
9775 uint32_t *gain_table;
9776
9777 if (!param->array_gain)
9778 return QDF_STATUS_E_FAILURE;
9779
9780 /* len must be multiple of a single array gain table */
9781 if (param->tbl_len %
9782 ((WMI_HOST_TX_NUM_CHAIN-1) * WMI_HOST_TPC_REGINDEX_MAX *
9783 WMI_HOST_ARRAY_GAIN_NUM_STREAMS) != 0) {
9784 WMI_LOGE("Array gain table len not correct\n");
9785 return QDF_STATUS_E_FAILURE;
9786 }
9787
9788 table_tlv_len = WMI_TLV_HDR_SIZE +
9789 roundup(param->tbl_len, sizeof(uint32_t));
9790 len = sizeof(*cmd) + table_tlv_len;
9791
9792 buf = wmi_buf_alloc(wmi_handle, len);
9793 if (!buf) {
9794 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9795 return QDF_STATUS_E_FAILURE;
9796 }
9797
9798 buf_ptr = wmi_buf_data(buf);
9799 qdf_mem_zero(buf_ptr, len);
9800
9801 cmd = (wmi_pdev_set_mimogain_table_cmd_fixed_param *)buf_ptr;
9802
9803 WMITLV_SET_HDR(&cmd->tlv_header,
9804 WMITLV_TAG_STRUC_wmi_pdev_set_mimogain_table_cmd_fixed_param,
9805 WMITLV_GET_STRUCT_TLVLEN(
9806 wmi_pdev_set_mimogain_table_cmd_fixed_param));
9807
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309808 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9809 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309810 WMI_MIMOGAIN_ARRAY_GAIN_LEN_SET(cmd->mimogain_info, param->tbl_len);
9811 WMI_MIMOGAIN_MULTI_CHAIN_BYPASS_SET(cmd->mimogain_info,
9812 param->multichain_gain_bypass);
9813
9814 buf_ptr += sizeof(*cmd);
9815 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
9816 (param->tbl_len));
9817 buf_ptr += WMI_TLV_HDR_SIZE;
9818 gain_table = (uint32_t *)buf_ptr;
9819
9820 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(gain_table,
9821 param->array_gain,
9822 param->tbl_len);
9823
9824 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9825 WMI_PDEV_SET_MIMOGAIN_TABLE_CMDID)) {
9826 return QDF_STATUS_E_FAILURE;
9827 }
9828
9829 return QDF_STATUS_SUCCESS;
9830}
9831
9832/**
9833 * send_packet_power_info_get_cmd_tlv() - send request to get packet power
9834 * info to fw
9835 * @wmi_handle: wmi handle
9836 * @param: pointer to hold packet power info param
9837 *
9838 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9839 */
9840static QDF_STATUS
9841send_packet_power_info_get_cmd_tlv(wmi_unified_t wmi_handle,
9842 struct packet_power_info_params *param)
9843{
9844 wmi_pdev_get_tpc_cmd_fixed_param *cmd;
9845 wmi_buf_t wmibuf;
9846 uint8_t *buf_ptr;
9847 u_int32_t len = sizeof(wmi_pdev_get_tpc_cmd_fixed_param);
9848
9849 wmibuf = wmi_buf_alloc(wmi_handle, len);
9850 if (wmibuf == NULL)
9851 return QDF_STATUS_E_NOMEM;
9852
9853 buf_ptr = (uint8_t *)wmi_buf_data(wmibuf);
9854
9855 cmd = (wmi_pdev_get_tpc_cmd_fixed_param *)buf_ptr;
9856 WMITLV_SET_HDR(&cmd->tlv_header,
9857 WMITLV_TAG_STRUC_wmi_pdev_get_tpc_cmd_fixed_param,
9858 WMITLV_GET_STRUCT_TLVLEN(
9859 wmi_pdev_get_tpc_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +05309860 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
9861 param->pdev_id);
Sathish Kumar497bef42017-03-01 14:02:36 +05309862 cmd->rate_flags = param->rate_flags;
9863 cmd->nss = param->nss;
9864 cmd->preamble = param->preamble;
9865 cmd->hw_rate = param->hw_rate;
9866 WMI_LOGI("%s[%d] commandID %d, wmi_pdev_get_tpc_cmd=0x%x\n",
9867 __func__,
9868 __LINE__,
9869 WMI_PDEV_GET_TPC_CMDID,
9870 *((u_int32_t *)cmd));
9871 if (wmi_unified_cmd_send(wmi_handle, wmibuf, len,
9872 WMI_PDEV_GET_TPC_CMDID)) {
9873 WMI_LOGE(FL("Failed to get tpc command\n"));
9874 wmi_buf_free(wmibuf);
9875 return QDF_STATUS_E_FAILURE;
9876 }
9877
9878 return QDF_STATUS_SUCCESS;
9879}
9880
9881/**
9882 * send_vdev_config_ratemask_cmd_tlv() - config ratemask param in fw
9883 * @wmi_handle: wmi handle
9884 * @param: pointer to hold config ratemask params
9885 *
9886 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9887 */
9888static QDF_STATUS send_vdev_config_ratemask_cmd_tlv(wmi_unified_t wmi_handle,
9889 struct config_ratemask_params *param)
9890{
9891 wmi_vdev_config_ratemask_cmd_fixed_param *cmd;
9892 wmi_buf_t buf;
9893 int32_t len = sizeof(*cmd);
9894
9895 buf = wmi_buf_alloc(wmi_handle, len);
9896 if (!buf) {
9897 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9898 return QDF_STATUS_E_FAILURE;
9899 }
9900 cmd = (wmi_vdev_config_ratemask_cmd_fixed_param *)wmi_buf_data(buf);
9901 WMITLV_SET_HDR(&cmd->tlv_header,
9902 WMITLV_TAG_STRUC_wmi_vdev_config_ratemask_fixed_param,
9903 WMITLV_GET_STRUCT_TLVLEN(
9904 wmi_vdev_config_ratemask_cmd_fixed_param));
9905 cmd->vdev_id = param->vdev_id;
9906 cmd->type = param->type;
9907 cmd->mask_lower32 = param->lower32;
9908 cmd->mask_higher32 = param->higher32;
9909 WMI_LOGI("Setting vdev ratemask vdev id = 0x%X, type = 0x%X, mask_l32 = 0x%X mask_h32 = 0x%X\n",
9910 param->vdev_id, param->type, param->lower32, param->higher32);
9911
9912 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9913 WMI_VDEV_RATEMASK_CMDID)) {
9914 WMI_LOGE("Seting vdev ratemask failed\n");
9915 wmi_buf_free(buf);
9916 return QDF_STATUS_E_FAILURE;
9917 }
9918
9919 return QDF_STATUS_SUCCESS;
9920}
9921
9922/**
9923 * send_set_vap_dscp_tid_map_cmd_tlv() - send vap dscp tid map cmd to fw
9924 * @wmi_handle: wmi handle
9925 * @param: pointer to hold vap dscp tid map param
9926 *
9927 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9928 */
9929static QDF_STATUS
9930send_set_vap_dscp_tid_map_cmd_tlv(wmi_unified_t wmi_handle,
9931 struct vap_dscp_tid_map_params *param)
9932{
9933 wmi_buf_t buf;
9934 wmi_vdev_set_dscp_tid_map_cmd_fixed_param *cmd;
9935 int32_t len = sizeof(*cmd);
9936
9937 buf = wmi_buf_alloc(wmi_handle, len);
9938 if (!buf) {
9939 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9940 return QDF_STATUS_E_FAILURE;
9941 }
9942
9943 cmd = (wmi_vdev_set_dscp_tid_map_cmd_fixed_param *)wmi_buf_data(buf);
9944 qdf_mem_copy(cmd->dscp_to_tid_map, param->dscp_to_tid_map,
9945 sizeof(A_UINT32) * WMI_DSCP_MAP_MAX);
9946
9947 cmd->vdev_id = param->vdev_id;
9948 cmd->enable_override = 0;
9949
9950 WMI_LOGI("Setting dscp for vap id: %d\n", cmd->vdev_id);
9951 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9952 WMI_VDEV_SET_DSCP_TID_MAP_CMDID)) {
9953 WMI_LOGE("Failed to set dscp cmd\n");
9954 wmi_buf_free(buf);
9955 return QDF_STATUS_E_FAILURE;
9956 }
9957
9958 return QDF_STATUS_SUCCESS;
9959}
9960
9961/**
9962 * send_vdev_set_neighbour_rx_cmd_tlv() - set neighbour rx param in fw
9963 * @wmi_handle: wmi handle
9964 * @macaddr: vdev mac address
9965 * @param: pointer to hold neigbour rx param
9966 *
9967 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
9968 */
9969static QDF_STATUS send_vdev_set_neighbour_rx_cmd_tlv(wmi_unified_t wmi_handle,
9970 uint8_t macaddr[IEEE80211_ADDR_LEN],
9971 struct set_neighbour_rx_params *param)
9972{
9973 wmi_vdev_filter_nrp_config_cmd_fixed_param *cmd;
9974 wmi_buf_t buf;
9975 int32_t len = sizeof(*cmd);
9976
9977 buf = wmi_buf_alloc(wmi_handle, len);
9978 if (!buf) {
9979 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
9980 return QDF_STATUS_E_FAILURE;
9981 }
9982 cmd = (wmi_vdev_filter_nrp_config_cmd_fixed_param *)wmi_buf_data(buf);
9983 WMITLV_SET_HDR(&cmd->tlv_header,
9984 WMITLV_TAG_STRUC_wmi_vdev_filter_nrp_config_cmd_fixed_param,
9985 WMITLV_GET_STRUCT_TLVLEN(
9986 wmi_vdev_filter_nrp_config_cmd_fixed_param));
9987 cmd->vdev_id = param->vdev_id;
9988 cmd->bssid_idx = param->idx;
9989 cmd->action = param->action;
9990 cmd->type = param->type;
9991 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->addr);
9992 cmd->flag = 0;
9993
9994 if (wmi_unified_cmd_send(wmi_handle, buf, len,
9995 WMI_VDEV_FILTER_NEIGHBOR_RX_PACKETS_CMDID)) {
9996 WMI_LOGE("Failed to set neighbour rx param\n");
9997 wmi_buf_free(buf);
9998 return QDF_STATUS_E_FAILURE;
9999 }
10000
10001 return QDF_STATUS_SUCCESS;
10002}
10003
10004/**
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010005 * send_smart_ant_set_tx_ant_cmd_tlv() - WMI set tx antenna function
Sathish Kumar497bef42017-03-01 14:02:36 +053010006 * @param wmi_handle : handle to WMI.
10007 * @param macaddr : vdev mac address
10008 * @param param : pointer to tx antenna param
10009 *
10010 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10011 */
10012static QDF_STATUS send_smart_ant_set_tx_ant_cmd_tlv(wmi_unified_t wmi_handle,
10013 uint8_t macaddr[IEEE80211_ADDR_LEN],
10014 struct smart_ant_tx_ant_params *param)
10015{
10016 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *cmd;
10017 wmi_peer_smart_ant_set_tx_antenna_series *ant_tx_series;
10018 wmi_buf_t buf;
10019 int32_t len = 0;
10020 int i;
10021 uint8_t *buf_ptr;
10022 QDF_STATUS ret;
10023
10024 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10025 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10026 sizeof(wmi_peer_smart_ant_set_tx_antenna_series);
10027 buf = wmi_buf_alloc(wmi_handle, len);
10028
10029 if (!buf) {
10030 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10031 return QDF_STATUS_E_NOMEM;
10032 }
10033
10034 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10035 qdf_mem_zero(buf_ptr, len);
10036 cmd = (wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param *)buf_ptr;
10037
10038 WMITLV_SET_HDR(&cmd->tlv_header,
10039 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param,
10040 WMITLV_GET_STRUCT_TLVLEN(
10041 wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param));
10042
10043 cmd->vdev_id = param->vdev_id;
10044 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10045
10046 buf_ptr += sizeof(wmi_peer_smart_ant_set_tx_antenna_cmd_fixed_param);
10047 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10048 sizeof(wmi_peer_smart_ant_set_tx_antenna_series));
10049 buf_ptr += WMI_TLV_HDR_SIZE;
10050 ant_tx_series = (wmi_peer_smart_ant_set_tx_antenna_series *)buf_ptr;
10051
10052 for (i = 0; i < WMI_SMART_ANT_MAX_RATE_SERIES; i++) {
10053 WMITLV_SET_HDR(&ant_tx_series->tlv_header,
10054 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_tx_antenna_series,
10055 WMITLV_GET_STRUCT_TLVLEN(
10056 wmi_peer_smart_ant_set_tx_antenna_series));
10057 ant_tx_series->antenna_series = param->antenna_array[i];
10058 ant_tx_series++;
10059 }
10060
10061 ret = wmi_unified_cmd_send(wmi_handle,
10062 buf,
10063 len,
10064 WMI_PEER_SMART_ANT_SET_TX_ANTENNA_CMDID);
10065
10066 if (ret != 0) {
10067 WMI_LOGE(" %s :WMI Failed\n", __func__);
10068 wmi_buf_free(buf);
10069 }
10070
10071 return ret;
10072}
10073
Sathish Kumar02c3b542017-02-22 17:24:45 +053010074/**
10075 * send_set_ant_switch_tbl_cmd_tlv() - send ant switch tbl cmd to fw
10076 * @wmi_handle: wmi handle
10077 * @param: pointer to hold ant switch tbl param
10078 *
10079 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10080 */
10081static QDF_STATUS
10082send_set_ant_switch_tbl_cmd_tlv(wmi_unified_t wmi_handle,
10083 struct ant_switch_tbl_params *param)
10084{
10085 uint8_t len;
10086 wmi_buf_t buf;
10087 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *cmd;
10088 wmi_pdev_set_ant_ctrl_chain *ctrl_chain;
10089 uint8_t *buf_ptr;
10090
10091 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10092 len += sizeof(wmi_pdev_set_ant_ctrl_chain);
10093 buf = wmi_buf_alloc(wmi_handle, len);
10094
10095 if (!buf) {
10096 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10097 return QDF_STATUS_E_NOMEM;
10098 }
10099
10100 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10101 qdf_mem_zero(buf_ptr, len);
10102 cmd = (wmi_pdev_set_ant_switch_tbl_cmd_fixed_param *)buf_ptr;
10103
10104 WMITLV_SET_HDR(&cmd->tlv_header,
10105 WMITLV_TAG_STRUC_wmi_pdev_set_ant_switch_tbl_cmd_fixed_param,
10106 WMITLV_GET_STRUCT_TLVLEN(
10107 wmi_pdev_set_ant_switch_tbl_cmd_fixed_param));
10108
10109 cmd->antCtrlCommon1 = param->ant_ctrl_common1;
10110 cmd->antCtrlCommon2 = param->ant_ctrl_common2;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010111 cmd->mac_id =
10112 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010113
10114 /* TLV indicating array of structures to follow */
10115 buf_ptr += sizeof(wmi_pdev_set_ant_switch_tbl_cmd_fixed_param);
10116 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10117 sizeof(wmi_pdev_set_ant_ctrl_chain));
10118 buf_ptr += WMI_TLV_HDR_SIZE;
10119 ctrl_chain = (wmi_pdev_set_ant_ctrl_chain *)buf_ptr;
10120
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010121 ctrl_chain->pdev_id =
10122 wmi_handle->ops->convert_pdev_id_host_to_target(param->pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010123 ctrl_chain->antCtrlChain = param->antCtrlChain;
10124
10125 if (wmi_unified_cmd_send(wmi_handle, buf, len,
10126 WMI_PDEV_SET_ANTENNA_SWITCH_TABLE_CMDID)) {
10127 wmi_buf_free(buf);
10128 return QDF_STATUS_E_FAILURE;
10129 }
10130
10131 return QDF_STATUS_SUCCESS;
10132}
10133
10134/**
10135 * send_smart_ant_set_training_info_cmd_tlv() - WMI set smart antenna
10136 * training information function
10137 * @param wmi_handle : handle to WMI.
10138 * @macaddr : vdev mac address
10139 * @param param : pointer to tx antenna param
10140 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10141 */
10142static QDF_STATUS send_smart_ant_set_training_info_cmd_tlv(
10143 wmi_unified_t wmi_handle,
10144 uint8_t macaddr[IEEE80211_ADDR_LEN],
10145 struct smart_ant_training_info_params *param)
10146{
10147 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *cmd;
10148 wmi_peer_smart_ant_set_train_antenna_param *train_param;
10149 wmi_buf_t buf;
10150 uint8_t *buf_ptr;
10151 int32_t len = 0;
10152 QDF_STATUS ret;
10153 int loop;
10154
10155 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10156 len += (WMI_SMART_ANT_MAX_RATE_SERIES) *
10157 sizeof(wmi_peer_smart_ant_set_train_antenna_param);
10158 buf = wmi_buf_alloc(wmi_handle, len);
10159
10160 if (!buf) {
10161 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10162 return QDF_STATUS_E_NOMEM;
10163 }
10164
10165 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10166 qdf_mem_zero(buf_ptr, len);
10167 cmd = (wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param *)buf_ptr;
10168
10169 WMITLV_SET_HDR(&cmd->tlv_header,
10170 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param,
10171 WMITLV_GET_STRUCT_TLVLEN(
10172 wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param));
10173
10174 cmd->vdev_id = param->vdev_id;
10175 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10176 cmd->num_pkts = param->numpkts;
10177
10178 buf_ptr += sizeof(wmi_peer_smart_ant_set_train_antenna_cmd_fixed_param);
10179 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10180 sizeof(wmi_peer_smart_ant_set_train_antenna_param) *
10181 WMI_SMART_ANT_MAX_RATE_SERIES);
10182
10183 buf_ptr += WMI_TLV_HDR_SIZE;
10184 train_param = (wmi_peer_smart_ant_set_train_antenna_param *)buf_ptr;
10185
10186 for (loop = 0; loop < WMI_SMART_ANT_MAX_RATE_SERIES; loop++) {
10187 WMITLV_SET_HDR(&train_param->tlv_header,
10188 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_train_antenna_param,
10189 WMITLV_GET_STRUCT_TLVLEN(
10190 wmi_peer_smart_ant_set_train_antenna_param));
10191 train_param->train_rate_series = param->rate_array[loop];
10192 train_param->train_antenna_series = param->antenna_array[loop];
10193 train_param->rc_flags = 0;
10194 WMI_LOGI(FL("Series number:%d\n"), loop);
10195 WMI_LOGI(FL("Rate [0x%02x] Tx_Antenna [0x%08x]\n"),
10196 train_param->train_rate_series,
10197 train_param->train_antenna_series);
10198 train_param++;
10199 }
10200
10201 ret = wmi_unified_cmd_send(wmi_handle,
10202 buf,
10203 len,
10204 WMI_PEER_SMART_ANT_SET_TRAIN_INFO_CMDID);
10205
10206 if (ret != 0) {
10207 WMI_LOGE(" %s :WMI Failed\n", __func__);
10208 wmi_buf_free(buf);
10209 return QDF_STATUS_E_FAILURE;
10210 }
10211
10212 return ret;
10213}
10214
10215/**
10216 * send_smart_ant_set_node_config_cmd_tlv() - WMI set node
10217 * configuration function
10218 * @param wmi_handle : handle to WMI.
10219 * @macaddr : vdev mad address
10220 * @param param : pointer to tx antenna param
10221 *
10222 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10223 */
10224static QDF_STATUS send_smart_ant_set_node_config_cmd_tlv(
10225 wmi_unified_t wmi_handle,
10226 uint8_t macaddr[IEEE80211_ADDR_LEN],
10227 struct smart_ant_node_config_params *param)
10228{
10229 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *cmd;
10230 wmi_buf_t buf;
10231 uint8_t *buf_ptr;
10232 int32_t len = 0, args_tlv_len;
10233 int ret;
10234 int i = 0;
10235 A_UINT32 *node_config_args;
10236
10237 args_tlv_len = WMI_TLV_HDR_SIZE + param->args_count * sizeof(A_UINT32);
10238 len = sizeof(*cmd) + args_tlv_len;
10239
10240 if ((param->args_count == 0)) {
10241 WMI_LOGE("%s: Can't send a command with %d arguments\n",
10242 __func__, param->args_count);
10243 return QDF_STATUS_E_FAILURE;
10244 }
10245
10246 buf = wmi_buf_alloc(wmi_handle, len);
10247 if (!buf) {
10248 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10249 return QDF_STATUS_E_NOMEM;
10250 }
10251
10252 cmd = (wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param *)
10253 wmi_buf_data(buf);
10254 buf_ptr = (uint8_t *)cmd;
10255 WMITLV_SET_HDR(&cmd->tlv_header,
10256 WMITLV_TAG_STRUC_wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param,
10257 WMITLV_GET_STRUCT_TLVLEN(
10258 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param));
10259 cmd->vdev_id = param->vdev_id;
10260 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10261 cmd->cmd_id = param->cmd_id;
10262 cmd->args_count = param->args_count;
10263 buf_ptr += sizeof(
10264 wmi_peer_smart_ant_set_node_config_ops_cmd_fixed_param);
10265 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
10266 (cmd->args_count * sizeof(A_UINT32)));
10267 buf_ptr += WMI_TLV_HDR_SIZE;
10268 node_config_args = (A_UINT32 *)buf_ptr;
10269
10270 for (i = 0; i < param->args_count; i++) {
10271 node_config_args[i] = param->args_arr[i];
10272 WMI_LOGI("%d", param->args_arr[i]);
10273 }
10274
10275 ret = wmi_unified_cmd_send(wmi_handle,
10276 buf,
10277 len,
10278 WMI_PEER_SMART_ANT_SET_NODE_CONFIG_OPS_CMDID);
10279
10280 if (ret != 0) {
10281 WMI_LOGE("%s: WMI FAILED:Sent cmd_id: 0x%x\n Node: %02x:%02x:%02x:%02x:%02x:%02x cmdstatus=%d\n",
10282 __func__, param->cmd_id, macaddr[0],
10283 macaddr[1], macaddr[2], macaddr[3],
10284 macaddr[4], macaddr[5], ret);
10285 wmi_buf_free(buf);
10286 }
10287
10288 return ret;
10289}
10290
10291/**
10292 * send_set_atf_cmd_tlv() - send set atf command to fw
10293 * @wmi_handle: wmi handle
10294 * @param: pointer to set atf param
10295 *
10296 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10297 */
10298static QDF_STATUS
10299send_set_atf_cmd_tlv(wmi_unified_t wmi_handle,
10300 struct set_atf_params *param)
10301{
10302 wmi_atf_peer_info *peer_info;
10303 wmi_peer_atf_request_fixed_param *cmd;
10304 wmi_buf_t buf;
10305 uint8_t *buf_ptr;
10306 int i;
10307 int32_t len = 0;
10308 QDF_STATUS retval;
10309
10310 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10311 len += param->num_peers * sizeof(wmi_atf_peer_info);
10312 buf = wmi_buf_alloc(wmi_handle, len);
10313 if (!buf) {
10314 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10315 return QDF_STATUS_E_FAILURE;
10316 }
10317 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10318 cmd = (wmi_peer_atf_request_fixed_param *)buf_ptr;
10319 WMITLV_SET_HDR(&cmd->tlv_header,
10320 WMITLV_TAG_STRUC_wmi_peer_atf_request_fixed_param,
10321 WMITLV_GET_STRUCT_TLVLEN(
10322 wmi_peer_atf_request_fixed_param));
10323 cmd->num_peers = param->num_peers;
10324
10325 buf_ptr += sizeof(*cmd);
10326 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10327 sizeof(wmi_atf_peer_info) *
10328 cmd->num_peers);
10329 buf_ptr += WMI_TLV_HDR_SIZE;
10330 peer_info = (wmi_atf_peer_info *)buf_ptr;
10331
10332 for (i = 0; i < cmd->num_peers; i++) {
10333 WMITLV_SET_HDR(&peer_info->tlv_header,
10334 WMITLV_TAG_STRUC_wmi_atf_peer_info,
10335 WMITLV_GET_STRUCT_TLVLEN(
10336 wmi_atf_peer_info));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010337 qdf_mem_copy(&(peer_info->peer_macaddr),
10338 &(param->peer_info[i].peer_macaddr),
10339 sizeof(wmi_mac_addr));
Sathish Kumar02c3b542017-02-22 17:24:45 +053010340 peer_info->atf_units = param->peer_info[i].percentage_peer;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010341 peer_info->vdev_id = param->peer_info[i].vdev_id;
10342 peer_info->pdev_id =
10343 wmi_handle->ops->convert_pdev_id_host_to_target(
10344 param->peer_info[i].pdev_id);
Sathish Kumar02c3b542017-02-22 17:24:45 +053010345 /*
10346 * TLV definition for peer atf request fixed param combines
10347 * extension stats. Legacy FW for WIN (Non-TLV) has peer atf
10348 * stats and atf extension stats as two different
10349 * implementations.
10350 * Need to discuss with FW on this.
10351 *
10352 * peer_info->atf_groupid = param->peer_ext_info[i].group_index;
10353 * peer_info->atf_units_reserved =
10354 * param->peer_ext_info[i].atf_index_reserved;
10355 */
10356 peer_info++;
10357 }
10358
10359 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10360 WMI_PEER_ATF_REQUEST_CMDID);
10361
10362 if (retval != QDF_STATUS_SUCCESS) {
10363 WMI_LOGE("%s : WMI Failed\n", __func__);
10364 wmi_buf_free(buf);
10365 }
10366
10367 return retval;
10368}
10369
10370/**
10371 * send_vdev_set_fwtest_param_cmd_tlv() - send fwtest param in fw
10372 * @wmi_handle: wmi handle
10373 * @param: pointer to hold fwtest param
10374 *
10375 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10376 */
10377static QDF_STATUS send_vdev_set_fwtest_param_cmd_tlv(wmi_unified_t wmi_handle,
10378 struct set_fwtest_params *param)
10379{
10380 wmi_fwtest_set_param_cmd_fixed_param *cmd;
10381 wmi_buf_t buf;
10382 int32_t len = sizeof(*cmd);
10383
10384 buf = wmi_buf_alloc(wmi_handle, len);
10385
10386 if (!buf) {
10387 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10388 return QDF_STATUS_E_FAILURE;
10389 }
10390
10391 cmd = (wmi_fwtest_set_param_cmd_fixed_param *)wmi_buf_data(buf);
10392 WMITLV_SET_HDR(&cmd->tlv_header,
10393 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
10394 WMITLV_GET_STRUCT_TLVLEN(
10395 wmi_fwtest_set_param_cmd_fixed_param));
10396 cmd->param_id = param->arg;
10397 cmd->param_value = param->value;
10398
10399 if (wmi_unified_cmd_send(wmi_handle, buf, len, WMI_FWTEST_CMDID)) {
10400 WMI_LOGE("Setting FW test param failed\n");
10401 wmi_buf_free(buf);
10402 return QDF_STATUS_E_FAILURE;
10403 }
10404
10405 return QDF_STATUS_SUCCESS;
10406}
10407
10408/**
10409 * send_set_qboost_param_cmd_tlv() - send set qboost command to fw
10410 * @wmi_handle: wmi handle
10411 * @param: pointer to qboost params
10412 * @macaddr: vdev mac address
10413 *
10414 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10415 */
10416static QDF_STATUS
10417send_set_qboost_param_cmd_tlv(wmi_unified_t wmi_handle,
10418 uint8_t macaddr[IEEE80211_ADDR_LEN],
10419 struct set_qboost_params *param)
10420{
10421 WMI_QBOOST_CFG_CMD_fixed_param *cmd;
10422 wmi_buf_t buf;
10423 int32_t len;
10424 QDF_STATUS ret;
10425
10426 len = sizeof(*cmd);
10427
10428 buf = wmi_buf_alloc(wmi_handle, len);
10429 if (!buf) {
10430 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10431 return QDF_STATUS_E_FAILURE;
10432 }
10433
10434 cmd = (WMI_QBOOST_CFG_CMD_fixed_param *)wmi_buf_data(buf);
10435 WMITLV_SET_HDR(&cmd->tlv_header,
10436 WMITLV_TAG_STRUC_WMI_QBOOST_CFG_CMD_fixed_param,
10437 WMITLV_GET_STRUCT_TLVLEN(
10438 WMI_QBOOST_CFG_CMD_fixed_param));
10439 cmd->vdev_id = param->vdev_id;
10440 WMI_CHAR_ARRAY_TO_MAC_ADDR(macaddr, &cmd->peer_macaddr);
10441 cmd->qb_enable = param->value;
10442
10443 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10444 WMI_QBOOST_CFG_CMDID);
10445
10446 if (ret != 0) {
10447 WMI_LOGE("Setting qboost cmd failed\n");
10448 wmi_buf_free(buf);
10449 }
10450
10451 return ret;
10452}
10453
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010454/**
10455 * send_gpio_config_cmd_tlv() - send gpio config to fw
10456 * @wmi_handle: wmi handle
10457 * @param: pointer to hold gpio config param
10458 *
10459 * Return: 0 for success or error code
10460 */
10461static QDF_STATUS
10462send_gpio_config_cmd_tlv(wmi_unified_t wmi_handle,
10463 struct gpio_config_params *param)
10464{
10465 wmi_gpio_config_cmd_fixed_param *cmd;
10466 wmi_buf_t buf;
10467 int32_t len;
10468 QDF_STATUS ret;
10469
10470 len = sizeof(*cmd);
10471
10472 /* Sanity Checks */
10473 if (param->pull_type > WMI_GPIO_PULL_DOWN ||
10474 param->intr_mode > WMI_GPIO_INTTYPE_LEVEL_HIGH) {
10475 return QDF_STATUS_E_FAILURE;
10476 }
10477
10478 buf = wmi_buf_alloc(wmi_handle, len);
10479 if (!buf) {
10480 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10481 return QDF_STATUS_E_FAILURE;
10482 }
10483
10484 cmd = (wmi_gpio_config_cmd_fixed_param *)wmi_buf_data(buf);
10485 WMITLV_SET_HDR(&cmd->tlv_header,
10486 WMITLV_TAG_STRUC_wmi_gpio_config_cmd_fixed_param,
10487 WMITLV_GET_STRUCT_TLVLEN(
10488 wmi_gpio_config_cmd_fixed_param));
10489 cmd->gpio_num = param->gpio_num;
10490 cmd->input = param->input;
10491 cmd->pull_type = param->pull_type;
10492 cmd->intr_mode = param->intr_mode;
10493
10494 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10495 WMI_GPIO_CONFIG_CMDID);
10496
10497 if (ret != 0) {
10498 WMI_LOGE("Sending GPIO config cmd failed\n");
10499 wmi_buf_free(buf);
10500 }
10501
10502 return ret;
10503}
10504
10505/**
10506 * send_gpio_output_cmd_tlv() - send gpio output to fw
10507 * @wmi_handle: wmi handle
10508 * @param: pointer to hold gpio output param
10509 *
10510 * Return: 0 for success or error code
10511 */
10512static QDF_STATUS
10513send_gpio_output_cmd_tlv(wmi_unified_t wmi_handle,
10514 struct gpio_output_params *param)
10515{
10516 wmi_gpio_output_cmd_fixed_param *cmd;
10517 wmi_buf_t buf;
10518 int32_t len;
10519 QDF_STATUS ret;
10520
10521 len = sizeof(*cmd);
10522
10523 buf = wmi_buf_alloc(wmi_handle, len);
10524 if (!buf) {
10525 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10526 return QDF_STATUS_E_FAILURE;
10527 }
10528
10529 cmd = (wmi_gpio_output_cmd_fixed_param *)wmi_buf_data(buf);
10530 WMITLV_SET_HDR(&cmd->tlv_header,
10531 WMITLV_TAG_STRUC_wmi_gpio_output_cmd_fixed_param,
10532 WMITLV_GET_STRUCT_TLVLEN(
10533 wmi_gpio_output_cmd_fixed_param));
10534 cmd->gpio_num = param->gpio_num;
10535 cmd->set = param->set;
10536
10537 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10538 WMI_GPIO_OUTPUT_CMDID);
10539
10540 if (ret != 0) {
10541 WMI_LOGE("Sending GPIO output cmd failed\n");
10542 wmi_buf_free(buf);
10543 }
10544
10545 return ret;
10546
10547}
10548
10549/**
10550 * send_phyerr_disable_cmd_tlv() - WMI phyerr disable function
10551 *
10552 * @param wmi_handle : handle to WMI.
10553 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10554 */
10555static QDF_STATUS send_phyerr_disable_cmd_tlv(wmi_unified_t wmi_handle)
10556{
10557 wmi_pdev_dfs_disable_cmd_fixed_param *cmd;
10558 wmi_buf_t buf;
10559 QDF_STATUS ret;
10560 int32_t len;
10561
10562 len = sizeof(*cmd);
10563
10564 buf = wmi_buf_alloc(wmi_handle, len);
10565 if (!buf) {
10566 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10567 return QDF_STATUS_E_FAILURE;
10568 }
10569
10570 cmd = (wmi_pdev_dfs_disable_cmd_fixed_param *)wmi_buf_data(buf);
10571 WMITLV_SET_HDR(&cmd->tlv_header,
10572 WMITLV_TAG_STRUC_wmi_pdev_dfs_disable_cmd_fixed_param,
10573 WMITLV_GET_STRUCT_TLVLEN(
10574 wmi_pdev_dfs_disable_cmd_fixed_param));
10575 /* Filling it with WMI_PDEV_ID_SOC for now */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010576 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10577 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarf6e3e632017-02-22 17:28:28 +053010578
10579 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10580 WMI_PDEV_DFS_DISABLE_CMDID);
10581
10582 if (ret != 0) {
10583 WMI_LOGE("Sending PDEV DFS disable cmd failed\n");
10584 wmi_buf_free(buf);
10585 }
10586
10587 return ret;
10588}
10589
10590/**
10591 * send_phyerr_enable_cmd_tlv() - WMI phyerr disable function
10592 *
10593 * @param wmi_handle : handle to WMI.
10594 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
10595 */
10596static QDF_STATUS send_phyerr_enable_cmd_tlv(wmi_unified_t wmi_handle)
10597{
10598 wmi_pdev_dfs_enable_cmd_fixed_param *cmd;
10599 wmi_buf_t buf;
10600 QDF_STATUS ret;
10601 int32_t len;
10602
10603 len = sizeof(*cmd);
10604
10605 buf = wmi_buf_alloc(wmi_handle, len);
10606 if (!buf) {
10607 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10608 return QDF_STATUS_E_FAILURE;
10609 }
10610
10611 cmd = (wmi_pdev_dfs_enable_cmd_fixed_param *)wmi_buf_data(buf);
10612 WMITLV_SET_HDR(&cmd->tlv_header,
10613 WMITLV_TAG_STRUC_wmi_pdev_dfs_enable_cmd_fixed_param,
10614 WMITLV_GET_STRUCT_TLVLEN(
10615 wmi_pdev_dfs_enable_cmd_fixed_param));
10616 /* Reserved for future use */
10617 cmd->reserved0 = 0;
10618
10619 ret = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
10620 WMI_PDEV_DFS_ENABLE_CMDID);
10621
10622 if (ret != 0) {
10623 WMI_LOGE("Sending PDEV DFS enable cmd failed\n");
10624 wmi_buf_free(buf);
10625 }
10626
10627 return ret;
10628}
10629
10630/**
10631 * send_nf_dbr_dbm_info_get_cmd_tlv() - send request to get nf to fw
10632 * @wmi_handle: wmi handle
10633 *
10634 * Return: 0 for success or error code
10635 */
10636static QDF_STATUS
10637send_nf_dbr_dbm_info_get_cmd_tlv(wmi_unified_t wmi_handle)
10638{
10639 wmi_buf_t buf;
10640 QDF_STATUS ret;
10641
10642 buf = wmi_buf_alloc(wmi_handle, 0);
10643 if (buf == NULL)
10644 return QDF_STATUS_E_NOMEM;
10645
10646 ret = wmi_unified_cmd_send(wmi_handle, buf, 0,
10647 WMI_PDEV_GET_NFCAL_POWER_CMDID);
10648 if (ret != 0) {
10649 WMI_LOGE("Sending get nfcal power cmd failed\n");
10650 wmi_buf_free(buf);
10651 }
10652
10653 return ret;
10654}
10655
10656/**
10657 * send_set_ht_ie_cmd_tlv() - send ht ie command to fw
10658 * @wmi_handle: wmi handle
10659 * @param: pointer to ht ie param
10660 *
10661 * Return: 0 for success or error code
10662 */
10663static QDF_STATUS
10664send_set_ht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10665 struct ht_ie_params *param)
10666{
10667 wmi_pdev_set_ht_ie_cmd_fixed_param *cmd;
10668 wmi_buf_t buf;
10669 QDF_STATUS ret;
10670 int32_t len;
10671 uint8_t *buf_ptr;
10672
10673 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10674 roundup(param->ie_len, sizeof(uint32_t));
10675
10676 buf = wmi_buf_alloc(wmi_handle, len);
10677 if (!buf) {
10678 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10679 return QDF_STATUS_E_FAILURE;
10680 }
10681
10682 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10683 cmd = (wmi_pdev_set_ht_ie_cmd_fixed_param *)buf_ptr;
10684 WMITLV_SET_HDR(&cmd->tlv_header,
10685 WMITLV_TAG_STRUC_wmi_pdev_set_ht_ie_cmd_fixed_param,
10686 WMITLV_GET_STRUCT_TLVLEN(
10687 wmi_pdev_set_ht_ie_cmd_fixed_param));
10688 cmd->reserved0 = 0;
10689 cmd->ie_len = param->ie_len;
10690 cmd->tx_streams = param->tx_streams;
10691 cmd->rx_streams = param->rx_streams;
10692
10693 buf_ptr += sizeof(*cmd);
10694 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10695 buf_ptr += WMI_TLV_HDR_SIZE;
10696 if (param->ie_len)
10697 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10698 cmd->ie_len);
10699
10700 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10701 WMI_PDEV_SET_HT_CAP_IE_CMDID);
10702
10703 if (ret != 0) {
10704 WMI_LOGE("Sending set ht ie cmd failed\n");
10705 wmi_buf_free(buf);
10706 }
10707
10708 return ret;
10709}
10710
10711/**
10712 * send_set_vht_ie_cmd_tlv() - send vht ie command to fw
10713 * @wmi_handle: wmi handle
10714 * @param: pointer to vht ie param
10715 *
10716 * Return: 0 for success or error code
10717 */
10718static QDF_STATUS
10719send_set_vht_ie_cmd_tlv(wmi_unified_t wmi_handle,
10720 struct vht_ie_params *param)
10721{
10722 wmi_pdev_set_vht_ie_cmd_fixed_param *cmd;
10723 wmi_buf_t buf;
10724 QDF_STATUS ret;
10725 int32_t len;
10726 uint8_t *buf_ptr;
10727
10728 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
10729 roundup(param->ie_len, sizeof(uint32_t));
10730
10731 buf = wmi_buf_alloc(wmi_handle, len);
10732 if (!buf) {
10733 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10734 return QDF_STATUS_E_FAILURE;
10735 }
10736
10737 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10738 cmd = (wmi_pdev_set_vht_ie_cmd_fixed_param *)buf_ptr;
10739 WMITLV_SET_HDR(&cmd->tlv_header,
10740 WMITLV_TAG_STRUC_wmi_pdev_set_vht_ie_cmd_fixed_param,
10741 WMITLV_GET_STRUCT_TLVLEN(
10742 wmi_pdev_set_vht_ie_cmd_fixed_param));
10743 cmd->reserved0 = 0;
10744 cmd->ie_len = param->ie_len;
10745 cmd->tx_streams = param->tx_streams;
10746 cmd->rx_streams = param->rx_streams;
10747
10748 buf_ptr += sizeof(*cmd);
10749 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, cmd->ie_len);
10750 buf_ptr += WMI_TLV_HDR_SIZE;
10751 if (param->ie_len)
10752 WMI_HOST_IF_MSG_COPY_CHAR_ARRAY(buf_ptr, param->ie_data,
10753 cmd->ie_len);
10754
10755 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10756 WMI_PDEV_SET_VHT_CAP_IE_CMDID);
10757
10758 if (ret != 0) {
10759 WMI_LOGE("Sending set vht ie cmd failed\n");
10760 wmi_buf_free(buf);
10761 }
10762
10763 return ret;
10764}
10765
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053010766/**
10767 * send_set_quiet_mode_cmd_tlv() - send set quiet mode command to fw
10768 * @wmi_handle: wmi handle
10769 * @param: pointer to quiet mode params
10770 *
10771 * Return: 0 for success or error code
10772 */
10773static QDF_STATUS
10774send_set_quiet_mode_cmd_tlv(wmi_unified_t wmi_handle,
10775 struct set_quiet_mode_params *param)
10776{
10777 wmi_pdev_set_quiet_cmd_fixed_param *quiet_cmd;
10778 wmi_buf_t buf;
10779 QDF_STATUS ret;
10780 int32_t len;
10781
10782 len = sizeof(*quiet_cmd);
10783 buf = wmi_buf_alloc(wmi_handle, len);
10784 if (!buf) {
10785 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10786 return QDF_STATUS_E_FAILURE;
10787 }
10788
10789 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
10790 WMITLV_SET_HDR(&quiet_cmd->tlv_header,
10791 WMITLV_TAG_STRUC_wmi_pdev_set_quiet_cmd_fixed_param,
10792 WMITLV_GET_STRUCT_TLVLEN(
10793 wmi_pdev_set_quiet_cmd_fixed_param));
10794 quiet_cmd = (wmi_pdev_set_quiet_cmd_fixed_param *)wmi_buf_data(buf);
10795 quiet_cmd->enabled = param->enabled;
10796 quiet_cmd->period = (param->period)*(param->intval);
10797 quiet_cmd->duration = param->duration;
10798 quiet_cmd->next_start = param->offset;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053010799 quiet_cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
10800 WMI_HOST_PDEV_ID_SOC);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053010801
10802 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10803 WMI_PDEV_SET_QUIET_MODE_CMDID);
10804
10805 if (ret != 0) {
10806 WMI_LOGE("Sending set quiet cmd failed\n");
10807 wmi_buf_free(buf);
10808 }
10809
10810 return ret;
10811}
10812
10813/**
10814 * send_set_bwf_cmd_tlv() - send set bwf command to fw
10815 * @wmi_handle: wmi handle
10816 * @param: pointer to set bwf param
10817 *
10818 * Return: 0 for success or error code
10819 */
10820static QDF_STATUS
10821send_set_bwf_cmd_tlv(wmi_unified_t wmi_handle,
10822 struct set_bwf_params *param)
10823{
10824 wmi_bwf_peer_info *peer_info;
10825 wmi_peer_bwf_request_fixed_param *cmd;
10826 wmi_buf_t buf;
10827 QDF_STATUS retval;
10828 int32_t len;
10829 uint8_t *buf_ptr;
10830 int i;
10831
10832 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
10833 len += param->num_peers * sizeof(wmi_bwf_peer_info);
10834 buf = wmi_buf_alloc(wmi_handle, len);
10835 if (!buf) {
10836 WMI_LOGE("%s:wmi_buf_alloc failed\n", __func__);
10837 return QDF_STATUS_E_FAILURE;
10838 }
10839 buf_ptr = (uint8_t *)wmi_buf_data(buf);
10840 cmd = (wmi_peer_bwf_request_fixed_param *)buf_ptr;
10841 WMITLV_SET_HDR(&cmd->tlv_header,
10842 WMITLV_TAG_STRUC_wmi_peer_bwf_request_fixed_param,
10843 WMITLV_GET_STRUCT_TLVLEN(
10844 wmi_peer_bwf_request_fixed_param));
10845 cmd->num_peers = param->num_peers;
10846
10847 buf_ptr += sizeof(*cmd);
10848 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
10849 sizeof(wmi_bwf_peer_info) *
10850 cmd->num_peers);
10851 buf_ptr += WMI_TLV_HDR_SIZE;
10852 peer_info = (wmi_bwf_peer_info *)buf_ptr;
10853
10854 for (i = 0; i < cmd->num_peers; i++) {
10855 WMITLV_SET_HDR(&peer_info->tlv_header,
10856 WMITLV_TAG_STRUC_wmi_bwf_peer_info,
10857 WMITLV_GET_STRUCT_TLVLEN(wmi_bwf_peer_info));
10858 peer_info->bwf_guaranteed_bandwidth =
10859 param->peer_info[i].throughput;
10860 peer_info->bwf_max_airtime =
10861 param->peer_info[i].max_airtime;
10862 peer_info->bwf_peer_priority =
10863 param->peer_info[i].priority;
10864 qdf_mem_copy(&peer_info->peer_macaddr,
10865 &param->peer_info[i].peer_macaddr,
10866 sizeof(param->peer_info[i].peer_macaddr));
Subrat Mishraa1c92f52017-04-03 12:32:42 +053010867 peer_info->vdev_id =
10868 param->peer_info[i].vdev_id;
10869 peer_info->pdev_id =
10870 wmi_handle->ops->convert_pdev_id_host_to_target(
10871 param->peer_info[i].pdev_id);
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053010872 peer_info++;
10873 }
10874
10875 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
10876 WMI_PEER_BWF_REQUEST_CMDID);
10877
10878 if (retval != QDF_STATUS_SUCCESS) {
10879 WMI_LOGE("%s : WMI Failed\n", __func__);
10880 wmi_buf_free(buf);
10881 }
10882
10883 return retval;
10884}
10885
10886/**
10887 * send_mcast_group_update_cmd_tlv() - send mcast group update cmd to fw
10888 * @wmi_handle: wmi handle
10889 * @param: pointer to hold mcast update param
10890 *
10891 * Return: 0 for success or error code
10892 */
10893static QDF_STATUS
10894send_mcast_group_update_cmd_tlv(wmi_unified_t wmi_handle,
10895 struct mcast_group_update_params *param)
10896{
10897 wmi_peer_mcast_group_cmd_fixed_param *cmd;
10898 wmi_buf_t buf;
10899 QDF_STATUS ret;
10900 int32_t len;
10901 int offset = 0;
10902 static char dummymask[4] = { 0xFF, 0xFF, 0xFF, 0xFF};
10903
10904 len = sizeof(*cmd);
10905 buf = wmi_buf_alloc(wmi_handle, len);
10906 if (!buf) {
10907 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10908 return QDF_STATUS_E_FAILURE;
10909 }
10910 cmd = (wmi_peer_mcast_group_cmd_fixed_param *)wmi_buf_data(buf);
10911 WMITLV_SET_HDR(&cmd->tlv_header,
10912 WMITLV_TAG_STRUC_wmi_peer_mcast_group_cmd_fixed_param,
10913 WMITLV_GET_STRUCT_TLVLEN(
10914 wmi_peer_mcast_group_cmd_fixed_param));
10915 /* confirm the buffer is 4-byte aligned */
10916 QDF_ASSERT((((size_t) cmd) & 0x3) == 0);
10917 qdf_mem_zero(cmd, sizeof(*cmd));
10918
10919 cmd->vdev_id = param->vap_id;
10920 /* construct the message assuming our endianness matches the target */
10921 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_ACTION_M &
10922 (param->action << WMI_PEER_MCAST_GROUP_FLAG_ACTION_S);
10923 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_M &
10924 (param->wildcard << WMI_PEER_MCAST_GROUP_FLAG_WILDCARD_S);
10925 if (param->is_action_delete)
10926 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_DELETEALL_M;
10927
10928 if (param->is_mcast_addr_len)
10929 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_IPV6_M;
10930
10931 if (param->is_filter_mode_snoop)
10932 cmd->flags |= WMI_PEER_MCAST_GROUP_FLAG_SRC_FILTER_EXCLUDE_M;
10933
10934 /* unicast address spec only applies for non-wildcard cases */
10935 if (!param->wildcard && param->ucast_mac_addr) {
10936 WMI_CHAR_ARRAY_TO_MAC_ADDR(param->ucast_mac_addr,
10937 &cmd->ucast_mac_addr);
10938 }
10939 if (param->mcast_ip_addr) {
10940 QDF_ASSERT(param->mcast_ip_addr_bytes <=
10941 sizeof(cmd->mcast_ip_addr));
10942 offset = sizeof(cmd->mcast_ip_addr) -
10943 param->mcast_ip_addr_bytes;
10944 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_addr) + offset,
10945 param->mcast_ip_addr,
10946 param->mcast_ip_addr_bytes);
10947 }
10948 if (!param->mask)
10949 param->mask = &dummymask[0];
10950
10951 qdf_mem_copy(((uint8_t *)&cmd->mcast_ip_mask) + offset,
10952 param->mask,
10953 param->mcast_ip_addr_bytes);
10954
10955 if (param->srcs && param->nsrcs) {
10956 cmd->num_filter_addr = param->nsrcs;
10957 QDF_ASSERT((param->nsrcs * param->mcast_ip_addr_bytes) <=
10958 sizeof(cmd->filter_addr));
10959
10960 qdf_mem_copy(((uint8_t *) &cmd->filter_addr), param->srcs,
10961 param->nsrcs * param->mcast_ip_addr_bytes);
10962 }
10963
10964 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
10965 WMI_PEER_MCAST_GROUP_CMDID);
10966
10967 if (ret != QDF_STATUS_SUCCESS) {
10968 WMI_LOGE("%s : WMI Failed\n", __func__);
10969 wmi_buf_free(buf);
10970 }
10971
10972 return ret;
10973}
10974
10975/**
10976 * send_vdev_spectral_configure_cmd_tlv() - send VDEV spectral configure
10977 * command to fw
10978 * @wmi_handle: wmi handle
10979 * @param: pointer to hold spectral config parameter
10980 *
10981 * Return: 0 for success or error code
10982 */
10983static QDF_STATUS send_vdev_spectral_configure_cmd_tlv(wmi_unified_t wmi_handle,
10984 struct vdev_spectral_configure_params *param)
10985{
10986 wmi_vdev_spectral_configure_cmd_fixed_param *cmd;
10987 wmi_buf_t buf;
10988 QDF_STATUS ret;
10989 int32_t len;
10990
10991 len = sizeof(*cmd);
10992 buf = wmi_buf_alloc(wmi_handle, len);
10993 if (!buf) {
10994 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
10995 return QDF_STATUS_E_FAILURE;
10996 }
10997
10998 cmd = (wmi_vdev_spectral_configure_cmd_fixed_param *)wmi_buf_data(buf);
10999 WMITLV_SET_HDR(&cmd->tlv_header,
11000 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param,
11001 WMITLV_GET_STRUCT_TLVLEN(
11002 WMITLV_TAG_STRUC_wmi_vdev_spectral_configure_cmd_fixed_param));
11003
11004 cmd->vdev_id = param->vdev_id;
11005 cmd->spectral_scan_count = param->count;
11006 cmd->spectral_scan_period = param->period;
11007 cmd->spectral_scan_priority = param->spectral_pri;
11008 cmd->spectral_scan_fft_size = param->fft_size;
11009 cmd->spectral_scan_gc_ena = param->gc_enable;
11010 cmd->spectral_scan_restart_ena = param->restart_enable;
11011 cmd->spectral_scan_noise_floor_ref = param->noise_floor_ref;
11012 cmd->spectral_scan_init_delay = param->init_delay;
11013 cmd->spectral_scan_nb_tone_thr = param->nb_tone_thr;
11014 cmd->spectral_scan_str_bin_thr = param->str_bin_thr;
11015 cmd->spectral_scan_wb_rpt_mode = param->wb_rpt_mode;
11016 cmd->spectral_scan_rssi_rpt_mode = param->rssi_rpt_mode;
11017 cmd->spectral_scan_rssi_thr = param->rssi_thr;
11018 cmd->spectral_scan_pwr_format = param->pwr_format;
11019 cmd->spectral_scan_rpt_mode = param->rpt_mode;
11020 cmd->spectral_scan_bin_scale = param->bin_scale;
11021 cmd->spectral_scan_dBm_adj = param->dBm_adj;
11022 cmd->spectral_scan_chn_mask = param->chn_mask;
11023
11024 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11025 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID);
11026
11027 if (ret != 0) {
11028 WMI_LOGE("Sending set quiet cmd failed\n");
11029 wmi_buf_free(buf);
11030 }
11031
11032 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID\n",
11033 __func__);
11034
11035 WMI_LOGI("vdev_id = %u\n"
11036 "spectral_scan_count = %u\n"
11037 "spectral_scan_period = %u\n"
11038 "spectral_scan_priority = %u\n"
11039 "spectral_scan_fft_size = %u\n"
11040 "spectral_scan_gc_ena = %u\n"
11041 "spectral_scan_restart_ena = %u\n"
11042 "spectral_scan_noise_floor_ref = %u\n"
11043 "spectral_scan_init_delay = %u\n"
11044 "spectral_scan_nb_tone_thr = %u\n"
11045 "spectral_scan_str_bin_thr = %u\n"
11046 "spectral_scan_wb_rpt_mode = %u\n"
11047 "spectral_scan_rssi_rpt_mode = %u\n"
11048 "spectral_scan_rssi_thr = %u\n"
11049 "spectral_scan_pwr_format = %u\n"
11050 "spectral_scan_rpt_mode = %u\n"
11051 "spectral_scan_bin_scale = %u\n"
11052 "spectral_scan_dBm_adj = %u\n"
11053 "spectral_scan_chn_mask = %u\n",
11054 param->vdev_id,
11055 param->count,
11056 param->period,
11057 param->spectral_pri,
11058 param->fft_size,
11059 param->gc_enable,
11060 param->restart_enable,
11061 param->noise_floor_ref,
11062 param->init_delay,
11063 param->nb_tone_thr,
11064 param->str_bin_thr,
11065 param->wb_rpt_mode,
11066 param->rssi_rpt_mode,
11067 param->rssi_thr,
11068 param->pwr_format,
11069 param->rpt_mode,
11070 param->bin_scale,
11071 param->dBm_adj,
11072 param->chn_mask);
11073 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11074
11075 return ret;
11076}
11077
11078/**
11079 * send_vdev_spectral_enable_cmd_tlv() - send VDEV spectral configure
11080 * command to fw
11081 * @wmi_handle: wmi handle
11082 * @param: pointer to hold spectral enable parameter
11083 *
11084 * Return: 0 for success or error code
11085 */
11086static QDF_STATUS send_vdev_spectral_enable_cmd_tlv(wmi_unified_t wmi_handle,
11087 struct vdev_spectral_enable_params *param)
11088{
11089 wmi_vdev_spectral_enable_cmd_fixed_param *cmd;
11090 wmi_buf_t buf;
11091 QDF_STATUS ret;
11092 int32_t len;
11093
11094 len = sizeof(*cmd);
11095 buf = wmi_buf_alloc(wmi_handle, len);
11096 if (!buf) {
11097 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11098 return QDF_STATUS_E_FAILURE;
11099 }
11100
11101 cmd = (wmi_vdev_spectral_enable_cmd_fixed_param *)wmi_buf_data(buf);
11102 WMITLV_SET_HDR(&cmd->tlv_header,
11103 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param,
11104 WMITLV_GET_STRUCT_TLVLEN(
11105 WMITLV_TAG_STRUC_wmi_vdev_spectral_enable_cmd_fixed_param));
11106
11107 cmd->vdev_id = param->vdev_id;
11108
11109 if (param->active_valid) {
11110 cmd->trigger_cmd = param->active ? 1 : 2;
11111 /* 1: Trigger, 2: Clear Trigger */
11112 } else {
11113 cmd->trigger_cmd = 0; /* 0: Ignore */
11114 }
11115
11116 if (param->enabled_valid) {
11117 cmd->enable_cmd = param->enabled ? 1 : 2;
11118 /* 1: Enable 2: Disable */
11119 } else {
11120 cmd->enable_cmd = 0; /* 0: Ignore */
11121 }
11122
11123 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11124 WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID);
11125
11126 if (ret != 0) {
11127 WMI_LOGE("Sending scan enable CMD failed\n");
11128 wmi_buf_free(buf);
11129 }
11130
11131 WMI_LOGI("%s: Sent WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID\n", __func__);
11132
11133 WMI_LOGI("vdev_id = %u\n"
11134 "trigger_cmd = %u\n"
11135 "enable_cmd = %u\n",
11136 cmd->vdev_id,
11137 cmd->trigger_cmd,
11138 cmd->enable_cmd);
11139
11140 WMI_LOGI("%s: Status: %d\n\n", __func__, ret);
11141
11142 return ret;
11143}
11144
11145/**
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011146 * send_thermal_mitigation_param_cmd_tlv() - configure thermal mitigation params
11147 * @param wmi_handle : handle to WMI.
11148 * @param param : pointer to hold thermal mitigation param
11149 *
11150 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
11151 */
11152static QDF_STATUS send_thermal_mitigation_param_cmd_tlv(
11153 wmi_unified_t wmi_handle,
11154 struct thermal_mitigation_params *param)
11155{
11156 wmi_therm_throt_config_request_fixed_param *tt_conf = NULL;
11157 wmi_therm_throt_level_config_info *lvl_conf = NULL;
11158 wmi_buf_t buf = NULL;
11159 uint8_t *buf_ptr = NULL;
11160 int error;
11161 int32_t len;
11162 int i;
11163
11164 len = sizeof(*tt_conf) + WMI_TLV_HDR_SIZE +
11165 THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info);
11166
11167 buf = wmi_buf_alloc(wmi_handle, len);
11168 if (!buf) {
11169 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11170 return QDF_STATUS_E_NOMEM;
11171 }
11172 tt_conf = (wmi_therm_throt_config_request_fixed_param *) wmi_buf_data(buf);
11173
11174 /* init fixed params */
11175 WMITLV_SET_HDR(tt_conf,
11176 WMITLV_TAG_STRUC_wmi_therm_throt_config_request_fixed_param,
11177 (WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_config_request_fixed_param)));
11178
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011179 tt_conf->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11180 param->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053011181 tt_conf->enable = param->enable;
11182 tt_conf->dc = param->dc;
11183 tt_conf->dc_per_event = param->dc_per_event;
11184 tt_conf->therm_throt_levels = THERMAL_LEVELS;
11185
11186 buf_ptr = (uint8_t *) ++tt_conf;
11187 /* init TLV params */
11188 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
11189 (THERMAL_LEVELS * sizeof(wmi_therm_throt_level_config_info)));
11190
11191 lvl_conf = (wmi_therm_throt_level_config_info *) (buf_ptr + WMI_TLV_HDR_SIZE);
11192 for (i = 0; i < THERMAL_LEVELS; i++) {
11193 WMITLV_SET_HDR(&lvl_conf->tlv_header,
11194 WMITLV_TAG_STRUC_wmi_therm_throt_level_config_info,
11195 WMITLV_GET_STRUCT_TLVLEN(wmi_therm_throt_level_config_info));
11196 lvl_conf->temp_lwm = param->levelconf[i].tmplwm;
11197 lvl_conf->temp_hwm = param->levelconf[i].tmphwm;
11198 lvl_conf->dc_off_percent = param->levelconf[i].dcoffpercent;
11199 lvl_conf->prio = param->levelconf[i].priority;
11200 lvl_conf++;
11201 }
11202
11203 error = wmi_unified_cmd_send(wmi_handle, buf, len,
11204 WMI_THERM_THROT_SET_CONF_CMDID);
11205 if (QDF_IS_STATUS_ERROR(error)) {
11206 wmi_buf_free(buf);
11207 WMI_LOGE("Failed to send WMI_THERM_THROT_SET_CONF_CMDID command");
11208 }
11209
11210 return error;
11211}
11212
11213/**
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011214 * send_pdev_qvit_cmd_tlv() - send qvit command to fw
11215 * @wmi_handle: wmi handle
11216 * @param: pointer to pdev_qvit_params
11217 *
11218 * Return: 0 for success or error code
11219 */
11220static QDF_STATUS
11221send_pdev_qvit_cmd_tlv(wmi_unified_t wmi_handle,
11222 struct pdev_qvit_params *param)
11223{
11224 wmi_buf_t buf;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011225 QDF_STATUS ret = QDF_STATUS_E_INVAL;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011226 uint8_t *cmd;
11227 static uint8_t msgref = 1;
11228 uint8_t segnumber = 0, seginfo, numsegments;
11229 uint16_t chunk_len, total_bytes;
11230 uint8_t *bufpos;
11231 QVIT_SEG_HDR_INFO_STRUCT seghdrinfo;
11232
11233 bufpos = param->utf_payload;
11234 total_bytes = param->len;
11235 ASSERT(total_bytes / MAX_WMI_QVIT_LEN ==
11236 (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN));
11237 numsegments = (uint8_t) (total_bytes / MAX_WMI_QVIT_LEN);
11238
11239 if (param->len - (numsegments * MAX_WMI_QVIT_LEN))
11240 numsegments++;
11241
11242 while (param->len) {
11243 if (param->len > MAX_WMI_QVIT_LEN)
11244 chunk_len = MAX_WMI_QVIT_LEN; /* MAX messsage */
11245 else
11246 chunk_len = param->len;
11247
11248 buf = wmi_buf_alloc(wmi_handle,
11249 (chunk_len + sizeof(seghdrinfo) +
11250 WMI_TLV_HDR_SIZE));
11251 if (!buf) {
11252 WMI_LOGE("%s:wmi_buf_alloc failed", __func__);
11253 return QDF_STATUS_E_NOMEM;
11254 }
11255
11256 cmd = (uint8_t *) wmi_buf_data(buf);
11257
11258 seghdrinfo.len = total_bytes;
11259 seghdrinfo.msgref = msgref;
11260 seginfo = ((numsegments << 4) & 0xF0) | (segnumber & 0xF);
11261 seghdrinfo.segmentInfo = seginfo;
11262
11263 segnumber++;
11264
11265 WMITLV_SET_HDR(cmd, WMITLV_TAG_ARRAY_BYTE,
11266 (chunk_len + sizeof(seghdrinfo)));
11267 cmd += WMI_TLV_HDR_SIZE;
11268 qdf_mem_copy(cmd, &seghdrinfo, sizeof(seghdrinfo));
11269 qdf_mem_copy(&cmd[sizeof(seghdrinfo)], bufpos, chunk_len);
11270
11271 ret = wmi_unified_cmd_send(wmi_handle, buf,
11272 (chunk_len + sizeof(seghdrinfo) +
11273 WMI_TLV_HDR_SIZE),
11274 WMI_PDEV_QVIT_CMDID);
11275
11276 if (ret != 0) {
11277 WMI_LOGE("Failed to send WMI_PDEV_QVIT_CMDID command");
11278 wmi_buf_free(buf);
11279 break;
11280 }
11281
11282 param->len -= chunk_len;
11283 bufpos += chunk_len;
11284 }
11285 msgref++;
11286
11287 return ret;
11288}
11289
11290/**
11291 * send_wmm_update_cmd_tlv() - send wmm update command to fw
11292 * @wmi_handle: wmi handle
11293 * @param: pointer to wmm update param
11294 *
11295 * Return: 0 for success or error code
11296 */
11297static QDF_STATUS
11298send_wmm_update_cmd_tlv(wmi_unified_t wmi_handle,
11299 struct wmm_update_params *param)
11300{
11301 wmi_pdev_set_wmm_params_cmd_fixed_param *cmd;
11302 wmi_wmm_params *wmm_param;
11303 wmi_buf_t buf;
11304 QDF_STATUS ret;
11305 int32_t len;
11306 int ac = 0;
11307 struct wmi_host_wmeParams *wmep;
11308 uint8_t *buf_ptr;
11309
11310 len = sizeof(*cmd) + (WME_NUM_AC * sizeof(*wmm_param));
11311 buf = wmi_buf_alloc(wmi_handle, len);
11312 if (!buf) {
11313 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11314 return QDF_STATUS_E_FAILURE;
11315 }
11316
11317 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11318 cmd = (wmi_pdev_set_wmm_params_cmd_fixed_param *) buf_ptr;
11319 WMITLV_SET_HDR(&cmd->tlv_header,
11320 WMITLV_TAG_STRUC_wmi_pdev_set_wmm_params_cmd_fixed_param,
11321 WMITLV_GET_STRUCT_TLVLEN
11322 (wmi_pdev_set_wmm_params_cmd_fixed_param));
11323
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011324 cmd->reserved0 = WMI_HOST_PDEV_ID_SOC;
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053011325
11326 buf_ptr += sizeof(wmi_pdev_set_wmm_params_cmd_fixed_param);
11327
11328 for (ac = 0; ac < WME_NUM_AC; ac++) {
11329 wmep = &param->wmep_array[ac];
11330 wmm_param = (wmi_wmm_params *)buf_ptr;
11331 WMITLV_SET_HDR(&wmm_param->tlv_header,
11332 WMITLV_TAG_STRUC_wmi_wmm_params,
11333 WMITLV_GET_STRUCT_TLVLEN(wmi_wmm_params));
11334 wmm_param->aifs = wmep->wmep_aifsn;
11335 wmm_param->cwmin = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmin);
11336 wmm_param->cwmax = ATH_EXPONENT_TO_VALUE(wmep->wmep_logcwmax);
11337 wmm_param->txoplimit = ATH_TXOP_TO_US(wmep->wmep_txopLimit);
11338 wmm_param->acm = wmep->wmep_acm;
11339 wmm_param->no_ack = wmep->wmep_noackPolicy;
11340 buf_ptr += sizeof(wmi_wmm_params);
11341 }
11342 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11343 WMI_PDEV_SET_WMM_PARAMS_CMDID);
11344
11345 if (ret != 0) {
11346 WMI_LOGE("Sending WMM update CMD failed\n");
11347 wmi_buf_free(buf);
11348 }
11349
11350 return ret;
11351}
11352
Sathish Kumar80f4f382017-04-24 11:36:00 +053011353/**
11354 * send_coex_config_cmd_tlv() - send coex config command to fw
11355 * @wmi_handle: wmi handle
11356 * @param: pointer to coex config param
11357 *
11358 * Return: 0 for success or error code
11359 */
11360static QDF_STATUS
11361send_coex_config_cmd_tlv(wmi_unified_t wmi_handle,
11362 struct coex_config_params *param)
11363{
11364 WMI_COEX_CONFIG_CMD_fixed_param *cmd;
11365 wmi_buf_t buf;
11366 QDF_STATUS ret;
11367 int32_t len;
11368
11369 len = sizeof(*cmd);
11370 buf = wmi_buf_alloc(wmi_handle, len);
11371 if (!buf) {
11372 WMI_LOGE("%s: wmi_buf_alloc failed\n", __func__);
11373 return QDF_STATUS_E_FAILURE;
11374 }
11375
11376 cmd = (WMI_COEX_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
11377 WMITLV_SET_HDR(&cmd->tlv_header,
11378 WMITLV_TAG_STRUC_WMI_COEX_CONFIG_CMD_fixed_param,
11379 WMITLV_GET_STRUCT_TLVLEN(
Sathish Kumar8458a052017-05-12 15:52:00 +053011380 WMI_COEX_CONFIG_CMD_fixed_param));
Sathish Kumar80f4f382017-04-24 11:36:00 +053011381
11382 cmd->vdev_id = param->vdev_id;
11383 cmd->config_type = param->config_type;
11384 cmd->config_arg1 = param->config_arg1;
11385 cmd->config_arg2 = param->config_arg2;
11386 cmd->config_arg3 = param->config_arg3;
11387 cmd->config_arg4 = param->config_arg4;
11388 cmd->config_arg5 = param->config_arg5;
11389 cmd->config_arg6 = param->config_arg6;
11390
11391 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11392 WMI_COEX_CONFIG_CMDID);
11393
11394 if (ret != 0) {
11395 WMI_LOGE("Sending COEX CONFIG CMD failed\n");
11396 wmi_buf_free(buf);
11397 }
11398
11399 return ret;
11400}
11401
Jeff Johnson9366d7a2016-10-07 13:03:02 -070011402static
Govind Singh9ddd5162016-03-07 16:30:32 +053011403void wmi_copy_resource_config(wmi_resource_config *resource_cfg,
Govind Singhe7f2f342016-05-23 12:12:52 +053011404 target_resource_config *tgt_res_cfg)
Govind Singh9ddd5162016-03-07 16:30:32 +053011405{
Govind Singhe7f2f342016-05-23 12:12:52 +053011406 resource_cfg->num_vdevs = tgt_res_cfg->num_vdevs;
Govind Singh9ddd5162016-03-07 16:30:32 +053011407 resource_cfg->num_peers = tgt_res_cfg->num_peers;
11408 resource_cfg->num_offload_peers = tgt_res_cfg->num_offload_peers;
11409 resource_cfg->num_offload_reorder_buffs =
11410 tgt_res_cfg->num_offload_reorder_buffs;
11411 resource_cfg->num_peer_keys = tgt_res_cfg->num_peer_keys;
11412 resource_cfg->num_tids = tgt_res_cfg->num_tids;
11413 resource_cfg->ast_skid_limit = tgt_res_cfg->ast_skid_limit;
11414 resource_cfg->tx_chain_mask = tgt_res_cfg->tx_chain_mask;
11415 resource_cfg->rx_chain_mask = tgt_res_cfg->rx_chain_mask;
11416 resource_cfg->rx_timeout_pri[0] = tgt_res_cfg->rx_timeout_pri[0];
11417 resource_cfg->rx_timeout_pri[1] = tgt_res_cfg->rx_timeout_pri[1];
11418 resource_cfg->rx_timeout_pri[2] = tgt_res_cfg->rx_timeout_pri[2];
11419 resource_cfg->rx_timeout_pri[3] = tgt_res_cfg->rx_timeout_pri[3];
11420 resource_cfg->rx_decap_mode = tgt_res_cfg->rx_decap_mode;
11421 resource_cfg->scan_max_pending_req =
11422 tgt_res_cfg->scan_max_pending_req;
11423 resource_cfg->bmiss_offload_max_vdev =
11424 tgt_res_cfg->bmiss_offload_max_vdev;
11425 resource_cfg->roam_offload_max_vdev =
11426 tgt_res_cfg->roam_offload_max_vdev;
11427 resource_cfg->roam_offload_max_ap_profiles =
11428 tgt_res_cfg->roam_offload_max_ap_profiles;
11429 resource_cfg->num_mcast_groups = tgt_res_cfg->num_mcast_groups;
11430 resource_cfg->num_mcast_table_elems =
11431 tgt_res_cfg->num_mcast_table_elems;
11432 resource_cfg->mcast2ucast_mode = tgt_res_cfg->mcast2ucast_mode;
11433 resource_cfg->tx_dbg_log_size = tgt_res_cfg->tx_dbg_log_size;
11434 resource_cfg->num_wds_entries = tgt_res_cfg->num_wds_entries;
11435 resource_cfg->dma_burst_size = tgt_res_cfg->dma_burst_size;
11436 resource_cfg->mac_aggr_delim = tgt_res_cfg->mac_aggr_delim;
11437 resource_cfg->rx_skip_defrag_timeout_dup_detection_check =
11438 tgt_res_cfg->rx_skip_defrag_timeout_dup_detection_check;
11439 resource_cfg->vow_config = tgt_res_cfg->vow_config;
11440 resource_cfg->gtk_offload_max_vdev = tgt_res_cfg->gtk_offload_max_vdev;
11441 resource_cfg->num_msdu_desc = tgt_res_cfg->num_msdu_desc;
11442 resource_cfg->max_frag_entries = tgt_res_cfg->max_frag_entries;
11443 resource_cfg->num_tdls_vdevs = tgt_res_cfg->num_tdls_vdevs;
11444 resource_cfg->num_tdls_conn_table_entries =
11445 tgt_res_cfg->num_tdls_conn_table_entries;
11446 resource_cfg->beacon_tx_offload_max_vdev =
11447 tgt_res_cfg->beacon_tx_offload_max_vdev;
11448 resource_cfg->num_multicast_filter_entries =
11449 tgt_res_cfg->num_multicast_filter_entries;
11450 resource_cfg->num_wow_filters =
11451 tgt_res_cfg->num_wow_filters;
11452 resource_cfg->num_keep_alive_pattern =
11453 tgt_res_cfg->num_keep_alive_pattern;
11454 resource_cfg->keep_alive_pattern_size =
11455 tgt_res_cfg->keep_alive_pattern_size;
11456 resource_cfg->max_tdls_concurrent_sleep_sta =
11457 tgt_res_cfg->max_tdls_concurrent_sleep_sta;
11458 resource_cfg->max_tdls_concurrent_buffer_sta =
11459 tgt_res_cfg->max_tdls_concurrent_buffer_sta;
11460 resource_cfg->wmi_send_separate =
11461 tgt_res_cfg->wmi_send_separate;
11462 resource_cfg->num_ocb_vdevs =
11463 tgt_res_cfg->num_ocb_vdevs;
11464 resource_cfg->num_ocb_channels =
11465 tgt_res_cfg->num_ocb_channels;
11466 resource_cfg->num_ocb_schedules =
11467 tgt_res_cfg->num_ocb_schedules;
Kiran Venkatappa8e146df2017-02-08 14:51:13 +053011468 resource_cfg->bpf_instruction_size = tgt_res_cfg->bpf_instruction_size;
11469 resource_cfg->max_bssid_rx_filters = tgt_res_cfg->max_bssid_rx_filters;
11470 resource_cfg->use_pdev_id = tgt_res_cfg->use_pdev_id;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053011471
11472 WMI_RSRC_CFG_FLAG_ATF_CONFIG_ENABLE_SET(resource_cfg->flag1,
11473 tgt_res_cfg->atf_config);
Govind Singh9ddd5162016-03-07 16:30:32 +053011474}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011475#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011476/**
11477 * send_init_cmd_tlv() - wmi init command
11478 * @wmi_handle: pointer to wmi handle
11479 * @res_cfg: resource config
11480 * @num_mem_chunks: no of mem chunck
11481 * @mem_chunk: pointer to mem chunck structure
11482 *
11483 * This function sends IE information to firmware
11484 *
Govind Singhb53420c2016-03-09 14:32:57 +053011485 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011486 *
11487 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011488static QDF_STATUS send_init_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011489 wmi_resource_config *tgt_res_cfg,
11490 uint8_t num_mem_chunks, struct wmi_host_mem_chunk *mem_chunks,
11491 bool action)
11492{
11493 wmi_buf_t buf;
11494 wmi_init_cmd_fixed_param *cmd;
11495 wmi_abi_version my_vers;
11496 int num_whitelist;
11497 uint8_t *buf_ptr;
11498 wmi_resource_config *resource_cfg;
11499 wlan_host_memory_chunk *host_mem_chunks;
11500 uint32_t mem_chunk_len = 0;
11501 uint16_t idx;
11502 int len;
11503 int ret;
11504
11505 len = sizeof(*cmd) + sizeof(wmi_resource_config) + WMI_TLV_HDR_SIZE;
11506 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
11507 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len);
11508 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011509 WMI_LOGD("%s: wmi_buf_alloc failed\n", __func__);
11510 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011511 }
11512
11513 buf_ptr = (uint8_t *) wmi_buf_data(buf);
11514 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
11515 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
11516
11517 host_mem_chunks = (wlan_host_memory_chunk *)
11518 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
11519 + WMI_TLV_HDR_SIZE);
11520
11521 WMITLV_SET_HDR(&cmd->tlv_header,
11522 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
11523 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
11524
Govind Singhb53420c2016-03-09 14:32:57 +053011525 qdf_mem_copy(resource_cfg, tgt_res_cfg, sizeof(wmi_resource_config));
Govind Singh9ddd5162016-03-07 16:30:32 +053011526 WMITLV_SET_HDR(&resource_cfg->tlv_header,
11527 WMITLV_TAG_STRUC_wmi_resource_config,
11528 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
11529
11530 for (idx = 0; idx < num_mem_chunks; ++idx) {
11531 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
11532 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
11533 WMITLV_GET_STRUCT_TLVLEN
11534 (wlan_host_memory_chunk));
11535 host_mem_chunks[idx].ptr = mem_chunks[idx].paddr;
11536 host_mem_chunks[idx].size = mem_chunks[idx].len;
11537 host_mem_chunks[idx].req_id = mem_chunks[idx].req_id;
Govind Singhb53420c2016-03-09 14:32:57 +053011538 WMI_LOGD("chunk %d len %d requested ,ptr 0x%x ",
Govind Singh9ddd5162016-03-07 16:30:32 +053011539 idx, host_mem_chunks[idx].size,
11540 host_mem_chunks[idx].ptr);
11541 }
11542 cmd->num_host_mem_chunks = num_mem_chunks;
11543 len += (num_mem_chunks * sizeof(wlan_host_memory_chunk));
11544 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
11545 WMITLV_TAG_ARRAY_STRUC,
11546 (sizeof(wlan_host_memory_chunk) *
11547 num_mem_chunks));
11548
11549 num_whitelist = sizeof(version_whitelist) /
11550 sizeof(wmi_whitelist_version_info);
11551 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
11552 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
11553 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
11554 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
11555 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
11556 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
Govind Singh87542482016-06-08 19:40:11 +053011557#ifdef CONFIG_MCL
11558 /* This needs to be enabled for WIN Lithium after removing dependency
11559 * on wmi_unified.h from priv.h for using wmi_abi_version type */
Govind Singh9ddd5162016-03-07 16:30:32 +053011560 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
11561 &my_vers,
11562 &wmi_handle->fw_abi_version,
11563 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053011564#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011565 WMI_LOGD("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
Govind Singh9ddd5162016-03-07 16:30:32 +053011566 __func__, WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
11567 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
11568 cmd->host_abi_vers.abi_version_ns_0,
11569 cmd->host_abi_vers.abi_version_ns_1,
11570 cmd->host_abi_vers.abi_version_ns_2,
11571 cmd->host_abi_vers.abi_version_ns_3);
Govind Singh87542482016-06-08 19:40:11 +053011572#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011573 /* Save version sent from host -
11574 * Will be used to check ready event
11575 */
Govind Singhb53420c2016-03-09 14:32:57 +053011576 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011577 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011578#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011579 if (action) {
11580 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
11581 WMI_INIT_CMDID);
11582 if (ret) {
Govind Singhb53420c2016-03-09 14:32:57 +053011583 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), ret);
Govind Singh9ddd5162016-03-07 16:30:32 +053011584 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011585 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011586 }
11587 } else {
11588 wmi_handle->saved_wmi_init_cmd.buf = buf;
11589 wmi_handle->saved_wmi_init_cmd.buf_len = len;
11590 }
11591
Govind Singhb53420c2016-03-09 14:32:57 +053011592 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011593
11594}
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053011595#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011596/**
11597 * send_saved_init_cmd_tlv() - wmi init command
11598 * @wmi_handle: pointer to wmi handle
11599 *
11600 * This function sends IE information to firmware
11601 *
Govind Singhb53420c2016-03-09 14:32:57 +053011602 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011603 *
11604 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011605static QDF_STATUS send_saved_init_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singh9ddd5162016-03-07 16:30:32 +053011606{
11607 int status;
11608
11609 if (!wmi_handle->saved_wmi_init_cmd.buf ||
11610 !wmi_handle->saved_wmi_init_cmd.buf_len) {
Govind Singhb53420c2016-03-09 14:32:57 +053011611 WMI_LOGP("Service ready ext event w/o WMI_SERVICE_EXT_MSG!");
11612 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011613 }
11614 status = wmi_unified_cmd_send(wmi_handle,
11615 wmi_handle->saved_wmi_init_cmd.buf,
11616 wmi_handle->saved_wmi_init_cmd.buf_len,
11617 WMI_INIT_CMDID);
11618 if (status) {
Govind Singhb53420c2016-03-09 14:32:57 +053011619 WMI_LOGE(FL("Failed to send set WMI INIT command ret = %d"), status);
Govind Singh9ddd5162016-03-07 16:30:32 +053011620 wmi_buf_free(wmi_handle->saved_wmi_init_cmd.buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011621 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011622 }
11623 wmi_handle->saved_wmi_init_cmd.buf = NULL;
11624 wmi_handle->saved_wmi_init_cmd.buf_len = 0;
11625
Govind Singhb53420c2016-03-09 14:32:57 +053011626 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011627}
11628
Sathish Kumarfd347372017-02-13 12:29:09 +053011629static QDF_STATUS save_fw_version_cmd_tlv(wmi_unified_t wmi_handle, void *evt_buf)
Govind Singh9ddd5162016-03-07 16:30:32 +053011630{
11631 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
11632 wmi_service_ready_event_fixed_param *ev;
11633
11634
11635 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
11636
11637 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
11638 if (!ev)
Govind Singhe7f2f342016-05-23 12:12:52 +053011639 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011640
Govind Singh87542482016-06-08 19:40:11 +053011641#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011642 /*Save fw version from service ready message */
11643 /*This will be used while sending INIT message */
Govind Singhb53420c2016-03-09 14:32:57 +053011644 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011645 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011646#endif
Govind Singhb53420c2016-03-09 14:32:57 +053011647 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011648}
11649
11650/**
11651 * wmi_unified_save_fw_version_cmd() - save fw version
11652 * @wmi_handle: pointer to wmi handle
11653 * @res_cfg: resource config
11654 * @num_mem_chunks: no of mem chunck
11655 * @mem_chunk: pointer to mem chunck structure
11656 *
11657 * This function sends IE information to firmware
11658 *
Govind Singhb53420c2016-03-09 14:32:57 +053011659 * Return: QDF_STATUS_SUCCESS for success otherwise failure
Govind Singh9ddd5162016-03-07 16:30:32 +053011660 *
11661 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011662static QDF_STATUS check_and_update_fw_version_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singh9ddd5162016-03-07 16:30:32 +053011663 void *evt_buf)
11664{
11665 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
11666 wmi_ready_event_fixed_param *ev = NULL;
11667
11668 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
11669 ev = param_buf->fixed_param;
Govind Singh87542482016-06-08 19:40:11 +053011670#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053011671 if (!wmi_versions_are_compatible(&wmi_handle->final_abi_vers,
11672 &ev->fw_abi_vers)) {
11673 /*
11674 * Error: Our host version and the given firmware version
11675 * are incompatible.
11676 **/
Govind Singhb53420c2016-03-09 14:32:57 +053011677 WMI_LOGD("%s: Error: Incompatible WMI version."
Govind Singh9ddd5162016-03-07 16:30:32 +053011678 "Host: %d,%d,0x%x 0x%x 0x%x 0x%x, FW: %d,%d,0x%x 0x%x 0x%x 0x%x\n",
11679 __func__,
11680 WMI_VER_GET_MAJOR(wmi_handle->final_abi_vers.
11681 abi_version_0),
11682 WMI_VER_GET_MINOR(wmi_handle->final_abi_vers.
11683 abi_version_0),
11684 wmi_handle->final_abi_vers.abi_version_ns_0,
11685 wmi_handle->final_abi_vers.abi_version_ns_1,
11686 wmi_handle->final_abi_vers.abi_version_ns_2,
11687 wmi_handle->final_abi_vers.abi_version_ns_3,
11688 WMI_VER_GET_MAJOR(ev->fw_abi_vers.abi_version_0),
11689 WMI_VER_GET_MINOR(ev->fw_abi_vers.abi_version_0),
11690 ev->fw_abi_vers.abi_version_ns_0,
11691 ev->fw_abi_vers.abi_version_ns_1,
11692 ev->fw_abi_vers.abi_version_ns_2,
11693 ev->fw_abi_vers.abi_version_ns_3);
11694
Govind Singhb53420c2016-03-09 14:32:57 +053011695 return QDF_STATUS_E_FAILURE;
Govind Singh9ddd5162016-03-07 16:30:32 +053011696 }
Govind Singhb53420c2016-03-09 14:32:57 +053011697 qdf_mem_copy(&wmi_handle->final_abi_vers, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011698 sizeof(wmi_abi_version));
Govind Singhb53420c2016-03-09 14:32:57 +053011699 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
Govind Singh9ddd5162016-03-07 16:30:32 +053011700 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053011701#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053011702
Govind Singhb53420c2016-03-09 14:32:57 +053011703 return QDF_STATUS_SUCCESS;
Govind Singh9ddd5162016-03-07 16:30:32 +053011704}
Govind Singha4836fd2016-03-07 16:45:38 +053011705
11706/**
11707 * send_set_base_macaddr_indicate_cmd_tlv() - set base mac address in fw
11708 * @wmi_handle: wmi handle
11709 * @custom_addr: base mac address
11710 *
Govind Singhe7f2f342016-05-23 12:12:52 +053011711 * Return: QDF_STATUS_SUCCESS for success or error code
Govind Singha4836fd2016-03-07 16:45:38 +053011712 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011713static QDF_STATUS send_set_base_macaddr_indicate_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011714 uint8_t *custom_addr)
11715{
11716 wmi_pdev_set_base_macaddr_cmd_fixed_param *cmd;
11717 wmi_buf_t buf;
11718 int err;
11719
11720 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
11721 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011722 WMI_LOGE("Failed to allocate buffer to send base macaddr cmd");
Govind Singh67922e82016-04-01 16:48:57 +053011723 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011724 }
11725
11726 cmd = (wmi_pdev_set_base_macaddr_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053011727 qdf_mem_zero(cmd, sizeof(*cmd));
Govind Singha4836fd2016-03-07 16:45:38 +053011728
11729 WMITLV_SET_HDR(&cmd->tlv_header,
11730 WMITLV_TAG_STRUC_wmi_pdev_set_base_macaddr_cmd_fixed_param,
11731 WMITLV_GET_STRUCT_TLVLEN
11732 (wmi_pdev_set_base_macaddr_cmd_fixed_param));
11733 WMI_CHAR_ARRAY_TO_MAC_ADDR(custom_addr, &cmd->base_macaddr);
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053011734 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
11735 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053011736 err = wmi_unified_cmd_send(wmi_handle, buf,
11737 sizeof(*cmd),
11738 WMI_PDEV_SET_BASE_MACADDR_CMDID);
11739 if (err) {
Govind Singhb53420c2016-03-09 14:32:57 +053011740 WMI_LOGE("Failed to send set_base_macaddr cmd");
Abhishek Singh716c46c2016-05-04 16:24:07 +053011741 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011742 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053011743 }
11744
11745 return 0;
11746}
11747
11748/**
11749 * send_log_supported_evt_cmd_tlv() - Enable/Disable FW diag/log events
11750 * @handle: wmi handle
11751 * @event: Event received from FW
11752 * @len: Length of the event
11753 *
11754 * Enables the low frequency events and disables the high frequency
11755 * events. Bit 17 indicates if the event if low/high frequency.
11756 * 1 - high frequency, 0 - low frequency
11757 *
11758 * Return: 0 on successfully enabling/disabling the events
11759 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011760static QDF_STATUS send_log_supported_evt_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011761 uint8_t *event,
11762 uint32_t len)
11763{
11764 uint32_t num_of_diag_events_logs;
11765 wmi_diag_event_log_config_fixed_param *cmd;
11766 wmi_buf_t buf;
11767 uint8_t *buf_ptr;
11768 uint32_t *cmd_args, *evt_args;
11769 uint32_t buf_len, i;
11770
11771 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *param_buf;
11772 wmi_diag_event_log_supported_event_fixed_params *wmi_event;
11773
Govind Singhb53420c2016-03-09 14:32:57 +053011774 WMI_LOGI("Received WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID");
Govind Singha4836fd2016-03-07 16:45:38 +053011775
11776 param_buf = (WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID_param_tlvs *) event;
11777 if (!param_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011778 WMI_LOGE("Invalid log supported event buffer");
Govind Singh67922e82016-04-01 16:48:57 +053011779 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011780 }
11781 wmi_event = param_buf->fixed_param;
11782 num_of_diag_events_logs = wmi_event->num_of_diag_events_logs;
11783 evt_args = param_buf->diag_events_logs_list;
11784 if (!evt_args) {
Govind Singhb53420c2016-03-09 14:32:57 +053011785 WMI_LOGE("%s: Event list is empty, num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011786 __func__, num_of_diag_events_logs);
Govind Singh67922e82016-04-01 16:48:57 +053011787 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011788 }
11789
Govind Singhb53420c2016-03-09 14:32:57 +053011790 WMI_LOGD("%s: num_of_diag_events_logs=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053011791 __func__, num_of_diag_events_logs);
11792
11793 /* Free any previous allocation */
11794 if (wmi_handle->events_logs_list)
Govind Singhb53420c2016-03-09 14:32:57 +053011795 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053011796
11797 /* Store the event list for run time enable/disable */
Govind Singhb53420c2016-03-09 14:32:57 +053011798 wmi_handle->events_logs_list = qdf_mem_malloc(num_of_diag_events_logs *
Govind Singha4836fd2016-03-07 16:45:38 +053011799 sizeof(uint32_t));
11800 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011801 WMI_LOGE("%s: event log list memory allocation failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011802 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011803 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011804 }
11805 wmi_handle->num_of_diag_events_logs = num_of_diag_events_logs;
11806
11807 /* Prepare the send buffer */
11808 buf_len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11809 (num_of_diag_events_logs * sizeof(uint32_t));
11810
11811 buf = wmi_buf_alloc(wmi_handle, buf_len);
11812 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011813 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
11814 qdf_mem_free(wmi_handle->events_logs_list);
Govind Singha4836fd2016-03-07 16:45:38 +053011815 wmi_handle->events_logs_list = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053011816 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011817 }
11818
11819 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11820 buf_ptr = (uint8_t *) cmd;
11821
11822 WMITLV_SET_HDR(&cmd->tlv_header,
11823 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11824 WMITLV_GET_STRUCT_TLVLEN(
11825 wmi_diag_event_log_config_fixed_param));
11826
11827 cmd->num_of_diag_events_logs = num_of_diag_events_logs;
11828
11829 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11830
11831 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11832 (num_of_diag_events_logs * sizeof(uint32_t)));
11833
11834 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11835
11836 /* Populate the events */
11837 for (i = 0; i < num_of_diag_events_logs; i++) {
11838 /* Low freq (0) - Enable (1) the event
11839 * High freq (1) - Disable (0) the event
11840 */
11841 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[i],
11842 !(WMI_DIAG_FREQUENCY_GET(evt_args[i])));
11843 /* Set the event ID */
11844 WMI_DIAG_ID_SET(cmd_args[i],
11845 WMI_DIAG_ID_GET(evt_args[i]));
11846 /* Set the type */
11847 WMI_DIAG_TYPE_SET(cmd_args[i],
11848 WMI_DIAG_TYPE_GET(evt_args[i]));
Govind Singhb53420c2016-03-09 14:32:57 +053011849 /* Storing the event/log list in WMI */
Govind Singha4836fd2016-03-07 16:45:38 +053011850 wmi_handle->events_logs_list[i] = evt_args[i];
11851 }
11852
11853 if (wmi_unified_cmd_send(wmi_handle, buf, buf_len,
11854 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011855 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011856 __func__);
11857 wmi_buf_free(buf);
11858 /* Not clearing events_logs_list, though wmi cmd failed.
11859 * Host can still have this list
11860 */
Govind Singh67922e82016-04-01 16:48:57 +053011861 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011862 }
11863
11864 return 0;
11865}
11866
11867/**
11868 * send_enable_specific_fw_logs_cmd_tlv() - Start/Stop logging of diag log id
11869 * @wmi_handle: wmi handle
11870 * @start_log: Start logging related parameters
11871 *
11872 * Send the command to the FW based on which specific logging of diag
11873 * event/log id can be started/stopped
11874 *
11875 * Return: None
11876 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011877static QDF_STATUS send_enable_specific_fw_logs_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053011878 struct wmi_wifi_start_log *start_log)
11879{
11880 wmi_diag_event_log_config_fixed_param *cmd;
11881 wmi_buf_t buf;
11882 uint8_t *buf_ptr;
11883 uint32_t len, count, log_level, i;
11884 uint32_t *cmd_args;
11885 uint32_t total_len;
11886 count = 0;
11887
11888 if (!wmi_handle->events_logs_list) {
Govind Singhb53420c2016-03-09 14:32:57 +053011889 WMI_LOGE("%s: Not received event/log list from FW, yet",
Govind Singha4836fd2016-03-07 16:45:38 +053011890 __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011891 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011892 }
11893 /* total_len stores the number of events where BITS 17 and 18 are set.
11894 * i.e., events of high frequency (17) and for extended debugging (18)
11895 */
11896 total_len = 0;
11897 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11898 if ((WMI_DIAG_FREQUENCY_GET(wmi_handle->events_logs_list[i])) &&
11899 (WMI_DIAG_EXT_FEATURE_GET(wmi_handle->events_logs_list[i])))
11900 total_len++;
11901 }
11902
11903 len = sizeof(*cmd) + WMI_TLV_HDR_SIZE +
11904 (total_len * sizeof(uint32_t));
11905
11906 buf = wmi_buf_alloc(wmi_handle, len);
11907 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011908 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011909 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011910 }
11911 cmd = (wmi_diag_event_log_config_fixed_param *) wmi_buf_data(buf);
11912 buf_ptr = (uint8_t *) cmd;
11913
11914 WMITLV_SET_HDR(&cmd->tlv_header,
11915 WMITLV_TAG_STRUC_wmi_diag_event_log_config_fixed_param,
11916 WMITLV_GET_STRUCT_TLVLEN(
11917 wmi_diag_event_log_config_fixed_param));
11918
11919 cmd->num_of_diag_events_logs = total_len;
11920
11921 buf_ptr += sizeof(wmi_diag_event_log_config_fixed_param);
11922
11923 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
11924 (total_len * sizeof(uint32_t)));
11925
11926 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
11927
Govind Singh224a7312016-06-21 14:33:26 +053011928 if (start_log->verbose_level >= WMI_LOG_LEVEL_ACTIVE)
Govind Singha4836fd2016-03-07 16:45:38 +053011929 log_level = 1;
11930 else
11931 log_level = 0;
11932
Govind Singhb53420c2016-03-09 14:32:57 +053011933 WMI_LOGD("%s: Length:%d, Log_level:%d", __func__, total_len, log_level);
Govind Singha4836fd2016-03-07 16:45:38 +053011934 for (i = 0; i < wmi_handle->num_of_diag_events_logs; i++) {
11935 uint32_t val = wmi_handle->events_logs_list[i];
11936 if ((WMI_DIAG_FREQUENCY_GET(val)) &&
11937 (WMI_DIAG_EXT_FEATURE_GET(val))) {
11938
11939 WMI_DIAG_ID_SET(cmd_args[count],
11940 WMI_DIAG_ID_GET(val));
11941 WMI_DIAG_TYPE_SET(cmd_args[count],
11942 WMI_DIAG_TYPE_GET(val));
11943 WMI_DIAG_ID_ENABLED_DISABLED_SET(cmd_args[count],
11944 log_level);
Govind Singhb53420c2016-03-09 14:32:57 +053011945 WMI_LOGD("%s: Idx:%d, val:%x", __func__, i, val);
Govind Singha4836fd2016-03-07 16:45:38 +053011946 count++;
11947 }
11948 }
11949
11950 if (wmi_unified_cmd_send(wmi_handle, buf, len,
11951 WMI_DIAG_EVENT_LOG_CONFIG_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011952 WMI_LOGE("%s: WMI_DIAG_EVENT_LOG_CONFIG_CMDID failed",
Govind Singha4836fd2016-03-07 16:45:38 +053011953 __func__);
11954 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011955 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011956 }
11957
Govind Singhb53420c2016-03-09 14:32:57 +053011958 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053011959}
11960
11961/**
11962 * send_flush_logs_to_fw_cmd_tlv() - Send log flush command to FW
11963 * @wmi_handle: WMI handle
11964 *
11965 * This function is used to send the flush command to the FW,
11966 * that will flush the fw logs that are residue in the FW
11967 *
11968 * Return: None
11969 */
Sathish Kumarfd347372017-02-13 12:29:09 +053011970static QDF_STATUS send_flush_logs_to_fw_cmd_tlv(wmi_unified_t wmi_handle)
Govind Singha4836fd2016-03-07 16:45:38 +053011971{
11972 wmi_debug_mesg_flush_fixed_param *cmd;
11973 wmi_buf_t buf;
11974 int len = sizeof(*cmd);
Govind Singh67922e82016-04-01 16:48:57 +053011975 QDF_STATUS ret;
Govind Singha4836fd2016-03-07 16:45:38 +053011976
11977 buf = wmi_buf_alloc(wmi_handle, len);
11978 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053011979 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
Govind Singh67922e82016-04-01 16:48:57 +053011980 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053011981 }
11982
11983 cmd = (wmi_debug_mesg_flush_fixed_param *) wmi_buf_data(buf);
11984 WMITLV_SET_HDR(&cmd->tlv_header,
11985 WMITLV_TAG_STRUC_wmi_debug_mesg_flush_fixed_param,
11986 WMITLV_GET_STRUCT_TLVLEN(
11987 wmi_debug_mesg_flush_fixed_param));
11988 cmd->reserved0 = 0;
11989
11990 ret = wmi_unified_cmd_send(wmi_handle,
11991 buf,
11992 len,
11993 WMI_DEBUG_MESG_FLUSH_CMDID);
Govind Singh67922e82016-04-01 16:48:57 +053011994 if (QDF_IS_STATUS_ERROR(ret)) {
Govind Singhb53420c2016-03-09 14:32:57 +053011995 WMI_LOGE("Failed to send WMI_DEBUG_MESG_FLUSH_CMDID");
Govind Singha4836fd2016-03-07 16:45:38 +053011996 wmi_buf_free(buf);
Govind Singh67922e82016-04-01 16:48:57 +053011997 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053011998 }
Govind Singhb53420c2016-03-09 14:32:57 +053011999 WMI_LOGI("Sent WMI_DEBUG_MESG_FLUSH_CMDID to FW");
Govind Singha4836fd2016-03-07 16:45:38 +053012000
Govind Singh67922e82016-04-01 16:48:57 +053012001 return ret;
Govind Singha4836fd2016-03-07 16:45:38 +053012002}
12003
12004/**
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012005 * send_pdev_set_pcl_cmd_tlv() - Send WMI_SOC_SET_PCL_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012006 * @wmi_handle: wmi handle
12007 * @msg: PCL structure containing the PCL and the number of channels
12008 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012009 * WMI_PDEV_SET_PCL_CMDID provides a Preferred Channel List (PCL) to the WLAN
Govind Singha4836fd2016-03-07 16:45:38 +053012010 * firmware. The DBS Manager is the consumer of this information in the WLAN
12011 * firmware. The channel list will be used when a Virtual DEVice (VDEV) needs
12012 * to migrate to a new channel without host driver involvement. An example of
12013 * this behavior is Legacy Fast Roaming (LFR 3.0). Generally, the host will
12014 * manage the channel selection without firmware involvement.
12015 *
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012016 * WMI_PDEV_SET_PCL_CMDID will carry only the weight list and not the actual
12017 * channel list. The weights corresponds to the channels sent in
12018 * WMI_SCAN_CHAN_LIST_CMDID. The channels from PCL would be having a higher
12019 * weightage compared to the non PCL channels.
12020 *
Govind Singha4836fd2016-03-07 16:45:38 +053012021 * Return: Success if the cmd is sent successfully to the firmware
12022 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012023static QDF_STATUS send_pdev_set_pcl_cmd_tlv(wmi_unified_t wmi_handle,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012024 struct wmi_pcl_chan_weights *msg)
Govind Singha4836fd2016-03-07 16:45:38 +053012025{
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012026 wmi_pdev_set_pcl_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012027 wmi_buf_t buf;
12028 uint8_t *buf_ptr;
12029 uint32_t *cmd_args, i, len;
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012030 uint32_t chan_len;
12031
12032 chan_len = msg->saved_num_chan;
Govind Singha4836fd2016-03-07 16:45:38 +053012033
12034 len = sizeof(*cmd) +
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012035 WMI_TLV_HDR_SIZE + (chan_len * sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053012036
12037 buf = wmi_buf_alloc(wmi_handle, len);
12038 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012039 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12040 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012041 }
12042
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012043 cmd = (wmi_pdev_set_pcl_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012044 buf_ptr = (uint8_t *) cmd;
12045 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012046 WMITLV_TAG_STRUC_wmi_pdev_set_pcl_cmd_fixed_param,
12047 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_pcl_cmd_fixed_param));
Govind Singha4836fd2016-03-07 16:45:38 +053012048
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012049 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12050 WMI_HOST_PDEV_ID_SOC);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012051 cmd->num_chan = chan_len;
Govind Singhe7f2f342016-05-23 12:12:52 +053012052 WMI_LOGI("%s: Total chan (PCL) len:%d", __func__, cmd->num_chan);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012053
12054 buf_ptr += sizeof(wmi_pdev_set_pcl_cmd_fixed_param);
Govind Singha4836fd2016-03-07 16:45:38 +053012055 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012056 (chan_len * sizeof(uint32_t)));
Govind Singha4836fd2016-03-07 16:45:38 +053012057 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012058 for (i = 0; i < chan_len ; i++) {
12059 cmd_args[i] = msg->weighed_valid_list[i];
Govind Singhe7f2f342016-05-23 12:12:52 +053012060 WMI_LOGI("%s: chan:%d weight:%d", __func__,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012061 msg->saved_chan_list[i], cmd_args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053012062 }
12063 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053012064 WMI_PDEV_SET_PCL_CMDID)) {
12065 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_PCL_CMDID", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012066 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012067 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012068 }
Govind Singhb53420c2016-03-09 14:32:57 +053012069 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012070}
12071
12072/**
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012073 * send_pdev_set_hw_mode_cmd_tlv() - Send WMI_PDEV_SET_HW_MODE_CMDID to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012074 * @wmi_handle: wmi handle
12075 * @msg: Structure containing the following parameters
12076 *
12077 * - hw_mode_index: The HW_Mode field is a enumerated type that is selected
12078 * from the HW_Mode table, which is returned in the WMI_SERVICE_READY_EVENTID.
12079 *
12080 * Provides notification to the WLAN firmware that host driver is requesting a
12081 * HardWare (HW) Mode change. This command is needed to support iHelium in the
12082 * configurations that include the Dual Band Simultaneous (DBS) feature.
12083 *
12084 * Return: Success if the cmd is sent successfully to the firmware
12085 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012086static QDF_STATUS send_pdev_set_hw_mode_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012087 uint32_t hw_mode_index)
12088{
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012089 wmi_pdev_set_hw_mode_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012090 wmi_buf_t buf;
12091 uint32_t len;
12092
12093 len = sizeof(*cmd);
12094
12095 buf = wmi_buf_alloc(wmi_handle, len);
12096 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012097 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12098 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012099 }
12100
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012101 cmd = (wmi_pdev_set_hw_mode_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012102 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012103 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
12104 WMITLV_GET_STRUCT_TLVLEN(wmi_pdev_set_hw_mode_cmd_fixed_param));
12105
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012106 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12107 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012108 cmd->hw_mode_index = hw_mode_index;
Govind Singhb53420c2016-03-09 14:32:57 +053012109 WMI_LOGI("%s: HW mode index:%d", __func__, cmd->hw_mode_index);
Govind Singha4836fd2016-03-07 16:45:38 +053012110
12111 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053012112 WMI_PDEV_SET_HW_MODE_CMDID)) {
12113 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_HW_MODE_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012114 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012115 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012116 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012117 }
12118
Govind Singhb53420c2016-03-09 14:32:57 +053012119 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012120}
12121
12122/**
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012123 * send_pdev_set_dual_mac_config_cmd_tlv() - Set dual mac config to FW
Govind Singha4836fd2016-03-07 16:45:38 +053012124 * @wmi_handle: wmi handle
12125 * @msg: Dual MAC config parameters
12126 *
12127 * Configures WLAN firmware with the dual MAC features
12128 *
Govind Singhb53420c2016-03-09 14:32:57 +053012129 * Return: QDF_STATUS. 0 on success.
Govind Singha4836fd2016-03-07 16:45:38 +053012130 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070012131static
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012132QDF_STATUS send_pdev_set_dual_mac_config_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053012133 struct wmi_dual_mac_config *msg)
12134{
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012135 wmi_pdev_set_mac_config_cmd_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012136 wmi_buf_t buf;
12137 uint32_t len;
12138
12139 len = sizeof(*cmd);
12140
12141 buf = wmi_buf_alloc(wmi_handle, len);
12142 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012143 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
12144 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012145 }
12146
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012147 cmd = (wmi_pdev_set_mac_config_cmd_fixed_param *) wmi_buf_data(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012148 WMITLV_SET_HDR(&cmd->tlv_header,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012149 WMITLV_TAG_STRUC_wmi_pdev_set_mac_config_cmd_fixed_param,
Govind Singha4836fd2016-03-07 16:45:38 +053012150 WMITLV_GET_STRUCT_TLVLEN(
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012151 wmi_pdev_set_mac_config_cmd_fixed_param));
12152
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012153 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12154 WMI_HOST_PDEV_ID_SOC);
Govind Singha4836fd2016-03-07 16:45:38 +053012155 cmd->concurrent_scan_config_bits = msg->scan_config;
12156 cmd->fw_mode_config_bits = msg->fw_mode_config;
Govind Singhb53420c2016-03-09 14:32:57 +053012157 WMI_LOGI("%s: scan_config:%x fw_mode_config:%x",
Govind Singha4836fd2016-03-07 16:45:38 +053012158 __func__, msg->scan_config, msg->fw_mode_config);
12159
12160 if (wmi_unified_cmd_send(wmi_handle, buf, len,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053012161 WMI_PDEV_SET_MAC_CONFIG_CMDID)) {
12162 WMI_LOGE("%s: Failed to send WMI_PDEV_SET_MAC_CONFIG_CMDID",
Govind Singha4836fd2016-03-07 16:45:38 +053012163 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053012164 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053012165 }
Govind Singhb53420c2016-03-09 14:32:57 +053012166 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012167}
12168
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012169#ifdef BIG_ENDIAN_HOST
12170/**
12171* fips_conv_data_be() - LE to BE conversion of FIPS ev data
12172* @param data_len - data length
12173* @param data - pointer to data
12174*
12175* Return: QDF_STATUS - success or error status
12176*/
12177static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12178 struct fips_params *param)
12179{
12180 unsigned char *key_unaligned, *data_unaligned;
12181 int c;
12182 u_int8_t *key_aligned = NULL;
12183 u_int8_t *data_aligned = NULL;
12184
12185 /* Assigning unaligned space to copy the key */
12186 key_unaligned = qdf_mem_malloc(
12187 sizeof(u_int8_t)*param->key_len + FIPS_ALIGN);
12188 data_unaligned = qdf_mem_malloc(
12189 sizeof(u_int8_t)*param->data_len + FIPS_ALIGN);
12190
12191 /* Checking if kmalloc is succesful to allocate space */
12192 if (key_unaligned == NULL)
12193 return QDF_STATUS_SUCCESS;
12194 /* Checking if space is aligned */
12195 if (!FIPS_IS_ALIGNED(key_unaligned, FIPS_ALIGN)) {
12196 /* align to 4 */
12197 key_aligned =
12198 (u_int8_t *)FIPS_ALIGNTO(key_unaligned,
12199 FIPS_ALIGN);
12200 } else {
12201 key_aligned = (u_int8_t *)key_unaligned;
12202 }
12203
12204 /* memset and copy content from key to key aligned */
12205 OS_MEMSET(key_aligned, 0, param->key_len);
12206 OS_MEMCPY(key_aligned, param->key, param->key_len);
12207
12208 /* print a hexdump for host debug */
12209 print_hex_dump(KERN_DEBUG,
12210 "\t Aligned and Copied Key:@@@@ ",
12211 DUMP_PREFIX_NONE,
12212 16, 1, key_aligned, param->key_len, true);
12213
12214 /* Checking if kmalloc is succesful to allocate space */
12215 if (data_unaligned == NULL)
12216 return QDF_STATUS_SUCCESS;
12217 /* Checking of space is aligned */
12218 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
12219 /* align to 4 */
12220 data_aligned =
12221 (u_int8_t *)FIPS_ALIGNTO(data_unaligned,
12222 FIPS_ALIGN);
12223 } else {
12224 data_aligned = (u_int8_t *)data_unaligned;
12225 }
12226
12227 /* memset and copy content from data to data aligned */
12228 OS_MEMSET(data_aligned, 0, param->data_len);
12229 OS_MEMCPY(data_aligned, param->data, param->data_len);
12230
12231 /* print a hexdump for host debug */
12232 print_hex_dump(KERN_DEBUG,
12233 "\t Properly Aligned and Copied Data:@@@@ ",
12234 DUMP_PREFIX_NONE,
12235 16, 1, data_aligned, param->data_len, true);
12236
12237 /* converting to little Endian both key_aligned and
12238 * data_aligned*/
12239 for (c = 0; c < param->key_len/4; c++) {
12240 *((u_int32_t *)key_aligned+c) =
12241 qdf_cpu_to_le32(*((u_int32_t *)key_aligned+c));
12242 }
12243 for (c = 0; c < param->data_len/4; c++) {
12244 *((u_int32_t *)data_aligned+c) =
12245 qdf_cpu_to_le32(*((u_int32_t *)data_aligned+c));
12246 }
12247
12248 /* update endian data to key and data vectors */
12249 OS_MEMCPY(param->key, key_aligned, param->key_len);
12250 OS_MEMCPY(param->data, data_aligned, param->data_len);
12251
12252 /* clean up allocated spaces */
12253 qdf_mem_free(key_unaligned);
12254 key_unaligned = NULL;
12255 key_aligned = NULL;
12256
12257 qdf_mem_free(data_unaligned);
12258 data_unaligned = NULL;
12259 data_aligned = NULL;
12260
12261 return QDF_STATUS_SUCCESS;
12262}
12263#else
12264/**
12265* fips_align_data_be() - DUMMY for LE platform
12266*
12267* Return: QDF_STATUS - success
12268*/
12269static QDF_STATUS fips_align_data_be(wmi_unified_t wmi_handle,
12270 struct fips_params *param)
12271{
12272 return QDF_STATUS_SUCCESS;
12273}
12274#endif
12275
12276
12277/**
12278 * send_pdev_fips_cmd_tlv() - send pdev fips cmd to fw
12279 * @wmi_handle: wmi handle
12280 * @param: pointer to hold pdev fips param
12281 *
12282 * Return: 0 for success or error code
12283 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012284static QDF_STATUS
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012285send_pdev_fips_cmd_tlv(wmi_unified_t wmi_handle,
12286 struct fips_params *param)
12287{
12288 wmi_pdev_fips_cmd_fixed_param *cmd;
12289 wmi_buf_t buf;
12290 uint8_t *buf_ptr;
12291 uint32_t len = sizeof(wmi_pdev_fips_cmd_fixed_param);
12292 QDF_STATUS retval = QDF_STATUS_SUCCESS;
12293
12294 /* Length TLV placeholder for array of bytes */
12295 len += WMI_TLV_HDR_SIZE;
12296 if (param->data_len)
12297 len += (param->data_len*sizeof(uint8_t));
12298
12299 /*
12300 * Data length must be multiples of 16 bytes - checked against 0xF -
12301 * and must be less than WMI_SVC_MSG_SIZE - static size of
12302 * wmi_pdev_fips_cmd structure
12303 */
12304
12305 /* do sanity on the input */
12306 if (!(((param->data_len & 0xF) == 0) &&
12307 ((param->data_len > 0) &&
12308 (param->data_len < (WMI_HOST_MAX_BUFFER_SIZE -
12309 sizeof(wmi_pdev_fips_cmd_fixed_param)))))) {
12310 return QDF_STATUS_E_INVAL;
12311 }
12312
12313 buf = wmi_buf_alloc(wmi_handle, len);
12314 if (!buf) {
12315 qdf_print("%s:wmi_buf_alloc failed\n", __func__);
12316 return QDF_STATUS_E_FAILURE;
12317 }
12318
12319 buf_ptr = (uint8_t *) wmi_buf_data(buf);
12320 cmd = (wmi_pdev_fips_cmd_fixed_param *)buf_ptr;
12321 WMITLV_SET_HDR(&cmd->tlv_header,
12322 WMITLV_TAG_STRUC_wmi_pdev_fips_cmd_fixed_param,
12323 WMITLV_GET_STRUCT_TLVLEN
12324 (wmi_pdev_fips_cmd_fixed_param));
12325
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053012326 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
12327 param->pdev_id);
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053012328 if (param->key != NULL && param->data != NULL) {
12329 cmd->key_len = param->key_len;
12330 cmd->data_len = param->data_len;
12331 cmd->fips_cmd = !!(param->op);
12332
12333 if (fips_align_data_be(wmi_handle, param) != QDF_STATUS_SUCCESS)
12334 return QDF_STATUS_E_FAILURE;
12335
12336 qdf_mem_copy(cmd->key, param->key, param->key_len);
12337
12338 if (param->mode == FIPS_ENGINE_AES_CTR ||
12339 param->mode == FIPS_ENGINE_AES_MIC) {
12340 cmd->mode = param->mode;
12341 } else {
12342 cmd->mode = FIPS_ENGINE_AES_CTR;
12343 }
12344 qdf_print(KERN_ERR "Key len = %d, Data len = %d\n",
12345 cmd->key_len, cmd->data_len);
12346
12347 print_hex_dump(KERN_DEBUG, "Key: ", DUMP_PREFIX_NONE, 16, 1,
12348 cmd->key, cmd->key_len, true);
12349 buf_ptr += sizeof(*cmd);
12350
12351 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE, param->data_len);
12352
12353 buf_ptr += WMI_TLV_HDR_SIZE;
12354 if (param->data_len)
12355 qdf_mem_copy(buf_ptr,
12356 (uint8_t *) param->data, param->data_len);
12357
12358 print_hex_dump(KERN_DEBUG, "Plain text: ", DUMP_PREFIX_NONE,
12359 16, 1, buf_ptr, cmd->data_len, true);
12360
12361 buf_ptr += param->data_len;
12362
12363 retval = wmi_unified_cmd_send(wmi_handle, buf, len,
12364 WMI_PDEV_FIPS_CMDID);
12365 qdf_print("%s return value %d\n", __func__, retval);
12366 } else {
12367 qdf_print("\n%s:%d Key or Data is NULL\n", __func__, __LINE__);
12368 wmi_buf_free(buf);
12369 retval = -QDF_STATUS_E_BADMSG;
12370 }
12371
12372 return retval;
12373}
12374
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012375#ifdef WLAN_PMO_ENABLE
12376/**
12377 * send_add_wow_wakeup_event_cmd_tlv() - Configures wow wakeup events.
12378 * @wmi_handle: wmi handle
12379 * @vdev_id: vdev id
12380 * @bitmap: Event bitmap
12381 * @enable: enable/disable
12382 *
12383 * Return: CDF status
12384 */
12385static QDF_STATUS send_add_wow_wakeup_event_cmd_tlv(wmi_unified_t wmi_handle,
12386 uint32_t vdev_id,
12387 uint32_t bitmap,
12388 bool enable)
12389{
12390 WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *cmd;
12391 uint16_t len;
12392 wmi_buf_t buf;
12393 int ret;
12394
12395 len = sizeof(WMI_WOW_ADD_DEL_EVT_CMD_fixed_param);
12396 buf = wmi_buf_alloc(wmi_handle, len);
12397 if (!buf) {
12398 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12399 return QDF_STATUS_E_NOMEM;
12400 }
12401 cmd = (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param *) wmi_buf_data(buf);
12402 WMITLV_SET_HDR(&cmd->tlv_header,
12403 WMITLV_TAG_STRUC_WMI_WOW_ADD_DEL_EVT_CMD_fixed_param,
12404 WMITLV_GET_STRUCT_TLVLEN
12405 (WMI_WOW_ADD_DEL_EVT_CMD_fixed_param));
12406 cmd->vdev_id = vdev_id;
12407 cmd->is_add = enable;
12408 cmd->event_bitmap = bitmap;
12409
12410 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12411 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID);
12412 if (ret) {
12413 WMI_LOGE("Failed to config wow wakeup event");
12414 wmi_buf_free(buf);
12415 return QDF_STATUS_E_FAILURE;
12416 }
12417
12418 WMI_LOGD("Wakeup pattern 0x%x %s in fw", bitmap,
12419 enable ? "enabled" : "disabled");
12420
12421 return QDF_STATUS_SUCCESS;
12422}
12423
12424/**
12425 * send_wow_patterns_to_fw_cmd_tlv() - Sends WOW patterns to FW.
12426 * @wmi_handle: wmi handle
12427 * @vdev_id: vdev id
12428 * @ptrn_id: pattern id
12429 * @ptrn: pattern
12430 * @ptrn_len: pattern length
12431 * @ptrn_offset: pattern offset
12432 * @mask: mask
12433 * @mask_len: mask length
12434 * @user: true for user configured pattern and false for default pattern
12435 * @default_patterns: default patterns
12436 *
12437 * Return: CDF status
12438 */
12439static QDF_STATUS send_wow_patterns_to_fw_cmd_tlv(wmi_unified_t wmi_handle,
12440 uint8_t vdev_id, uint8_t ptrn_id,
12441 const uint8_t *ptrn, uint8_t ptrn_len,
12442 uint8_t ptrn_offset, const uint8_t *mask,
12443 uint8_t mask_len, bool user,
12444 uint8_t default_patterns)
12445{
12446 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12447 WOW_BITMAP_PATTERN_T *bitmap_pattern;
12448 wmi_buf_t buf;
12449 uint8_t *buf_ptr;
12450 int32_t len;
12451 int ret;
12452
12453 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12454 WMI_TLV_HDR_SIZE +
12455 1 * sizeof(WOW_BITMAP_PATTERN_T) +
12456 WMI_TLV_HDR_SIZE +
12457 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12458 WMI_TLV_HDR_SIZE +
12459 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12460 WMI_TLV_HDR_SIZE +
12461 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12462 WMI_TLV_HDR_SIZE +
12463 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12464
12465 buf = wmi_buf_alloc(wmi_handle, len);
12466 if (!buf) {
12467 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12468 return QDF_STATUS_E_NOMEM;
12469 }
12470
12471 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12472 buf_ptr = (uint8_t *) cmd;
12473
12474 WMITLV_SET_HDR(&cmd->tlv_header,
12475 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12476 WMITLV_GET_STRUCT_TLVLEN
12477 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12478 cmd->vdev_id = vdev_id;
12479 cmd->pattern_id = ptrn_id;
12480
12481 cmd->pattern_type = WOW_BITMAP_PATTERN;
12482 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12483
12484 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12485 sizeof(WOW_BITMAP_PATTERN_T));
12486 buf_ptr += WMI_TLV_HDR_SIZE;
12487 bitmap_pattern = (WOW_BITMAP_PATTERN_T *) buf_ptr;
12488
12489 WMITLV_SET_HDR(&bitmap_pattern->tlv_header,
12490 WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T,
12491 WMITLV_GET_STRUCT_TLVLEN(WOW_BITMAP_PATTERN_T));
12492
12493 qdf_mem_copy(&bitmap_pattern->patternbuf[0], ptrn, ptrn_len);
12494 qdf_mem_copy(&bitmap_pattern->bitmaskbuf[0], mask, mask_len);
12495
12496 bitmap_pattern->pattern_offset = ptrn_offset;
12497 bitmap_pattern->pattern_len = ptrn_len;
12498
12499 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMAP_PATTERN_SIZE)
12500 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMAP_PATTERN_SIZE;
12501
12502 if (bitmap_pattern->pattern_len > WOW_DEFAULT_BITMASK_SIZE)
12503 bitmap_pattern->pattern_len = WOW_DEFAULT_BITMASK_SIZE;
12504
12505 bitmap_pattern->bitmask_len = bitmap_pattern->pattern_len;
12506 bitmap_pattern->pattern_id = ptrn_id;
12507
12508 WMI_LOGI("vdev: %d, ptrn id: %d, ptrn len: %d, ptrn offset: %d user %d",
12509 cmd->vdev_id, cmd->pattern_id, bitmap_pattern->pattern_len,
12510 bitmap_pattern->pattern_offset, user);
12511 WMI_LOGI("Pattern : ");
12512 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12513 &bitmap_pattern->patternbuf[0], bitmap_pattern->pattern_len);
12514
12515 WMI_LOGI("Mask : ");
12516 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_INFO,
12517 &bitmap_pattern->bitmaskbuf[0], bitmap_pattern->pattern_len);
12518
12519 buf_ptr += sizeof(WOW_BITMAP_PATTERN_T);
12520
12521 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12522 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12523 buf_ptr += WMI_TLV_HDR_SIZE;
12524
12525 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12526 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12527 buf_ptr += WMI_TLV_HDR_SIZE;
12528
12529 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12530 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12531 buf_ptr += WMI_TLV_HDR_SIZE;
12532
12533 /* Fill TLV for pattern_info_timeout but no data. */
12534 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12535 buf_ptr += WMI_TLV_HDR_SIZE;
12536
12537 /* Fill TLV for ratelimit_interval with dummy data as this fix elem */
12538 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 1 * sizeof(A_UINT32));
12539 buf_ptr += WMI_TLV_HDR_SIZE;
12540 *(A_UINT32 *) buf_ptr = 0;
12541
12542 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12543 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12544 if (ret) {
12545 WMI_LOGE("%s: Failed to send wow ptrn to fw", __func__);
12546 wmi_buf_free(buf);
12547 return QDF_STATUS_E_FAILURE;
12548 }
12549
12550 return QDF_STATUS_SUCCESS;
12551}
12552
Govind Singha4836fd2016-03-07 16:45:38 +053012553/**
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012554 * fill_arp_offload_params_tlv() - Fill ARP offload data
12555 * @wmi_handle: wmi handle
12556 * @offload_req: offload request
12557 * @buf_ptr: buffer pointer
12558 *
12559 * To fill ARP offload data to firmware
12560 * when target goes to wow mode.
12561 *
12562 * Return: None
12563 */
12564static void fill_arp_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012565 struct pmo_arp_offload_params *offload_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012566{
12567
12568 int i;
12569 WMI_ARP_OFFLOAD_TUPLE *arp_tuple;
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012570 bool enable_or_disable = offload_req->enable;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012571
12572 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12573 (WMI_MAX_ARP_OFFLOADS*sizeof(WMI_ARP_OFFLOAD_TUPLE)));
12574 *buf_ptr += WMI_TLV_HDR_SIZE;
12575 for (i = 0; i < WMI_MAX_ARP_OFFLOADS; i++) {
12576 arp_tuple = (WMI_ARP_OFFLOAD_TUPLE *)*buf_ptr;
12577 WMITLV_SET_HDR(&arp_tuple->tlv_header,
12578 WMITLV_TAG_STRUC_WMI_ARP_OFFLOAD_TUPLE,
12579 WMITLV_GET_STRUCT_TLVLEN(WMI_ARP_OFFLOAD_TUPLE));
12580
12581 /* Fill data for ARP and NS in the first tupple for LA */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012582 if ((enable_or_disable & PMO_OFFLOAD_ENABLE) && (i == 0)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012583 /* Copy the target ip addr and flags */
12584 arp_tuple->flags = WMI_ARPOFF_FLAGS_VALID;
12585 qdf_mem_copy(&arp_tuple->target_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012586 offload_req->host_ipv4_addr,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012587 WMI_IPV4_ADDR_LEN);
12588 WMI_LOGD("ARPOffload IP4 address: %pI4",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012589 offload_req->host_ipv4_addr);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012590 }
12591 *buf_ptr += sizeof(WMI_ARP_OFFLOAD_TUPLE);
12592 }
12593}
12594
12595#ifdef WLAN_NS_OFFLOAD
12596/**
12597 * fill_ns_offload_params_tlv() - Fill NS offload data
12598 * @wmi|_handle: wmi handle
12599 * @offload_req: offload request
12600 * @buf_ptr: buffer pointer
12601 *
12602 * To fill NS offload data to firmware
12603 * when target goes to wow mode.
12604 *
12605 * Return: None
12606 */
12607static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012608 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012609{
12610
12611 int i;
12612 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012613
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012614 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12615 (WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12616 *buf_ptr += WMI_TLV_HDR_SIZE;
12617 for (i = 0; i < WMI_MAX_NS_OFFLOADS; i++) {
12618 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12619 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12620 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12621 (sizeof(WMI_NS_OFFLOAD_TUPLE) - WMI_TLV_HDR_SIZE));
12622
12623 /*
12624 * Fill data only for NS offload in the first ARP tuple for LA
12625 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012626 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012627 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12628 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012629 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012630 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012631 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012632 sizeof(WMI_IPV6_ADDR));
12633 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012634 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012635 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012636 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012637 ns_tuple->flags |=
12638 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12639 }
12640 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012641 i, &ns_req->self_ipv6_addr[i],
12642 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012643
12644 /* target MAC is optional, check if it is valid,
12645 * if this is not valid, the target will use the known
12646 * local MAC address rather than the tuple
12647 */
12648 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012649 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012650 &ns_tuple->target_mac);
12651 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12652 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12653 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12654 }
12655 }
12656 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12657 }
12658}
12659
12660
12661/**
12662 * fill_nsoffload_ext_tlv() - Fill NS offload ext data
12663 * @wmi: wmi handle
12664 * @offload_req: offload request
12665 * @buf_ptr: buffer pointer
12666 *
12667 * To fill extended NS offload extended data to firmware
12668 * when target goes to wow mode.
12669 *
12670 * Return: None
12671 */
12672static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012673 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012674{
12675 int i;
12676 WMI_NS_OFFLOAD_TUPLE *ns_tuple;
12677 uint32_t count, num_ns_ext_tuples;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012678
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012679 count = ns_req->num_ns_offload_count;
12680 num_ns_ext_tuples = ns_req->num_ns_offload_count -
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012681 WMI_MAX_NS_OFFLOADS;
12682
12683 /* Populate extended NS offload tuples */
12684 WMITLV_SET_HDR(*buf_ptr, WMITLV_TAG_ARRAY_STRUC,
12685 (num_ns_ext_tuples * sizeof(WMI_NS_OFFLOAD_TUPLE)));
12686 *buf_ptr += WMI_TLV_HDR_SIZE;
12687 for (i = WMI_MAX_NS_OFFLOADS; i < count; i++) {
12688 ns_tuple = (WMI_NS_OFFLOAD_TUPLE *)*buf_ptr;
12689 WMITLV_SET_HDR(&ns_tuple->tlv_header,
12690 WMITLV_TAG_STRUC_WMI_NS_OFFLOAD_TUPLE,
12691 (sizeof(WMI_NS_OFFLOAD_TUPLE)-WMI_TLV_HDR_SIZE));
12692
12693 /*
12694 * Fill data only for NS offload in the first ARP tuple for LA
12695 */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012696 if ((ns_req->enable & PMO_OFFLOAD_ENABLE)) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012697 ns_tuple->flags |= WMI_NSOFF_FLAGS_VALID;
12698 /* Copy the target/solicitation/remote ip addr */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012699 if (ns_req->target_ipv6_addr_valid[i])
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012700 qdf_mem_copy(&ns_tuple->target_ipaddr[0],
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012701 &ns_req->target_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012702 sizeof(WMI_IPV6_ADDR));
12703 qdf_mem_copy(&ns_tuple->solicitation_ipaddr,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012704 &ns_req->self_ipv6_addr[i],
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012705 sizeof(WMI_IPV6_ADDR));
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012706 if (ns_req->target_ipv6_addr_ac_type[i]) {
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012707 ns_tuple->flags |=
12708 WMI_NSOFF_FLAGS_IS_IPV6_ANYCAST;
12709 }
12710 WMI_LOGD("Index %d NS solicitedIp %pI6, targetIp %pI6",
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012711 i, &ns_req->self_ipv6_addr[i],
12712 &ns_req->target_ipv6_addr[i]);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012713
12714 /* target MAC is optional, check if it is valid,
12715 * if this is not valid, the target will use the
12716 * known local MAC address rather than the tuple
12717 */
12718 WMI_CHAR_ARRAY_TO_MAC_ADDR(
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012719 ns_req->self_macaddr.bytes,
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012720 &ns_tuple->target_mac);
12721 if ((ns_tuple->target_mac.mac_addr31to0 != 0) ||
12722 (ns_tuple->target_mac.mac_addr47to32 != 0)) {
12723 ns_tuple->flags |= WMI_NSOFF_FLAGS_MAC_VALID;
12724 }
12725 }
12726 *buf_ptr += sizeof(WMI_NS_OFFLOAD_TUPLE);
12727 }
12728}
12729#else
12730static void fill_ns_offload_params_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012731 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012732{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012733}
12734
12735static void fill_nsoffload_ext_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012736 struct pmo_ns_offload_params *ns_req, uint8_t **buf_ptr)
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012737{
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012738}
12739#endif
12740
12741/**
Govind Singha4836fd2016-03-07 16:45:38 +053012742 * send_enable_arp_ns_offload_cmd_tlv() - enable ARP NS offload
12743 * @wma: wmi handle
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012744 * @arp_offload_req: arp offload request
12745 * @ns_offload_req: ns offload request
Govind Singha4836fd2016-03-07 16:45:38 +053012746 * @arp_only: flag
12747 *
12748 * To configure ARP NS off load data to firmware
12749 * when target goes to wow mode.
12750 *
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012751 * Return: QDF Status
Govind Singha4836fd2016-03-07 16:45:38 +053012752 */
Sathish Kumarfd347372017-02-13 12:29:09 +053012753static QDF_STATUS send_enable_arp_ns_offload_cmd_tlv(wmi_unified_t wmi_handle,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012754 struct pmo_arp_offload_params *arp_offload_req,
12755 struct pmo_ns_offload_params *ns_offload_req,
Govind Singha4836fd2016-03-07 16:45:38 +053012756 uint8_t vdev_id)
12757{
Govind Singha4836fd2016-03-07 16:45:38 +053012758 int32_t res;
12759 WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *cmd;
Govind Singha4836fd2016-03-07 16:45:38 +053012760 A_UINT8 *buf_ptr;
12761 wmi_buf_t buf;
12762 int32_t len;
12763 uint32_t count = 0, num_ns_ext_tuples = 0;
12764
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012765 count = ns_offload_req->num_ns_offload_count;
Govind Singha4836fd2016-03-07 16:45:38 +053012766
Govind Singha4836fd2016-03-07 16:45:38 +053012767 /*
12768 * TLV place holder size for array of NS tuples
12769 * TLV place holder size for array of ARP tuples
12770 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012771 len = sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param) +
12772 WMI_TLV_HDR_SIZE +
12773 WMI_MAX_NS_OFFLOADS * sizeof(WMI_NS_OFFLOAD_TUPLE) +
12774 WMI_TLV_HDR_SIZE +
12775 WMI_MAX_ARP_OFFLOADS * sizeof(WMI_ARP_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053012776
12777 /*
12778 * If there are more than WMI_MAX_NS_OFFLOADS addresses then allocate
12779 * extra length for extended NS offload tuples which follows ARP offload
12780 * tuples. Host needs to fill this structure in following format:
12781 * 2 NS ofload tuples
12782 * 2 ARP offload tuples
12783 * N numbers of extended NS offload tuples if HDD has given more than
12784 * 2 NS offload addresses
12785 */
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012786 if (count > WMI_MAX_NS_OFFLOADS) {
Govind Singha4836fd2016-03-07 16:45:38 +053012787 num_ns_ext_tuples = count - WMI_MAX_NS_OFFLOADS;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012788 len += WMI_TLV_HDR_SIZE + num_ns_ext_tuples
12789 * sizeof(WMI_NS_OFFLOAD_TUPLE);
Govind Singha4836fd2016-03-07 16:45:38 +053012790 }
12791
12792 buf = wmi_buf_alloc(wmi_handle, len);
12793 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053012794 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
Govind Singhb53420c2016-03-09 14:32:57 +053012795 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053012796 }
12797
12798 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
12799 cmd = (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param *) buf_ptr;
12800 WMITLV_SET_HDR(&cmd->tlv_header,
12801 WMITLV_TAG_STRUC_WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param,
12802 WMITLV_GET_STRUCT_TLVLEN
12803 (WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param));
12804 cmd->flags = 0;
12805 cmd->vdev_id = vdev_id;
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012806 cmd->num_ns_ext_tuples = num_ns_ext_tuples;
Govind Singha4836fd2016-03-07 16:45:38 +053012807
Govind Singhb53420c2016-03-09 14:32:57 +053012808 WMI_LOGD("ARP NS Offload vdev_id: %d", cmd->vdev_id);
Govind Singha4836fd2016-03-07 16:45:38 +053012809
Govind Singha4836fd2016-03-07 16:45:38 +053012810 buf_ptr += sizeof(WMI_SET_ARP_NS_OFFLOAD_CMD_fixed_param);
Mukul Sharma3a5eedb2016-09-07 20:31:47 +053012811 fill_ns_offload_params_tlv(wmi_handle, ns_offload_req, &buf_ptr);
12812 fill_arp_offload_params_tlv(wmi_handle, arp_offload_req, &buf_ptr);
12813 if (num_ns_ext_tuples)
12814 fill_nsoffload_ext_tlv(wmi_handle, ns_offload_req, &buf_ptr);
Govind Singha4836fd2016-03-07 16:45:38 +053012815
12816 res = wmi_unified_cmd_send(wmi_handle, buf, len,
12817 WMI_SET_ARP_NS_OFFLOAD_CMDID);
12818 if (res) {
Govind Singhb53420c2016-03-09 14:32:57 +053012819 WMI_LOGE("Failed to enable ARP NDP/NSffload");
Govind Singha4836fd2016-03-07 16:45:38 +053012820 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053012821 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053012822 }
12823
Govind Singhb53420c2016-03-09 14:32:57 +053012824 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053012825}
12826
Mukul Sharmab758ddf2017-02-25 01:50:47 +053012827/**
12828 * send_enable_enhance_multicast_offload_tlv() - send enhance multicast offload
12829 * @wmi_handle: wmi handle
12830 * @vdev_id: vdev id
12831 * @action: true for enable else false
12832 *
12833 * To enable enhance multicast offload to firmware
12834 * when target goes to wow mode.
12835 *
12836 * Return: QDF Status
12837 */
12838
12839static
12840QDF_STATUS send_enable_enhance_multicast_offload_tlv(
12841 wmi_unified_t wmi_handle,
12842 uint8_t vdev_id, bool action)
12843{
12844 QDF_STATUS status;
12845 wmi_buf_t buf;
12846 wmi_config_enhanced_mcast_filter_cmd_fixed_param *cmd;
12847
12848 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
12849 if (!buf) {
12850 WMI_LOGE("Failed to allocate buffer to send set key cmd");
12851 return QDF_STATUS_E_NOMEM;
12852 }
12853
12854 cmd = (wmi_config_enhanced_mcast_filter_cmd_fixed_param *)
12855 wmi_buf_data(buf);
12856
12857 WMITLV_SET_HDR(&cmd->tlv_header,
12858 WMITLV_TAG_STRUC_wmi_config_enhanced_mcast_filter_fixed_param,
12859 WMITLV_GET_STRUCT_TLVLEN(
12860 wmi_config_enhanced_mcast_filter_cmd_fixed_param));
12861
12862 cmd->vdev_id = vdev_id;
12863 cmd->enable = ((action == 0) ? ENHANCED_MCAST_FILTER_DISABLED :
12864 ENHANCED_MCAST_FILTER_ENABLED);
12865 WMI_LOGD("%s: config enhance multicast offload action %d for vdev %d",
12866 __func__, action, vdev_id);
12867 status = wmi_unified_cmd_send(wmi_handle, buf,
12868 sizeof(*cmd), WMI_CONFIG_ENHANCED_MCAST_FILTER_CMDID);
12869 if (status != QDF_STATUS_SUCCESS) {
12870 qdf_nbuf_free(buf);
12871 WMI_LOGE("%s:Failed to send ENHANCED_MCAST_FILTER_CMDID",
12872 __func__);
12873 }
12874
12875 return status;
12876}
12877
12878/**
12879 * extract_gtk_rsp_event_tlv() - extract gtk rsp params from event
12880 * @wmi_handle: wmi handle
12881 * @param evt_buf: pointer to event buffer
12882 * @param hdr: Pointer to hold header
12883 * @param bufp: Pointer to hold pointer to rx param buffer
12884 *
12885 * Return: QDF_STATUS_SUCCESS for success or error code
12886 */
12887static QDF_STATUS extract_gtk_rsp_event_tlv(wmi_unified_t wmi_handle,
12888 void *evt_buf, struct pmo_gtk_rsp_params *gtk_rsp_param, uint32_t len)
12889{
12890 WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *fixed_param;
12891 WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *param_buf;
12892
12893 param_buf = (WMI_GTK_OFFLOAD_STATUS_EVENTID_param_tlvs *)evt_buf;
12894 if (!param_buf) {
12895 WMI_LOGE("gtk param_buf is NULL");
12896 return QDF_STATUS_E_INVAL;
12897 }
12898
12899 if (len < sizeof(WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param)) {
12900 WMI_LOGE("Invalid length for GTK status");
12901 return QDF_STATUS_E_INVAL;
12902 }
12903
12904 fixed_param = (WMI_GTK_OFFLOAD_STATUS_EVENT_fixed_param *)
12905 param_buf->fixed_param;
12906 gtk_rsp_param->vdev_id = fixed_param->vdev_id;
12907 gtk_rsp_param->status_flag = QDF_STATUS_SUCCESS;
12908 gtk_rsp_param->refresh_cnt = fixed_param->refresh_cnt;
12909 qdf_mem_copy(&gtk_rsp_param->replay_counter,
12910 &fixed_param->replay_counter,
12911 GTK_REPLAY_COUNTER_BYTES);
12912
12913 return QDF_STATUS_SUCCESS;
12914
12915}
12916
12917#ifdef FEATURE_WLAN_RA_FILTERING
12918/**
12919 * send_wow_sta_ra_filter_cmd_tlv() - set RA filter pattern in fw
12920 * @wmi_handle: wmi handle
12921 * @vdev_id: vdev id
12922 *
12923 * Return: CDF status
12924 */
12925static QDF_STATUS send_wow_sta_ra_filter_cmd_tlv(wmi_unified_t wmi_handle,
12926 uint8_t vdev_id, uint8_t default_pattern,
12927 uint16_t rate_limit_interval)
12928{
12929
12930 WMI_WOW_ADD_PATTERN_CMD_fixed_param *cmd;
12931 wmi_buf_t buf;
12932 uint8_t *buf_ptr;
12933 int32_t len;
12934 int ret;
12935
12936 len = sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param) +
12937 WMI_TLV_HDR_SIZE +
12938 0 * sizeof(WOW_BITMAP_PATTERN_T) +
12939 WMI_TLV_HDR_SIZE +
12940 0 * sizeof(WOW_IPV4_SYNC_PATTERN_T) +
12941 WMI_TLV_HDR_SIZE +
12942 0 * sizeof(WOW_IPV6_SYNC_PATTERN_T) +
12943 WMI_TLV_HDR_SIZE +
12944 0 * sizeof(WOW_MAGIC_PATTERN_CMD) +
12945 WMI_TLV_HDR_SIZE +
12946 0 * sizeof(A_UINT32) + WMI_TLV_HDR_SIZE + 1 * sizeof(A_UINT32);
12947
12948 buf = wmi_buf_alloc(wmi_handle, len);
12949 if (!buf) {
12950 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
12951 return QDF_STATUS_E_NOMEM;
12952 }
12953
12954 cmd = (WMI_WOW_ADD_PATTERN_CMD_fixed_param *) wmi_buf_data(buf);
12955 buf_ptr = (uint8_t *) cmd;
12956
12957 WMITLV_SET_HDR(&cmd->tlv_header,
12958 WMITLV_TAG_STRUC_WMI_WOW_ADD_PATTERN_CMD_fixed_param,
12959 WMITLV_GET_STRUCT_TLVLEN
12960 (WMI_WOW_ADD_PATTERN_CMD_fixed_param));
12961 cmd->vdev_id = vdev_id;
12962 cmd->pattern_id = default_pattern,
12963 cmd->pattern_type = WOW_IPV6_RA_PATTERN;
12964 buf_ptr += sizeof(WMI_WOW_ADD_PATTERN_CMD_fixed_param);
12965
12966 /* Fill TLV for WMITLV_TAG_STRUC_WOW_BITMAP_PATTERN_T but no data. */
12967 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12968 buf_ptr += WMI_TLV_HDR_SIZE;
12969
12970 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV4_SYNC_PATTERN_T but no data. */
12971 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12972 buf_ptr += WMI_TLV_HDR_SIZE;
12973
12974 /* Fill TLV for WMITLV_TAG_STRUC_WOW_IPV6_SYNC_PATTERN_T but no data. */
12975 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12976 buf_ptr += WMI_TLV_HDR_SIZE;
12977
12978 /* Fill TLV for WMITLV_TAG_STRUC_WOW_MAGIC_PATTERN_CMD but no data. */
12979 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, 0);
12980 buf_ptr += WMI_TLV_HDR_SIZE;
12981
12982 /* Fill TLV for pattern_info_timeout but no data. */
12983 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, 0);
12984 buf_ptr += WMI_TLV_HDR_SIZE;
12985
12986 /* Fill TLV for ra_ratelimit_interval. */
12987 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32, sizeof(A_UINT32));
12988 buf_ptr += WMI_TLV_HDR_SIZE;
12989
12990 *((A_UINT32 *) buf_ptr) = rate_limit_interval;
12991
12992 WMI_LOGD("%s: send RA rate limit [%d] to fw vdev = %d", __func__,
12993 rate_limit_interval, vdev_id);
12994
12995 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
12996 WMI_WOW_ADD_WAKE_PATTERN_CMDID);
12997 if (ret) {
12998 WMI_LOGE("%s: Failed to send RA rate limit to fw", __func__);
12999 wmi_buf_free(buf);
13000 return QDF_STATUS_E_FAILURE;
13001 }
13002
13003 return QDF_STATUS_SUCCESS;
13004
13005}
13006#endif /* FEATURE_WLAN_RA_FILTERING */
13007
13008/**
13009 * send_add_clear_mcbc_filter_cmd_tlv() - set mcast filter command to fw
13010 * @wmi_handle: wmi handle
13011 * @vdev_id: vdev id
13012 * @multicastAddr: mcast address
13013 * @clearList: clear list flag
13014 *
13015 * Return: QDF_STATUS_SUCCESS for success or error code
13016 */
13017static QDF_STATUS send_add_clear_mcbc_filter_cmd_tlv(wmi_unified_t wmi_handle,
13018 uint8_t vdev_id,
13019 struct qdf_mac_addr multicast_addr,
13020 bool clearList)
13021{
13022 WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *cmd;
13023 wmi_buf_t buf;
13024 int err;
13025
13026 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13027 if (!buf) {
13028 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13029 return QDF_STATUS_E_NOMEM;
13030 }
13031
13032 cmd = (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param *) wmi_buf_data(buf);
13033 qdf_mem_zero(cmd, sizeof(*cmd));
13034
13035 WMITLV_SET_HDR(&cmd->tlv_header,
13036 WMITLV_TAG_STRUC_WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param,
13037 WMITLV_GET_STRUCT_TLVLEN
13038 (WMI_SET_MCASTBCAST_FILTER_CMD_fixed_param));
13039 cmd->action =
13040 (clearList ? WMI_MCAST_FILTER_DELETE : WMI_MCAST_FILTER_SET);
13041 cmd->vdev_id = vdev_id;
13042 WMI_CHAR_ARRAY_TO_MAC_ADDR(multicast_addr.bytes, &cmd->mcastbdcastaddr);
13043
13044 WMI_LOGD("Action:%d; vdev_id:%d; clearList:%d; MCBC MAC Addr: %pM",
13045 cmd->action, vdev_id, clearList, multicast_addr.bytes);
13046
13047 err = wmi_unified_cmd_send(wmi_handle, buf,
13048 sizeof(*cmd),
13049 WMI_SET_MCASTBCAST_FILTER_CMDID);
13050 if (err) {
13051 WMI_LOGE("Failed to send set_param cmd");
13052 wmi_buf_free(buf);
13053 return QDF_STATUS_E_FAILURE;
13054 }
13055
13056 return QDF_STATUS_SUCCESS;
13057}
13058
13059/**
13060 * send_gtk_offload_cmd_tlv() - send GTK offload command to fw
13061 * @wmi_handle: wmi handle
13062 * @vdev_id: vdev id
13063 * @params: GTK offload parameters
13064 *
13065 * Return: CDF status
13066 */
13067static
13068QDF_STATUS send_gtk_offload_cmd_tlv(wmi_unified_t wmi_handle, uint8_t vdev_id,
13069 struct pmo_gtk_req *params,
13070 bool enable_offload,
13071 uint32_t gtk_offload_opcode)
13072{
13073 int len;
13074 wmi_buf_t buf;
13075 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13076 QDF_STATUS status = QDF_STATUS_SUCCESS;
13077
13078 WMI_LOGD("%s Enter", __func__);
13079
13080 len = sizeof(*cmd);
13081
13082 /* alloc wmi buffer */
13083 buf = wmi_buf_alloc(wmi_handle, len);
13084 if (!buf) {
13085 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13086 status = QDF_STATUS_E_NOMEM;
13087 goto out;
13088 }
13089
13090 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13091 WMITLV_SET_HDR(&cmd->tlv_header,
13092 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13093 WMITLV_GET_STRUCT_TLVLEN
13094 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13095
13096 cmd->vdev_id = vdev_id;
13097
13098 /* Request target to enable GTK offload */
13099 if (enable_offload == PMO_GTK_OFFLOAD_ENABLE) {
13100 cmd->flags = gtk_offload_opcode;
13101
13102 /* Copy the keys and replay counter */
13103 qdf_mem_copy(cmd->KCK, params->kck, PMO_KCK_LEN);
13104 qdf_mem_copy(cmd->KEK, params->kek, PMO_KEK_LEN);
13105 qdf_mem_copy(cmd->replay_counter, &params->replay_counter,
13106 GTK_REPLAY_COUNTER_BYTES);
13107 } else {
13108 cmd->flags = gtk_offload_opcode;
13109 }
13110
13111 WMI_LOGD("VDEVID: %d, GTK_FLAGS: x%x", vdev_id, cmd->flags);
13112
13113 /* send the wmi command */
13114 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13115 WMI_GTK_OFFLOAD_CMDID)) {
13116 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID");
13117 wmi_buf_free(buf);
13118 status = QDF_STATUS_E_FAILURE;
13119 }
13120
13121out:
13122 WMI_LOGD("%s Exit", __func__);
13123 return status;
13124}
13125
13126/**
13127 * send_process_gtk_offload_getinfo_cmd_tlv() - send GTK offload cmd to fw
13128 * @wmi_handle: wmi handle
13129 * @params: GTK offload params
13130 *
13131 * Return: CDF status
13132 */
13133static QDF_STATUS send_process_gtk_offload_getinfo_cmd_tlv(
13134 wmi_unified_t wmi_handle,
13135 uint8_t vdev_id,
13136 uint64_t offload_req_opcode)
13137{
13138 int len;
13139 wmi_buf_t buf;
13140 WMI_GTK_OFFLOAD_CMD_fixed_param *cmd;
13141 QDF_STATUS status = QDF_STATUS_SUCCESS;
13142
13143 len = sizeof(*cmd);
13144
13145 /* alloc wmi buffer */
13146 buf = wmi_buf_alloc(wmi_handle, len);
13147 if (!buf) {
13148 WMI_LOGE("wmi_buf_alloc failed for WMI_GTK_OFFLOAD_CMD");
13149 status = QDF_STATUS_E_NOMEM;
13150 goto out;
13151 }
13152
13153 cmd = (WMI_GTK_OFFLOAD_CMD_fixed_param *) wmi_buf_data(buf);
13154 WMITLV_SET_HDR(&cmd->tlv_header,
13155 WMITLV_TAG_STRUC_WMI_GTK_OFFLOAD_CMD_fixed_param,
13156 WMITLV_GET_STRUCT_TLVLEN
13157 (WMI_GTK_OFFLOAD_CMD_fixed_param));
13158
13159 /* Request for GTK offload status */
13160 cmd->flags = offload_req_opcode;
13161 cmd->vdev_id = vdev_id;
13162
13163 /* send the wmi command */
13164 if (wmi_unified_cmd_send(wmi_handle, buf, len,
13165 WMI_GTK_OFFLOAD_CMDID)) {
13166 WMI_LOGE("Failed to send WMI_GTK_OFFLOAD_CMDID for req info");
13167 wmi_buf_free(buf);
13168 status = QDF_STATUS_E_FAILURE;
13169 }
13170
13171out:
13172 return status;
13173}
13174
13175/**
13176 * send_action_frame_patterns_cmd_tlv() - send wmi cmd of action filter params
13177 * @wmi_handle: wmi handler
13178 * @action_params: pointer to action_params
13179 *
13180 * Return: 0 for success, otherwise appropriate error code
13181 */
13182static QDF_STATUS send_action_frame_patterns_cmd_tlv(wmi_unified_t wmi_handle,
13183 struct pmo_action_wakeup_set_params *action_params)
13184{
13185 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *cmd;
13186 wmi_buf_t buf;
13187 int i;
13188 int32_t err;
13189
13190 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
13191 if (!buf) {
13192 WMI_LOGE("Failed to allocate buffer to send action filter cmd");
13193 return QDF_STATUS_E_NOMEM;
13194 }
13195 cmd = (WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param *) wmi_buf_data(buf);
13196 WMITLV_SET_HDR(&cmd->tlv_header,
13197 WMITLV_TAG_STRUC_wmi_wow_set_action_wake_up_cmd_fixed_param,
13198 WMITLV_GET_STRUCT_TLVLEN(
13199 WMI_WOW_SET_ACTION_WAKE_UP_CMD_fixed_param));
13200
13201 cmd->vdev_id = action_params->vdev_id;
13202 cmd->operation = action_params->operation;
13203
13204 for (i = 0; i < MAX_SUPPORTED_ACTION_CATEGORY_ELE_LIST; i++)
13205 cmd->action_category_map[i] =
13206 action_params->action_category_map[i];
13207
13208 err = wmi_unified_cmd_send(wmi_handle, buf,
13209 sizeof(*cmd), WMI_WOW_SET_ACTION_WAKE_UP_CMDID);
13210 if (err) {
13211 WMI_LOGE("Failed to send ap_ps_egap cmd");
13212 wmi_buf_free(buf);
13213 return QDF_STATUS_E_FAILURE;
13214 }
13215
13216 return QDF_STATUS_SUCCESS;
13217}
13218
13219#ifdef FEATURE_WLAN_LPHB
13220
13221/**
13222 * send_lphb_config_hbenable_cmd_tlv() - enable command of LPHB configuration
13223 * @wmi_handle: wmi handle
13224 * @lphb_conf_req: configuration info
13225 *
13226 * Return: CDF status
13227 */
13228static QDF_STATUS send_lphb_config_hbenable_cmd_tlv(wmi_unified_t wmi_handle,
13229 wmi_hb_set_enable_cmd_fixed_param *params)
13230{
13231 QDF_STATUS status;
13232 wmi_buf_t buf = NULL;
13233 uint8_t *buf_ptr;
13234 wmi_hb_set_enable_cmd_fixed_param *hb_enable_fp;
13235 int len = sizeof(wmi_hb_set_enable_cmd_fixed_param);
13236
13237
13238 buf = wmi_buf_alloc(wmi_handle, len);
13239 if (!buf) {
13240 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13241 return QDF_STATUS_E_NOMEM;
13242 }
13243
13244 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13245 hb_enable_fp = (wmi_hb_set_enable_cmd_fixed_param *) buf_ptr;
13246 WMITLV_SET_HDR(&hb_enable_fp->tlv_header,
13247 WMITLV_TAG_STRUC_wmi_hb_set_enable_cmd_fixed_param,
13248 WMITLV_GET_STRUCT_TLVLEN
13249 (wmi_hb_set_enable_cmd_fixed_param));
13250
13251 /* fill in values */
13252 hb_enable_fp->vdev_id = params->session;
13253 hb_enable_fp->enable = params->enable;
13254 hb_enable_fp->item = params->item;
13255 hb_enable_fp->session = params->session;
13256
13257 status = wmi_unified_cmd_send(wmi_handle, buf,
13258 len, WMI_HB_SET_ENABLE_CMDID);
13259 if (QDF_IS_STATUS_ERROR(status)) {
13260 WMI_LOGE("cmd_send WMI_HB_SET_ENABLE returned Error %d",
13261 status);
13262 wmi_buf_free(buf);
13263 }
13264
13265 return status;
13266}
13267
13268/**
13269 * send_lphb_config_tcp_params_cmd_tlv() - set tcp params of LPHB configuration
13270 * @wmi_handle: wmi handle
13271 * @lphb_conf_req: lphb config request
13272 *
13273 * Return: CDF status
13274 */
13275static QDF_STATUS send_lphb_config_tcp_params_cmd_tlv(wmi_unified_t wmi_handle,
13276 wmi_hb_set_tcp_params_cmd_fixed_param *lphb_conf_req)
13277{
13278 QDF_STATUS status;
13279 wmi_buf_t buf = NULL;
13280 uint8_t *buf_ptr;
13281 wmi_hb_set_tcp_params_cmd_fixed_param *hb_tcp_params_fp;
13282 int len = sizeof(wmi_hb_set_tcp_params_cmd_fixed_param);
13283
13284 buf = wmi_buf_alloc(wmi_handle, len);
13285 if (!buf) {
13286 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13287 return QDF_STATUS_E_NOMEM;
13288 }
13289
13290 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13291 hb_tcp_params_fp = (wmi_hb_set_tcp_params_cmd_fixed_param *) buf_ptr;
13292 WMITLV_SET_HDR(&hb_tcp_params_fp->tlv_header,
13293 WMITLV_TAG_STRUC_wmi_hb_set_tcp_params_cmd_fixed_param,
13294 WMITLV_GET_STRUCT_TLVLEN
13295 (wmi_hb_set_tcp_params_cmd_fixed_param));
13296
13297 /* fill in values */
13298 hb_tcp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13299 hb_tcp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13300 hb_tcp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13301 hb_tcp_params_fp->seq = lphb_conf_req->seq;
13302 hb_tcp_params_fp->src_port = lphb_conf_req->src_port;
13303 hb_tcp_params_fp->dst_port = lphb_conf_req->dst_port;
13304 hb_tcp_params_fp->interval = lphb_conf_req->interval;
13305 hb_tcp_params_fp->timeout = lphb_conf_req->timeout;
13306 hb_tcp_params_fp->session = lphb_conf_req->session;
13307 qdf_mem_copy(&hb_tcp_params_fp->gateway_mac,
13308 &lphb_conf_req->gateway_mac,
13309 sizeof(hb_tcp_params_fp->gateway_mac));
13310
13311 status = wmi_unified_cmd_send(wmi_handle, buf,
13312 len, WMI_HB_SET_TCP_PARAMS_CMDID);
13313 if (QDF_IS_STATUS_ERROR(status)) {
13314 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PARAMS returned Error %d",
13315 status);
13316 wmi_buf_free(buf);
13317 }
13318
13319 return status;
13320}
13321
13322/**
13323 * send_lphb_config_tcp_pkt_filter_cmd_tlv() - configure tcp packet filter cmd
13324 * @wmi_handle: wmi handle
13325 * @lphb_conf_req: lphb config request
13326 *
13327 * Return: CDF status
13328 */
13329static
13330QDF_STATUS send_lphb_config_tcp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13331 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *g_hb_tcp_filter_fp)
13332{
13333 QDF_STATUS status;
13334 wmi_buf_t buf = NULL;
13335 uint8_t *buf_ptr;
13336 wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *hb_tcp_filter_fp;
13337 int len = sizeof(wmi_hb_set_tcp_pkt_filter_cmd_fixed_param);
13338
13339 buf = wmi_buf_alloc(wmi_handle, len);
13340 if (!buf) {
13341 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13342 return QDF_STATUS_E_NOMEM;
13343 }
13344
13345 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13346 hb_tcp_filter_fp =
13347 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param *) buf_ptr;
13348 WMITLV_SET_HDR(&hb_tcp_filter_fp->tlv_header,
13349 WMITLV_TAG_STRUC_wmi_hb_set_tcp_pkt_filter_cmd_fixed_param,
13350 WMITLV_GET_STRUCT_TLVLEN
13351 (wmi_hb_set_tcp_pkt_filter_cmd_fixed_param));
13352
13353 /* fill in values */
13354 hb_tcp_filter_fp->vdev_id = g_hb_tcp_filter_fp->vdev_id;
13355 hb_tcp_filter_fp->length = g_hb_tcp_filter_fp->length;
13356 hb_tcp_filter_fp->offset = g_hb_tcp_filter_fp->offset;
13357 hb_tcp_filter_fp->session = g_hb_tcp_filter_fp->session;
13358 memcpy((void *)&hb_tcp_filter_fp->filter,
13359 (void *)&g_hb_tcp_filter_fp->filter,
13360 WMI_WLAN_HB_MAX_FILTER_SIZE);
13361
13362 status = wmi_unified_cmd_send(wmi_handle, buf,
13363 len, WMI_HB_SET_TCP_PKT_FILTER_CMDID);
13364 if (QDF_IS_STATUS_ERROR(status)) {
13365 WMI_LOGE("cmd_send WMI_HB_SET_TCP_PKT_FILTER returned Error %d",
13366 status);
13367 wmi_buf_free(buf);
13368 }
13369
13370 return status;
13371}
13372
13373/**
13374 * send_lphb_config_udp_params_cmd_tlv() - configure udp param command of LPHB
13375 * @wmi_handle: wmi handle
13376 * @lphb_conf_req: lphb config request
13377 *
13378 * Return: CDF status
13379 */
13380static QDF_STATUS send_lphb_config_udp_params_cmd_tlv(wmi_unified_t wmi_handle,
13381 wmi_hb_set_udp_params_cmd_fixed_param *lphb_conf_req)
13382{
13383 QDF_STATUS status;
13384 wmi_buf_t buf = NULL;
13385 uint8_t *buf_ptr;
13386 wmi_hb_set_udp_params_cmd_fixed_param *hb_udp_params_fp;
13387 int len = sizeof(wmi_hb_set_udp_params_cmd_fixed_param);
13388
13389 buf = wmi_buf_alloc(wmi_handle, len);
13390 if (!buf) {
13391 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13392 return QDF_STATUS_E_NOMEM;
13393 }
13394
13395 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13396 hb_udp_params_fp = (wmi_hb_set_udp_params_cmd_fixed_param *) buf_ptr;
13397 WMITLV_SET_HDR(&hb_udp_params_fp->tlv_header,
13398 WMITLV_TAG_STRUC_wmi_hb_set_udp_params_cmd_fixed_param,
13399 WMITLV_GET_STRUCT_TLVLEN
13400 (wmi_hb_set_udp_params_cmd_fixed_param));
13401
13402 /* fill in values */
13403 hb_udp_params_fp->vdev_id = lphb_conf_req->vdev_id;
13404 hb_udp_params_fp->srv_ip = lphb_conf_req->srv_ip;
13405 hb_udp_params_fp->dev_ip = lphb_conf_req->dev_ip;
13406 hb_udp_params_fp->src_port = lphb_conf_req->src_port;
13407 hb_udp_params_fp->dst_port = lphb_conf_req->dst_port;
13408 hb_udp_params_fp->interval = lphb_conf_req->interval;
13409 hb_udp_params_fp->timeout = lphb_conf_req->timeout;
13410 hb_udp_params_fp->session = lphb_conf_req->session;
13411 qdf_mem_copy(&hb_udp_params_fp->gateway_mac,
13412 &lphb_conf_req->gateway_mac,
13413 sizeof(lphb_conf_req->gateway_mac));
13414
13415 status = wmi_unified_cmd_send(wmi_handle, buf,
13416 len, WMI_HB_SET_UDP_PARAMS_CMDID);
13417 if (QDF_IS_STATUS_ERROR(status)) {
13418 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PARAMS returned Error %d",
13419 status);
13420 wmi_buf_free(buf);
13421 }
13422
13423 return status;
13424}
13425
13426/**
13427 * send_lphb_config_udp_pkt_filter_cmd_tlv() - configure udp pkt filter command
13428 * @wmi_handle: wmi handle
13429 * @lphb_conf_req: lphb config request
13430 *
13431 * Return: CDF status
13432 */
13433static
13434QDF_STATUS send_lphb_config_udp_pkt_filter_cmd_tlv(wmi_unified_t wmi_handle,
13435 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *lphb_conf_req)
13436{
13437 QDF_STATUS status;
13438 wmi_buf_t buf = NULL;
13439 uint8_t *buf_ptr;
13440 wmi_hb_set_udp_pkt_filter_cmd_fixed_param *hb_udp_filter_fp;
13441 int len = sizeof(wmi_hb_set_udp_pkt_filter_cmd_fixed_param);
13442
13443 buf = wmi_buf_alloc(wmi_handle, len);
13444 if (!buf) {
13445 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
13446 return QDF_STATUS_E_NOMEM;
13447 }
13448
13449 buf_ptr = (uint8_t *) wmi_buf_data(buf);
13450 hb_udp_filter_fp =
13451 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param *) buf_ptr;
13452 WMITLV_SET_HDR(&hb_udp_filter_fp->tlv_header,
13453 WMITLV_TAG_STRUC_wmi_hb_set_udp_pkt_filter_cmd_fixed_param,
13454 WMITLV_GET_STRUCT_TLVLEN
13455 (wmi_hb_set_udp_pkt_filter_cmd_fixed_param));
13456
13457 /* fill in values */
13458 hb_udp_filter_fp->vdev_id = lphb_conf_req->vdev_id;
13459 hb_udp_filter_fp->length = lphb_conf_req->length;
13460 hb_udp_filter_fp->offset = lphb_conf_req->offset;
13461 hb_udp_filter_fp->session = lphb_conf_req->session;
13462 memcpy((void *)&hb_udp_filter_fp->filter,
13463 (void *)&lphb_conf_req->filter,
13464 WMI_WLAN_HB_MAX_FILTER_SIZE);
13465
13466 status = wmi_unified_cmd_send(wmi_handle, buf,
13467 len, WMI_HB_SET_UDP_PKT_FILTER_CMDID);
13468 if (QDF_IS_STATUS_ERROR(status)) {
13469 WMI_LOGE("cmd_send WMI_HB_SET_UDP_PKT_FILTER returned Error %d",
13470 status);
13471 wmi_buf_free(buf);
13472 }
13473
13474 return status;
13475}
13476#endif /* FEATURE_WLAN_LPHB */
Mukul Sharmab758ddf2017-02-25 01:50:47 +053013477
Sathish Kumarfd347372017-02-13 12:29:09 +053013478static QDF_STATUS send_enable_broadcast_filter_cmd_tlv(wmi_unified_t wmi_handle,
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013479 uint8_t vdev_id, bool enable)
13480{
13481 int32_t res;
13482 wmi_hw_data_filter_cmd_fixed_param *cmd;
13483 A_UINT8 *buf_ptr;
13484 wmi_buf_t buf;
13485 int32_t len;
13486
13487 /*
13488 * TLV place holder size for array of ARP tuples
13489 */
13490 len = sizeof(wmi_hw_data_filter_cmd_fixed_param);
13491
13492 buf = wmi_buf_alloc(wmi_handle, len);
13493 if (!buf) {
13494 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13495 return QDF_STATUS_E_NOMEM;
13496 }
13497
13498 buf_ptr = (A_UINT8 *) wmi_buf_data(buf);
13499 cmd = (wmi_hw_data_filter_cmd_fixed_param *) buf_ptr;
13500 WMITLV_SET_HDR(&cmd->tlv_header,
13501 WMITLV_TAG_STRUC_wmi_hw_data_filter_cmd_fixed_param,
13502 WMITLV_GET_STRUCT_TLVLEN
13503 (wmi_hw_data_filter_cmd_fixed_param));
13504 cmd->vdev_id = vdev_id;
13505 cmd->enable = enable;
13506 cmd->hw_filter_bitmap = WMI_HW_DATA_FILTER_DROP_NON_ARP_BC;
13507
13508 WMI_LOGD("HW Broadcast Filter vdev_id: %d", cmd->vdev_id);
13509
13510 res = wmi_unified_cmd_send(wmi_handle, buf, len,
13511 WMI_HW_DATA_FILTER_CMDID);
13512 if (res) {
13513 WMI_LOGE("Failed to enable ARP NDP/NSffload");
13514 wmi_buf_free(buf);
13515 return QDF_STATUS_E_FAILURE;
13516 }
13517
13518 return QDF_STATUS_SUCCESS;
13519}
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053013520
13521/**
13522 * send_enable_disable_packet_filter_cmd_tlv() - enable/disable packet filter
13523 * @wmi_handle: wmi handle
13524 * @vdev_id: vdev id
13525 * @enable: Flag to enable/disable packet filter
13526 *
13527 * Return: QDF_STATUS_SUCCESS for success or error code
13528 */
13529static QDF_STATUS send_enable_disable_packet_filter_cmd_tlv(
13530 wmi_unified_t wmi_handle, uint8_t vdev_id, bool enable)
13531{
13532 int32_t len;
13533 int ret = 0;
13534 wmi_buf_t buf;
13535 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *cmd;
13536
13537 len = sizeof(WMI_PACKET_FILTER_ENABLE_CMD_fixed_param);
13538
13539 buf = wmi_buf_alloc(wmi_handle, len);
13540 if (!buf) {
13541 WMI_LOGE("%s: Failed allocate wmi buffer", __func__);
13542 return QDF_STATUS_E_NOMEM;
13543 }
13544
13545 cmd = (WMI_PACKET_FILTER_ENABLE_CMD_fixed_param *) wmi_buf_data(buf);
13546 WMITLV_SET_HDR(&cmd->tlv_header,
13547 WMITLV_TAG_STRUC_wmi_packet_filter_enable_fixed_param,
13548 WMITLV_GET_STRUCT_TLVLEN(
13549 WMI_PACKET_FILTER_ENABLE_CMD_fixed_param));
13550
13551 cmd->vdev_id = vdev_id;
13552 if (enable)
13553 cmd->enable = PACKET_FILTER_SET_ENABLE;
13554 else
13555 cmd->enable = PACKET_FILTER_SET_DISABLE;
13556
13557 WMI_LOGE("%s: Packet filter enable %d for vdev_id %d",
13558 __func__, cmd->enable, vdev_id);
13559
13560 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
13561 WMI_PACKET_FILTER_ENABLE_CMDID);
13562 if (ret) {
13563 WMI_LOGE("Failed to send packet filter wmi cmd to fw");
13564 wmi_buf_free(buf);
13565 }
13566
13567 return ret;
13568}
13569
13570/**
13571 * send_config_packet_filter_cmd_tlv() - configure packet filter in target
13572 * @wmi_handle: wmi handle
13573 * @vdev_id: vdev id
13574 * @rcv_filter_param: Packet filter parameters
13575 * @filter_id: Filter id
13576 * @enable: Flag to add/delete packet filter configuration
13577 *
13578 * Return: QDF_STATUS_SUCCESS for success or error code
13579 */
13580static QDF_STATUS send_config_packet_filter_cmd_tlv(wmi_unified_t wmi_handle,
13581 uint8_t vdev_id, struct pmo_rcv_pkt_fltr_cfg *rcv_filter_param,
13582 uint8_t filter_id, bool enable)
13583{
13584 int len, i;
13585 int err = 0;
13586 wmi_buf_t buf;
13587 WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *cmd;
13588
13589
13590 /* allocate the memory */
13591 len = sizeof(*cmd);
13592 buf = wmi_buf_alloc(wmi_handle, len);
13593 if (!buf) {
13594 WMI_LOGE("Failed to allocate buffer to send set_param cmd");
13595 return QDF_STATUS_E_NOMEM;
13596 }
13597
13598 cmd = (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param *)wmi_buf_data(buf);
13599 WMITLV_SET_HDR(&cmd->tlv_header,
13600 WMITLV_TAG_STRUC_wmi_packet_filter_config_fixed_param,
13601 WMITLV_GET_STRUCT_TLVLEN
13602 (WMI_PACKET_FILTER_CONFIG_CMD_fixed_param));
13603
13604 cmd->vdev_id = vdev_id;
13605 cmd->filter_id = filter_id;
13606 if (enable)
13607 cmd->filter_action = PACKET_FILTER_SET_ACTIVE;
13608 else
13609 cmd->filter_action = PACKET_FILTER_SET_INACTIVE;
13610
13611 if (enable) {
13612 cmd->num_params = QDF_MIN(
13613 WMI_PACKET_FILTER_MAX_CMP_PER_PACKET_FILTER,
13614 rcv_filter_param->num_params);
13615 cmd->filter_type = rcv_filter_param->filter_type;
13616 cmd->coalesce_time = rcv_filter_param->coalesce_time;
13617
13618 for (i = 0; i < cmd->num_params; i++) {
13619 cmd->paramsData[i].proto_type =
13620 rcv_filter_param->params_data[i].protocol_layer;
13621 cmd->paramsData[i].cmp_type =
13622 rcv_filter_param->params_data[i].compare_flag;
13623 cmd->paramsData[i].data_length =
13624 rcv_filter_param->params_data[i].data_length;
13625 cmd->paramsData[i].data_offset =
13626 rcv_filter_param->params_data[i].data_offset;
13627 memcpy(&cmd->paramsData[i].compareData,
13628 rcv_filter_param->params_data[i].compare_data,
13629 sizeof(cmd->paramsData[i].compareData));
13630 memcpy(&cmd->paramsData[i].dataMask,
13631 rcv_filter_param->params_data[i].data_mask,
13632 sizeof(cmd->paramsData[i].dataMask));
13633 }
13634 }
13635
13636 WMI_LOGE("Packet filter action %d filter with id: %d, num_params=%d",
13637 cmd->filter_action, cmd->filter_id, cmd->num_params);
13638 /* send the command along with data */
13639 err = wmi_unified_cmd_send(wmi_handle, buf, len,
13640 WMI_PACKET_FILTER_CONFIG_CMDID);
13641 if (err) {
13642 WMI_LOGE("Failed to send pkt_filter cmd");
13643 wmi_buf_free(buf);
13644 return QDF_STATUS_E_FAILURE;
13645 }
13646
13647 return QDF_STATUS_SUCCESS;
13648}
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053013649#endif /* End of WLAN_PMO_ENABLE */
Hanumanth Reddy Pothula3e3e7a62017-01-19 18:47:43 +053013650
Govind Singha4836fd2016-03-07 16:45:38 +053013651/**
13652 * send_set_ssid_hotlist_cmd_tlv() - Handle an SSID hotlist set request
13653 * @wmi_handle: wmi handle
13654 * @request: SSID hotlist set request
13655 *
Govind Singhb53420c2016-03-09 14:32:57 +053013656 * Return: QDF_STATUS enumeration
Govind Singha4836fd2016-03-07 16:45:38 +053013657 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013658static QDF_STATUS
Govind Singha4836fd2016-03-07 16:45:38 +053013659send_set_ssid_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
13660 struct ssid_hotlist_request_params *request)
13661{
13662 wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *cmd;
13663 wmi_buf_t wmi_buf;
13664 uint32_t len;
13665 uint32_t array_size;
13666 uint8_t *buf_ptr;
13667
13668 /* length of fixed portion */
13669 len = sizeof(*cmd);
13670
13671 /* length of variable portion */
13672 array_size =
13673 request->ssid_count * sizeof(wmi_extscan_hotlist_ssid_entry);
13674 len += WMI_TLV_HDR_SIZE + array_size;
13675
13676 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13677 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013678 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13679 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013680 }
13681
13682 buf_ptr = (uint8_t *) wmi_buf_data(wmi_buf);
13683 cmd = (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param *)
13684 buf_ptr;
13685 WMITLV_SET_HDR
13686 (&cmd->tlv_header,
13687 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param,
13688 WMITLV_GET_STRUCT_TLVLEN
13689 (wmi_extscan_configure_hotlist_ssid_monitor_cmd_fixed_param));
13690
13691 cmd->request_id = request->request_id;
13692 cmd->requestor_id = 0;
13693 cmd->vdev_id = request->session_id;
13694 cmd->table_id = 0;
13695 cmd->lost_ap_scan_count = request->lost_ssid_sample_size;
13696 cmd->total_entries = request->ssid_count;
13697 cmd->num_entries_in_page = request->ssid_count;
13698 cmd->first_entry_index = 0;
13699
13700 buf_ptr += sizeof(*cmd);
13701 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC, array_size);
13702
13703 if (request->ssid_count) {
13704 wmi_extscan_hotlist_ssid_entry *entry;
13705 int i;
13706
13707 buf_ptr += WMI_TLV_HDR_SIZE;
13708 entry = (wmi_extscan_hotlist_ssid_entry *)buf_ptr;
13709 for (i = 0; i < request->ssid_count; i++) {
13710 WMITLV_SET_HDR
13711 (entry,
13712 WMITLV_TAG_ARRAY_STRUC,
13713 WMITLV_GET_STRUCT_TLVLEN
13714 (wmi_extscan_hotlist_ssid_entry));
13715 entry->ssid.ssid_len = request->ssids[i].ssid.length;
Govind Singhb53420c2016-03-09 14:32:57 +053013716 qdf_mem_copy(entry->ssid.ssid,
Govind Singha4836fd2016-03-07 16:45:38 +053013717 request->ssids[i].ssid.mac_ssid,
13718 request->ssids[i].ssid.length);
13719 entry->band = request->ssids[i].band;
13720 entry->min_rssi = request->ssids[i].rssi_low;
13721 entry->max_rssi = request->ssids[i].rssi_high;
13722 entry++;
13723 }
13724 cmd->mode = WMI_EXTSCAN_MODE_START;
13725 } else {
13726 cmd->mode = WMI_EXTSCAN_MODE_STOP;
13727 }
13728
13729 if (wmi_unified_cmd_send
13730 (wmi_handle, wmi_buf, len,
13731 WMI_EXTSCAN_CONFIGURE_HOTLIST_SSID_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013732 WMI_LOGE("%s: failed to send command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013733 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013734 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013735 }
13736
Govind Singhb53420c2016-03-09 14:32:57 +053013737 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013738}
13739
13740/**
13741 * send_process_roam_synch_complete_cmd_tlv() - roam synch complete command to fw.
13742 * @wmi_handle: wmi handle
13743 * @vdev_id: vdev id
13744 *
13745 * This function sends roam synch complete event to fw.
13746 *
13747 * Return: CDF STATUS
13748 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013749static QDF_STATUS send_process_roam_synch_complete_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013750 uint8_t vdev_id)
13751{
13752 wmi_roam_synch_complete_fixed_param *cmd;
13753 wmi_buf_t wmi_buf;
13754 uint8_t *buf_ptr;
13755 uint16_t len;
13756 len = sizeof(wmi_roam_synch_complete_fixed_param);
13757
13758 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13759 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013760 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
13761 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013762 }
13763 cmd = (wmi_roam_synch_complete_fixed_param *) wmi_buf_data(wmi_buf);
13764 buf_ptr = (uint8_t *) cmd;
13765 WMITLV_SET_HDR(&cmd->tlv_header,
13766 WMITLV_TAG_STRUC_wmi_roam_synch_complete_fixed_param,
13767 WMITLV_GET_STRUCT_TLVLEN
13768 (wmi_roam_synch_complete_fixed_param));
13769 cmd->vdev_id = vdev_id;
13770 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13771 WMI_ROAM_SYNCH_COMPLETE)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013772 WMI_LOGP("%s: failed to send roam synch confirmation",
Govind Singha4836fd2016-03-07 16:45:38 +053013773 __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013774 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013775 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013776 }
13777
Govind Singhb53420c2016-03-09 14:32:57 +053013778 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013779}
13780
13781/**
Anurag Chouhan459e0152016-07-22 20:19:54 +053013782 * send_fw_test_cmd_tlv() - send fw test command to fw.
13783 * @wmi_handle: wmi handle
13784 * @wmi_fwtest: fw test command
13785 *
13786 * This function sends fw test command to fw.
13787 *
13788 * Return: CDF STATUS
13789 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070013790static
Anurag Chouhan459e0152016-07-22 20:19:54 +053013791QDF_STATUS send_fw_test_cmd_tlv(wmi_unified_t wmi_handle,
13792 struct set_fwtest_params *wmi_fwtest)
13793{
13794 wmi_fwtest_set_param_cmd_fixed_param *cmd;
13795 wmi_buf_t wmi_buf;
13796 uint16_t len;
13797
13798 len = sizeof(*cmd);
13799
13800 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13801 if (!wmi_buf) {
13802 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13803 return QDF_STATUS_E_NOMEM;
13804 }
13805
13806 cmd = (wmi_fwtest_set_param_cmd_fixed_param *) wmi_buf_data(wmi_buf);
13807 WMITLV_SET_HDR(&cmd->tlv_header,
13808 WMITLV_TAG_STRUC_wmi_fwtest_set_param_cmd_fixed_param,
13809 WMITLV_GET_STRUCT_TLVLEN(
13810 wmi_fwtest_set_param_cmd_fixed_param));
13811 cmd->param_id = wmi_fwtest->arg;
13812 cmd->param_value = wmi_fwtest->value;
13813
13814 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13815 WMI_FWTEST_CMDID)) {
13816 WMI_LOGP("%s: failed to send fw test command", __func__);
13817 qdf_nbuf_free(wmi_buf);
13818 return QDF_STATUS_E_FAILURE;
13819 }
13820
13821 return QDF_STATUS_SUCCESS;
13822}
13823
13824/**
Govind Singha4836fd2016-03-07 16:45:38 +053013825 * send_unit_test_cmd_tlv() - send unit test command to fw.
13826 * @wmi_handle: wmi handle
13827 * @wmi_utest: unit test command
13828 *
13829 * This function send unit test command to fw.
13830 *
13831 * Return: CDF STATUS
13832 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013833static QDF_STATUS send_unit_test_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013834 struct wmi_unit_test_cmd *wmi_utest)
13835{
13836 wmi_unit_test_cmd_fixed_param *cmd;
13837 wmi_buf_t wmi_buf;
13838 uint8_t *buf_ptr;
13839 int i;
13840 uint16_t len, args_tlv_len;
13841 A_UINT32 *unit_test_cmd_args;
13842
13843 args_tlv_len =
13844 WMI_TLV_HDR_SIZE + wmi_utest->num_args * sizeof(A_UINT32);
13845 len = sizeof(wmi_unit_test_cmd_fixed_param) + args_tlv_len;
13846
13847 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13848 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013849 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13850 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013851 }
13852
13853 cmd = (wmi_unit_test_cmd_fixed_param *) wmi_buf_data(wmi_buf);
13854 buf_ptr = (uint8_t *) cmd;
13855 WMITLV_SET_HDR(&cmd->tlv_header,
13856 WMITLV_TAG_STRUC_wmi_unit_test_cmd_fixed_param,
13857 WMITLV_GET_STRUCT_TLVLEN(wmi_unit_test_cmd_fixed_param));
13858 cmd->vdev_id = wmi_utest->vdev_id;
13859 cmd->module_id = wmi_utest->module_id;
13860 cmd->num_args = wmi_utest->num_args;
13861 buf_ptr += sizeof(wmi_unit_test_cmd_fixed_param);
13862 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13863 (wmi_utest->num_args * sizeof(uint32_t)));
13864 unit_test_cmd_args = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053013865 WMI_LOGI("%s: %d num of args = ", __func__, wmi_utest->num_args);
Govind Singha4836fd2016-03-07 16:45:38 +053013866 for (i = 0; (i < wmi_utest->num_args && i < WMI_MAX_NUM_ARGS); i++) {
13867 unit_test_cmd_args[i] = wmi_utest->args[i];
Govind Singhb53420c2016-03-09 14:32:57 +053013868 WMI_LOGI("%d,", wmi_utest->args[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053013869 }
13870 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13871 WMI_UNIT_TEST_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013872 WMI_LOGP("%s: failed to send unit test command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053013873 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013874 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013875 }
13876
Govind Singhb53420c2016-03-09 14:32:57 +053013877 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013878}
13879
13880/**
13881 * send_roam_invoke_cmd_tlv() - send roam invoke command to fw.
13882 * @wmi_handle: wma handle
13883 * @roaminvoke: roam invoke command
13884 *
13885 * Send roam invoke command to fw for fastreassoc.
13886 *
13887 * Return: CDF STATUS
13888 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013889static QDF_STATUS send_roam_invoke_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013890 struct wmi_roam_invoke_cmd *roaminvoke,
13891 uint32_t ch_hz)
13892{
13893 wmi_roam_invoke_cmd_fixed_param *cmd;
13894 wmi_buf_t wmi_buf;
13895 u_int8_t *buf_ptr;
13896 u_int16_t len, args_tlv_len;
13897 A_UINT32 *channel_list;
13898 wmi_mac_addr *bssid_list;
Naveen Rawat77797922017-01-20 17:00:07 -080013899 wmi_tlv_buf_len_param *buf_len_tlv;
Govind Singha4836fd2016-03-07 16:45:38 +053013900
13901 /* Host sends only one channel and one bssid */
Naveen Rawat77797922017-01-20 17:00:07 -080013902 args_tlv_len = (4 * WMI_TLV_HDR_SIZE) + sizeof(A_UINT32) +
13903 sizeof(wmi_mac_addr) + sizeof(wmi_tlv_buf_len_param) +
13904 roundup(roaminvoke->frame_len, sizeof(uint32_t));
Govind Singha4836fd2016-03-07 16:45:38 +053013905 len = sizeof(wmi_roam_invoke_cmd_fixed_param) + args_tlv_len;
13906 wmi_buf = wmi_buf_alloc(wmi_handle, len);
13907 if (!wmi_buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013908 WMI_LOGE("%s: wmai_buf_alloc failed", __func__);
13909 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053013910 }
13911
13912 cmd = (wmi_roam_invoke_cmd_fixed_param *)wmi_buf_data(wmi_buf);
13913 buf_ptr = (u_int8_t *) cmd;
13914 WMITLV_SET_HDR(&cmd->tlv_header,
13915 WMITLV_TAG_STRUC_wmi_roam_invoke_cmd_fixed_param,
13916 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_invoke_cmd_fixed_param));
13917 cmd->vdev_id = roaminvoke->vdev_id;
13918 cmd->flags = 0;
Naveen Rawat77797922017-01-20 17:00:07 -080013919
13920 if (roaminvoke->frame_len)
13921 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_SKIP;
13922 else
13923 cmd->roam_scan_mode = WMI_ROAM_INVOKE_SCAN_MODE_FIXED_CH;
13924
Govind Singha4836fd2016-03-07 16:45:38 +053013925 cmd->roam_ap_sel_mode = 0;
13926 cmd->roam_delay = 0;
13927 cmd->num_chan = 1;
13928 cmd->num_bssid = 1;
Naveen Rawat77797922017-01-20 17:00:07 -080013929 /* packing 1 beacon/probe_rsp frame with WMI cmd */
13930 cmd->num_buf = 1;
13931
Govind Singha4836fd2016-03-07 16:45:38 +053013932 buf_ptr += sizeof(wmi_roam_invoke_cmd_fixed_param);
13933 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
13934 (sizeof(u_int32_t)));
13935 channel_list = (A_UINT32 *)(buf_ptr + WMI_TLV_HDR_SIZE);
13936 *channel_list = ch_hz;
13937 buf_ptr += sizeof(A_UINT32) + WMI_TLV_HDR_SIZE;
13938 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
13939 (sizeof(wmi_mac_addr)));
13940 bssid_list = (wmi_mac_addr *)(buf_ptr + WMI_TLV_HDR_SIZE);
13941 WMI_CHAR_ARRAY_TO_MAC_ADDR(roaminvoke->bssid, bssid_list);
Naveen Rawat77797922017-01-20 17:00:07 -080013942
13943 /* move to next tlv i.e. bcn_prb_buf_list */
13944 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_mac_addr);
13945
13946 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_FIXED_STRUC,
13947 sizeof(wmi_tlv_buf_len_param));
13948
13949 buf_len_tlv = (wmi_tlv_buf_len_param *)(buf_ptr + WMI_TLV_HDR_SIZE);
13950 buf_len_tlv->buf_len = roaminvoke->frame_len;
13951
13952 /* move to next tlv i.e. bcn_prb_frm */
13953 buf_ptr += WMI_TLV_HDR_SIZE + sizeof(wmi_tlv_buf_len_param);
13954 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_BYTE,
13955 roundup(roaminvoke->frame_len, sizeof(uint32_t)));
13956
13957 /* copy frame after the header */
13958 qdf_mem_copy(buf_ptr + WMI_TLV_HDR_SIZE,
13959 roaminvoke->frame_buf,
13960 roaminvoke->frame_len);
13961
13962 WMI_LOGD(FL("bcn/prb_rsp frame, length: %d"), roaminvoke->frame_len);
13963 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_WMA, QDF_TRACE_LEVEL_DEBUG,
13964 buf_ptr + WMI_TLV_HDR_SIZE,
13965 roaminvoke->frame_len);
13966
Govind Singha4836fd2016-03-07 16:45:38 +053013967 if (wmi_unified_cmd_send(wmi_handle, wmi_buf, len,
13968 WMI_ROAM_INVOKE_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053013969 WMI_LOGP("%s: failed to send roam invoke command", __func__);
Govind Singha4836fd2016-03-07 16:45:38 +053013970 wmi_buf_free(wmi_buf);
Govind Singhb53420c2016-03-09 14:32:57 +053013971 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053013972 }
13973
Govind Singhb53420c2016-03-09 14:32:57 +053013974 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053013975}
13976
13977/**
13978 * send_roam_scan_offload_cmd_tlv() - set roam offload command
13979 * @wmi_handle: wmi handle
13980 * @command: command
13981 * @vdev_id: vdev id
13982 *
13983 * This function set roam offload command to fw.
13984 *
13985 * Return: CDF status
13986 */
Sathish Kumarfd347372017-02-13 12:29:09 +053013987static QDF_STATUS send_roam_scan_offload_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053013988 uint32_t command, uint32_t vdev_id)
13989{
Govind Singh67922e82016-04-01 16:48:57 +053013990 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053013991 wmi_roam_scan_cmd_fixed_param *cmd_fp;
13992 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053013993 int len;
13994 uint8_t *buf_ptr;
13995
13996 len = sizeof(wmi_roam_scan_cmd_fixed_param);
13997 buf = wmi_buf_alloc(wmi_handle, len);
13998 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053013999 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14000 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014001 }
14002
14003 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14004
14005 cmd_fp = (wmi_roam_scan_cmd_fixed_param *) buf_ptr;
14006 WMITLV_SET_HDR(&cmd_fp->tlv_header,
14007 WMITLV_TAG_STRUC_wmi_roam_scan_cmd_fixed_param,
14008 WMITLV_GET_STRUCT_TLVLEN(wmi_roam_scan_cmd_fixed_param));
14009 cmd_fp->vdev_id = vdev_id;
14010 cmd_fp->command_arg = command;
14011
14012 status = wmi_unified_cmd_send(wmi_handle, buf,
14013 len, WMI_ROAM_SCAN_CMD);
Govind Singh67922e82016-04-01 16:48:57 +053014014 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014015 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_CMD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014016 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014017 goto error;
14018 }
14019
Govind Singhb53420c2016-03-09 14:32:57 +053014020 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CMD", __func__);
14021 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014022
14023error:
14024 wmi_buf_free(buf);
14025
Govind Singh67922e82016-04-01 16:48:57 +053014026 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014027}
14028
14029/**
14030 * send_roam_scan_offload_ap_profile_cmd_tlv() - set roam ap profile in fw
14031 * @wmi_handle: wmi handle
14032 * @ap_profile_p: ap profile
14033 * @vdev_id: vdev id
14034 *
14035 * Send WMI_ROAM_AP_PROFILE to firmware
14036 *
14037 * Return: CDF status
14038 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014039static QDF_STATUS send_roam_scan_offload_ap_profile_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014040 wmi_ap_profile *ap_profile_p,
14041 uint32_t vdev_id)
14042{
Govind Singha4836fd2016-03-07 16:45:38 +053014043 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014044 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014045 int len;
14046 uint8_t *buf_ptr;
14047 wmi_roam_ap_profile_fixed_param *roam_ap_profile_fp;
14048
14049 len = sizeof(wmi_roam_ap_profile_fixed_param) + sizeof(wmi_ap_profile);
14050
14051 buf = wmi_buf_alloc(wmi_handle, len);
14052 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014053 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14054 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014055 }
14056
14057 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14058 roam_ap_profile_fp = (wmi_roam_ap_profile_fixed_param *) buf_ptr;
14059 WMITLV_SET_HDR(&roam_ap_profile_fp->tlv_header,
14060 WMITLV_TAG_STRUC_wmi_roam_ap_profile_fixed_param,
14061 WMITLV_GET_STRUCT_TLVLEN
14062 (wmi_roam_ap_profile_fixed_param));
14063 /* fill in threshold values */
14064 roam_ap_profile_fp->vdev_id = vdev_id;
14065 roam_ap_profile_fp->id = 0;
14066 buf_ptr += sizeof(wmi_roam_ap_profile_fixed_param);
14067
Govind Singhb53420c2016-03-09 14:32:57 +053014068 qdf_mem_copy(buf_ptr, ap_profile_p, sizeof(wmi_ap_profile));
Govind Singha4836fd2016-03-07 16:45:38 +053014069 WMITLV_SET_HDR(buf_ptr,
14070 WMITLV_TAG_STRUC_wmi_ap_profile,
14071 WMITLV_GET_STRUCT_TLVLEN(wmi_ap_profile));
14072 status = wmi_unified_cmd_send(wmi_handle, buf,
14073 len, WMI_ROAM_AP_PROFILE);
Govind Singh67922e82016-04-01 16:48:57 +053014074 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014075 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_AP_PROFILE returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014076 status);
Govind Singh67922e82016-04-01 16:48:57 +053014077 wmi_buf_free(buf);
Govind Singha4836fd2016-03-07 16:45:38 +053014078 }
14079
Govind Singhb53420c2016-03-09 14:32:57 +053014080 WMI_LOGI("WMI --> WMI_ROAM_AP_PROFILE and other parameters");
Govind Singha4836fd2016-03-07 16:45:38 +053014081
Govind Singh67922e82016-04-01 16:48:57 +053014082 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014083}
14084
14085/**
14086 * send_roam_scan_offload_scan_period_cmd_tlv() - set roam offload scan period
14087 * @wmi_handle: wmi handle
14088 * @scan_period: scan period
14089 * @scan_age: scan age
14090 * @vdev_id: vdev id
14091 *
14092 * Send WMI_ROAM_SCAN_PERIOD parameters to fw.
14093 *
14094 * Return: CDF status
14095 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014096static QDF_STATUS send_roam_scan_offload_scan_period_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014097 uint32_t scan_period,
14098 uint32_t scan_age,
14099 uint32_t vdev_id)
14100{
Govind Singh67922e82016-04-01 16:48:57 +053014101 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014102 wmi_buf_t buf = NULL;
Govind Singha4836fd2016-03-07 16:45:38 +053014103 int len;
14104 uint8_t *buf_ptr;
14105 wmi_roam_scan_period_fixed_param *scan_period_fp;
14106
14107 /* Send scan period values */
14108 len = sizeof(wmi_roam_scan_period_fixed_param);
14109 buf = wmi_buf_alloc(wmi_handle, len);
14110 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014111 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14112 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014113 }
14114
14115 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14116 scan_period_fp = (wmi_roam_scan_period_fixed_param *) buf_ptr;
14117 WMITLV_SET_HDR(&scan_period_fp->tlv_header,
14118 WMITLV_TAG_STRUC_wmi_roam_scan_period_fixed_param,
14119 WMITLV_GET_STRUCT_TLVLEN
14120 (wmi_roam_scan_period_fixed_param));
14121 /* fill in scan period values */
14122 scan_period_fp->vdev_id = vdev_id;
14123 scan_period_fp->roam_scan_period = scan_period; /* 20 seconds */
14124 scan_period_fp->roam_scan_age = scan_age;
14125
14126 status = wmi_unified_cmd_send(wmi_handle, buf,
14127 len, WMI_ROAM_SCAN_PERIOD);
Govind Singh67922e82016-04-01 16:48:57 +053014128 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014129 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_PERIOD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014130 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014131 goto error;
14132 }
14133
Govind Singhb53420c2016-03-09 14:32:57 +053014134 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_PERIOD roam_scan_period=%d, roam_scan_age=%d",
Govind Singha4836fd2016-03-07 16:45:38 +053014135 __func__, scan_period, scan_age);
Govind Singhb53420c2016-03-09 14:32:57 +053014136 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014137error:
14138 wmi_buf_free(buf);
14139
Govind Singh67922e82016-04-01 16:48:57 +053014140 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014141}
14142
14143/**
14144 * send_roam_scan_offload_chan_list_cmd_tlv() - set roam offload channel list
14145 * @wmi_handle: wmi handle
14146 * @chan_count: channel count
14147 * @chan_list: channel list
14148 * @list_type: list type
14149 * @vdev_id: vdev id
14150 *
14151 * Set roam offload channel list.
14152 *
14153 * Return: CDF status
14154 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014155static QDF_STATUS send_roam_scan_offload_chan_list_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014156 uint8_t chan_count,
Varun Reddy Yeturu5a552cf2016-07-07 17:42:49 -070014157 uint32_t *chan_list,
Govind Singha4836fd2016-03-07 16:45:38 +053014158 uint8_t list_type, uint32_t vdev_id)
14159{
Govind Singha4836fd2016-03-07 16:45:38 +053014160 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014161 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014162 int len, list_tlv_len;
14163 int i;
14164 uint8_t *buf_ptr;
14165 wmi_roam_chan_list_fixed_param *chan_list_fp;
14166 A_UINT32 *roam_chan_list_array;
14167
14168 if (chan_count == 0) {
Govind Singhb53420c2016-03-09 14:32:57 +053014169 WMI_LOGD("%s : invalid number of channels %d", __func__,
Govind Singha4836fd2016-03-07 16:45:38 +053014170 chan_count);
Govind Singhb53420c2016-03-09 14:32:57 +053014171 return QDF_STATUS_E_EMPTY;
Govind Singha4836fd2016-03-07 16:45:38 +053014172 }
14173 /* Channel list is a table of 2 TLV's */
14174 list_tlv_len = WMI_TLV_HDR_SIZE + chan_count * sizeof(A_UINT32);
14175 len = sizeof(wmi_roam_chan_list_fixed_param) + list_tlv_len;
14176 buf = wmi_buf_alloc(wmi_handle, len);
14177 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014178 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14179 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014180 }
14181
14182 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14183 chan_list_fp = (wmi_roam_chan_list_fixed_param *) buf_ptr;
14184 WMITLV_SET_HDR(&chan_list_fp->tlv_header,
14185 WMITLV_TAG_STRUC_wmi_roam_chan_list_fixed_param,
14186 WMITLV_GET_STRUCT_TLVLEN
14187 (wmi_roam_chan_list_fixed_param));
14188 chan_list_fp->vdev_id = vdev_id;
14189 chan_list_fp->num_chan = chan_count;
Govind Singh224a7312016-06-21 14:33:26 +053014190 if (chan_count > 0 && list_type == WMI_CHANNEL_LIST_STATIC) {
Govind Singha4836fd2016-03-07 16:45:38 +053014191 /* external app is controlling channel list */
14192 chan_list_fp->chan_list_type =
14193 WMI_ROAM_SCAN_CHAN_LIST_TYPE_STATIC;
14194 } else {
14195 /* umac supplied occupied channel list in LFR */
14196 chan_list_fp->chan_list_type =
14197 WMI_ROAM_SCAN_CHAN_LIST_TYPE_DYNAMIC;
14198 }
14199
14200 buf_ptr += sizeof(wmi_roam_chan_list_fixed_param);
14201 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14202 (chan_list_fp->num_chan * sizeof(uint32_t)));
14203 roam_chan_list_array = (A_UINT32 *) (buf_ptr + WMI_TLV_HDR_SIZE);
Govind Singhb53420c2016-03-09 14:32:57 +053014204 WMI_LOGI("%s: %d channels = ", __func__, chan_list_fp->num_chan);
Govind Singha4836fd2016-03-07 16:45:38 +053014205 for (i = 0; ((i < chan_list_fp->num_chan) &&
14206 (i < WMI_ROAM_MAX_CHANNELS)); i++) {
14207 roam_chan_list_array[i] = chan_list[i];
Govind Singhb53420c2016-03-09 14:32:57 +053014208 WMI_LOGI("%d,", roam_chan_list_array[i]);
Govind Singha4836fd2016-03-07 16:45:38 +053014209 }
14210
14211 status = wmi_unified_cmd_send(wmi_handle, buf,
14212 len, WMI_ROAM_CHAN_LIST);
Govind Singh67922e82016-04-01 16:48:57 +053014213 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014214 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_CHAN_LIST returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014215 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014216 goto error;
14217 }
14218
Govind Singhb53420c2016-03-09 14:32:57 +053014219 WMI_LOGI("%s: WMI --> WMI_ROAM_SCAN_CHAN_LIST", __func__);
14220 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014221error:
14222 wmi_buf_free(buf);
14223
Govind Singh67922e82016-04-01 16:48:57 +053014224 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014225}
14226
14227/**
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014228 * send_per_roam_config_cmd_tlv() - set per roaming config to FW
14229 * @wmi_handle: wmi handle
14230 * @req_buf: per roam config buffer
14231 *
14232 * Return: QDF status
14233 */
14234static QDF_STATUS send_per_roam_config_cmd_tlv(wmi_unified_t wmi_handle,
14235 struct wmi_per_roam_config_req *req_buf)
14236{
14237 wmi_buf_t buf = NULL;
14238 QDF_STATUS status;
14239 int len;
14240 uint8_t *buf_ptr;
14241 wmi_roam_per_config_fixed_param *wmi_per_config;
14242
14243 len = sizeof(wmi_roam_per_config_fixed_param);
14244 buf = wmi_buf_alloc(wmi_handle, len);
14245 if (!buf) {
14246 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14247 return QDF_STATUS_E_NOMEM;
14248 }
14249
14250 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14251 wmi_per_config =
14252 (wmi_roam_per_config_fixed_param *) buf_ptr;
14253 WMITLV_SET_HDR(&wmi_per_config->tlv_header,
14254 WMITLV_TAG_STRUC_wmi_roam_per_config_fixed_param,
14255 WMITLV_GET_STRUCT_TLVLEN
14256 (wmi_roam_per_config_fixed_param));
14257
14258 /* fill in per roam config values */
14259 wmi_per_config->vdev_id = req_buf->vdev_id;
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014260
14261 wmi_per_config->enable = req_buf->per_config.enable;
14262 wmi_per_config->high_rate_thresh =
14263 (req_buf->per_config.tx_high_rate_thresh << 16) |
14264 (req_buf->per_config.rx_high_rate_thresh & 0x0000ffff);
14265 wmi_per_config->low_rate_thresh =
14266 (req_buf->per_config.tx_low_rate_thresh << 16) |
14267 (req_buf->per_config.rx_low_rate_thresh & 0x0000ffff);
14268 wmi_per_config->pkt_err_rate_thresh_pct =
14269 (req_buf->per_config.tx_rate_thresh_percnt << 16) |
14270 (req_buf->per_config.rx_rate_thresh_percnt & 0x0000ffff);
14271 wmi_per_config->per_rest_time = req_buf->per_config.per_rest_time;
Kapil Gupta071b1552017-02-13 15:51:52 +053014272 wmi_per_config->pkt_err_rate_mon_time =
14273 (req_buf->per_config.tx_per_mon_time << 16) |
14274 (req_buf->per_config.rx_per_mon_time & 0x0000ffff);
Kapil Gupta54ea36e2017-02-24 15:50:03 +053014275
14276 /* Send per roam config parameters */
14277 status = wmi_unified_cmd_send(wmi_handle, buf,
14278 len, WMI_ROAM_PER_CONFIG_CMDID);
14279 if (QDF_IS_STATUS_ERROR(status)) {
14280 WMI_LOGE("WMI_ROAM_PER_CONFIG_CMDID failed, Error %d",
14281 status);
14282 wmi_buf_free(buf);
14283 return status;
14284 }
14285
14286 WMI_LOGI(FL("per roam enable=%d, vdev=%d"),
14287 req_buf->per_config.enable, req_buf->vdev_id);
14288 return QDF_STATUS_SUCCESS;
14289}
14290
14291/**
Govind Singha4836fd2016-03-07 16:45:38 +053014292 * send_roam_scan_offload_rssi_change_cmd_tlv() - set roam offload RSSI th
14293 * @wmi_handle: wmi handle
14294 * @rssi_change_thresh: RSSI Change threshold
14295 * @bcn_rssi_weight: beacon RSSI weight
14296 * @vdev_id: vdev id
14297 *
14298 * Send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD parameters to fw.
14299 *
14300 * Return: CDF status
14301 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014302static QDF_STATUS send_roam_scan_offload_rssi_change_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014303 uint32_t vdev_id,
14304 int32_t rssi_change_thresh,
14305 uint32_t bcn_rssi_weight,
14306 uint32_t hirssi_delay_btw_scans)
14307{
Govind Singha4836fd2016-03-07 16:45:38 +053014308 wmi_buf_t buf = NULL;
Govind Singh67922e82016-04-01 16:48:57 +053014309 QDF_STATUS status;
Govind Singha4836fd2016-03-07 16:45:38 +053014310 int len;
14311 uint8_t *buf_ptr;
14312 wmi_roam_scan_rssi_change_threshold_fixed_param *rssi_change_fp;
14313
14314 /* Send rssi change parameters */
14315 len = sizeof(wmi_roam_scan_rssi_change_threshold_fixed_param);
14316 buf = wmi_buf_alloc(wmi_handle, len);
14317 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014318 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14319 return QDF_STATUS_E_NOMEM;
Govind Singha4836fd2016-03-07 16:45:38 +053014320 }
14321
14322 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14323 rssi_change_fp =
14324 (wmi_roam_scan_rssi_change_threshold_fixed_param *) buf_ptr;
14325 WMITLV_SET_HDR(&rssi_change_fp->tlv_header,
14326 WMITLV_TAG_STRUC_wmi_roam_scan_rssi_change_threshold_fixed_param,
14327 WMITLV_GET_STRUCT_TLVLEN
14328 (wmi_roam_scan_rssi_change_threshold_fixed_param));
14329 /* fill in rssi change threshold (hysteresis) values */
14330 rssi_change_fp->vdev_id = vdev_id;
14331 rssi_change_fp->roam_scan_rssi_change_thresh = rssi_change_thresh;
14332 rssi_change_fp->bcn_rssi_weight = bcn_rssi_weight;
14333 rssi_change_fp->hirssi_delay_btw_scans = hirssi_delay_btw_scans;
14334
14335 status = wmi_unified_cmd_send(wmi_handle, buf,
14336 len, WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD);
Govind Singh67922e82016-04-01 16:48:57 +053014337 if (QDF_IS_STATUS_ERROR(status)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014338 WMI_LOGE("wmi_unified_cmd_send WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD returned Error %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014339 status);
Govind Singha4836fd2016-03-07 16:45:38 +053014340 goto error;
14341 }
14342
Govind Singhb53420c2016-03-09 14:32:57 +053014343 WMI_LOGI(FL("roam_scan_rssi_change_thresh=%d, bcn_rssi_weight=%d"),
Govind Singha4836fd2016-03-07 16:45:38 +053014344 rssi_change_thresh, bcn_rssi_weight);
Govind Singhb53420c2016-03-09 14:32:57 +053014345 WMI_LOGI(FL("hirssi_delay_btw_scans=%d"), hirssi_delay_btw_scans);
14346 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014347error:
14348 wmi_buf_free(buf);
14349
Govind Singh67922e82016-04-01 16:48:57 +053014350 return status;
Govind Singha4836fd2016-03-07 16:45:38 +053014351}
14352
14353/** wmi_get_hotlist_entries_per_page() - hotlist entries per page
14354 * @wmi_handle: wmi handle.
14355 * @cmd: size of command structure.
14356 * @per_entry_size: per entry size.
14357 *
14358 * This utility function calculates how many hotlist entries can
14359 * fit in one page.
14360 *
14361 * Return: number of entries
14362 */
14363static inline int wmi_get_hotlist_entries_per_page(wmi_unified_t wmi_handle,
14364 size_t cmd_size,
14365 size_t per_entry_size)
14366{
14367 uint32_t avail_space = 0;
14368 int num_entries = 0;
14369 uint16_t max_msg_len = wmi_get_max_msg_len(wmi_handle);
14370
14371 /* Calculate number of hotlist entries that can
14372 * be passed in wma message request.
14373 */
14374 avail_space = max_msg_len - cmd_size;
14375 num_entries = avail_space / per_entry_size;
14376 return num_entries;
14377}
14378
14379/**
14380 * send_get_buf_extscan_hotlist_cmd_tlv() - prepare hotlist command
14381 * @wmi_handle: wmi handle
14382 * @photlist: hotlist command params
14383 * @buf_len: buffer length
14384 *
14385 * This function fills individual elements for hotlist request and
14386 * TLV for bssid entries
14387 *
14388 * Return: CDF Status.
14389 */
Sathish Kumarfd347372017-02-13 12:29:09 +053014390static QDF_STATUS send_get_buf_extscan_hotlist_cmd_tlv(wmi_unified_t wmi_handle,
Govind Singha4836fd2016-03-07 16:45:38 +053014391 struct ext_scan_setbssi_hotlist_params *
14392 photlist, int *buf_len)
14393{
14394 wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *cmd = NULL;
14395 wmi_extscan_hotlist_entry *dest_hotlist;
14396 struct ap_threshold_params *src_ap = photlist->ap;
14397 wmi_buf_t buf;
14398 uint8_t *buf_ptr;
14399
14400 int j, index = 0;
14401 int cmd_len = 0;
14402 int num_entries;
14403 int min_entries = 0;
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014404 uint32_t numap = photlist->numAp;
Govind Singha4836fd2016-03-07 16:45:38 +053014405 int len = sizeof(*cmd);
14406
14407 len += WMI_TLV_HDR_SIZE;
14408 cmd_len = len;
14409
14410 num_entries = wmi_get_hotlist_entries_per_page(wmi_handle,
14411 cmd_len,
14412 sizeof(*dest_hotlist));
14413 /* setbssid hotlist expects the bssid list
14414 * to be non zero value
14415 */
Srinivas Girigowda4c777b42016-12-07 14:45:34 -080014416 if (!numap || (numap > WMI_WLAN_EXTSCAN_MAX_HOTLIST_APS)) {
Srinivas Girigowdabf1a9ef2016-12-07 14:32:24 -080014417 WMI_LOGE("Invalid number of APs: %d", numap);
Govind Singhb53420c2016-03-09 14:32:57 +053014418 return QDF_STATUS_E_INVAL;
Govind Singha4836fd2016-03-07 16:45:38 +053014419 }
14420
14421 /* Split the hot list entry pages and send multiple command
14422 * requests if the buffer reaches the maximum request size
14423 */
14424 while (index < numap) {
Govind Singhb53420c2016-03-09 14:32:57 +053014425 min_entries = QDF_MIN(num_entries, numap);
Govind Singha4836fd2016-03-07 16:45:38 +053014426 len += min_entries * sizeof(wmi_extscan_hotlist_entry);
14427 buf = wmi_buf_alloc(wmi_handle, len);
14428 if (!buf) {
Govind Singhb53420c2016-03-09 14:32:57 +053014429 WMI_LOGP("%s: wmi_buf_alloc failed", __func__);
14430 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014431 }
14432 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14433 cmd = (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param *)
14434 buf_ptr;
14435 WMITLV_SET_HDR(&cmd->tlv_header,
14436 WMITLV_TAG_STRUC_wmi_extscan_configure_hotlist_monitor_cmd_fixed_param,
14437 WMITLV_GET_STRUCT_TLVLEN
14438 (wmi_extscan_configure_hotlist_monitor_cmd_fixed_param));
14439
14440 /* Multiple requests are sent until the num_entries_in_page
14441 * matches the total_entries
14442 */
14443 cmd->request_id = photlist->requestId;
14444 cmd->vdev_id = photlist->sessionId;
14445 cmd->total_entries = numap;
14446 cmd->mode = 1;
14447 cmd->num_entries_in_page = min_entries;
14448 cmd->lost_ap_scan_count = photlist->lost_ap_sample_size;
14449 cmd->first_entry_index = index;
14450
Govind Singhb53420c2016-03-09 14:32:57 +053014451 WMI_LOGD("%s: vdev id:%d total_entries: %d num_entries: %d lost_ap_sample_size: %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014452 __func__, cmd->vdev_id, cmd->total_entries,
14453 cmd->num_entries_in_page,
14454 cmd->lost_ap_scan_count);
14455
14456 buf_ptr += sizeof(*cmd);
14457 WMITLV_SET_HDR(buf_ptr,
14458 WMITLV_TAG_ARRAY_STRUC,
14459 min_entries * sizeof(wmi_extscan_hotlist_entry));
14460 dest_hotlist = (wmi_extscan_hotlist_entry *)
14461 (buf_ptr + WMI_TLV_HDR_SIZE);
14462
14463 /* Populate bssid, channel info and rssi
14464 * for the bssid's that are sent as hotlists.
14465 */
14466 for (j = 0; j < min_entries; j++) {
14467 WMITLV_SET_HDR(dest_hotlist,
14468 WMITLV_TAG_STRUC_wmi_extscan_bucket_cmd_fixed_param,
14469 WMITLV_GET_STRUCT_TLVLEN
14470 (wmi_extscan_hotlist_entry));
14471
14472 dest_hotlist->min_rssi = src_ap->low;
14473 WMI_CHAR_ARRAY_TO_MAC_ADDR(src_ap->bssid.bytes,
14474 &dest_hotlist->bssid);
14475
Govind Singhb53420c2016-03-09 14:32:57 +053014476 WMI_LOGD("%s:channel:%d min_rssi %d",
Govind Singha4836fd2016-03-07 16:45:38 +053014477 __func__, dest_hotlist->channel,
14478 dest_hotlist->min_rssi);
Govind Singhb53420c2016-03-09 14:32:57 +053014479 WMI_LOGD
Govind Singha4836fd2016-03-07 16:45:38 +053014480 ("%s: bssid mac_addr31to0: 0x%x, mac_addr47to32: 0x%x",
14481 __func__, dest_hotlist->bssid.mac_addr31to0,
14482 dest_hotlist->bssid.mac_addr47to32);
14483 dest_hotlist++;
14484 src_ap++;
14485 }
14486 buf_ptr += WMI_TLV_HDR_SIZE +
14487 (min_entries * sizeof(wmi_extscan_hotlist_entry));
14488
14489 if (wmi_unified_cmd_send(wmi_handle, buf, len,
14490 WMI_EXTSCAN_CONFIGURE_HOTLIST_MONITOR_CMDID)) {
Govind Singhb53420c2016-03-09 14:32:57 +053014491 WMI_LOGE("%s: failed to send command", __func__);
Abhishek Singh716c46c2016-05-04 16:24:07 +053014492 wmi_buf_free(buf);
Govind Singhb53420c2016-03-09 14:32:57 +053014493 return QDF_STATUS_E_FAILURE;
Govind Singha4836fd2016-03-07 16:45:38 +053014494 }
14495 index = index + min_entries;
14496 num_entries = numap - min_entries;
14497 len = cmd_len;
14498 }
Govind Singhb53420c2016-03-09 14:32:57 +053014499 return QDF_STATUS_SUCCESS;
Govind Singha4836fd2016-03-07 16:45:38 +053014500}
14501
Govind Singhbca3b1b2016-05-02 17:59:24 +053014502/**
Dustin Brown4423f632017-01-13 15:24:07 -080014503 * send_set_active_bpf_mode_cmd_tlv() - configure active BPF mode in FW
14504 * @wmi_handle: the WMI handle
14505 * @vdev_id: the Id of the vdev to apply the configuration to
14506 * @ucast_mode: the active BPF mode to configure for unicast packets
14507 * @mcast_bcast_mode: the active BPF mode to configure for multicast/broadcast
14508 * packets
14509 *
14510 * Return: QDF status
14511 */
14512static QDF_STATUS send_set_active_bpf_mode_cmd_tlv(wmi_unified_t wmi_handle,
14513 uint8_t vdev_id,
14514 enum wmi_host_active_bpf_mode ucast_mode,
14515 enum wmi_host_active_bpf_mode mcast_bcast_mode)
14516{
14517 const WMITLV_TAG_ID tag_id =
14518 WMITLV_TAG_STRUC_wmi_bpf_set_vdev_active_mode_cmd_fixed_param;
14519 const uint32_t tlv_len = WMITLV_GET_STRUCT_TLVLEN(
14520 wmi_bpf_set_vdev_active_mode_cmd_fixed_param);
14521 QDF_STATUS status;
14522 wmi_bpf_set_vdev_active_mode_cmd_fixed_param *cmd;
14523 wmi_buf_t buf;
14524
14525 WMI_LOGI("Sending WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID(%u, %d, %d)",
14526 vdev_id, ucast_mode, mcast_bcast_mode);
14527
14528 /* allocate command buffer */
14529 buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
14530 if (!buf) {
14531 WMI_LOGE("%s: wmi_buf_alloc failed", __func__);
14532 return QDF_STATUS_E_NOMEM;
14533 }
14534
14535 /* set TLV header */
14536 cmd = (wmi_bpf_set_vdev_active_mode_cmd_fixed_param *)wmi_buf_data(buf);
14537 WMITLV_SET_HDR(&cmd->tlv_header, tag_id, tlv_len);
14538
14539 /* populate data */
14540 cmd->vdev_id = vdev_id;
14541 cmd->uc_mode = ucast_mode;
14542 cmd->mcbc_mode = mcast_bcast_mode;
14543
14544 /* send to FW */
14545 status = wmi_unified_cmd_send(wmi_handle, buf, sizeof(*cmd),
14546 WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID);
14547 if (QDF_IS_STATUS_ERROR(status)) {
14548 WMI_LOGE("Failed to send WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID:%d",
14549 status);
14550 wmi_buf_free(buf);
14551 return status;
14552 }
14553
14554 WMI_LOGI("Sent WMI_BPF_SET_VDEV_ACTIVE_MODE_CMDID successfully");
14555
14556 return QDF_STATUS_SUCCESS;
14557}
14558
14559/**
Govind Singhbca3b1b2016-05-02 17:59:24 +053014560 * send_power_dbg_cmd_tlv() - send power debug commands
14561 * @wmi_handle: wmi handle
14562 * @param: wmi power debug parameter
14563 *
14564 * Send WMI_POWER_DEBUG_CMDID parameters to fw.
14565 *
14566 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14567 */
Jeff Johnson9366d7a2016-10-07 13:03:02 -070014568static QDF_STATUS send_power_dbg_cmd_tlv(wmi_unified_t wmi_handle,
14569 struct wmi_power_dbg_params *param)
Govind Singhbca3b1b2016-05-02 17:59:24 +053014570{
14571 wmi_buf_t buf = NULL;
14572 QDF_STATUS status;
14573 int len, args_tlv_len;
14574 uint8_t *buf_ptr;
14575 uint8_t i;
14576 wmi_pdev_wal_power_debug_cmd_fixed_param *cmd;
14577 uint32_t *cmd_args;
14578
14579 /* Prepare and send power debug cmd parameters */
14580 args_tlv_len = WMI_TLV_HDR_SIZE + param->num_args * sizeof(uint32_t);
14581 len = sizeof(*cmd) + args_tlv_len;
14582 buf = wmi_buf_alloc(wmi_handle, len);
14583 if (!buf) {
14584 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14585 return QDF_STATUS_E_NOMEM;
14586 }
14587
14588 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14589 cmd = (wmi_pdev_wal_power_debug_cmd_fixed_param *) buf_ptr;
14590 WMITLV_SET_HDR(&cmd->tlv_header,
14591 WMITLV_TAG_STRUC_wmi_pdev_wal_power_debug_cmd_fixed_param,
14592 WMITLV_GET_STRUCT_TLVLEN
14593 (wmi_pdev_wal_power_debug_cmd_fixed_param));
14594
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014595 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14596 param->pdev_id);
Govind Singhbca3b1b2016-05-02 17:59:24 +053014597 cmd->module_id = param->module_id;
14598 cmd->num_args = param->num_args;
14599 buf_ptr += sizeof(*cmd);
14600 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_UINT32,
14601 (param->num_args * sizeof(uint32_t)));
14602 cmd_args = (uint32_t *) (buf_ptr + WMI_TLV_HDR_SIZE);
14603 WMI_LOGI("%s: %d num of args = ", __func__, param->num_args);
14604 for (i = 0; (i < param->num_args && i < WMI_MAX_NUM_ARGS); i++) {
14605 cmd_args[i] = param->args[i];
14606 WMI_LOGI("%d,", param->args[i]);
14607 }
14608
14609 status = wmi_unified_cmd_send(wmi_handle, buf,
14610 len, WMI_PDEV_WAL_POWER_DEBUG_CMDID);
14611 if (QDF_IS_STATUS_ERROR(status)) {
14612 WMI_LOGE("wmi_unified_cmd_send WMI_PDEV_WAL_POWER_DEBUG_CMDID returned Error %d",
14613 status);
14614 goto error;
14615 }
14616
14617 return QDF_STATUS_SUCCESS;
14618error:
14619 wmi_buf_free(buf);
14620
14621 return status;
14622}
14623
Kiran Venkatappa26117052016-12-23 19:58:54 +053014624/* copy_hw_mode_id_in_init_cmd() - Helper routine to copy hw_mode in init cmd
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014625 * @wmi_handle: pointer to wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014626 * @buf_ptr: pointer to current position in init command buffer
14627 * @len: pointer to length. This will be updated with current lenght of cmd
14628 * @param: point host parameters for init command
14629 *
14630 * Return: Updated pointer of buf_ptr.
14631 */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014632static inline uint8_t *copy_hw_mode_in_init_cmd(struct wmi_unified *wmi_handle,
14633 uint8_t *buf_ptr, int *len, struct wmi_init_cmd_param *param)
Kiran Venkatappa26117052016-12-23 19:58:54 +053014634{
14635 uint16_t idx;
14636
14637 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX) {
14638 wmi_pdev_set_hw_mode_cmd_fixed_param *hw_mode;
14639 wmi_pdev_band_to_mac *band_to_mac;
14640
14641 hw_mode = (wmi_pdev_set_hw_mode_cmd_fixed_param *)
14642 (buf_ptr + sizeof(wmi_init_cmd_fixed_param) +
14643 sizeof(wmi_resource_config) +
14644 WMI_TLV_HDR_SIZE + (param->num_mem_chunks *
14645 sizeof(wlan_host_memory_chunk)));
14646
14647 WMITLV_SET_HDR(&hw_mode->tlv_header,
14648 WMITLV_TAG_STRUC_wmi_pdev_set_hw_mode_cmd_fixed_param,
14649 (WMITLV_GET_STRUCT_TLVLEN
14650 (wmi_pdev_set_hw_mode_cmd_fixed_param)));
14651
14652 hw_mode->hw_mode_index = param->hw_mode_id;
14653 hw_mode->num_band_to_mac = param->num_band_to_mac;
14654
14655 buf_ptr = (uint8_t *) (hw_mode + 1);
14656 band_to_mac = (wmi_pdev_band_to_mac *) (buf_ptr +
14657 WMI_TLV_HDR_SIZE);
14658 for (idx = 0; idx < param->num_band_to_mac; idx++) {
14659 WMITLV_SET_HDR(&band_to_mac[idx].tlv_header,
14660 WMITLV_TAG_STRUC_wmi_pdev_band_to_mac,
14661 WMITLV_GET_STRUCT_TLVLEN
14662 (wmi_pdev_band_to_mac));
14663 band_to_mac[idx].pdev_id =
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014664 wmi_handle->ops->convert_pdev_id_host_to_target(
14665 param->band_to_mac[idx].pdev_id);
Kiran Venkatappa26117052016-12-23 19:58:54 +053014666 band_to_mac[idx].start_freq =
14667 param->band_to_mac[idx].start_freq;
14668 band_to_mac[idx].end_freq =
14669 param->band_to_mac[idx].end_freq;
14670 }
14671 *len += sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14672 (param->num_band_to_mac *
14673 sizeof(wmi_pdev_band_to_mac)) +
14674 WMI_TLV_HDR_SIZE;
14675
14676 WMITLV_SET_HDR(buf_ptr, WMITLV_TAG_ARRAY_STRUC,
14677 (param->num_band_to_mac *
14678 sizeof(wmi_pdev_band_to_mac)));
14679 }
14680
14681 return buf_ptr;
14682}
14683
Govind Singhe7f2f342016-05-23 12:12:52 +053014684/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053014685 * send_multiple_vdev_restart_req_cmd_tlv() - send multiple vdev restart req
14686 * @wmi_handle: wmi handle
14687 * @param: wmi multiple vdev restart req param
14688 *
14689 * Send WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID parameters to fw.
14690 *
14691 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14692 */
14693static QDF_STATUS send_multiple_vdev_restart_req_cmd_tlv(
14694 wmi_unified_t wmi_handle,
14695 struct multiple_vdev_restart_params *param)
14696{
14697 wmi_buf_t buf;
14698 QDF_STATUS qdf_status;
14699 wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *cmd;
14700 int i;
14701 uint8_t *buf_ptr;
14702 uint32_t *vdev_ids;
14703 wmi_channel *chan_info;
14704 struct channel_param *tchan_info;
14705 uint16_t len = sizeof(*cmd) + WMI_TLV_HDR_SIZE;
14706
14707 len += sizeof(wmi_channel);
14708 if (param->num_vdevs)
14709 len += sizeof(uint32_t) * param->num_vdevs;
14710
14711 buf = wmi_buf_alloc(wmi_handle, len);
14712 if (!buf) {
14713 WMI_LOGE("Failed to allocate memory\n");
14714 qdf_status = QDF_STATUS_E_NOMEM;
14715 goto end;
14716 }
14717
14718 buf_ptr = (uint8_t *)wmi_buf_data(buf);
14719 cmd = (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param *)
14720 buf_ptr;
14721
14722 WMITLV_SET_HDR(&cmd->tlv_header,
14723 WMITLV_TAG_STRUC_wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param,
14724 WMITLV_GET_STRUCT_TLVLEN
14725 (wmi_pdev_multiple_vdev_restart_request_cmd_fixed_param));
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014726 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(
14727 param->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053014728 cmd->requestor_id = param->requestor_id;
14729 cmd->disable_hw_ack = param->disable_hw_ack;
14730 cmd->cac_duration_ms = param->cac_duration_ms;
14731 cmd->num_vdevs = param->num_vdevs;
14732
14733 buf_ptr += sizeof(*cmd);
14734
14735 WMITLV_SET_HDR(buf_ptr,
14736 WMITLV_TAG_ARRAY_UINT32,
14737 sizeof(A_UINT32) * param->num_vdevs);
14738 vdev_ids = (uint32_t *)(buf_ptr + WMI_TLV_HDR_SIZE);
14739 for (i = 0; i < param->num_vdevs; i++) {
14740 vdev_ids[i] = param->vdev_ids[i];
14741 }
14742
14743 buf_ptr += (sizeof(A_UINT32) * param->num_vdevs) + WMI_TLV_HDR_SIZE;
14744
14745 WMITLV_SET_HDR(buf_ptr,
14746 WMITLV_TAG_STRUC_wmi_channel,
14747 WMITLV_GET_STRUCT_TLVLEN(wmi_channel));
Sathish Kumar3e28e002017-03-07 15:53:04 +053014748 chan_info = (wmi_channel *)buf_ptr;
Sathish Kumar45e991b2017-02-27 10:35:40 +053014749 tchan_info = &(param->ch_param);
14750 chan_info->mhz = tchan_info->mhz;
14751 chan_info->band_center_freq1 = tchan_info->cfreq1;
14752 chan_info->band_center_freq2 = tchan_info->cfreq2;
14753 if (tchan_info->is_chan_passive)
14754 WMI_SET_CHANNEL_FLAG(chan_info,
14755 WMI_CHAN_FLAG_PASSIVE);
14756 if (tchan_info->allow_vht)
14757 WMI_SET_CHANNEL_FLAG(chan_info,
14758 WMI_CHAN_FLAG_ALLOW_VHT);
14759 else if (tchan_info->allow_ht)
14760 WMI_SET_CHANNEL_FLAG(chan_info,
14761 WMI_CHAN_FLAG_ALLOW_HT);
14762 WMI_SET_CHANNEL_MODE(chan_info, tchan_info->phy_mode);
14763 WMI_SET_CHANNEL_MIN_POWER(chan_info, tchan_info->minpower);
14764 WMI_SET_CHANNEL_MAX_POWER(chan_info, tchan_info->maxpower);
14765 WMI_SET_CHANNEL_REG_POWER(chan_info, tchan_info->maxregpower);
14766 WMI_SET_CHANNEL_ANTENNA_MAX(chan_info, tchan_info->antennamax);
14767 WMI_SET_CHANNEL_REG_CLASSID(chan_info, tchan_info->reg_class_id);
14768
14769 qdf_status = wmi_unified_cmd_send(wmi_handle, buf, len,
14770 WMI_PDEV_MULTIPLE_VDEV_RESTART_REQUEST_CMDID);
14771
14772 if (QDF_IS_STATUS_ERROR(qdf_status)) {
14773 WMI_LOGE("%s: Failed to send\n", __func__);
14774 wmi_buf_free(buf);
14775 }
14776
14777end:
14778 return qdf_status;
14779}
14780
14781/**
Arif Hussainf00be1d2017-01-07 18:21:55 -080014782 * send_dfs_phyerr_offload_en_cmd_tlv() - send dfs phyerr offload enable cmd
14783 * @wmi_handle: wmi handle
14784 * @pdev_id: pdev id
14785 *
14786 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID command to firmware.
14787 *
14788 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14789 */
14790static QDF_STATUS send_dfs_phyerr_offload_en_cmd_tlv(wmi_unified_t wmi_handle,
14791 uint32_t pdev_id)
14792{
14793 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *cmd;
14794 wmi_buf_t buf;
14795 uint16_t len;
14796 QDF_STATUS ret;
14797
14798 len = sizeof(*cmd);
14799 buf = wmi_buf_alloc(wmi_handle, len);
14800
14801 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
14802
14803 if (!buf) {
14804 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14805 return QDF_STATUS_E_NOMEM;
14806 }
14807
14808 cmd = (wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param *)
14809 wmi_buf_data(buf);
14810
14811 WMITLV_SET_HDR(&cmd->tlv_header,
14812 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param,
14813 WMITLV_GET_STRUCT_TLVLEN(
14814 wmi_pdev_dfs_phyerr_offload_enable_cmd_fixed_param));
14815
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014816 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080014817 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14818 WMI_PDEV_DFS_PHYERR_OFFLOAD_ENABLE_CMDID);
14819 if (QDF_IS_STATUS_ERROR(ret)) {
14820 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
14821 __func__, ret, pdev_id);
14822 wmi_buf_free(buf);
14823 return QDF_STATUS_E_FAILURE;
14824 }
14825
14826 return QDF_STATUS_SUCCESS;
14827}
14828
14829/**
14830 * send_dfs_phyerr_offload_dis_cmd_tlv() - send dfs phyerr offload disable cmd
14831 * @wmi_handle: wmi handle
14832 * @pdev_id: pdev id
14833 *
14834 * Send WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID command to firmware.
14835 *
14836 * Return: QDF_STATUS_SUCCESS on success, QDF_STATUS_E_** on error
14837 */
14838static QDF_STATUS send_dfs_phyerr_offload_dis_cmd_tlv(wmi_unified_t wmi_handle,
14839 uint32_t pdev_id)
14840{
14841 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *cmd;
14842 wmi_buf_t buf;
14843 uint16_t len;
14844 QDF_STATUS ret;
14845
14846 len = sizeof(*cmd);
14847 buf = wmi_buf_alloc(wmi_handle, len);
14848
14849 WMI_LOGI("%s: pdev_id=%d", __func__, pdev_id);
14850
14851 if (!buf) {
14852 WMI_LOGE("%s : wmi_buf_alloc failed", __func__);
14853 return QDF_STATUS_E_NOMEM;
14854 }
14855
14856 cmd = (wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param *)
14857 wmi_buf_data(buf);
14858
14859 WMITLV_SET_HDR(&cmd->tlv_header,
14860 WMITLV_TAG_STRUC_wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param,
14861 WMITLV_GET_STRUCT_TLVLEN(
14862 wmi_pdev_dfs_phyerr_offload_disable_cmd_fixed_param));
14863
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014864 cmd->pdev_id = wmi_handle->ops->convert_pdev_id_host_to_target(pdev_id);
Arif Hussainf00be1d2017-01-07 18:21:55 -080014865 ret = wmi_unified_cmd_send(wmi_handle, buf, len,
14866 WMI_PDEV_DFS_PHYERR_OFFLOAD_DISABLE_CMDID);
14867 if (QDF_IS_STATUS_ERROR(ret)) {
14868 WMI_LOGE("%s: Failed to send cmd to fw, ret=%d, pdev_id=%d",
14869 __func__, ret, pdev_id);
14870 wmi_buf_free(buf);
14871 return QDF_STATUS_E_FAILURE;
14872 }
14873
14874 return QDF_STATUS_SUCCESS;
14875}
14876
14877/**
Govind Singhe7f2f342016-05-23 12:12:52 +053014878 * init_cmd_send_tlv() - send initialization cmd to fw
14879 * @wmi_handle: wmi handle
Kiran Venkatappa26117052016-12-23 19:58:54 +053014880 * @param param: pointer to wmi init param
Govind Singhe7f2f342016-05-23 12:12:52 +053014881 *
14882 * Return: QDF_STATUS_SUCCESS for success or error code
14883 */
14884static QDF_STATUS init_cmd_send_tlv(wmi_unified_t wmi_handle,
Kiran Venkatappa26117052016-12-23 19:58:54 +053014885 struct wmi_init_cmd_param *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053014886{
14887 wmi_buf_t buf;
14888 wmi_init_cmd_fixed_param *cmd;
14889 wmi_abi_version my_vers;
14890 int num_whitelist;
14891 uint8_t *buf_ptr;
14892 wmi_resource_config *resource_cfg;
14893 wlan_host_memory_chunk *host_mem_chunks;
Kiran Venkatappa26117052016-12-23 19:58:54 +053014894 uint32_t mem_chunk_len = 0, hw_mode_len = 0;
Govind Singhe7f2f342016-05-23 12:12:52 +053014895 uint16_t idx;
14896 int len;
Abhishek Singh716c46c2016-05-04 16:24:07 +053014897 QDF_STATUS ret;
Govind Singhe7f2f342016-05-23 12:12:52 +053014898
Kiran Venkatappa26117052016-12-23 19:58:54 +053014899 len = sizeof(*cmd) + sizeof(wmi_resource_config) +
14900 WMI_TLV_HDR_SIZE;
Govind Singhe7f2f342016-05-23 12:12:52 +053014901 mem_chunk_len = (sizeof(wlan_host_memory_chunk) * MAX_MEM_CHUNKS);
Kiran Venkatappa26117052016-12-23 19:58:54 +053014902
14903 if (param->hw_mode_id != WMI_HOST_HW_MODE_MAX)
14904 hw_mode_len = sizeof(wmi_pdev_set_hw_mode_cmd_fixed_param) +
14905 WMI_TLV_HDR_SIZE +
14906 (param->num_band_to_mac * sizeof(wmi_pdev_band_to_mac));
14907
14908 buf = wmi_buf_alloc(wmi_handle, len + mem_chunk_len + hw_mode_len);
Govind Singhe7f2f342016-05-23 12:12:52 +053014909 if (!buf) {
14910 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
14911 return QDF_STATUS_E_FAILURE;
14912 }
14913
14914 buf_ptr = (uint8_t *) wmi_buf_data(buf);
14915 cmd = (wmi_init_cmd_fixed_param *) buf_ptr;
14916 resource_cfg = (wmi_resource_config *) (buf_ptr + sizeof(*cmd));
14917
14918 host_mem_chunks = (wlan_host_memory_chunk *)
14919 (buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)
14920 + WMI_TLV_HDR_SIZE);
14921
14922 WMITLV_SET_HDR(&cmd->tlv_header,
14923 WMITLV_TAG_STRUC_wmi_init_cmd_fixed_param,
14924 WMITLV_GET_STRUCT_TLVLEN(wmi_init_cmd_fixed_param));
14925
Kiran Venkatappa26117052016-12-23 19:58:54 +053014926 wmi_copy_resource_config(resource_cfg, param->res_cfg);
Govind Singhe7f2f342016-05-23 12:12:52 +053014927 WMITLV_SET_HDR(&resource_cfg->tlv_header,
14928 WMITLV_TAG_STRUC_wmi_resource_config,
14929 WMITLV_GET_STRUCT_TLVLEN(wmi_resource_config));
14930
Kiran Venkatappa26117052016-12-23 19:58:54 +053014931 for (idx = 0; idx < param->num_mem_chunks; ++idx) {
Govind Singhe7f2f342016-05-23 12:12:52 +053014932 WMITLV_SET_HDR(&(host_mem_chunks[idx].tlv_header),
14933 WMITLV_TAG_STRUC_wlan_host_memory_chunk,
14934 WMITLV_GET_STRUCT_TLVLEN
14935 (wlan_host_memory_chunk));
Kiran Venkatappa26117052016-12-23 19:58:54 +053014936 host_mem_chunks[idx].ptr = param->mem_chunks[idx].paddr;
14937 host_mem_chunks[idx].size = param->mem_chunks[idx].len;
14938 host_mem_chunks[idx].req_id = param->mem_chunks[idx].req_id;
Govind Singhe7f2f342016-05-23 12:12:52 +053014939 qdf_print("chunk %d len %d requested ,ptr 0x%x ",
14940 idx, host_mem_chunks[idx].size,
14941 host_mem_chunks[idx].ptr);
14942 }
Kiran Venkatappa26117052016-12-23 19:58:54 +053014943 cmd->num_host_mem_chunks = param->num_mem_chunks;
14944 len += (param->num_mem_chunks * sizeof(wlan_host_memory_chunk));
14945
Govind Singhe7f2f342016-05-23 12:12:52 +053014946 WMITLV_SET_HDR((buf_ptr + sizeof(*cmd) + sizeof(wmi_resource_config)),
14947 WMITLV_TAG_ARRAY_STRUC,
14948 (sizeof(wlan_host_memory_chunk) *
Kiran Venkatappa26117052016-12-23 19:58:54 +053014949 param->num_mem_chunks));
14950
14951 /* Fill hw mode id config */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053014952 buf_ptr = copy_hw_mode_in_init_cmd(wmi_handle, buf_ptr, &len, param);
Govind Singhe7f2f342016-05-23 12:12:52 +053014953
14954 num_whitelist = sizeof(version_whitelist) /
14955 sizeof(wmi_whitelist_version_info);
14956 my_vers.abi_version_0 = WMI_ABI_VERSION_0;
14957 my_vers.abi_version_1 = WMI_ABI_VERSION_1;
14958 my_vers.abi_version_ns_0 = WMI_ABI_VERSION_NS_0;
14959 my_vers.abi_version_ns_1 = WMI_ABI_VERSION_NS_1;
14960 my_vers.abi_version_ns_2 = WMI_ABI_VERSION_NS_2;
14961 my_vers.abi_version_ns_3 = WMI_ABI_VERSION_NS_3;
14962
Govind Singh87542482016-06-08 19:40:11 +053014963#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014964 wmi_cmp_and_set_abi_version(num_whitelist, version_whitelist,
14965 &my_vers,
14966 (struct _wmi_abi_version *)&wmi_handle->fw_abi_version,
14967 &cmd->host_abi_vers);
Govind Singh87542482016-06-08 19:40:11 +053014968#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053014969 qdf_print("%s: INIT_CMD version: %d, %d, 0x%x, 0x%x, 0x%x, 0x%x",
14970 __func__,
14971 WMI_VER_GET_MAJOR(cmd->host_abi_vers.abi_version_0),
14972 WMI_VER_GET_MINOR(cmd->host_abi_vers.abi_version_0),
14973 cmd->host_abi_vers.abi_version_ns_0,
14974 cmd->host_abi_vers.abi_version_ns_1,
14975 cmd->host_abi_vers.abi_version_ns_2,
14976 cmd->host_abi_vers.abi_version_ns_3);
14977
14978 /* Save version sent from host -
14979 * Will be used to check ready event
14980 */
Govind Singh87542482016-06-08 19:40:11 +053014981#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053014982 qdf_mem_copy(&wmi_handle->final_abi_vers, &cmd->host_abi_vers,
14983 sizeof(wmi_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053014984#endif
Abhishek Singh716c46c2016-05-04 16:24:07 +053014985 ret = wmi_unified_cmd_send(wmi_handle, buf, len, WMI_INIT_CMDID);
14986 if (QDF_IS_STATUS_ERROR(ret)) {
14987 WMI_LOGE("wmi_unified_cmd_send WMI_INIT_CMDID returned Error %d",
14988 ret);
14989 wmi_buf_free(buf);
14990 }
14991 return ret;
14992
Govind Singhe7f2f342016-05-23 12:12:52 +053014993}
14994
14995/**
14996 * save_service_bitmap_tlv() - save service bitmap
14997 * @wmi_handle: wmi handle
14998 * @param evt_buf: pointer to event buffer
Rajeev Kumar77901472017-02-12 02:12:17 -080014999 * @param bitmap_buf: bitmap buffer, for converged legacy support
Govind Singhe7f2f342016-05-23 12:12:52 +053015000 *
15001 * Return: None
15002 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015003#ifndef CONFIG_MCL
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015004static
Rajeev Kumar77901472017-02-12 02:12:17 -080015005void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15006 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015007{
15008 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15009 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15010
15011 qdf_mem_copy(wmi_handle->wmi_service_bitmap,
15012 param_buf->wmi_service_bitmap,
15013 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Rajeev Kumar77901472017-02-12 02:12:17 -080015014
15015 if (bitmap_buf)
15016 qdf_mem_copy(bitmap_buf,
15017 param_buf->wmi_service_bitmap,
15018 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
Govind Singhe7f2f342016-05-23 12:12:52 +053015019}
15020#else
Jeff Johnson9366d7a2016-10-07 13:03:02 -070015021static
Rajeev Kumar77901472017-02-12 02:12:17 -080015022void save_service_bitmap_tlv(wmi_unified_t wmi_handle, void *evt_buf,
15023 void *bitmap_buf)
Govind Singhe7f2f342016-05-23 12:12:52 +053015024{
Rajeev Kumar77901472017-02-12 02:12:17 -080015025 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15026 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
Govind Singhe7f2f342016-05-23 12:12:52 +053015027
Rajeev Kumar77901472017-02-12 02:12:17 -080015028 if (bitmap_buf)
15029 qdf_mem_copy(bitmap_buf,
15030 param_buf->wmi_service_bitmap,
15031 (WMI_SERVICE_BM_SIZE * sizeof(uint32_t)));
15032}
Govind Singhe7f2f342016-05-23 12:12:52 +053015033#endif
15034
15035/**
15036 * is_service_enabled_tlv() - Check if service enabled
15037 * @param wmi_handle: wmi handle
15038 * @param service_id: service identifier
15039 *
15040 * Return: 1 enabled, 0 disabled
15041 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053015042#ifndef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015043static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15044 uint32_t service_id)
15045{
15046 return WMI_SERVICE_IS_ENABLED(wmi_handle->wmi_service_bitmap,
15047 service_id);
15048}
15049#else
15050static bool is_service_enabled_tlv(wmi_unified_t wmi_handle,
15051 uint32_t service_id)
15052{
15053 return false;
15054}
15055#endif
15056
15057/**
15058 * extract_service_ready_tlv() - extract service ready event
15059 * @wmi_handle: wmi handle
15060 * @param evt_buf: pointer to received event buffer
15061 * @param cap: pointer to hold target capability information extracted from even
15062 *
15063 * Return: QDF_STATUS_SUCCESS for success or error code
15064 */
15065static QDF_STATUS extract_service_ready_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015066 void *evt_buf, struct wlan_psoc_target_capability_info *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015067{
15068 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15069 wmi_service_ready_event_fixed_param *ev;
15070
15071
15072 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15073
15074 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15075 if (!ev) {
15076 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15077 return QDF_STATUS_E_FAILURE;
15078 }
15079
15080 cap->phy_capability = ev->phy_capability;
15081 cap->max_frag_entry = ev->max_frag_entry;
15082 cap->num_rf_chains = ev->num_rf_chains;
15083 cap->ht_cap_info = ev->ht_cap_info;
15084 cap->vht_cap_info = ev->vht_cap_info;
15085 cap->vht_supp_mcs = ev->vht_supp_mcs;
15086 cap->hw_min_tx_power = ev->hw_min_tx_power;
15087 cap->hw_max_tx_power = ev->hw_max_tx_power;
15088 cap->sys_cap_info = ev->sys_cap_info;
15089 cap->min_pkt_size_enable = ev->min_pkt_size_enable;
15090 cap->max_bcn_ie_size = ev->max_bcn_ie_size;
15091 cap->max_num_scan_channels = ev->max_num_scan_channels;
15092 cap->max_supported_macs = ev->max_supported_macs;
15093 cap->wmi_fw_sub_feat_caps = ev->wmi_fw_sub_feat_caps;
15094 cap->txrx_chainmask = ev->txrx_chainmask;
15095 cap->default_dbs_hw_mode_index = ev->default_dbs_hw_mode_index;
15096 cap->num_msdu_desc = ev->num_msdu_desc;
15097
15098 return QDF_STATUS_SUCCESS;
15099}
15100
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015101/* convert_wireless_modes_tlv() - Convert REGDMN_MODE values sent by target
15102 * to host internal WMI_HOST_REGDMN_MODE values.
15103 * REGULATORY TODO : REGDMN_MODE_11AC_VHT*_2G values are not used by the
15104 * host currently. Add this in the future if required.
15105 * 11AX (Phase II) : 11ax related values are not currently
15106 * advertised separately by FW. As part of phase II regulatory bring-up,
15107 * finalize the advertisement mechanism.
15108 * @target_wireless_mode: target wireless mode received in message
15109 *
15110 * Return: returns the host internal wireless mode.
15111 */
15112static inline uint32_t convert_wireless_modes_tlv(uint32_t target_wireless_mode)
15113{
15114
15115 uint32_t wireless_modes = 0;
15116
15117 if (target_wireless_mode & REGDMN_MODE_11A)
15118 wireless_modes |= WMI_HOST_REGDMN_MODE_11A;
15119
15120 if (target_wireless_mode & REGDMN_MODE_TURBO)
15121 wireless_modes |= WMI_HOST_REGDMN_MODE_TURBO;
15122
15123 if (target_wireless_mode & REGDMN_MODE_11B)
15124 wireless_modes |= WMI_HOST_REGDMN_MODE_11B;
15125
15126 if (target_wireless_mode & REGDMN_MODE_PUREG)
15127 wireless_modes |= WMI_HOST_REGDMN_MODE_PUREG;
15128
15129 if (target_wireless_mode & REGDMN_MODE_11G)
15130 wireless_modes |= WMI_HOST_REGDMN_MODE_11G;
15131
15132 if (target_wireless_mode & REGDMN_MODE_108G)
15133 wireless_modes |= WMI_HOST_REGDMN_MODE_108G;
15134
15135 if (target_wireless_mode & REGDMN_MODE_108A)
15136 wireless_modes |= WMI_HOST_REGDMN_MODE_108A;
15137
15138 if (target_wireless_mode & REGDMN_MODE_XR)
15139 wireless_modes |= WMI_HOST_REGDMN_MODE_XR;
15140
15141 if (target_wireless_mode & REGDMN_MODE_11A_HALF_RATE)
15142 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_HALF_RATE;
15143
15144 if (target_wireless_mode & REGDMN_MODE_11A_QUARTER_RATE)
15145 wireless_modes |= WMI_HOST_REGDMN_MODE_11A_QUARTER_RATE;
15146
15147 if (target_wireless_mode & REGDMN_MODE_11NG_HT20)
15148 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT20;
15149
15150 if (target_wireless_mode & REGDMN_MODE_11NA_HT20)
15151 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT20;
15152
15153 if (target_wireless_mode & REGDMN_MODE_11NG_HT40PLUS)
15154 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40PLUS;
15155
15156 if (target_wireless_mode & REGDMN_MODE_11NG_HT40MINUS)
15157 wireless_modes |= WMI_HOST_REGDMN_MODE_11NG_HT40MINUS;
15158
15159 if (target_wireless_mode & REGDMN_MODE_11NA_HT40PLUS)
15160 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40PLUS;
15161
15162 if (target_wireless_mode & REGDMN_MODE_11NA_HT40MINUS)
15163 wireless_modes |= WMI_HOST_REGDMN_MODE_11NA_HT40MINUS;
15164
15165 if (target_wireless_mode & REGDMN_MODE_11AC_VHT20)
15166 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT20;
15167
15168 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40PLUS)
15169 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40PLUS;
15170
15171 if (target_wireless_mode & REGDMN_MODE_11AC_VHT40MINUS)
15172 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT40MINUS;
15173
15174 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80)
15175 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80;
15176
15177 if (target_wireless_mode & REGDMN_MODE_11AC_VHT160)
15178 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT160;
15179
15180 if (target_wireless_mode & REGDMN_MODE_11AC_VHT80_80)
15181 wireless_modes |= WMI_HOST_REGDMN_MODE_11AC_VHT80_80;
15182
15183 return wireless_modes;
15184}
15185
Govind Singhe7f2f342016-05-23 12:12:52 +053015186/**
15187 * extract_hal_reg_cap_tlv() - extract HAL registered capabilities
15188 * @wmi_handle: wmi handle
15189 * @param evt_buf: Pointer to event buffer
15190 * @param cap: pointer to hold HAL reg capabilities
15191 *
15192 * Return: QDF_STATUS_SUCCESS for success or error code
15193 */
15194static QDF_STATUS extract_hal_reg_cap_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080015195 void *evt_buf, struct wlan_psoc_hal_reg_capability *cap)
Govind Singhe7f2f342016-05-23 12:12:52 +053015196{
15197 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15198
15199 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15200
15201 qdf_mem_copy(cap, (((uint8_t *)param_buf->hal_reg_capabilities) +
15202 sizeof(uint32_t)),
Rajeev Kumar037799b2017-02-03 00:39:49 -080015203 sizeof(struct wlan_psoc_hal_reg_capability));
Govind Singhe7f2f342016-05-23 12:12:52 +053015204
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053015205 cap->wireless_modes = convert_wireless_modes_tlv(
15206 param_buf->hal_reg_capabilities->wireless_modes);
Pratik Gandhi33bb7142017-01-05 19:38:41 +053015207
Govind Singhe7f2f342016-05-23 12:12:52 +053015208 return QDF_STATUS_SUCCESS;
15209}
15210
15211/**
15212 * extract_host_mem_req_tlv() - Extract host memory request event
15213 * @wmi_handle: wmi handle
15214 * @param evt_buf: pointer to event buffer
15215 * @param num_entries: pointer to hold number of entries requested
15216 *
15217 * Return: Number of entries requested
15218 */
15219static host_mem_req *extract_host_mem_req_tlv(wmi_unified_t wmi_handle,
15220 void *evt_buf, uint8_t *num_entries)
15221{
15222 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15223 wmi_service_ready_event_fixed_param *ev;
15224
15225 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15226
15227 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15228 if (!ev) {
15229 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15230 return NULL;
15231 }
15232
15233 *num_entries = ev->num_mem_reqs;
15234
15235 return (host_mem_req *)param_buf->mem_reqs;
15236}
15237
15238/**
15239 * save_fw_version_in_service_ready_tlv() - Save fw version in service
15240 * ready function
15241 * @wmi_handle: wmi handle
15242 * @param evt_buf: pointer to event buffer
15243 *
15244 * Return: QDF_STATUS_SUCCESS for success or error code
15245 */
15246static QDF_STATUS
15247save_fw_version_in_service_ready_tlv(wmi_unified_t wmi_handle, void *evt_buf)
15248{
15249 WMI_SERVICE_READY_EVENTID_param_tlvs *param_buf;
15250 wmi_service_ready_event_fixed_param *ev;
15251
15252
15253 param_buf = (WMI_SERVICE_READY_EVENTID_param_tlvs *) evt_buf;
15254
15255 ev = (wmi_service_ready_event_fixed_param *) param_buf->fixed_param;
15256 if (!ev) {
15257 qdf_print("%s: wmi_buf_alloc failed\n", __func__);
15258 return QDF_STATUS_E_FAILURE;
15259 }
15260
Govind Singh87542482016-06-08 19:40:11 +053015261#ifdef CONFIG_MCL
Govind Singhe7f2f342016-05-23 12:12:52 +053015262 /*Save fw version from service ready message */
15263 /*This will be used while sending INIT message */
15264 qdf_mem_copy(&wmi_handle->fw_abi_version, &ev->fw_abi_vers,
15265 sizeof(wmi_handle->fw_abi_version));
Govind Singh87542482016-06-08 19:40:11 +053015266#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053015267 return QDF_STATUS_SUCCESS;
15268}
15269
15270/**
15271 * ready_extract_init_status_tlv() - Extract init status from ready event
15272 * @wmi_handle: wmi handle
15273 * @param evt_buf: Pointer to event buffer
15274 *
15275 * Return: ready status
15276 */
15277static uint32_t ready_extract_init_status_tlv(wmi_unified_t wmi_handle,
15278 void *evt_buf)
15279{
15280 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15281 wmi_ready_event_fixed_param *ev = NULL;
15282
15283
15284 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15285 ev = param_buf->fixed_param;
15286
15287 qdf_print("%s:%d\n", __func__, ev->status);
15288
15289 return ev->status;
15290}
15291
15292/**
15293 * ready_extract_mac_addr_tlv() - extract mac address from ready event
15294 * @wmi_handle: wmi handle
15295 * @param evt_buf: pointer to event buffer
15296 * @param macaddr: Pointer to hold MAC address
15297 *
15298 * Return: QDF_STATUS_SUCCESS for success or error code
15299 */
15300static QDF_STATUS ready_extract_mac_addr_tlv(wmi_unified_t wmi_hamdle,
15301 void *evt_buf, uint8_t *macaddr)
15302{
15303 WMI_READY_EVENTID_param_tlvs *param_buf = NULL;
15304 wmi_ready_event_fixed_param *ev = NULL;
15305
15306
15307 param_buf = (WMI_READY_EVENTID_param_tlvs *) evt_buf;
15308 ev = param_buf->fixed_param;
15309
15310 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->mac_addr, macaddr);
15311
15312 return QDF_STATUS_SUCCESS;
15313}
15314
15315/**
15316 * extract_dbglog_data_len_tlv() - extract debuglog data length
15317 * @wmi_handle: wmi handle
15318 * @param evt_buf: pointer to event buffer
15319 *
15320 * Return: length
15321 */
15322static uint8_t *extract_dbglog_data_len_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar029b9ea2017-01-25 12:46:21 -080015323 void *evt_buf, uint32_t *len)
Govind Singhe7f2f342016-05-23 12:12:52 +053015324{
15325 WMI_DEBUG_MESG_EVENTID_param_tlvs *param_buf;
15326
15327 param_buf = (WMI_DEBUG_MESG_EVENTID_param_tlvs *) evt_buf;
15328
15329 *len = param_buf->num_bufp;
15330
15331 return param_buf->bufp;
15332}
15333
15334/**
15335 * extract_vdev_start_resp_tlv() - extract vdev start response
15336 * @wmi_handle: wmi handle
15337 * @param evt_buf: pointer to event buffer
15338 * @param vdev_rsp: Pointer to hold vdev response
15339 *
15340 * Return: QDF_STATUS_SUCCESS for success or error code
15341 */
15342static QDF_STATUS extract_vdev_start_resp_tlv(wmi_unified_t wmi_handle,
15343 void *evt_buf, wmi_host_vdev_start_resp *vdev_rsp)
15344{
15345 WMI_VDEV_START_RESP_EVENTID_param_tlvs *param_buf;
15346 wmi_vdev_start_response_event_fixed_param *ev;
15347
15348 param_buf = (WMI_VDEV_START_RESP_EVENTID_param_tlvs *) evt_buf;
15349 if (!param_buf) {
15350 qdf_print("Invalid start response event buffer\n");
15351 return QDF_STATUS_E_INVAL;
15352 }
15353
15354 ev = param_buf->fixed_param;
15355 if (!ev) {
15356 qdf_print("Invalid start response event buffer\n");
15357 return QDF_STATUS_E_INVAL;
15358 }
15359
15360 qdf_mem_zero(vdev_rsp, sizeof(*vdev_rsp));
15361
15362 vdev_rsp->vdev_id = ev->vdev_id;
15363 vdev_rsp->requestor_id = ev->requestor_id;
15364 vdev_rsp->resp_type = ev->resp_type;
15365 vdev_rsp->status = ev->status;
15366 vdev_rsp->chain_mask = ev->chain_mask;
15367 vdev_rsp->smps_mode = ev->smps_mode;
15368 vdev_rsp->mac_id = ev->mac_id;
15369 vdev_rsp->cfgd_tx_streams = ev->cfgd_tx_streams;
15370 vdev_rsp->cfgd_rx_streams = ev->cfgd_rx_streams;
15371
15372 return QDF_STATUS_SUCCESS;
15373}
15374
15375/**
15376 * extract_tbttoffset_update_params_tlv() - extract tbtt offset update param
15377 * @wmi_handle: wmi handle
15378 * @param evt_buf: pointer to event buffer
15379 * @param vdev_map: Pointer to hold vdev map
15380 * @param tbttoffset_list: Pointer to tbtt offset list
15381 *
15382 * Return: QDF_STATUS_SUCCESS for success or error code
15383 */
15384static QDF_STATUS extract_tbttoffset_update_params_tlv(void *wmi_hdl,
15385 void *evt_buf, uint32_t *vdev_map, uint32_t **tbttoffset_list)
15386{
15387 WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *param_buf;
15388 wmi_tbtt_offset_event_fixed_param *tbtt_offset_event;
15389
15390 param_buf = (WMI_TBTTOFFSET_UPDATE_EVENTID_param_tlvs *) evt_buf;
15391 if (!param_buf) {
15392 qdf_print("Invalid tbtt update event buffer\n");
15393 return QDF_STATUS_E_INVAL;
15394 }
15395 tbtt_offset_event = param_buf->fixed_param;
15396
15397 *vdev_map = tbtt_offset_event->vdev_map;
15398 *tbttoffset_list = param_buf->tbttoffset_list;
15399
15400 return QDF_STATUS_SUCCESS;
15401}
15402
15403/**
15404 * extract_mgmt_rx_params_tlv() - extract management rx params from event
15405 * @wmi_handle: wmi handle
15406 * @param evt_buf: pointer to event buffer
15407 * @param hdr: Pointer to hold header
15408 * @param bufp: Pointer to hold pointer to rx param buffer
15409 *
15410 * Return: QDF_STATUS_SUCCESS for success or error code
15411 */
15412static QDF_STATUS extract_mgmt_rx_params_tlv(wmi_unified_t wmi_handle,
Himanshu Agarwalb4992a42017-01-05 14:23:18 +053015413 void *evt_buf, struct mgmt_rx_event_params *hdr,
15414 uint8_t **bufp)
Govind Singhe7f2f342016-05-23 12:12:52 +053015415{
15416 WMI_MGMT_RX_EVENTID_param_tlvs *param_tlvs = NULL;
15417 wmi_mgmt_rx_hdr *ev_hdr = NULL;
15418
15419 param_tlvs = (WMI_MGMT_RX_EVENTID_param_tlvs *) evt_buf;
15420 if (!param_tlvs) {
15421 WMI_LOGE("Get NULL point message from FW");
15422 return QDF_STATUS_E_INVAL;
15423 }
15424
15425 ev_hdr = param_tlvs->hdr;
15426 if (!hdr) {
15427 WMI_LOGE("Rx event is NULL");
15428 return QDF_STATUS_E_INVAL;
15429 }
15430
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015431 hdr->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15432 ev_hdr->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053015433
15434 hdr->channel = ev_hdr->channel;
15435 hdr->snr = ev_hdr->snr;
15436 hdr->rate = ev_hdr->rate;
15437 hdr->phy_mode = ev_hdr->phy_mode;
15438 hdr->buf_len = ev_hdr->buf_len;
15439 hdr->status = ev_hdr->status;
15440 hdr->flags = ev_hdr->flags;
15441 hdr->rssi = ev_hdr->rssi;
15442 hdr->tsf_delta = ev_hdr->tsf_delta;
15443 qdf_mem_copy(hdr->rssi_ctl, ev_hdr->rssi_ctl, sizeof(hdr->rssi_ctl));
15444
15445 *bufp = param_tlvs->bufp;
15446
15447 return QDF_STATUS_SUCCESS;
15448}
15449
15450/**
15451 * extract_vdev_stopped_param_tlv() - extract vdev stop param from event
15452 * @wmi_handle: wmi handle
15453 * @param evt_buf: pointer to event buffer
15454 * @param vdev_id: Pointer to hold vdev identifier
15455 *
15456 * Return: QDF_STATUS_SUCCESS for success or error code
15457 */
15458static QDF_STATUS extract_vdev_stopped_param_tlv(wmi_unified_t wmi_handle,
15459 void *evt_buf, uint32_t *vdev_id)
15460{
15461 WMI_VDEV_STOPPED_EVENTID_param_tlvs *param_buf;
15462 wmi_vdev_stopped_event_fixed_param *resp_event;
15463
15464 param_buf = (WMI_VDEV_STOPPED_EVENTID_param_tlvs *) evt_buf;
15465 if (!param_buf) {
15466 WMI_LOGE("Invalid event buffer");
15467 return QDF_STATUS_E_INVAL;
15468 }
15469 resp_event = param_buf->fixed_param;
15470 *vdev_id = resp_event->vdev_id;
15471
15472 return QDF_STATUS_SUCCESS;
15473}
15474
15475/**
15476 * extract_vdev_roam_param_tlv() - extract vdev roam param from event
15477 * @wmi_handle: wmi handle
15478 * @param evt_buf: pointer to event buffer
15479 * @param param: Pointer to hold roam param
15480 *
15481 * Return: QDF_STATUS_SUCCESS for success or error code
15482 */
15483static QDF_STATUS extract_vdev_roam_param_tlv(wmi_unified_t wmi_handle,
15484 void *evt_buf, wmi_host_roam_event *param)
15485{
15486 WMI_ROAM_EVENTID_param_tlvs *param_buf;
15487 wmi_roam_event_fixed_param *evt;
15488
15489 param_buf = (WMI_ROAM_EVENTID_param_tlvs *) evt_buf;
15490 if (!param_buf) {
15491 WMI_LOGE("Invalid roam event buffer");
15492 return QDF_STATUS_E_INVAL;
15493 }
15494
15495 evt = param_buf->fixed_param;
15496 qdf_mem_zero(param, sizeof(*param));
15497
15498 param->vdev_id = evt->vdev_id;
15499 param->reason = evt->reason;
15500 param->rssi = evt->rssi;
15501
15502 return QDF_STATUS_SUCCESS;
15503}
15504
15505/**
15506 * extract_vdev_scan_ev_param_tlv() - extract vdev scan param from event
15507 * @wmi_handle: wmi handle
15508 * @param evt_buf: pointer to event buffer
15509 * @param param: Pointer to hold vdev scan param
15510 *
15511 * Return: QDF_STATUS_SUCCESS for success or error code
15512 */
15513static QDF_STATUS extract_vdev_scan_ev_param_tlv(wmi_unified_t wmi_handle,
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015514 void *evt_buf, struct scan_event *param)
Govind Singhe7f2f342016-05-23 12:12:52 +053015515{
15516 WMI_SCAN_EVENTID_param_tlvs *param_buf = NULL;
15517 wmi_scan_event_fixed_param *evt = NULL;
15518
15519 param_buf = (WMI_SCAN_EVENTID_param_tlvs *) evt_buf;
15520 evt = param_buf->fixed_param;
15521
15522 qdf_mem_zero(param, sizeof(*param));
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015523
Govind Singhe7f2f342016-05-23 12:12:52 +053015524 switch (evt->event) {
15525 case WMI_SCAN_EVENT_STARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015526 param->type = SCAN_EVENT_TYPE_STARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015527 break;
15528 case WMI_SCAN_EVENT_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015529 param->type = SCAN_EVENT_TYPE_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015530 break;
15531 case WMI_SCAN_EVENT_BSS_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015532 param->type = SCAN_EVENT_TYPE_BSS_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015533 break;
15534 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015535 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL;
Govind Singhe7f2f342016-05-23 12:12:52 +053015536 break;
15537 case WMI_SCAN_EVENT_DEQUEUED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015538 param->type = SCAN_EVENT_TYPE_DEQUEUED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015539 break;
15540 case WMI_SCAN_EVENT_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015541 param->type = SCAN_EVENT_TYPE_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015542 break;
15543 case WMI_SCAN_EVENT_START_FAILED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015544 param->type = SCAN_EVENT_TYPE_START_FAILED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015545 break;
15546 case WMI_SCAN_EVENT_RESTARTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015547 param->type = SCAN_EVENT_TYPE_RESTARTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015548 break;
15549 case WMI_HOST_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015550 param->type = SCAN_EVENT_TYPE_FOREIGN_CHANNEL_EXIT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015551 break;
15552 case WMI_SCAN_EVENT_MAX:
15553 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015554 param->type = SCAN_EVENT_TYPE_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015555 break;
15556 };
15557
15558 switch (evt->reason) {
15559 case WMI_SCAN_REASON_NONE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015560 param->reason = SCAN_REASON_NONE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015561 break;
15562 case WMI_SCAN_REASON_COMPLETED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015563 param->reason = SCAN_REASON_COMPLETED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015564 break;
15565 case WMI_SCAN_REASON_CANCELLED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015566 param->reason = SCAN_REASON_CANCELLED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015567 break;
15568 case WMI_SCAN_REASON_PREEMPTED:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015569 param->reason = SCAN_REASON_PREEMPTED;
Govind Singhe7f2f342016-05-23 12:12:52 +053015570 break;
15571 case WMI_SCAN_REASON_TIMEDOUT:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015572 param->reason = SCAN_REASON_TIMEDOUT;
Govind Singhe7f2f342016-05-23 12:12:52 +053015573 break;
15574 case WMI_SCAN_REASON_INTERNAL_FAILURE:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015575 param->reason = SCAN_REASON_INTERNAL_FAILURE;
Govind Singhe7f2f342016-05-23 12:12:52 +053015576 break;
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015577 case WMI_SCAN_REASON_SUSPENDED:
15578 param->reason = SCAN_REASON_SUSPENDED;
15579 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015580 case WMI_SCAN_REASON_MAX:
Anish Nataraj78b8ccd2017-03-20 12:57:55 +053015581 param->reason = SCAN_REASON_MAX;
15582 break;
Govind Singhe7f2f342016-05-23 12:12:52 +053015583 default:
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015584 param->reason = SCAN_REASON_MAX;
Govind Singhe7f2f342016-05-23 12:12:52 +053015585 break;
15586 };
15587
Om Prakash Tripathi1d83e352017-02-25 15:53:30 +053015588 param->chan_freq = evt->channel_freq;
15589 param->requester = evt->requestor;
Govind Singhe7f2f342016-05-23 12:12:52 +053015590 param->scan_id = evt->scan_id;
15591 param->vdev_id = evt->vdev_id;
15592
15593 return QDF_STATUS_SUCCESS;
15594}
15595
Frank Liu3d5e9992017-03-15 17:51:43 +080015596#ifdef CONVERGED_TDLS_ENABLE
15597/**
15598 * extract_vdev_tdls_ev_param_tlv() - extract vdev tdls param from event
15599 * @wmi_handle: wmi handle
15600 * @param evt_buf: pointer to event buffer
15601 * @param param: Pointer to hold vdev tdls param
15602 *
15603 * Return: QDF_STATUS_SUCCESS for success or error code
15604 */
15605static QDF_STATUS extract_vdev_tdls_ev_param_tlv(wmi_unified_t wmi_handle,
15606 void *evt_buf, struct tdls_event_info *param)
15607{
15608 WMI_TDLS_PEER_EVENTID_param_tlvs *param_buf;
15609 wmi_tdls_peer_event_fixed_param *evt;
15610
15611 param_buf = (WMI_TDLS_PEER_EVENTID_param_tlvs *)evt_buf;
15612 if (!param_buf) {
15613 WMI_LOGE("%s: NULL param_buf", __func__);
15614 return QDF_STATUS_E_NULL_VALUE;
15615 }
15616
15617 evt = param_buf->fixed_param;
15618
15619 qdf_mem_zero(param, sizeof(*param));
15620
15621 param->vdev_id = evt->vdev_id;
15622 WMI_MAC_ADDR_TO_CHAR_ARRAY(&evt->peer_macaddr,
15623 param->peermac.bytes);
15624 switch (evt->peer_status) {
15625 case WMI_TDLS_SHOULD_DISCOVER:
15626 param->message_type = TDLS_SHOULD_DISCOVER;
15627 break;
15628 case WMI_TDLS_SHOULD_TEARDOWN:
15629 param->message_type = TDLS_SHOULD_TEARDOWN;
15630 break;
15631 case WMI_TDLS_PEER_DISCONNECTED:
15632 param->message_type = TDLS_PEER_DISCONNECTED;
15633 break;
15634 case WMI_TDLS_CONNECTION_TRACKER_NOTIFICATION:
15635 param->message_type = TDLS_CONNECTION_TRACKER_NOTIFY;
15636 break;
15637 default:
15638 WMI_LOGE("%s: Discarding unknown tdls event %d from target",
15639 __func__, evt->peer_status);
15640 return QDF_STATUS_E_INVAL;
15641 };
15642
15643 switch (evt->peer_reason) {
15644 case WMI_TDLS_TEARDOWN_REASON_TX:
15645 param->peer_reason = TDLS_TEARDOWN_TX;
15646 break;
15647 case WMI_TDLS_TEARDOWN_REASON_RSSI:
15648 param->peer_reason = TDLS_TEARDOWN_RSSI;
15649 break;
15650 case WMI_TDLS_TEARDOWN_REASON_SCAN:
15651 param->peer_reason = TDLS_TEARDOWN_SCAN;
15652 break;
15653 case WMI_TDLS_DISCONNECTED_REASON_PEER_DELETE:
15654 param->peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
15655 break;
15656 case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT:
15657 param->peer_reason = TDLS_TEARDOWN_PTR_TIMEOUT;
15658 break;
15659 case WMI_TDLS_TEARDOWN_REASON_BAD_PTR:
15660 param->peer_reason = TDLS_TEARDOWN_BAD_PTR;
15661 break;
15662 case WMI_TDLS_TEARDOWN_REASON_NO_RESPONSE:
15663 param->peer_reason = TDLS_TEARDOWN_NO_RSP;
15664 break;
15665 case WMI_TDLS_ENTER_BUF_STA:
15666 param->peer_reason = TDLS_PEER_ENTER_BUF_STA;
15667 break;
15668 case WMI_TDLS_EXIT_BUF_STA:
15669 param->peer_reason = TDLS_PEER_EXIT_BUF_STA;
15670 break;
15671 case WMI_TDLS_ENTER_BT_BUSY_MODE:
15672 param->peer_reason = TDLS_ENTER_BT_BUSY;
15673 break;
15674 case WMI_TDLS_EXIT_BT_BUSY_MODE:
15675 param->peer_reason = TDLS_EXIT_BT_BUSY;
15676 break;
15677 case WMI_TDLS_SCAN_STARTED_EVENT:
15678 param->peer_reason = TDLS_SCAN_STARTED;
15679 break;
15680 case WMI_TDLS_SCAN_COMPLETED_EVENT:
15681 param->peer_reason = TDLS_SCAN_COMPLETED;
15682 break;
15683
15684 default:
15685 WMI_LOGE("%s: unknown reason %d in tdls event %d from target",
15686 __func__, evt->peer_reason, evt->peer_status);
15687 return QDF_STATUS_E_INVAL;
15688 };
15689
15690 WMI_LOGD("%s: tdls event, peer: %pM, type: 0x%x, reason: %d, vdev: %d",
15691 __func__, param->peermac.bytes, param->message_type,
15692 param->peer_reason, param->vdev_id);
15693
15694 return QDF_STATUS_SUCCESS;
15695}
15696#endif
15697
Govind Singhe7f2f342016-05-23 12:12:52 +053015698/**
15699 * extract_mgmt_tx_compl_param_tlv() - extract MGMT tx completion event params
15700 * @wmi_handle: wmi handle
15701 * @param evt_buf: pointer to event buffer
15702 * @param param: Pointer to hold MGMT TX completion params
15703 *
15704 * Return: QDF_STATUS_SUCCESS for success or error code
15705 */
15706static QDF_STATUS extract_mgmt_tx_compl_param_tlv(wmi_unified_t wmi_handle,
15707 void *evt_buf, wmi_host_mgmt_tx_compl_event *param)
15708{
15709 WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
15710 wmi_mgmt_tx_compl_event_fixed_param *cmpl_params;
15711
15712 param_buf = (WMI_MGMT_TX_COMPLETION_EVENTID_param_tlvs *)
15713 evt_buf;
15714 if (!param_buf) {
15715 WMI_LOGE("%s: Invalid mgmt Tx completion event", __func__);
15716 return QDF_STATUS_E_INVAL;
15717 }
15718 cmpl_params = param_buf->fixed_param;
15719
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015720 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15721 cmpl_params->pdev_id);
Govind Singhe7f2f342016-05-23 12:12:52 +053015722 param->desc_id = cmpl_params->desc_id;
15723 param->status = cmpl_params->status;
15724
15725 return QDF_STATUS_SUCCESS;
15726}
15727
15728/**
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053015729 * extract_offchan_data_tx_compl_param_tlv() -
15730 * extract Offchan data tx completion event params
15731 * @wmi_handle: wmi handle
15732 * @param evt_buf: pointer to event buffer
15733 * @param param: Pointer to hold offchan data TX completion params
15734 *
15735 * Return: QDF_STATUS_SUCCESS for success or error code
15736 */
15737static QDF_STATUS extract_offchan_data_tx_compl_param_tlv(
15738 wmi_unified_t wmi_handle, void *evt_buf,
15739 struct wmi_host_offchan_data_tx_compl_event *param)
15740{
15741 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *param_buf;
15742 wmi_offchan_data_tx_compl_event_fixed_param *cmpl_params;
15743
15744 param_buf = (WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID_param_tlvs *)
15745 evt_buf;
15746 if (!param_buf) {
15747 WMI_LOGE("%s: Invalid offchan data Tx compl event", __func__);
15748 return QDF_STATUS_E_INVAL;
15749 }
15750 cmpl_params = param_buf->fixed_param;
15751
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015752 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15753 cmpl_params->pdev_id);
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053015754 param->desc_id = cmpl_params->desc_id;
15755 param->status = cmpl_params->status;
15756
15757 return QDF_STATUS_SUCCESS;
15758}
15759
15760/**
Sathish Kumar45e991b2017-02-27 10:35:40 +053015761 * extract_pdev_csa_switch_count_status_tlv() - extract pdev csa switch count
15762 * status tlv
15763 * @wmi_handle: wmi handle
15764 * @param evt_buf: pointer to event buffer
15765 * @param param: Pointer to hold csa switch count status event param
15766 *
15767 * Return: QDF_STATUS_SUCCESS for success or error code
15768 */
15769static QDF_STATUS extract_pdev_csa_switch_count_status_tlv(
15770 wmi_unified_t wmi_handle,
15771 void *evt_buf,
15772 struct pdev_csa_switch_count_status *param)
15773{
15774 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *param_buf;
15775 wmi_pdev_csa_switch_count_status_event_fixed_param *csa_status;
15776
15777 param_buf = (WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID_param_tlvs *)
15778 evt_buf;
15779 if (!param_buf) {
15780 WMI_LOGE("%s: Invalid CSA status event\n", __func__);
15781 return QDF_STATUS_E_INVAL;
15782 }
15783
15784 csa_status = param_buf->fixed_param;
15785
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053015786 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
15787 csa_status->pdev_id);
Sathish Kumar45e991b2017-02-27 10:35:40 +053015788 param->current_switch_count = csa_status->current_switch_count;
15789 param->num_vdevs = csa_status->num_vdevs;
15790 param->vdev_ids = param_buf->vdev_ids;
15791
15792 return QDF_STATUS_SUCCESS;
15793}
15794
15795/**
Govind Singhe7f2f342016-05-23 12:12:52 +053015796 * extract_swba_vdev_map_tlv() - extract swba vdev map from event
15797 * @wmi_handle: wmi handle
15798 * @param evt_buf: pointer to event buffer
15799 * @param vdev_map: Pointer to hold vdev map
15800 *
15801 * Return: QDF_STATUS_SUCCESS for success or error code
15802 */
15803static QDF_STATUS extract_swba_vdev_map_tlv(wmi_unified_t wmi_handle,
15804 void *evt_buf, uint32_t *vdev_map)
15805{
15806 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15807 wmi_host_swba_event_fixed_param *swba_event;
15808
15809 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15810 if (!param_buf) {
15811 WMI_LOGE("Invalid swba event buffer");
15812 return QDF_STATUS_E_INVAL;
15813 }
15814 swba_event = param_buf->fixed_param;
15815 *vdev_map = swba_event->vdev_map;
15816
15817 return QDF_STATUS_SUCCESS;
15818}
15819
15820/**
15821 * extract_swba_tim_info_tlv() - extract swba tim info from event
15822 * @wmi_handle: wmi handle
15823 * @param evt_buf: pointer to event buffer
15824 * @param idx: Index to bcn info
15825 * @param tim_info: Pointer to hold tim info
15826 *
15827 * Return: QDF_STATUS_SUCCESS for success or error code
15828 */
15829static QDF_STATUS extract_swba_tim_info_tlv(wmi_unified_t wmi_handle,
15830 void *evt_buf, uint32_t idx, wmi_host_tim_info *tim_info)
15831{
15832 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15833 wmi_tim_info *tim_info_ev;
15834
15835 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15836 if (!param_buf) {
15837 WMI_LOGE("Invalid swba event buffer");
15838 return QDF_STATUS_E_INVAL;
15839 }
15840
15841 tim_info_ev = &param_buf->tim_info[idx];
15842
15843 tim_info->tim_len = tim_info_ev->tim_len;
15844 tim_info->tim_mcast = tim_info_ev->tim_mcast;
15845 qdf_mem_copy(tim_info->tim_bitmap, tim_info_ev->tim_bitmap,
15846 (sizeof(uint32_t) * WMI_TIM_BITMAP_ARRAY_SIZE));
15847 tim_info->tim_changed = tim_info_ev->tim_changed;
15848 tim_info->tim_num_ps_pending = tim_info_ev->tim_num_ps_pending;
15849
15850 return QDF_STATUS_SUCCESS;
15851}
15852
15853/**
15854 * extract_swba_noa_info_tlv() - extract swba NoA information from event
15855 * @wmi_handle: wmi handle
15856 * @param evt_buf: pointer to event buffer
15857 * @param idx: Index to bcn info
15858 * @param p2p_desc: Pointer to hold p2p NoA info
15859 *
15860 * Return: QDF_STATUS_SUCCESS for success or error code
15861 */
15862static QDF_STATUS extract_swba_noa_info_tlv(wmi_unified_t wmi_handle,
15863 void *evt_buf, uint32_t idx, wmi_host_p2p_noa_info *p2p_desc)
15864{
15865 WMI_HOST_SWBA_EVENTID_param_tlvs *param_buf;
15866 wmi_p2p_noa_info *p2p_noa_info;
15867 uint8_t i = 0;
15868
15869 param_buf = (WMI_HOST_SWBA_EVENTID_param_tlvs *) evt_buf;
15870 if (!param_buf) {
15871 WMI_LOGE("Invalid swba event buffer");
15872 return QDF_STATUS_E_INVAL;
15873 }
15874
15875 p2p_noa_info = &param_buf->p2p_noa_info[idx];
15876
15877 p2p_desc->modified = false;
15878 p2p_desc->num_descriptors = 0;
15879 if (WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(p2p_noa_info)) {
15880 p2p_desc->modified = true;
15881 p2p_desc->index =
15882 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(p2p_noa_info);
15883 p2p_desc->oppPS =
15884 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(p2p_noa_info);
15885 p2p_desc->ctwindow =
15886 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(p2p_noa_info);
15887 p2p_desc->num_descriptors =
15888 (uint8_t) WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET
15889 (p2p_noa_info);
15890 for (i = 0; i < p2p_desc->num_descriptors; i++) {
15891 p2p_desc->noa_descriptors[i].type_count =
15892 (uint8_t) p2p_noa_info->noa_descriptors[i].
15893 type_count;
15894 p2p_desc->noa_descriptors[i].duration =
15895 p2p_noa_info->noa_descriptors[i].duration;
15896 p2p_desc->noa_descriptors[i].interval =
15897 p2p_noa_info->noa_descriptors[i].interval;
15898 p2p_desc->noa_descriptors[i].start_time =
15899 p2p_noa_info->noa_descriptors[i].start_time;
15900 }
15901 }
15902
15903 return QDF_STATUS_SUCCESS;
15904}
15905
Wu Gaocd3a8512017-03-13 20:17:34 +080015906#ifdef CONVERGED_P2P_ENABLE
15907/**
15908 * extract_p2p_noa_ev_param_tlv() - extract p2p noa information from event
15909 * @wmi_handle: wmi handle
15910 * @param evt_buf: pointer to event buffer
15911 * @param param: Pointer to hold p2p noa info
15912 *
15913 * Return: QDF_STATUS_SUCCESS for success or error code
15914 */
15915static QDF_STATUS extract_p2p_noa_ev_param_tlv(
15916 wmi_unified_t wmi_handle, void *evt_buf,
15917 struct p2p_noa_info *param)
15918{
15919 WMI_P2P_NOA_EVENTID_param_tlvs *param_tlvs;
15920 wmi_p2p_noa_event_fixed_param *fixed_param;
15921 uint8_t i;
15922 wmi_p2p_noa_info *wmi_noa_info;
15923 uint8_t *buf_ptr;
15924 uint32_t descriptors;
15925
15926 param_tlvs = (WMI_P2P_NOA_EVENTID_param_tlvs *) evt_buf;
15927 if (!param_tlvs) {
15928 WMI_LOGE("%s: Invalid P2P NoA event buffer", __func__);
15929 return QDF_STATUS_E_INVAL;
15930 }
15931
15932 if (!param) {
15933 WMI_LOGE("noa information param is null");
15934 return QDF_STATUS_E_INVAL;
15935 }
15936
15937 fixed_param = param_tlvs->fixed_param;
15938 buf_ptr = (uint8_t *) fixed_param;
15939 buf_ptr += sizeof(wmi_p2p_noa_event_fixed_param);
15940 wmi_noa_info = (wmi_p2p_noa_info *) (buf_ptr);
15941
15942 if (!WMI_UNIFIED_NOA_ATTR_IS_MODIFIED(wmi_noa_info)) {
15943 WMI_LOGE("%s: noa attr is not modified", __func__);
15944 return QDF_STATUS_E_INVAL;
15945 }
15946
15947 param->vdev_id = fixed_param->vdev_id;
15948 param->index =
15949 (uint8_t) WMI_UNIFIED_NOA_ATTR_INDEX_GET(wmi_noa_info);
15950 param->opps_ps =
15951 (uint8_t) WMI_UNIFIED_NOA_ATTR_OPP_PS_GET(wmi_noa_info);
15952 param->ct_window =
15953 (uint8_t) WMI_UNIFIED_NOA_ATTR_CTWIN_GET(wmi_noa_info);
15954 descriptors = WMI_UNIFIED_NOA_ATTR_NUM_DESC_GET(wmi_noa_info);
15955 param->num_desc = (uint8_t) descriptors;
15956
15957 WMI_LOGD("%s:index %u, opps_ps %u, ct_window %u, num_descriptors = %u", __func__,
15958 param->index, param->opps_ps, param->ct_window,
15959 param->num_desc);
15960 for (i = 0; i < param->num_desc; i++) {
15961 param->noa_desc[i].type_count =
15962 (uint8_t) wmi_noa_info->noa_descriptors[i].
15963 type_count;
15964 param->noa_desc[i].duration =
15965 wmi_noa_info->noa_descriptors[i].duration;
15966 param->noa_desc[i].interval =
15967 wmi_noa_info->noa_descriptors[i].interval;
15968 param->noa_desc[i].start_time =
15969 wmi_noa_info->noa_descriptors[i].start_time;
15970 WMI_LOGD("%s:NoA descriptor[%d] type_count %u, duration %u, interval %u, start_time = %u",
15971 __func__, i, param->noa_desc[i].type_count,
15972 param->noa_desc[i].duration,
15973 param->noa_desc[i].interval,
15974 param->noa_desc[i].start_time);
15975 }
15976
15977 return QDF_STATUS_SUCCESS;
15978}
15979
15980/**
15981 * extract_p2p_lo_stop_ev_param_tlv() - extract p2p lo stop
15982 * information from event
15983 * @wmi_handle: wmi handle
15984 * @param evt_buf: pointer to event buffer
15985 * @param param: Pointer to hold p2p lo stop event information
15986 *
15987 * Return: QDF_STATUS_SUCCESS for success or error code
15988 */
15989static QDF_STATUS extract_p2p_lo_stop_ev_param_tlv(
15990 wmi_unified_t wmi_handle, void *evt_buf,
15991 struct p2p_lo_event *param)
15992{
15993 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *param_tlvs;
15994 wmi_p2p_lo_stopped_event_fixed_param *lo_param;
15995
15996 param_tlvs = (WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID_param_tlvs *)
15997 evt_buf;
15998 if (!param_tlvs) {
15999 WMI_LOGE("%s: Invalid P2P lo stop event buffer", __func__);
16000 return QDF_STATUS_E_INVAL;
16001 }
16002
16003 if (!param) {
16004 WMI_LOGE("lo stop event param is null");
16005 return QDF_STATUS_E_INVAL;
16006 }
16007
16008 lo_param = param_tlvs->fixed_param;
16009 param->vdev_id = lo_param->vdev_id;
16010 param->reason_code = lo_param->reason;
16011 WMI_LOGD("%s: vdev_id:%d, reason:%d", __func__,
16012 param->vdev_id, param->reason_code);
16013
16014 return QDF_STATUS_SUCCESS;
16015}
16016#endif /* End of CONVERGED_P2P_ENABLE */
16017
Govind Singhe7f2f342016-05-23 12:12:52 +053016018/**
16019 * extract_peer_sta_kickout_ev_tlv() - extract peer sta kickout event
16020 * @wmi_handle: wmi handle
16021 * @param evt_buf: pointer to event buffer
16022 * @param ev: Pointer to hold peer param
16023 *
16024 * Return: QDF_STATUS_SUCCESS for success or error code
16025 */
16026static QDF_STATUS extract_peer_sta_kickout_ev_tlv(wmi_unified_t wmi_handle,
16027 void *evt_buf, wmi_host_peer_sta_kickout_event *ev)
16028{
16029 WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *param_buf = NULL;
16030 wmi_peer_sta_kickout_event_fixed_param *kickout_event = NULL;
16031
16032 param_buf = (WMI_PEER_STA_KICKOUT_EVENTID_param_tlvs *) evt_buf;
16033 kickout_event = param_buf->fixed_param;
16034
16035 WMI_MAC_ADDR_TO_CHAR_ARRAY(&kickout_event->peer_macaddr,
16036 ev->peer_macaddr);
16037
16038 ev->reason = kickout_event->reason;
16039 ev->rssi = kickout_event->rssi;
16040
16041 return QDF_STATUS_SUCCESS;
16042}
16043
16044/**
16045 * extract_all_stats_counts_tlv() - extract all stats count from event
16046 * @wmi_handle: wmi handle
16047 * @param evt_buf: pointer to event buffer
16048 * @param stats_param: Pointer to hold stats count
16049 *
16050 * Return: QDF_STATUS_SUCCESS for success or error code
16051 */
16052static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
16053 void *evt_buf, wmi_host_stats_event *stats_param)
16054{
16055 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16056 wmi_stats_event_fixed_param *ev;
16057
16058 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16059
16060 ev = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16061 if (!ev) {
16062 WMI_LOGE("%s: Failed to alloc memory\n", __func__);
16063 return QDF_STATUS_E_FAILURE;
16064 }
16065
16066 switch (ev->stats_id) {
16067 case WMI_REQUEST_PEER_STAT:
16068 stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
16069 break;
16070
16071 case WMI_REQUEST_AP_STAT:
16072 stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
16073 break;
16074
16075 case WMI_REQUEST_PDEV_STAT:
16076 stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
16077 break;
16078
16079 case WMI_REQUEST_VDEV_STAT:
16080 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
16081 break;
16082
16083 case WMI_REQUEST_BCNFLT_STAT:
16084 stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
16085 break;
16086
16087 case WMI_REQUEST_VDEV_RATE_STAT:
16088 stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
16089 break;
16090
16091 default:
16092 stats_param->stats_id = 0;
16093 break;
16094
16095 }
16096
16097 stats_param->num_pdev_stats = ev->num_pdev_stats;
16098 stats_param->num_pdev_ext_stats = 0;
16099 stats_param->num_vdev_stats = ev->num_vdev_stats;
16100 stats_param->num_peer_stats = ev->num_peer_stats;
16101 stats_param->num_bcnflt_stats = ev->num_bcnflt_stats;
16102 stats_param->num_chan_stats = ev->num_chan_stats;
16103
16104 return QDF_STATUS_SUCCESS;
16105}
16106
16107/**
16108 * extract_pdev_stats_tlv() - extract pdev stats from event
16109 * @wmi_handle: wmi handle
16110 * @param evt_buf: pointer to event buffer
16111 * @param index: Index into pdev stats
16112 * @param pdev_stats: Pointer to hold pdev stats
16113 *
16114 * Return: QDF_STATUS_SUCCESS for success or error code
16115 */
16116static QDF_STATUS extract_pdev_stats_tlv(wmi_unified_t wmi_handle,
16117 void *evt_buf, uint32_t index, wmi_host_pdev_stats *pdev_stats)
16118{
16119 return QDF_STATUS_SUCCESS;
16120}
16121
16122/**
16123 * extract_pdev_ext_stats_tlv() - extract extended pdev stats from event
16124 * @wmi_handle: wmi handle
16125 * @param evt_buf: pointer to event buffer
16126 * @param index: Index into extended pdev stats
16127 * @param pdev_ext_stats: Pointer to hold extended pdev stats
16128 *
16129 * Return: QDF_STATUS_SUCCESS for success or error code
16130 */
16131static QDF_STATUS extract_pdev_ext_stats_tlv(wmi_unified_t wmi_handle,
16132 void *evt_buf, uint32_t index, wmi_host_pdev_ext_stats *pdev_ext_stats)
16133{
16134 return QDF_STATUS_SUCCESS;
16135}
16136
16137/**
16138 * extract_vdev_stats_tlv() - extract vdev stats from event
16139 * @wmi_handle: wmi handle
16140 * @param evt_buf: pointer to event buffer
16141 * @param index: Index into vdev stats
16142 * @param vdev_stats: Pointer to hold vdev stats
16143 *
16144 * Return: QDF_STATUS_SUCCESS for success or error code
16145 */
16146static QDF_STATUS extract_vdev_stats_tlv(wmi_unified_t wmi_handle,
16147 void *evt_buf, uint32_t index, wmi_host_vdev_stats *vdev_stats)
16148{
16149 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16150 wmi_stats_event_fixed_param *ev_param;
16151 uint8_t *data;
16152
16153 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16154 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16155 data = (uint8_t *) param_buf->data;
16156
16157 if (index < ev_param->num_vdev_stats) {
16158 wmi_vdev_stats *ev = (wmi_vdev_stats *) ((data) +
16159 ((ev_param->num_pdev_stats) *
16160 sizeof(wmi_pdev_stats)) +
16161 (index * sizeof(wmi_vdev_stats)));
16162
16163 vdev_stats->vdev_id = ev->vdev_id;
16164 vdev_stats->vdev_snr.bcn_snr = ev->vdev_snr.bcn_snr;
16165 vdev_stats->vdev_snr.dat_snr = ev->vdev_snr.dat_snr;
16166
16167 OS_MEMCPY(vdev_stats->tx_frm_cnt, ev->tx_frm_cnt,
16168 sizeof(ev->tx_frm_cnt));
16169 vdev_stats->rx_frm_cnt = ev->rx_frm_cnt;
16170 OS_MEMCPY(vdev_stats->multiple_retry_cnt,
16171 ev->multiple_retry_cnt,
16172 sizeof(ev->multiple_retry_cnt));
16173 OS_MEMCPY(vdev_stats->fail_cnt, ev->fail_cnt,
16174 sizeof(ev->fail_cnt));
16175 vdev_stats->rts_fail_cnt = ev->rts_fail_cnt;
16176 vdev_stats->rts_succ_cnt = ev->rts_succ_cnt;
16177 vdev_stats->rx_err_cnt = ev->rx_err_cnt;
16178 vdev_stats->rx_discard_cnt = ev->rx_discard_cnt;
16179 vdev_stats->ack_fail_cnt = ev->ack_fail_cnt;
16180 OS_MEMCPY(vdev_stats->tx_rate_history, ev->tx_rate_history,
16181 sizeof(ev->tx_rate_history));
16182 OS_MEMCPY(vdev_stats->bcn_rssi_history, ev->bcn_rssi_history,
16183 sizeof(ev->bcn_rssi_history));
16184
16185 }
16186
16187 return QDF_STATUS_SUCCESS;
16188}
16189
16190/**
16191 * extract_peer_stats_tlv() - extract peer stats from event
16192 * @wmi_handle: wmi handle
16193 * @param evt_buf: pointer to event buffer
16194 * @param index: Index into peer stats
16195 * @param peer_stats: Pointer to hold peer stats
16196 *
16197 * Return: QDF_STATUS_SUCCESS for success or error code
16198 */
16199static QDF_STATUS extract_peer_stats_tlv(wmi_unified_t wmi_handle,
16200 void *evt_buf, uint32_t index, wmi_host_peer_stats *peer_stats)
16201{
16202 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16203 wmi_stats_event_fixed_param *ev_param;
16204 uint8_t *data;
16205
16206 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16207 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16208 data = (uint8_t *) param_buf->data;
16209
16210 if (index < ev_param->num_peer_stats) {
16211 wmi_peer_stats *ev = (wmi_peer_stats *) ((data) +
16212 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16213 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16214 (index * sizeof(wmi_peer_stats)));
16215
16216 OS_MEMSET(peer_stats, 0, sizeof(wmi_host_peer_stats));
16217
16218 OS_MEMCPY(&(peer_stats->peer_macaddr),
16219 &(ev->peer_macaddr), sizeof(wmi_mac_addr));
16220
16221 peer_stats->peer_rssi = ev->peer_rssi;
16222 peer_stats->peer_tx_rate = ev->peer_tx_rate;
16223 peer_stats->peer_rx_rate = ev->peer_rx_rate;
16224 }
16225
16226 return QDF_STATUS_SUCCESS;
16227}
16228
16229/**
16230 * extract_bcnflt_stats_tlv() - extract bcn fault stats from event
16231 * @wmi_handle: wmi handle
16232 * @param evt_buf: pointer to event buffer
16233 * @param index: Index into bcn fault stats
16234 * @param bcnflt_stats: Pointer to hold bcn fault stats
16235 *
16236 * Return: QDF_STATUS_SUCCESS for success or error code
16237 */
16238static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
16239 void *evt_buf, uint32_t index, wmi_host_bcnflt_stats *peer_stats)
16240{
16241 return QDF_STATUS_SUCCESS;
16242}
16243
16244/**
16245 * extract_peer_extd_stats_tlv() - extract extended peer stats from event
16246 * @wmi_handle: wmi handle
16247 * @param evt_buf: pointer to event buffer
16248 * @param index: Index into extended peer stats
16249 * @param peer_extd_stats: Pointer to hold extended peer stats
16250 *
16251 * Return: QDF_STATUS_SUCCESS for success or error code
16252 */
16253static QDF_STATUS extract_peer_extd_stats_tlv(wmi_unified_t wmi_handle,
16254 void *evt_buf, uint32_t index,
16255 wmi_host_peer_extd_stats *peer_extd_stats)
16256{
16257 return QDF_STATUS_SUCCESS;
16258}
16259
16260/**
16261 * extract_chan_stats_tlv() - extract chan stats from event
16262 * @wmi_handle: wmi handle
16263 * @param evt_buf: pointer to event buffer
16264 * @param index: Index into chan stats
16265 * @param vdev_extd_stats: Pointer to hold chan stats
16266 *
16267 * Return: QDF_STATUS_SUCCESS for success or error code
16268 */
16269static QDF_STATUS extract_chan_stats_tlv(wmi_unified_t wmi_handle,
16270 void *evt_buf, uint32_t index, wmi_host_chan_stats *chan_stats)
16271{
16272 WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
16273 wmi_stats_event_fixed_param *ev_param;
16274 uint8_t *data;
16275
16276 param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *) evt_buf;
16277 ev_param = (wmi_stats_event_fixed_param *) param_buf->fixed_param;
16278 data = (uint8_t *) param_buf->data;
16279
16280 if (index < ev_param->num_chan_stats) {
16281 wmi_chan_stats *ev = (wmi_chan_stats *) ((data) +
16282 ((ev_param->num_pdev_stats) * sizeof(wmi_pdev_stats)) +
16283 ((ev_param->num_vdev_stats) * sizeof(wmi_vdev_stats)) +
16284 ((ev_param->num_peer_stats) * sizeof(wmi_peer_stats)) +
16285 (index * sizeof(wmi_chan_stats)));
16286
16287
16288 /* Non-TLV doesnt have num_chan_stats */
16289 chan_stats->chan_mhz = ev->chan_mhz;
16290 chan_stats->sampling_period_us = ev->sampling_period_us;
16291 chan_stats->rx_clear_count = ev->rx_clear_count;
16292 chan_stats->tx_duration_us = ev->tx_duration_us;
16293 chan_stats->rx_duration_us = ev->rx_duration_us;
16294 }
16295
16296 return QDF_STATUS_SUCCESS;
16297}
16298
16299/**
16300 * extract_profile_ctx_tlv() - extract profile context from event
16301 * @wmi_handle: wmi handle
16302 * @param evt_buf: pointer to event buffer
16303 * @idx: profile stats index to extract
16304 * @param profile_ctx: Pointer to hold profile context
16305 *
16306 * Return: QDF_STATUS_SUCCESS for success or error code
16307 */
16308static QDF_STATUS extract_profile_ctx_tlv(wmi_unified_t wmi_handle,
16309 void *evt_buf, wmi_host_wlan_profile_ctx_t *profile_ctx)
16310{
16311 return QDF_STATUS_SUCCESS;
16312}
16313
16314/**
16315 * extract_profile_data_tlv() - extract profile data from event
16316 * @wmi_handle: wmi handle
16317 * @param evt_buf: pointer to event buffer
16318 * @param profile_data: Pointer to hold profile data
16319 *
16320 * Return: QDF_STATUS_SUCCESS for success or error code
16321 */
16322static QDF_STATUS extract_profile_data_tlv(wmi_unified_t wmi_handle,
16323 void *evt_buf, uint8_t idx, wmi_host_wlan_profile_t *profile_data)
16324{
16325
16326 return QDF_STATUS_SUCCESS;
16327}
16328
16329/**
16330 * extract_chan_info_event_tlv() - extract chan information from event
16331 * @wmi_handle: wmi handle
16332 * @param evt_buf: pointer to event buffer
16333 * @param chan_info: Pointer to hold chan information
16334 *
16335 * Return: QDF_STATUS_SUCCESS for success or error code
16336 */
16337static QDF_STATUS extract_chan_info_event_tlv(wmi_unified_t wmi_handle,
16338 void *evt_buf, wmi_host_chan_info_event *chan_info)
16339{
16340 WMI_CHAN_INFO_EVENTID_param_tlvs *param_buf;
16341 wmi_chan_info_event_fixed_param *ev;
16342
16343 param_buf = (WMI_CHAN_INFO_EVENTID_param_tlvs *) evt_buf;
16344
16345 ev = (wmi_chan_info_event_fixed_param *) param_buf->fixed_param;
16346 if (!ev) {
16347 WMI_LOGE("%s: Failed to allocmemory\n", __func__);
16348 return QDF_STATUS_E_FAILURE;
16349 }
16350
16351 chan_info->err_code = ev->err_code;
16352 chan_info->freq = ev->freq;
16353 chan_info->cmd_flags = ev->cmd_flags;
16354 chan_info->noise_floor = ev->noise_floor;
16355 chan_info->rx_clear_count = ev->rx_clear_count;
16356 chan_info->cycle_count = ev->cycle_count;
Sathish Kumar87db1bd2017-05-08 12:35:55 +053016357 chan_info->pdev_id = wlan_get_pdev_id_from_vdev_id(
16358 (struct wlan_objmgr_psoc *)wmi_handle->soc->wmi_psoc,
16359 ev->vdev_id, WLAN_SCAN_ID);
Govind Singhe7f2f342016-05-23 12:12:52 +053016360
16361 return QDF_STATUS_SUCCESS;
16362}
16363
16364/**
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016365 * extract_pdev_utf_event_tlv() - extract UTF data info from event
16366 * @wmi_handle: WMI handle
16367 * @param evt_buf: Pointer to event buffer
16368 * @param param: Pointer to hold data
16369 *
16370 * Return : QDF_STATUS_SUCCESS for success or error code
16371 */
16372static QDF_STATUS extract_pdev_utf_event_tlv(wmi_unified_t wmi_handle,
16373 uint8_t *evt_buf,
16374 struct wmi_host_pdev_utf_event *event)
16375{
16376 WMI_PDEV_UTF_EVENTID_param_tlvs *param_buf;
16377
16378 param_buf = (WMI_PDEV_UTF_EVENTID_param_tlvs *)evt_buf;
16379 event->data = param_buf->data;
16380 event->datalen = param_buf->num_data;
Kiran Venkatappa15978c62017-02-28 12:42:36 +053016381 /* Set pdev_id=1 until FW adds support to include pdev_id */
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016382 event->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16383 WMI_PDEV_ID_1ST);
Sathish Kumar27ee0a32017-01-24 17:51:26 +053016384
16385 return QDF_STATUS_SUCCESS;
16386}
Govind Singhe7f2f342016-05-23 12:12:52 +053016387
Kiran Venkatappa06520822016-08-10 23:55:40 +053016388/**
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016389 * extract_chainmask_tables_tlv() - extract chain mask tables from event
16390 * @wmi_handle: wmi handle
16391 * @param evt_buf: pointer to event buffer
16392 * @param param: Pointer to hold evt buf
16393 *
16394 * Return: QDF_STATUS_SUCCESS for success or error code
16395 */
16396static QDF_STATUS extract_chainmask_tables_tlv(wmi_unified_t wmi_handle,
16397 uint8_t *event, struct wlan_psoc_host_chainmask_table *chainmask_table)
16398{
16399 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16400 WMI_MAC_PHY_CHAINMASK_CAPABILITY *chainmask_caps;
16401 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16402 uint8_t i = 0, j = 0;
16403
16404 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16405 if (!param_buf)
16406 return QDF_STATUS_E_INVAL;
16407
16408 hw_caps = param_buf->soc_hw_mode_caps;
16409 if (!hw_caps)
16410 return QDF_STATUS_E_INVAL;
16411
16412 if (!hw_caps->num_chainmask_tables)
16413 return QDF_STATUS_E_INVAL;
16414
16415 chainmask_caps = param_buf->mac_phy_chainmask_caps;
16416
16417 if (chainmask_caps == NULL)
16418 return QDF_STATUS_E_INVAL;
16419
16420 for (i = 0; i < hw_caps->num_chainmask_tables; i++) {
16421
16422 qdf_print("Dumping chain mask combo data for table : %d\n", i);
16423 for (j = 0; j < chainmask_table[i].num_valid_chainmasks; j++) {
16424
16425 chainmask_table[i].cap_list[j].chainmask =
16426 chainmask_caps->chainmask;
16427
16428 chainmask_table[i].cap_list[j].supports_chan_width_20 =
16429 WMI_SUPPORT_CHAN_WIDTH_20_GET(chainmask_caps->supported_flags);
16430
16431 chainmask_table[i].cap_list[j].supports_chan_width_40 =
16432 WMI_SUPPORT_CHAN_WIDTH_40_GET(chainmask_caps->supported_flags);
16433
16434 chainmask_table[i].cap_list[j].supports_chan_width_80 =
16435 WMI_SUPPORT_CHAN_WIDTH_80_GET(chainmask_caps->supported_flags);
16436
16437 chainmask_table[i].cap_list[j].supports_chan_width_160 =
16438 WMI_SUPPORT_CHAN_WIDTH_160_GET(chainmask_caps->supported_flags);
16439
16440 chainmask_table[i].cap_list[j].supports_chan_width_80P80 =
16441 WMI_SUPPORT_CHAN_WIDTH_80P80_GET(chainmask_caps->supported_flags);
16442
16443 chainmask_table[i].cap_list[j].chain_mask_2G =
16444 WMI_SUPPORT_CHAIN_MASK_2G_GET(chainmask_caps->supported_flags);
16445
16446 chainmask_table[i].cap_list[j].chain_mask_5G =
16447 WMI_SUPPORT_CHAIN_MASK_5G_GET(chainmask_caps->supported_flags);
16448
16449 chainmask_table[i].cap_list[j].chain_mask_tx =
16450 WMI_SUPPORT_CHAIN_MASK_TX_GET(chainmask_caps->supported_flags);
16451
16452 chainmask_table[i].cap_list[j].chain_mask_rx =
16453 WMI_SUPPORT_CHAIN_MASK_RX_GET(chainmask_caps->supported_flags);
16454
16455 chainmask_table[i].cap_list[j].supports_aDFS =
16456 WMI_SUPPORT_CHAIN_MASK_ADFS_GET(chainmask_caps->supported_flags);
16457
16458 qdf_print("supported_flags: 0x%08x chainmasks: 0x%08x\n",
16459 chainmask_caps->supported_flags,
16460 chainmask_caps->chainmask
16461 );
16462 chainmask_caps++;
16463 }
16464 }
16465
16466 return QDF_STATUS_SUCCESS;
16467}
16468
16469/**
Kiran Venkatappa06520822016-08-10 23:55:40 +053016470 * extract_service_ready_ext_tlv() - extract basic extended service ready params
16471 * from event
16472 * @wmi_handle: wmi handle
16473 * @param evt_buf: pointer to event buffer
16474 * @param param: Pointer to hold evt buf
16475 *
16476 * Return: QDF_STATUS_SUCCESS for success or error code
16477 */
16478static QDF_STATUS extract_service_ready_ext_tlv(wmi_unified_t wmi_handle,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016479 uint8_t *event, struct wlan_psoc_host_service_ext_param *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016480{
16481 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16482 wmi_service_ready_ext_event_fixed_param *ev;
16483 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16484 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016485 WMI_MAC_PHY_CHAINMASK_COMBO *chain_mask_combo;
16486 uint8_t i = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016487
16488 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16489 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016490 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016491
16492 ev = param_buf->fixed_param;
16493 if (!ev)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016494 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016495
16496 /* Move this to host based bitmap */
16497 param->default_conc_scan_config_bits =
16498 ev->default_conc_scan_config_bits;
16499 param->default_fw_config_bits = ev->default_fw_config_bits;
16500 param->he_cap_info = ev->he_cap_info;
16501 param->mpdu_density = ev->mpdu_density;
16502 param->max_bssid_rx_filters = ev->max_bssid_rx_filters;
16503 qdf_mem_copy(&param->ppet, &ev->ppet, sizeof(param->ppet));
16504
16505 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016506 if (hw_caps)
16507 param->num_hw_modes = hw_caps->num_hw_modes;
16508 else
16509 param->num_hw_modes = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016510
16511 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016512 if (reg_caps)
16513 param->num_phy = reg_caps->num_phy;
16514 else
16515 param->num_phy = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016516
Kapil Gupta0692a1a2017-05-15 15:57:36 +053016517 if (hw_caps) {
16518 param->num_chainmask_tables = hw_caps->num_chainmask_tables;
16519 qdf_print("Num chain mask tables: %d\n", hw_caps->num_chainmask_tables);
16520 } else
16521 param->num_chainmask_tables = 0;
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016522
16523 chain_mask_combo = param_buf->mac_phy_chainmask_combo;
16524
16525 if (chain_mask_combo == NULL)
16526 return QDF_STATUS_SUCCESS;
16527
16528 qdf_print("Dumping chain mask combo data\n");
16529
Kapil Gupta0692a1a2017-05-15 15:57:36 +053016530 for (i = 0; i < param->num_chainmask_tables; i++) {
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016531
16532 qdf_print("table_id : %d Num valid chainmasks: %d\n",
16533 chain_mask_combo->chainmask_table_id,
16534 chain_mask_combo->num_valid_chainmask
16535 );
16536
16537 param->chainmask_table[i].table_id =
16538 chain_mask_combo->chainmask_table_id;
16539 param->chainmask_table[i].num_valid_chainmasks =
16540 chain_mask_combo->num_valid_chainmask;
16541 chain_mask_combo++;
16542 }
16543 qdf_print("chain mask combo end\n");
16544
Kiran Venkatappa06520822016-08-10 23:55:40 +053016545 return QDF_STATUS_SUCCESS;
16546}
16547
16548/**
16549 * extract_hw_mode_cap_service_ready_ext_tlv() -
16550 * extract HW mode cap from service ready event
16551 * @wmi_handle: wmi handle
16552 * @param evt_buf: pointer to event buffer
16553 * @param param: Pointer to hold evt buf
16554 * @param hw_mode_idx: hw mode idx should be less than num_mode
16555 *
16556 * Return: QDF_STATUS_SUCCESS for success or error code
16557 */
16558static QDF_STATUS extract_hw_mode_cap_service_ready_ext_tlv(
16559 wmi_unified_t wmi_handle,
16560 uint8_t *event, uint8_t hw_mode_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016561 struct wlan_psoc_host_hw_mode_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016562{
16563 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16564 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16565
16566 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16567 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016568 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016569
16570 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016571 if (!hw_caps)
16572 return QDF_STATUS_E_INVAL;
16573
Kiran Venkatappa06520822016-08-10 23:55:40 +053016574 if (hw_mode_idx >= hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016575 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016576
16577 param->hw_mode_id = param_buf->hw_mode_caps[hw_mode_idx].hw_mode_id;
16578 param->phy_id_map = param_buf->hw_mode_caps[hw_mode_idx].phy_id_map;
16579
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016580 param->hw_mode_config_type =
16581 param_buf->hw_mode_caps[hw_mode_idx].hw_mode_config_type;
16582
Kiran Venkatappa06520822016-08-10 23:55:40 +053016583 return QDF_STATUS_SUCCESS;
16584}
16585
16586/**
16587 * extract_mac_phy_cap_service_ready_ext_tlv() -
16588 * extract MAC phy cap from service ready event
16589 * @wmi_handle: wmi handle
16590 * @param evt_buf: pointer to event buffer
16591 * @param param: Pointer to hold evt buf
16592 * @param hw_mode_idx: hw mode idx should be less than num_mode
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016593 * @param phy_id: phy id within hw_mode
Kiran Venkatappa06520822016-08-10 23:55:40 +053016594 *
16595 * Return: QDF_STATUS_SUCCESS for success or error code
16596 */
16597static QDF_STATUS extract_mac_phy_cap_service_ready_ext_tlv(
16598 wmi_unified_t wmi_handle,
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016599 uint8_t *event, uint8_t hw_mode_id, uint8_t phy_id,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016600 struct wlan_psoc_host_mac_phy_caps *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016601{
16602 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016603 WMI_MAC_PHY_CAPABILITIES *mac_phy_caps;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016604 WMI_SOC_MAC_PHY_HW_MODE_CAPS *hw_caps;
16605 uint32_t phy_map;
16606 uint8_t hw_idx, phy_idx = 0;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016607
16608 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16609 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016610 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016611
16612 hw_caps = param_buf->soc_hw_mode_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016613 if (!hw_caps)
16614 return QDF_STATUS_E_INVAL;
16615
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016616 for (hw_idx = 0; hw_idx < hw_caps->num_hw_modes; hw_idx++) {
16617 if (hw_mode_id == param_buf->hw_mode_caps[hw_idx].hw_mode_id)
16618 break;
16619
16620 phy_map = param_buf->hw_mode_caps[hw_idx].phy_id_map;
16621 while (phy_map) {
16622 phy_map >>= 1;
16623 phy_idx++;
16624 }
16625 }
16626
16627 if (hw_idx == hw_caps->num_hw_modes)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016628 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016629
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016630 phy_idx += phy_id;
16631 if (phy_idx >= param_buf->num_mac_phy_caps)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016632 return QDF_STATUS_E_INVAL;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016633
16634 mac_phy_caps = &param_buf->mac_phy_caps[phy_idx];
Kiran Venkatappa06520822016-08-10 23:55:40 +053016635
16636 param->hw_mode_id = mac_phy_caps->hw_mode_id;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016637 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16638 mac_phy_caps->pdev_id);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016639 param->phy_id = mac_phy_caps->phy_id;
Kiran Venkatappa2b1b0d22016-12-26 15:38:06 +053016640 param->supports_11b =
16641 WMI_SUPPORT_11B_GET(mac_phy_caps->supported_flags);
16642 param->supports_11g =
16643 WMI_SUPPORT_11G_GET(mac_phy_caps->supported_flags);
16644 param->supports_11a =
16645 WMI_SUPPORT_11A_GET(mac_phy_caps->supported_flags);
16646 param->supports_11n =
16647 WMI_SUPPORT_11N_GET(mac_phy_caps->supported_flags);
16648 param->supports_11ac =
16649 WMI_SUPPORT_11AC_GET(mac_phy_caps->supported_flags);
16650 param->supports_11ax =
16651 WMI_SUPPORT_11AX_GET(mac_phy_caps->supported_flags);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016652
16653 param->supported_bands = mac_phy_caps->supported_bands;
16654 param->ampdu_density = mac_phy_caps->ampdu_density;
16655 param->max_bw_supported_2G = mac_phy_caps->max_bw_supported_2G;
16656 param->ht_cap_info_2G = mac_phy_caps->ht_cap_info_2G;
16657 param->vht_cap_info_2G = mac_phy_caps->vht_cap_info_2G;
16658 param->vht_supp_mcs_2G = mac_phy_caps->vht_supp_mcs_2G;
16659 param->he_cap_info_2G = mac_phy_caps->he_cap_info_2G;
16660 param->he_supp_mcs_2G = mac_phy_caps->he_supp_mcs_2G;
16661 param->tx_chain_mask_2G = mac_phy_caps->tx_chain_mask_2G;
16662 param->rx_chain_mask_2G = mac_phy_caps->rx_chain_mask_2G;
16663 param->max_bw_supported_5G = mac_phy_caps->max_bw_supported_5G;
16664 param->ht_cap_info_5G = mac_phy_caps->ht_cap_info_5G;
16665 param->vht_cap_info_5G = mac_phy_caps->vht_cap_info_5G;
16666 param->vht_supp_mcs_5G = mac_phy_caps->vht_supp_mcs_5G;
16667 param->he_cap_info_5G = mac_phy_caps->he_cap_info_5G;
16668 param->he_supp_mcs_5G = mac_phy_caps->he_supp_mcs_5G;
16669 param->tx_chain_mask_5G = mac_phy_caps->tx_chain_mask_5G;
16670 param->rx_chain_mask_5G = mac_phy_caps->rx_chain_mask_5G;
Kris Muthusamy61fe3692017-02-20 02:35:47 -080016671 qdf_mem_copy(&param->he_cap_phy_info_2G,
16672 &mac_phy_caps->he_cap_phy_info_2G,
16673 sizeof(param->he_cap_phy_info_2G));
16674 qdf_mem_copy(&param->he_cap_phy_info_5G,
16675 &mac_phy_caps->he_cap_phy_info_5G,
16676 sizeof(param->he_cap_phy_info_5G));
16677 qdf_mem_copy(&param->he_ppet2G, &mac_phy_caps->he_ppet2G,
16678 sizeof(param->he_ppet2G));
16679 qdf_mem_copy(&param->he_ppet5G, &mac_phy_caps->he_ppet5G,
16680 sizeof(param->he_ppet5G));
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053016681 param->chainmask_table_id = mac_phy_caps->chainmask_table_id;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016682
16683 return QDF_STATUS_SUCCESS;
16684}
16685
16686/**
16687 * extract_reg_cap_service_ready_ext_tlv() -
16688 * extract REG cap from service ready event
16689 * @wmi_handle: wmi handle
16690 * @param evt_buf: pointer to event buffer
16691 * @param param: Pointer to hold evt buf
16692 * @param phy_idx: phy idx should be less than num_mode
16693 *
16694 * Return: QDF_STATUS_SUCCESS for success or error code
16695 */
16696static QDF_STATUS extract_reg_cap_service_ready_ext_tlv(
16697 wmi_unified_t wmi_handle,
16698 uint8_t *event, uint8_t phy_idx,
Rajeev Kumar037799b2017-02-03 00:39:49 -080016699 struct wlan_psoc_host_hal_reg_capabilities_ext *param)
Kiran Venkatappa06520822016-08-10 23:55:40 +053016700{
16701 WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *param_buf;
16702 WMI_SOC_HAL_REG_CAPABILITIES *reg_caps;
16703 WMI_HAL_REG_CAPABILITIES_EXT *ext_reg_cap;
16704
16705 param_buf = (WMI_SERVICE_READY_EXT_EVENTID_param_tlvs *) event;
16706 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016707 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016708
16709 reg_caps = param_buf->soc_hal_reg_caps;
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016710 if (!reg_caps)
16711 return QDF_STATUS_E_INVAL;
16712
Kiran Venkatappa06520822016-08-10 23:55:40 +053016713 if (phy_idx >= reg_caps->num_phy)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016714 return QDF_STATUS_E_INVAL;
Kiran Venkatappa06520822016-08-10 23:55:40 +053016715
16716 ext_reg_cap = &param_buf->hal_reg_caps[phy_idx];
16717
16718 param->phy_id = ext_reg_cap->phy_id;
16719 param->eeprom_reg_domain = ext_reg_cap->eeprom_reg_domain;
16720 param->eeprom_reg_domain_ext = ext_reg_cap->eeprom_reg_domain_ext;
16721 param->regcap1 = ext_reg_cap->regcap1;
16722 param->regcap2 = ext_reg_cap->regcap2;
Kiran Venkatappa270f1fd2017-02-25 20:29:29 +053016723 param->wireless_modes = convert_wireless_modes_tlv(
16724 ext_reg_cap->wireless_modes);
Kiran Venkatappa06520822016-08-10 23:55:40 +053016725 param->low_2ghz_chan = ext_reg_cap->low_2ghz_chan;
16726 param->high_2ghz_chan = ext_reg_cap->high_2ghz_chan;
16727 param->low_5ghz_chan = ext_reg_cap->low_5ghz_chan;
16728 param->high_5ghz_chan = ext_reg_cap->high_5ghz_chan;
16729
16730 return QDF_STATUS_SUCCESS;
16731}
16732
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016733/**
16734 * extract_dcs_interference_type_tlv() - extract dcs interference type
16735 * from event
16736 * @wmi_handle: wmi handle
16737 * @param evt_buf: pointer to event buffer
16738 * @param param: Pointer to hold dcs interference param
16739 *
16740 * Return: 0 for success or error code
16741 */
16742static QDF_STATUS extract_dcs_interference_type_tlv(
16743 wmi_unified_t wmi_handle,
16744 void *evt_buf, struct wmi_host_dcs_interference_param *param)
16745{
16746 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16747
16748 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16749 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016750 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016751
16752 param->interference_type = param_buf->fixed_param->interference_type;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016753 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16754 param_buf->fixed_param->pdev_id);
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016755
16756 return QDF_STATUS_SUCCESS;
16757}
16758
16759/*
16760 * extract_dcs_cw_int_tlv() - extract dcs cw interference from event
16761 * @wmi_handle: wmi handle
16762 * @param evt_buf: pointer to event buffer
16763 * @param cw_int: Pointer to hold cw interference
16764 *
16765 * Return: 0 for success or error code
16766 */
16767static QDF_STATUS extract_dcs_cw_int_tlv(wmi_unified_t wmi_handle,
16768 void *evt_buf,
16769 wmi_host_ath_dcs_cw_int *cw_int)
16770{
16771 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16772 wlan_dcs_cw_int *ev;
16773
16774 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16775 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016776 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016777
16778 ev = param_buf->cw_int;
16779
16780 cw_int->channel = ev->channel;
16781
16782 return QDF_STATUS_SUCCESS;
16783}
16784
16785/**
16786 * extract_dcs_im_tgt_stats_tlv() - extract dcs im target stats from event
16787 * @wmi_handle: wmi handle
16788 * @param evt_buf: pointer to event buffer
16789 * @param wlan_stat: Pointer to hold wlan stats
16790 *
16791 * Return: 0 for success or error code
16792 */
16793static QDF_STATUS extract_dcs_im_tgt_stats_tlv(wmi_unified_t wmi_handle,
16794 void *evt_buf,
16795 wmi_host_dcs_im_tgt_stats_t *wlan_stat)
16796{
16797 WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *param_buf;
16798 wlan_dcs_im_tgt_stats_t *ev;
16799
16800 param_buf = (WMI_DCS_INTERFERENCE_EVENTID_param_tlvs *) evt_buf;
16801 if (!param_buf)
Kiran Venkatappa41ef3292017-02-23 11:39:37 +053016802 return QDF_STATUS_E_INVAL;
Kiran Venkatappafea8a802016-12-29 18:09:32 +053016803
16804 ev = param_buf->wlan_stat;
16805 wlan_stat->reg_tsf32 = ev->reg_tsf32;
16806 wlan_stat->last_ack_rssi = ev->last_ack_rssi;
16807 wlan_stat->tx_waste_time = ev->tx_waste_time;
16808 wlan_stat->rx_time = ev->rx_time;
16809 wlan_stat->phyerr_cnt = ev->phyerr_cnt;
16810 wlan_stat->mib_stats.listen_time = ev->listen_time;
16811 wlan_stat->mib_stats.reg_tx_frame_cnt = ev->reg_tx_frame_cnt;
16812 wlan_stat->mib_stats.reg_rx_frame_cnt = ev->reg_rx_frame_cnt;
16813 wlan_stat->mib_stats.reg_rxclr_cnt = ev->reg_rxclr_cnt;
16814 wlan_stat->mib_stats.reg_cycle_cnt = ev->reg_cycle_cnt;
16815 wlan_stat->mib_stats.reg_rxclr_ext_cnt = ev->reg_rxclr_ext_cnt;
16816 wlan_stat->mib_stats.reg_ofdm_phyerr_cnt = ev->reg_ofdm_phyerr_cnt;
16817 wlan_stat->mib_stats.reg_cck_phyerr_cnt = ev->reg_cck_phyerr_cnt;
16818 wlan_stat->chan_nf = ev->chan_nf;
16819 wlan_stat->my_bss_rx_cycle_count = ev->my_bss_rx_cycle_count;
16820
16821 return QDF_STATUS_SUCCESS;
16822}
16823
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053016824/**
16825 * extract_thermal_stats_tlv() - extract thermal stats from event
16826 * @wmi_handle: wmi handle
16827 * @param evt_buf: Pointer to event buffer
16828 * @param temp: Pointer to hold extracted temperature
16829 * @param level: Pointer to hold extracted level
16830 *
16831 * Return: 0 for success or error code
16832 */
16833static QDF_STATUS
16834extract_thermal_stats_tlv(wmi_unified_t wmi_handle,
16835 void *evt_buf, uint32_t *temp,
16836 uint32_t *level, uint32_t *pdev_id)
16837{
16838 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
16839 wmi_therm_throt_stats_event_fixed_param *tt_stats_event;
16840
16841 param_buf =
16842 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
16843 if (!param_buf)
16844 return QDF_STATUS_E_INVAL;
16845
16846 tt_stats_event = param_buf->fixed_param;
16847
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016848 *pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16849 tt_stats_event->pdev_id);
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053016850 *temp = tt_stats_event->temp;
16851 *level = tt_stats_event->level;
16852
16853 return QDF_STATUS_SUCCESS;
16854}
16855
16856/**
16857 * extract_thermal_level_stats_tlv() - extract thermal level stats from event
16858 * @wmi_handle: wmi handle
16859 * @param evt_buf: pointer to event buffer
16860 * @param idx: Index to level stats
16861 * @param levelcount: Pointer to hold levelcount
16862 * @param dccount: Pointer to hold dccount
16863 *
16864 * Return: 0 for success or error code
16865 */
16866static QDF_STATUS
16867extract_thermal_level_stats_tlv(wmi_unified_t wmi_handle,
16868 void *evt_buf, uint8_t idx, uint32_t *levelcount,
16869 uint32_t *dccount)
16870{
16871 WMI_THERM_THROT_STATS_EVENTID_param_tlvs *param_buf;
16872 wmi_therm_throt_level_stats_info *tt_level_info;
16873
16874 param_buf =
16875 (WMI_THERM_THROT_STATS_EVENTID_param_tlvs *) evt_buf;
16876 if (!param_buf)
16877 return QDF_STATUS_E_INVAL;
16878
16879 tt_level_info = param_buf->therm_throt_level_stats_info;
16880
16881 if (idx < THERMAL_LEVELS) {
16882 *levelcount = tt_level_info[idx].level_count;
16883 *dccount = tt_level_info[idx].dc_count;
16884 return QDF_STATUS_SUCCESS;
16885 }
16886
16887 return QDF_STATUS_E_FAILURE;
16888}
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016889#ifdef BIG_ENDIAN_HOST
16890/**
16891 * fips_conv_data_be() - LE to BE conversion of FIPS ev data
16892 * @param data_len - data length
16893 * @param data - pointer to data
16894 *
16895 * Return: QDF_STATUS - success or error status
16896 */
16897static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
16898{
16899 uint8_t *data_aligned = NULL;
16900 int c;
16901 unsigned char *data_unaligned;
16902
16903 data_unaligned = qdf_mem_malloc(((sizeof(uint8_t) * data_len) +
16904 FIPS_ALIGN));
16905 /* Assigning unaligned space to copy the data */
16906 /* Checking if kmalloc does succesful allocation */
16907 if (data_unaligned == NULL)
16908 return QDF_STATUS_E_FAILURE;
16909
16910 /* Checking if space is alligned */
16911 if (!FIPS_IS_ALIGNED(data_unaligned, FIPS_ALIGN)) {
16912 /* align the data space */
16913 data_aligned =
16914 (uint8_t *)FIPS_ALIGNTO(data_unaligned, FIPS_ALIGN);
16915 } else {
16916 data_aligned = (u_int8_t *)data_unaligned;
16917 }
16918
16919 /* memset and copy content from data to data aligned */
16920 OS_MEMSET(data_aligned, 0, data_len);
16921 OS_MEMCPY(data_aligned, data, data_len);
16922 /* Endianness to LE */
16923 for (c = 0; c < data_len/4; c++) {
16924 *((u_int32_t *)data_aligned + c) =
16925 qdf_os_le32_to_cpu(*((u_int32_t *)data_aligned + c));
16926 }
16927
16928 /* Copy content to event->data */
16929 OS_MEMCPY(data, data_aligned, data_len);
16930
16931 /* clean up allocated space */
16932 qdf_mem_free(data_unaligned);
16933 data_aligned = NULL;
16934 data_unaligned = NULL;
16935
16936 /*************************************************************/
16937
16938 return QDF_STATUS_SUCCESS;
16939}
16940#else
16941/**
16942 * fips_conv_data_be() - DUMMY for LE platform
16943 *
16944 * Return: QDF_STATUS - success
16945 */
16946static QDF_STATUS fips_conv_data_be(uint32_t data_len, uint8_t *data)
16947{
16948 return QDF_STATUS_SUCCESS;
16949}
16950#endif
16951
16952/**
16953 * extract_fips_event_data_tlv() - extract fips event data
16954 * @wmi_handle: wmi handle
16955 * @param evt_buf: pointer to event buffer
16956 * @param param: pointer FIPS event params
16957 *
16958 * Return: 0 for success or error code
16959 */
16960static QDF_STATUS extract_fips_event_data_tlv(wmi_unified_t wmi_handle,
16961 void *evt_buf, struct wmi_host_fips_event_param *param)
16962{
16963 WMI_PDEV_FIPS_EVENTID_param_tlvs *param_buf;
16964 wmi_pdev_fips_event_fixed_param *event;
16965
16966 param_buf = (WMI_PDEV_FIPS_EVENTID_param_tlvs *) evt_buf;
16967 event = (wmi_pdev_fips_event_fixed_param *) param_buf->fixed_param;
16968
16969 if (fips_conv_data_be(event->data_len, param_buf->data) !=
16970 QDF_STATUS_SUCCESS)
16971 return QDF_STATUS_E_FAILURE;
16972
16973 param->data = (uint32_t *)param_buf->data;
16974 param->data_len = event->data_len;
16975 param->error_status = event->error_status;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053016976 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
16977 event->pdev_id);
Kiran Venkatappac813ec92016-12-29 22:07:14 +053016978
16979 return QDF_STATUS_SUCCESS;
16980}
16981
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053016982/*
16983 * extract_peer_delete_response_event_tlv() - extract peer delete response event
16984 * @wmi_handle: wmi handle
16985 * @param evt_buf: pointer to event buffer
16986 * @param vdev_id: Pointer to hold vdev_id
16987 * @param mac_addr: Pointer to hold peer mac address
16988 *
16989 * Return: QDF_STATUS_SUCCESS for success or error code
16990 */
16991static QDF_STATUS extract_peer_delete_response_event_tlv(wmi_unified_t wmi_hdl,
16992 void *evt_buf, struct wmi_host_peer_delete_response_event *param)
16993{
16994 WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *param_buf;
16995 wmi_peer_delete_resp_event_fixed_param *ev;
16996
16997 param_buf = (WMI_PEER_DELETE_RESP_EVENTID_param_tlvs *)evt_buf;
16998
16999 ev = (wmi_peer_delete_resp_event_fixed_param *) param_buf->fixed_param;
17000 if (!ev) {
17001 WMI_LOGE("%s: Invalid peer_delete response\n", __func__);
17002 return QDF_STATUS_E_FAILURE;
17003 }
17004
17005 param->vdev_id = ev->vdev_id;
17006 WMI_MAC_ADDR_TO_CHAR_ARRAY(&ev->peer_macaddr,
17007 &param->mac_address.bytes[0]);
17008
17009 return QDF_STATUS_SUCCESS;
17010}
17011
Govind Singhecf03cd2016-05-12 12:45:51 +053017012static bool is_management_record_tlv(uint32_t cmd_id)
17013{
Pratik Gandhi29e33f02016-09-16 01:32:51 +053017014 if (cmd_id == WMI_MGMT_TX_COMPLETION_EVENTID)
Govind Singhecf03cd2016-05-12 12:45:51 +053017015 return true;
Govind Singhe7f2f342016-05-23 12:12:52 +053017016
Govind Singhecf03cd2016-05-12 12:45:51 +053017017 return false;
17018}
17019
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017020static uint16_t wmi_tag_vdev_set_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17021{
17022 wmi_vdev_set_param_cmd_fixed_param *set_cmd;
17023
17024 set_cmd = (wmi_vdev_set_param_cmd_fixed_param *)wmi_buf_data(buf);
17025
17026 switch (set_cmd->param_id) {
17027 case WMI_VDEV_PARAM_LISTEN_INTERVAL:
17028 case WMI_VDEV_PARAM_DTIM_POLICY:
17029 return HTC_TX_PACKET_TAG_AUTO_PM;
17030 default:
17031 break;
17032 }
17033
17034 return 0;
17035}
17036
17037static uint16_t wmi_tag_sta_powersave_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf)
17038{
17039 wmi_sta_powersave_param_cmd_fixed_param *ps_cmd;
17040
17041 ps_cmd = (wmi_sta_powersave_param_cmd_fixed_param *)wmi_buf_data(buf);
17042
17043 switch (ps_cmd->param) {
17044 case WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD:
17045 case WMI_STA_PS_PARAM_INACTIVITY_TIME:
17046 case WMI_STA_PS_ENABLE_QPOWER:
17047 return HTC_TX_PACKET_TAG_AUTO_PM;
17048 default:
17049 break;
17050 }
17051
17052 return 0;
17053}
17054
17055static uint16_t wmi_tag_common_cmd(wmi_unified_t wmi_hdl, wmi_buf_t buf,
17056 uint32_t cmd_id)
17057{
17058 if (qdf_atomic_read(&wmi_hdl->is_wow_bus_suspended))
17059 return 0;
17060
17061 switch (cmd_id) {
17062 case WMI_VDEV_SET_PARAM_CMDID:
17063 return wmi_tag_vdev_set_cmd(wmi_hdl, buf);
17064 case WMI_STA_POWERSAVE_PARAM_CMDID:
17065 return wmi_tag_sta_powersave_cmd(wmi_hdl, buf);
17066 default:
17067 break;
17068 }
17069
17070 return 0;
17071}
17072
17073static uint16_t wmi_tag_fw_hang_cmd(wmi_unified_t wmi_handle)
17074{
17075 uint16_t tag = 0;
17076
17077 if (qdf_atomic_read(&wmi_handle->is_target_suspended)) {
17078 pr_err("%s: Target is already suspended, Ignore FW Hang Command\n",
17079 __func__);
17080 return tag;
17081 }
17082
17083 if (wmi_handle->tag_crash_inject)
17084 tag = HTC_TX_PACKET_TAG_AUTO_PM;
17085
17086 wmi_handle->tag_crash_inject = false;
17087 return tag;
17088}
17089
17090/**
17091 * wmi_set_htc_tx_tag_tlv() - set HTC TX tag for WMI commands
17092 * @wmi_handle: WMI handle
17093 * @buf: WMI buffer
17094 * @cmd_id: WMI command Id
17095 *
17096 * Return htc_tx_tag
17097 */
17098static uint16_t wmi_set_htc_tx_tag_tlv(wmi_unified_t wmi_handle,
17099 wmi_buf_t buf,
17100 uint32_t cmd_id)
17101{
17102 uint16_t htc_tx_tag = 0;
17103
17104 switch (cmd_id) {
17105 case WMI_WOW_ENABLE_CMDID:
17106 case WMI_PDEV_SUSPEND_CMDID:
17107 case WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID:
17108 case WMI_WOW_ADD_WAKE_PATTERN_CMDID:
17109 case WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID:
17110 case WMI_PDEV_RESUME_CMDID:
17111 case WMI_WOW_DEL_WAKE_PATTERN_CMDID:
17112 case WMI_WOW_SET_ACTION_WAKE_UP_CMDID:
17113#ifdef FEATURE_WLAN_D0WOW
17114 case WMI_D0_WOW_ENABLE_DISABLE_CMDID:
17115#endif
17116 htc_tx_tag = HTC_TX_PACKET_TAG_AUTO_PM;
17117 break;
17118 case WMI_FORCE_FW_HANG_CMDID:
17119 htc_tx_tag = wmi_tag_fw_hang_cmd(wmi_handle);
17120 break;
17121 case WMI_VDEV_SET_PARAM_CMDID:
17122 case WMI_STA_POWERSAVE_PARAM_CMDID:
17123 htc_tx_tag = wmi_tag_common_cmd(wmi_handle, buf, cmd_id);
17124 default:
17125 break;
17126 }
17127
17128 return htc_tx_tag;
17129}
17130
Sathish Kumard3ab1002017-02-07 17:10:59 +053017131/**
17132 * extract_channel_hopping_event_tlv() - extract channel hopping param
17133 * from event
17134 * @wmi_handle: wmi handle
17135 * @param evt_buf: pointer to event buffer
17136 * @param ch_hopping: Pointer to hold channel hopping param
17137 *
17138 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17139 */
17140static QDF_STATUS extract_channel_hopping_event_tlv(
17141 wmi_unified_t wmi_handle, void *evt_buf,
17142 wmi_host_pdev_channel_hopping_event *ch_hopping)
17143{
17144 WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *param_buf;
17145 wmi_pdev_channel_hopping_event_fixed_param *event;
17146
17147 param_buf = (WMI_PDEV_CHANNEL_HOPPING_EVENTID_param_tlvs *)evt_buf;
17148 event = (wmi_pdev_channel_hopping_event_fixed_param *)
17149 param_buf->fixed_param;
17150
17151 ch_hopping->noise_floor_report_iter = event->noise_floor_report_iter;
17152 ch_hopping->noise_floor_total_iter = event->noise_floor_total_iter;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017153 ch_hopping->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17154 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017155
17156 return QDF_STATUS_SUCCESS;
17157}
17158
17159/**
17160 * extract_pdev_tpc_ev_param_tlv() - extract tpc param from event
17161 * @wmi_handle: wmi handle
17162 * @param evt_buf: pointer to event buffer
17163 * @param param: Pointer to hold tpc param
17164 *
17165 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17166 */
17167static QDF_STATUS extract_pdev_tpc_ev_param_tlv(wmi_unified_t wmi_handle,
17168 void *evt_buf,
17169 wmi_host_pdev_tpc_event *param)
17170{
17171 WMI_PDEV_TPC_EVENTID_param_tlvs *param_buf;
17172 wmi_pdev_tpc_event_fixed_param *event;
17173
17174 param_buf = (WMI_PDEV_TPC_EVENTID_param_tlvs *)evt_buf;
17175 event = (wmi_pdev_tpc_event_fixed_param *)param_buf->fixed_param;
17176
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017177 param->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17178 event->pdev_id);
Sathish Kumard3ab1002017-02-07 17:10:59 +053017179 qdf_mem_copy(param->tpc, param_buf->tpc, sizeof(param->tpc));
17180
17181 return QDF_STATUS_SUCCESS;
17182}
17183
17184
17185#ifdef BIG_ENDIAN_HOST
17186/**
17187 * wds_addr_ev_conv_data_be() - LE to BE conversion of wds addr event
17188 * @param data_len - data length
17189 * @param data - pointer to data
17190 *
17191 * Return: QDF_STATUS - success or error status
17192 */
17193static QDF_STATUS wds_addr_ev_conv_data_be(uint16_t data_len, uint8_t *ev)
17194{
17195 uint8_t *datap = (uint8_t *)ev;
17196 /* Skip swapping the first word */
17197 datap += sizeof(uint32_t);
17198 for (i = 0; i < ((data_len / sizeof(uint32_t))-1);
17199 i++, datap += sizeof(uint32_t)) {
17200 *(uint32_t *)datap = qdf_le32_to_cpu(*(uint32_t *)datap);
17201 }
17202
17203 return QDF_STATUS_SUCCESS;
17204}
17205#else
17206/**
17207 * wds_addr_ev_conv_data_be() - Dummy operation for LE platforms
17208 * @param data_len - data length
17209 * @param data - pointer to data
17210 *
17211 * Return: QDF_STATUS - success or error status
17212 */
17213static QDF_STATUS wds_addr_ev_conv_data_be(uint32_t data_len, uint8_t *ev)
17214{
17215 return QDF_STATUS_SUCCESS;
17216}
17217#endif
17218
17219/**
17220 * extract_wds_addr_event_tlv() - extract wds address from event
17221 * @wmi_handle: wmi handle
17222 * @param evt_buf: pointer to event buffer
17223 * @param wds_ev: Pointer to hold wds address
17224 *
17225 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17226 */
17227static QDF_STATUS extract_wds_addr_event_tlv(wmi_unified_t wmi_handle,
17228 void *evt_buf,
17229 uint16_t len, wds_addr_event_t *wds_ev)
17230{
17231 WMI_WDS_PEER_EVENTID_param_tlvs *param_buf;
17232 wmi_wds_addr_event_fixed_param *ev;
17233 int i;
17234
17235 param_buf = (WMI_WDS_PEER_EVENTID_param_tlvs *)evt_buf;
17236 ev = (wmi_wds_addr_event_fixed_param *)param_buf->fixed_param;
17237
17238 if (wds_addr_ev_conv_data_be(len, (uint8_t *)ev) != QDF_STATUS_SUCCESS)
17239 return QDF_STATUS_E_FAILURE;
17240
17241 qdf_mem_copy(wds_ev->event_type, ev->event_type,
17242 sizeof(wds_ev->event_type));
17243 for (i = 0; i < 4; i++) {
17244 wds_ev->peer_mac[i] =
17245 ((u_int8_t *)&(ev->peer_mac.mac_addr31to0))[i];
17246 wds_ev->dest_mac[i] =
17247 ((u_int8_t *)&(ev->dest_mac.mac_addr31to0))[i];
17248 }
17249 for (i = 0; i < 2; i++) {
17250 wds_ev->peer_mac[4+i] =
17251 ((u_int8_t *)&(ev->peer_mac.mac_addr47to32))[i];
17252 wds_ev->dest_mac[4+i] =
17253 ((u_int8_t *)&(ev->dest_mac.mac_addr47to32))[i];
17254 }
17255 return QDF_STATUS_SUCCESS;
17256}
17257
17258/**
17259 * extract_peer_sta_ps_statechange_ev_tlv() - extract peer sta ps state
17260 * from event
17261 * @wmi_handle: wmi handle
17262 * @param evt_buf: pointer to event buffer
17263 * @param ev: Pointer to hold peer param and ps state
17264 *
17265 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17266 */
17267static QDF_STATUS extract_peer_sta_ps_statechange_ev_tlv(wmi_unified_t wmi_handle,
17268 void *evt_buf, wmi_host_peer_sta_ps_statechange_event *ev)
17269{
17270 WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *param_buf;
17271 wmi_peer_sta_ps_statechange_event_fixed_param *event;
17272
17273 param_buf = (WMI_PEER_STA_PS_STATECHG_EVENTID_param_tlvs *)evt_buf;
17274 event = (wmi_peer_sta_ps_statechange_event_fixed_param *)
17275 param_buf->fixed_param;
17276
17277 WMI_MAC_ADDR_TO_CHAR_ARRAY(&event->peer_macaddr, ev->peer_macaddr);
17278 ev->peer_ps_state = event->peer_ps_state;
17279
17280 return QDF_STATUS_SUCCESS;
17281}
17282
17283/**
17284 * extract_inst_rssi_stats_event_tlv() - extract inst rssi stats from event
17285 * @wmi_handle: wmi handle
17286 * @param evt_buf: pointer to event buffer
17287 * @param inst_rssi_resp: Pointer to hold inst rssi response
17288 *
17289 * @return QDF_STATUS_SUCCESS on success and -ve on failure.
17290 */
17291static QDF_STATUS extract_inst_rssi_stats_event_tlv(
17292 wmi_unified_t wmi_handle, void *evt_buf,
17293 wmi_host_inst_stats_resp *inst_rssi_resp)
17294{
17295 WMI_INST_RSSI_STATS_EVENTID_param_tlvs *param_buf;
17296 wmi_inst_rssi_stats_resp_fixed_param *event;
17297
17298 param_buf = (WMI_INST_RSSI_STATS_EVENTID_param_tlvs *)evt_buf;
17299 event = (wmi_inst_rssi_stats_resp_fixed_param *)param_buf->fixed_param;
17300
17301 qdf_mem_copy(&(inst_rssi_resp->peer_macaddr),
17302 &(event->peer_macaddr), sizeof(wmi_mac_addr));
17303 inst_rssi_resp->iRSSI = event->iRSSI;
17304
17305 return QDF_STATUS_SUCCESS;
17306}
17307
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017308static struct cur_reg_rule
17309*create_reg_rules_from_wmi(uint32_t num_reg_rules,
17310 wmi_regulatory_rule_struct *wmi_reg_rule)
17311{
17312 struct cur_reg_rule *reg_rule_ptr;
17313 uint32_t count;
17314
17315 reg_rule_ptr = qdf_mem_malloc(num_reg_rules * sizeof(*reg_rule_ptr));
17316
17317 if (NULL == reg_rule_ptr) {
17318 WMI_LOGE("memory allocation failure");
17319 return NULL;
17320 }
17321
17322 for (count = 0; count < num_reg_rules; count++) {
17323 reg_rule_ptr[count].start_freq =
17324 WMI_REG_RULE_START_FREQ_GET(
17325 wmi_reg_rule[count].freq_info);
17326 reg_rule_ptr[count].end_freq =
17327 WMI_REG_RULE_END_FREQ_GET(
17328 wmi_reg_rule[count].freq_info);
17329 reg_rule_ptr[count].max_bw =
17330 WMI_REG_RULE_MAX_BW_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017331 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017332 reg_rule_ptr[count].reg_power =
17333 WMI_REG_RULE_REG_POWER_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017334 wmi_reg_rule[count].bw_pwr_info);
Abhijit Pradhanb5a1d242017-04-27 20:36:31 +053017335 reg_rule_ptr[count].ant_gain =
17336 WMI_REG_RULE_ANTENNA_GAIN_GET(
17337 wmi_reg_rule[count].bw_pwr_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017338 reg_rule_ptr[count].flags =
17339 WMI_REG_RULE_FLAGS_GET(
Karunakar Dasinenif6f8ca82017-03-31 17:42:44 -070017340 wmi_reg_rule[count].flag_info);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017341 }
17342
17343 return reg_rule_ptr;
17344}
17345
17346static QDF_STATUS extract_reg_chan_list_update_event_tlv(
17347 wmi_unified_t wmi_handle, uint8_t *evt_buf,
17348 struct cur_regulatory_info *reg_info, uint32_t len)
17349{
17350 WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *param_buf;
17351 wmi_reg_chan_list_cc_event_fixed_param *chan_list_event_hdr;
17352 wmi_regulatory_rule_struct *wmi_reg_rule;
17353 uint32_t num_2g_reg_rules, num_5g_reg_rules;
17354
17355 WMI_LOGD("processing regulatory channel list");
17356
17357 param_buf = (WMI_REG_CHAN_LIST_CC_EVENTID_param_tlvs *)evt_buf;
17358 if (!param_buf) {
17359 WMI_LOGE("invalid channel list event buf");
17360 return QDF_STATUS_E_FAILURE;
17361 }
17362
17363 chan_list_event_hdr = param_buf->fixed_param;
17364
17365 reg_info->num_2g_reg_rules = chan_list_event_hdr->num_2g_reg_rules;
17366 reg_info->num_5g_reg_rules = chan_list_event_hdr->num_5g_reg_rules;
17367 qdf_mem_copy(reg_info->alpha2, &(chan_list_event_hdr->alpha2),
17368 REG_ALPHA2_LEN);
17369 reg_info->dfs_region = chan_list_event_hdr->dfs_region;
17370 reg_info->phybitmap = chan_list_event_hdr->phybitmap;
Amar Singhala2d575f2017-05-04 17:12:34 -070017371 reg_info->offload_enabled = true;
Amar Singhala522f212017-05-12 16:39:23 -070017372 reg_info->num_phy = chan_list_event_hdr->num_phy;
17373 reg_info->ctry_code = chan_list_event_hdr->country_id;
17374 reg_info->reg_dmn_pair = chan_list_event_hdr->domain_code;
17375 if (chan_list_event_hdr->status_code == WMI_REG_SET_CC_STATUS_PASS)
17376 reg_info->status_code = REG_SET_CC_STATUS_PASS;
17377 else if (chan_list_event_hdr->status_code ==
17378 WMI_REG_CURRENT_ALPHA2_NOT_FOUND)
17379 reg_info->status_code = REG_CURRENT_ALPHA2_NOT_FOUND;
17380 else if (chan_list_event_hdr->status_code ==
17381 WMI_REG_INIT_ALPHA2_NOT_FOUND)
17382 reg_info->status_code = REG_INIT_ALPHA2_NOT_FOUND;
17383 else if (chan_list_event_hdr->status_code ==
17384 WMI_REG_SET_CC_CHANGE_NOT_ALLOWED)
17385 reg_info->status_code = REG_SET_CC_CHANGE_NOT_ALLOWED;
17386 else if (chan_list_event_hdr->status_code ==
17387 WMI_REG_SET_CC_STATUS_NO_MEMORY)
17388 reg_info->status_code = REG_SET_CC_STATUS_NO_MEMORY;
17389 else if (chan_list_event_hdr->status_code ==
17390 WMI_REG_SET_CC_STATUS_FAIL)
17391 reg_info->status_code = REG_SET_CC_STATUS_FAIL;
17392
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017393 reg_info->min_bw_2g = chan_list_event_hdr->min_bw_2g;
17394 reg_info->max_bw_2g = chan_list_event_hdr->max_bw_2g;
17395 reg_info->min_bw_5g = chan_list_event_hdr->min_bw_5g;
17396 reg_info->max_bw_5g = chan_list_event_hdr->max_bw_5g;
17397
17398 num_2g_reg_rules = reg_info->num_2g_reg_rules;
17399 num_5g_reg_rules = reg_info->num_5g_reg_rules;
17400
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017401 WMI_LOGD("%s:cc %s dsf %d BW: min_2g %d max_2g %d min_5g %d max_5g %d",
17402 __func__, reg_info->alpha2, reg_info->dfs_region,
17403 reg_info->min_bw_2g, reg_info->max_bw_2g,
17404 reg_info->min_bw_5g, reg_info->max_bw_5g);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017405
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017406 WMI_LOGD("%s: num_2g_reg_rules %d num_5g_reg_rules %d", __func__,
17407 num_2g_reg_rules, num_5g_reg_rules);
Kiran Kumar Lokeredd64e042017-03-31 15:50:26 -070017408 wmi_reg_rule =
17409 (wmi_regulatory_rule_struct *)((uint8_t *)chan_list_event_hdr
17410 + sizeof(wmi_reg_chan_list_cc_event_fixed_param)
17411 + WMI_TLV_HDR_SIZE);
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017412 reg_info->reg_rules_2g_ptr = create_reg_rules_from_wmi(num_2g_reg_rules,
17413 wmi_reg_rule);
17414 wmi_reg_rule += num_2g_reg_rules;
17415
17416 reg_info->reg_rules_5g_ptr = create_reg_rules_from_wmi(num_5g_reg_rules,
17417 wmi_reg_rule);
17418
17419 WMI_LOGD("processed regulatory channel list");
17420
17421 return QDF_STATUS_SUCCESS;
17422}
17423
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017424#ifdef DFS_COMPONENT_ENABLE
17425/**
17426 * extract_dfs_cac_complete_event_tlv() - extract cac complete event
17427 * @wmi_handle: wma handle
17428 * @evt_buf: event buffer
17429 * @vdev_id: vdev id
17430 * @len: length of buffer
17431 *
17432 * Return: 0 for success or error code
17433 */
17434static QDF_STATUS extract_dfs_cac_complete_event_tlv(wmi_unified_t wmi_handle,
17435 uint8_t *evt_buf,
17436 uint32_t *vdev_id,
17437 uint32_t len)
17438{
17439 WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *param_tlvs;
17440 wmi_vdev_dfs_cac_complete_event_fixed_param *cac_event;
17441
17442 param_tlvs = (WMI_VDEV_DFS_CAC_COMPLETE_EVENTID_param_tlvs *) evt_buf;
17443 if (!param_tlvs) {
17444 WMI_LOGE("invalid cac complete event buf");
17445 return QDF_STATUS_E_FAILURE;
17446 }
17447
17448 cac_event = param_tlvs->fixed_param;
17449 *vdev_id = cac_event->vdev_id;
17450 WMI_LOGD("processed cac complete event vdev %d", *vdev_id);
17451
17452 return QDF_STATUS_SUCCESS;
17453}
17454
17455/**
17456 * extract_dfs_radar_detection_event_tlv() - extract radar found event
17457 * @wmi_handle: wma handle
17458 * @evt_buf: event buffer
17459 * @radar_found: radar found event info
17460 * @len: length of buffer
17461 *
17462 * Return: 0 for success or error code
17463 */
17464static QDF_STATUS extract_dfs_radar_detection_event_tlv(
17465 wmi_unified_t wmi_handle,
17466 uint8_t *evt_buf,
17467 struct radar_found_info *radar_found,
17468 uint32_t len)
17469{
17470 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *param_tlv;
17471 wmi_pdev_dfs_radar_detection_event_fixed_param *radar_event;
17472
17473 param_tlv = (WMI_PDEV_DFS_RADAR_DETECTION_EVENTID_param_tlvs *) evt_buf;
17474 if (!param_tlv) {
17475 WMI_LOGE("invalid radar detection event buf");
17476 return QDF_STATUS_E_FAILURE;
17477 }
17478
17479 radar_event = param_tlv->fixed_param;
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017480 radar_found->pdev_id = wmi_handle->ops->convert_pdev_id_target_to_host(
17481 radar_event->pdev_id);
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017482 radar_found->detection_mode = radar_event->detection_mode;
17483 radar_found->freq_offset = radar_event->chan_freq;
17484 radar_found->chan_width = radar_event->chan_width;
17485 radar_found->detector_id = radar_event->detector_id;
17486 radar_found->segment_id = radar_event->segment_id;
17487 radar_found->timestamp = radar_event->timestamp;
17488 radar_found->is_chirp = radar_event->is_chirp;
17489
17490 WMI_LOGD("processed radar found event pdev %d", radar_event->pdev_id);
17491
17492 return QDF_STATUS_SUCCESS;
17493}
17494#endif
17495
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017496/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017497 * convert_host_pdev_id_to_target_pdev_id_legacy() - Convert pdev_id from
17498 * host to target defines. For legacy there is not conversion
17499 * required. Just return pdev_id as it is.
17500 * @param pdev_id: host pdev_id to be converted.
17501 * Return: target pdev_id after conversion.
17502 */
17503static uint32_t convert_host_pdev_id_to_target_pdev_id_legacy(
17504 uint32_t pdev_id)
17505{
17506 if (pdev_id == WMI_HOST_PDEV_ID_SOC)
17507 return WMI_PDEV_ID_SOC;
17508
17509 /*No conversion required*/
17510 return pdev_id;
17511}
17512
17513/**
17514 * convert_target_pdev_id_to_host_pdev_id_legacy() - Convert pdev_id from
17515 * target to host defines. For legacy there is not conversion
17516 * required. Just return pdev_id as it is.
17517 * @param pdev_id: target pdev_id to be converted.
17518 * Return: host pdev_id after conversion.
17519 */
17520static uint32_t convert_target_pdev_id_to_host_pdev_id_legacy(
17521 uint32_t pdev_id)
17522{
17523 /*No conversion required*/
17524 return pdev_id;
17525}
17526
17527/**
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017528 * send_set_country_cmd_tlv() - WMI scan channel list function
17529 * @param wmi_handle : handle to WMI.
17530 * @param param : pointer to hold scan channel list parameter
17531 *
17532 * Return: 0 on success and -ve on failure.
17533 */
17534static QDF_STATUS send_set_country_cmd_tlv(wmi_unified_t wmi_handle,
17535 struct set_country *params)
17536{
17537 wmi_buf_t buf;
17538 QDF_STATUS qdf_status;
17539 wmi_set_current_country_cmd_fixed_param *cmd;
17540 uint16_t len = sizeof(*cmd);
17541
17542 buf = wmi_buf_alloc(wmi_handle, len);
17543 if (!buf) {
17544 WMI_LOGE("Failed to allocate memory");
17545 qdf_status = QDF_STATUS_E_NOMEM;
17546 goto end;
17547 }
17548
17549 cmd = (wmi_set_current_country_cmd_fixed_param *)wmi_buf_data(buf);
17550 WMITLV_SET_HDR(&cmd->tlv_header,
17551 WMITLV_TAG_STRUC_wmi_set_current_country_cmd_fixed_param,
17552 WMITLV_GET_STRUCT_TLVLEN
17553 (wmi_set_current_country_cmd_fixed_param));
17554
17555 WMI_LOGD("setting cuurnet country to %s", params->country);
17556
17557 qdf_mem_copy((uint8_t *)&cmd->new_alpha2, params->country, 3);
17558
17559 cmd->pdev_id = params->pdev_id;
17560
17561 qdf_status = wmi_unified_cmd_send(wmi_handle,
17562 buf, len, WMI_SET_CURRENT_COUNTRY_CMDID);
17563
17564 if (QDF_IS_STATUS_ERROR(qdf_status)) {
17565 WMI_LOGE("Failed to send WMI_SET_CURRENT_COUNTRY_CMDID");
17566 wmi_buf_free(buf);
17567 }
17568
17569end:
17570 return qdf_status;
17571}
17572
Govind Singh5eb51532016-03-09 11:34:12 +053017573struct wmi_ops tlv_ops = {
17574 .send_vdev_create_cmd = send_vdev_create_cmd_tlv,
17575 .send_vdev_delete_cmd = send_vdev_delete_cmd_tlv,
17576 .send_vdev_down_cmd = send_vdev_down_cmd_tlv,
Himanshu Agarwal0007b762016-03-09 16:49:38 +053017577 .send_vdev_start_cmd = send_vdev_start_cmd_tlv,
17578 .send_hidden_ssid_vdev_restart_cmd =
17579 send_hidden_ssid_vdev_restart_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053017580 .send_peer_flush_tids_cmd = send_peer_flush_tids_cmd_tlv,
17581 .send_peer_param_cmd = send_peer_param_cmd_tlv,
17582 .send_vdev_up_cmd = send_vdev_up_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053017583 .send_vdev_stop_cmd = send_vdev_stop_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053017584 .send_peer_create_cmd = send_peer_create_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053017585 .send_peer_delete_cmd = send_peer_delete_cmd_tlv,
Leo Changeee40872016-09-28 13:43:36 -070017586 .send_peer_rx_reorder_queue_setup_cmd =
17587 send_peer_rx_reorder_queue_setup_cmd_tlv,
17588 .send_peer_rx_reorder_queue_remove_cmd =
17589 send_peer_rx_reorder_queue_remove_cmd_tlv,
Ishank Jainf4b8a7a2017-02-23 22:38:42 +053017590 .send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv,
17591 .send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv,
17592 .send_peer_update_wds_entry_cmd = send_peer_update_wds_entry_cmd_tlv,
Govind Singh5eb51532016-03-09 11:34:12 +053017593 .send_green_ap_ps_cmd = send_green_ap_ps_cmd_tlv,
17594 .send_pdev_utf_cmd = send_pdev_utf_cmd_tlv,
17595 .send_pdev_param_cmd = send_pdev_param_cmd_tlv,
17596 .send_suspend_cmd = send_suspend_cmd_tlv,
17597 .send_resume_cmd = send_resume_cmd_tlv,
17598 .send_wow_enable_cmd = send_wow_enable_cmd_tlv,
17599 .send_set_ap_ps_param_cmd = send_set_ap_ps_param_cmd_tlv,
17600 .send_set_sta_ps_param_cmd = send_set_sta_ps_param_cmd_tlv,
17601 .send_crash_inject_cmd = send_crash_inject_cmd_tlv,
17602 .send_dbglog_cmd = send_dbglog_cmd_tlv,
17603 .send_vdev_set_param_cmd = send_vdev_set_param_cmd_tlv,
17604 .send_stats_request_cmd = send_stats_request_cmd_tlv,
17605 .send_packet_log_enable_cmd = send_packet_log_enable_cmd_tlv,
17606 .send_beacon_send_cmd = send_beacon_send_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053017607#ifndef CONFIG_MCL
17608 .send_beacon_tmpl_send_cmd = send_beacon_tmpl_send_cmd_tlv,
17609#endif
Govind Singh5eb51532016-03-09 11:34:12 +053017610 .send_peer_assoc_cmd = send_peer_assoc_cmd_tlv,
17611 .send_scan_start_cmd = send_scan_start_cmd_tlv,
17612 .send_scan_stop_cmd = send_scan_stop_cmd_tlv,
17613 .send_scan_chan_list_cmd = send_scan_chan_list_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053017614 .send_mgmt_cmd = send_mgmt_cmd_tlv,
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017615 .send_offchan_data_tx_cmd = send_offchan_data_tx_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053017616 .send_modem_power_state_cmd = send_modem_power_state_cmd_tlv,
17617 .send_set_sta_ps_mode_cmd = send_set_sta_ps_mode_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017618 .send_set_sta_uapsd_auto_trig_cmd =
17619 send_set_sta_uapsd_auto_trig_cmd_tlv,
Govind Singh427ee5a2016-02-26 18:09:36 +053017620 .send_get_temperature_cmd = send_get_temperature_cmd_tlv,
17621 .send_set_p2pgo_oppps_req_cmd = send_set_p2pgo_oppps_req_cmd_tlv,
17622 .send_set_p2pgo_noa_req_cmd = send_set_p2pgo_noa_req_cmd_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080017623#ifdef CONVERGED_P2P_ENABLE
17624 .send_p2p_lo_start_cmd = send_p2p_lo_start_cmd_tlv,
17625 .send_p2p_lo_stop_cmd = send_p2p_lo_stop_cmd_tlv,
17626#endif
Govind Singh427ee5a2016-02-26 18:09:36 +053017627 .send_set_smps_params_cmd = send_set_smps_params_cmd_tlv,
17628 .send_set_mimops_cmd = send_set_mimops_cmd_tlv,
Govind Singh2edc80f2016-03-01 15:30:53 +053017629 .send_ocb_set_utc_time_cmd = send_ocb_set_utc_time_cmd_tlv,
17630 .send_ocb_get_tsf_timer_cmd = send_ocb_get_tsf_timer_cmd_tlv,
17631 .send_dcc_clear_stats_cmd = send_dcc_clear_stats_cmd_tlv,
17632 .send_dcc_get_stats_cmd = send_dcc_get_stats_cmd_tlv,
17633 .send_dcc_update_ndl_cmd = send_dcc_update_ndl_cmd_tlv,
17634 .send_ocb_set_config_cmd = send_ocb_set_config_cmd_tlv,
17635 .send_ocb_stop_timing_advert_cmd = send_ocb_stop_timing_advert_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017636 .send_ocb_start_timing_advert_cmd =
17637 send_ocb_start_timing_advert_cmd_tlv,
Govind Singh17a9cfa2016-03-01 15:54:59 +053017638 .send_set_enable_disable_mcc_adaptive_scheduler_cmd =
17639 send_set_enable_disable_mcc_adaptive_scheduler_cmd_tlv,
17640 .send_set_mcc_channel_time_latency_cmd =
17641 send_set_mcc_channel_time_latency_cmd_tlv,
17642 .send_set_mcc_channel_time_quota_cmd =
17643 send_set_mcc_channel_time_quota_cmd_tlv,
17644 .send_set_thermal_mgmt_cmd = send_set_thermal_mgmt_cmd_tlv,
17645 .send_lro_config_cmd = send_lro_config_cmd_tlv,
Poddar, Siddarth98281c42016-04-28 15:49:11 +053017646 .send_peer_rate_report_cmd = send_peer_rate_report_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017647 .send_set_sta_sa_query_param_cmd = send_set_sta_sa_query_param_cmd_tlv,
17648 .send_set_sta_keep_alive_cmd = send_set_sta_keep_alive_cmd_tlv,
17649 .send_vdev_set_gtx_cfg_cmd = send_vdev_set_gtx_cfg_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017650 .send_probe_rsp_tmpl_send_cmd =
17651 send_probe_rsp_tmpl_send_cmd_tlv,
17652 .send_p2p_go_set_beacon_ie_cmd =
17653 send_p2p_go_set_beacon_ie_cmd_tlv,
Himanshu Agarwal712622f2016-03-09 18:49:18 +053017654 .send_setup_install_key_cmd =
17655 send_setup_install_key_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017656 .send_set_gateway_params_cmd =
17657 send_set_gateway_params_cmd_tlv,
17658 .send_set_rssi_monitoring_cmd =
17659 send_set_rssi_monitoring_cmd_tlv,
17660 .send_scan_probe_setoui_cmd =
17661 send_scan_probe_setoui_cmd_tlv,
17662 .send_reset_passpoint_network_list_cmd =
17663 send_reset_passpoint_network_list_cmd_tlv,
17664 .send_set_passpoint_network_list_cmd =
17665 send_set_passpoint_network_list_cmd_tlv,
Himanshu Agarwalc5e4d892016-03-09 15:25:44 +053017666 .send_roam_scan_offload_rssi_thresh_cmd =
17667 send_roam_scan_offload_rssi_thresh_cmd_tlv,
17668 .send_roam_scan_filter_cmd =
17669 send_roam_scan_filter_cmd_tlv,
Govind Singh4eacd2b2016-03-07 14:24:22 +053017670 .send_set_epno_network_list_cmd =
17671 send_set_epno_network_list_cmd_tlv,
17672 .send_ipa_offload_control_cmd =
17673 send_ipa_offload_control_cmd_tlv,
17674 .send_extscan_get_capabilities_cmd =
17675 send_extscan_get_capabilities_cmd_tlv,
17676 .send_extscan_get_cached_results_cmd =
17677 send_extscan_get_cached_results_cmd_tlv,
17678 .send_extscan_stop_change_monitor_cmd =
17679 send_extscan_stop_change_monitor_cmd_tlv,
17680 .send_extscan_start_change_monitor_cmd =
17681 send_extscan_start_change_monitor_cmd_tlv,
17682 .send_extscan_stop_hotlist_monitor_cmd =
17683 send_extscan_stop_hotlist_monitor_cmd_tlv,
17684 .send_stop_extscan_cmd = send_stop_extscan_cmd_tlv,
17685 .send_start_extscan_cmd = send_start_extscan_cmd_tlv,
17686 .send_plm_stop_cmd = send_plm_stop_cmd_tlv,
17687 .send_plm_start_cmd = send_plm_start_cmd_tlv,
17688 .send_pno_stop_cmd = send_pno_stop_cmd_tlv,
17689 .send_pno_start_cmd = send_pno_start_cmd_tlv,
17690 .send_set_ric_req_cmd = send_set_ric_req_cmd_tlv,
17691 .send_process_ll_stats_clear_cmd = send_process_ll_stats_clear_cmd_tlv,
17692 .send_process_ll_stats_set_cmd = send_process_ll_stats_set_cmd_tlv,
17693 .send_process_ll_stats_get_cmd = send_process_ll_stats_get_cmd_tlv,
17694 .send_get_stats_cmd = send_get_stats_cmd_tlv,
Padma, Santhosh Kumarcb1ee462017-03-21 19:09:35 +053017695 .send_congestion_cmd = send_congestion_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017696 .send_snr_request_cmd = send_snr_request_cmd_tlv,
17697 .send_snr_cmd = send_snr_cmd_tlv,
17698 .send_link_status_req_cmd = send_link_status_req_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017699#ifdef WLAN_PMO_ENABLE
17700 .send_add_wow_wakeup_event_cmd = send_add_wow_wakeup_event_cmd_tlv,
17701 .send_wow_patterns_to_fw_cmd = send_wow_patterns_to_fw_cmd_tlv,
17702 .send_enable_arp_ns_offload_cmd = send_enable_arp_ns_offload_cmd_tlv,
17703 .send_add_clear_mcbc_filter_cmd = send_add_clear_mcbc_filter_cmd_tlv,
Ravi Kumar Bokka8f2c92f2017-03-23 15:22:51 +053017704 .send_enable_broadcast_filter_cmd =
17705 send_enable_broadcast_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017706 .send_gtk_offload_cmd = send_gtk_offload_cmd_tlv,
17707 .send_process_gtk_offload_getinfo_cmd =
17708 send_process_gtk_offload_getinfo_cmd_tlv,
17709 .send_enable_enhance_multicast_offload_cmd =
17710 send_enable_enhance_multicast_offload_tlv,
17711 .extract_gtk_rsp_event = extract_gtk_rsp_event_tlv,
17712#ifdef FEATURE_WLAN_RA_FILTERING
17713 .send_wow_sta_ra_filter_cmd = send_wow_sta_ra_filter_cmd_tlv,
17714#endif
17715 .send_action_frame_patterns_cmd = send_action_frame_patterns_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017716 .send_lphb_config_hbenable_cmd = send_lphb_config_hbenable_cmd_tlv,
17717 .send_lphb_config_tcp_params_cmd = send_lphb_config_tcp_params_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017718 .send_lphb_config_tcp_pkt_filter_cmd =
17719 send_lphb_config_tcp_pkt_filter_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017720 .send_lphb_config_udp_params_cmd = send_lphb_config_udp_params_cmd_tlv,
17721 .send_lphb_config_udp_pkt_filter_cmd =
17722 send_lphb_config_udp_pkt_filter_cmd_tlv,
Ravi Kumar Bokka0f3f04d2017-04-20 17:14:33 +053017723 .send_enable_disable_packet_filter_cmd =
17724 send_enable_disable_packet_filter_cmd_tlv,
17725 .send_config_packet_filter_cmd = send_config_packet_filter_cmd_tlv,
Mukul Sharmab758ddf2017-02-25 01:50:47 +053017726#endif /* End of WLAN_PMO_ENABLE */
17727#ifdef CONFIG_MCL
Govind Singh20c5dac2016-03-07 15:33:31 +053017728 .send_process_dhcp_ind_cmd = send_process_dhcp_ind_cmd_tlv,
17729 .send_get_link_speed_cmd = send_get_link_speed_cmd_tlv,
17730 .send_egap_conf_params_cmd = send_egap_conf_params_cmd_tlv,
Govind Singh87542482016-06-08 19:40:11 +053017731 .send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv,
17732 .send_process_update_edca_param_cmd =
17733 send_process_update_edca_param_cmd_tlv,
17734 .send_roam_scan_offload_mode_cmd =
17735 send_roam_scan_offload_mode_cmd_tlv,
17736 .send_pktlog_wmi_send_cmd = send_pktlog_wmi_send_cmd_tlv,
17737 .send_roam_scan_offload_ap_profile_cmd =
17738 send_roam_scan_offload_ap_profile_cmd_tlv,
17739#endif
Govind Singh20c5dac2016-03-07 15:33:31 +053017740 .send_fw_profiling_cmd = send_fw_profiling_cmd_tlv,
17741 .send_csa_offload_enable_cmd = send_csa_offload_enable_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017742 .send_nat_keepalive_en_cmd = send_nat_keepalive_en_cmd_tlv,
17743 .send_start_oem_data_cmd = send_start_oem_data_cmd_tlv,
17744 .send_dfs_phyerr_filter_offload_en_cmd =
17745 send_dfs_phyerr_filter_offload_en_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017746 .send_wow_delete_pattern_cmd = send_wow_delete_pattern_cmd_tlv,
17747 .send_host_wakeup_ind_to_fw_cmd = send_host_wakeup_ind_to_fw_cmd_tlv,
17748 .send_del_ts_cmd = send_del_ts_cmd_tlv,
17749 .send_aggr_qos_cmd = send_aggr_qos_cmd_tlv,
17750 .send_add_ts_cmd = send_add_ts_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017751 .send_process_add_periodic_tx_ptrn_cmd =
17752 send_process_add_periodic_tx_ptrn_cmd_tlv,
17753 .send_process_del_periodic_tx_ptrn_cmd =
17754 send_process_del_periodic_tx_ptrn_cmd_tlv,
17755 .send_stats_ext_req_cmd = send_stats_ext_req_cmd_tlv,
17756 .send_enable_ext_wow_cmd = send_enable_ext_wow_cmd_tlv,
17757 .send_set_app_type2_params_in_fw_cmd =
17758 send_set_app_type2_params_in_fw_cmd_tlv,
17759 .send_set_auto_shutdown_timer_cmd =
17760 send_set_auto_shutdown_timer_cmd_tlv,
17761 .send_nan_req_cmd = send_nan_req_cmd_tlv,
17762 .send_process_dhcpserver_offload_cmd =
17763 send_process_dhcpserver_offload_cmd_tlv,
17764 .send_set_led_flashing_cmd = send_set_led_flashing_cmd_tlv,
17765 .send_process_ch_avoid_update_cmd =
17766 send_process_ch_avoid_update_cmd_tlv,
Kiran Venkatappa36445a72017-02-08 15:02:44 +053017767 .send_pdev_set_regdomain_cmd =
17768 send_pdev_set_regdomain_cmd_tlv,
Govind Singh20c5dac2016-03-07 15:33:31 +053017769 .send_regdomain_info_to_fw_cmd = send_regdomain_info_to_fw_cmd_tlv,
17770 .send_set_tdls_offchan_mode_cmd = send_set_tdls_offchan_mode_cmd_tlv,
17771 .send_update_fw_tdls_state_cmd = send_update_fw_tdls_state_cmd_tlv,
17772 .send_update_tdls_peer_state_cmd = send_update_tdls_peer_state_cmd_tlv,
17773 .send_process_fw_mem_dump_cmd = send_process_fw_mem_dump_cmd_tlv,
17774 .send_process_set_ie_info_cmd = send_process_set_ie_info_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053017775#ifdef CONFIG_MCL
Govind Singh9ddd5162016-03-07 16:30:32 +053017776 .send_init_cmd = send_init_cmd_tlv,
Himanshu Agarwal7c83dcd2016-07-19 15:41:51 +053017777#endif
Govind Singh9ddd5162016-03-07 16:30:32 +053017778 .save_fw_version_cmd = save_fw_version_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017779 .check_and_update_fw_version =
Govind Singha4836fd2016-03-07 16:45:38 +053017780 check_and_update_fw_version_cmd_tlv,
Govind Singh9ddd5162016-03-07 16:30:32 +053017781 .send_saved_init_cmd = send_saved_init_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053017782 .send_set_base_macaddr_indicate_cmd =
17783 send_set_base_macaddr_indicate_cmd_tlv,
17784 .send_log_supported_evt_cmd = send_log_supported_evt_cmd_tlv,
17785 .send_enable_specific_fw_logs_cmd =
17786 send_enable_specific_fw_logs_cmd_tlv,
17787 .send_flush_logs_to_fw_cmd = send_flush_logs_to_fw_cmd_tlv,
Manishekar Chandrasekaran86508512016-04-21 19:16:32 +053017788 .send_pdev_set_pcl_cmd = send_pdev_set_pcl_cmd_tlv,
Manishekar Chandrasekaran17183782016-04-27 12:29:16 +053017789 .send_pdev_set_hw_mode_cmd = send_pdev_set_hw_mode_cmd_tlv,
Manishekar Chandrasekaran157a4de2016-04-27 12:52:51 +053017790 .send_pdev_set_dual_mac_config_cmd =
17791 send_pdev_set_dual_mac_config_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053017792 .send_app_type1_params_in_fw_cmd =
17793 send_app_type1_params_in_fw_cmd_tlv,
17794 .send_set_ssid_hotlist_cmd = send_set_ssid_hotlist_cmd_tlv,
17795 .send_process_roam_synch_complete_cmd =
17796 send_process_roam_synch_complete_cmd_tlv,
17797 .send_unit_test_cmd = send_unit_test_cmd_tlv,
17798 .send_roam_invoke_cmd = send_roam_invoke_cmd_tlv,
17799 .send_roam_scan_offload_cmd = send_roam_scan_offload_cmd_tlv,
Govind Singha4836fd2016-03-07 16:45:38 +053017800 .send_roam_scan_offload_scan_period_cmd =
17801 send_roam_scan_offload_scan_period_cmd_tlv,
17802 .send_roam_scan_offload_chan_list_cmd =
17803 send_roam_scan_offload_chan_list_cmd_tlv,
17804 .send_roam_scan_offload_rssi_change_cmd =
17805 send_roam_scan_offload_rssi_change_cmd_tlv,
17806 .send_get_buf_extscan_hotlist_cmd =
17807 send_get_buf_extscan_hotlist_cmd_tlv,
Dustin Brown4423f632017-01-13 15:24:07 -080017808 .send_set_active_bpf_mode_cmd = send_set_active_bpf_mode_cmd_tlv,
Gupta, Kapil2e685982016-04-25 19:14:19 +053017809 .send_adapt_dwelltime_params_cmd =
17810 send_adapt_dwelltime_params_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017811 .init_cmd_send = init_cmd_send_tlv,
Sathish Kumar497bef42017-03-01 14:02:36 +053017812 .send_smart_ant_enable_cmd = send_smart_ant_enable_cmd_tlv,
17813 .send_smart_ant_set_rx_ant_cmd = send_smart_ant_set_rx_ant_cmd_tlv,
17814 .send_set_ctl_table_cmd = send_set_ctl_table_cmd_tlv,
17815 .send_set_mimogain_table_cmd = send_set_mimogain_table_cmd_tlv,
17816 .send_packet_power_info_get_cmd = send_packet_power_info_get_cmd_tlv,
17817 .send_vdev_config_ratemask_cmd = send_vdev_config_ratemask_cmd_tlv,
17818 .send_set_vap_dscp_tid_map_cmd = send_set_vap_dscp_tid_map_cmd_tlv,
17819 .send_vdev_set_neighbour_rx_cmd = send_vdev_set_neighbour_rx_cmd_tlv,
17820 .send_smart_ant_set_tx_ant_cmd = send_smart_ant_set_tx_ant_cmd_tlv,
Sathish Kumar02c3b542017-02-22 17:24:45 +053017821 .send_set_ant_switch_tbl_cmd = send_set_ant_switch_tbl_cmd_tlv,
17822 .send_smart_ant_set_training_info_cmd =
17823 send_smart_ant_set_training_info_cmd_tlv,
17824 .send_smart_ant_set_node_config_cmd =
17825 send_smart_ant_set_node_config_cmd_tlv,
17826 .send_set_atf_cmd = send_set_atf_cmd_tlv,
17827 .send_vdev_set_fwtest_param_cmd = send_vdev_set_fwtest_param_cmd_tlv,
17828 .send_set_qboost_param_cmd = send_set_qboost_param_cmd_tlv,
Sathish Kumarf6e3e632017-02-22 17:28:28 +053017829 .send_gpio_config_cmd = send_gpio_config_cmd_tlv,
17830 .send_gpio_output_cmd = send_gpio_output_cmd_tlv,
17831 .send_phyerr_disable_cmd = send_phyerr_disable_cmd_tlv,
17832 .send_phyerr_enable_cmd = send_phyerr_enable_cmd_tlv,
17833 .send_nf_dbr_dbm_info_get_cmd = send_nf_dbr_dbm_info_get_cmd_tlv,
17834 .send_set_ht_ie_cmd = send_set_ht_ie_cmd_tlv,
17835 .send_set_vht_ie_cmd = send_set_vht_ie_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053017836 .send_set_quiet_mode_cmd = send_set_quiet_mode_cmd_tlv,
17837 .send_set_bwf_cmd = send_set_bwf_cmd_tlv,
17838 .send_mcast_group_update_cmd = send_mcast_group_update_cmd_tlv,
17839 .send_vdev_spectral_configure_cmd =
17840 send_vdev_spectral_configure_cmd_tlv,
17841 .send_vdev_spectral_enable_cmd =
17842 send_vdev_spectral_enable_cmd_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017843 .send_thermal_mitigation_param_cmd =
17844 send_thermal_mitigation_param_cmd_tlv,
Sathish Kumarcc5d70d2017-03-21 17:37:50 +053017845 .send_pdev_qvit_cmd = send_pdev_qvit_cmd_tlv,
17846 .send_wmm_update_cmd = send_wmm_update_cmd_tlv,
Sathish Kumar80f4f382017-04-24 11:36:00 +053017847 .send_coex_config_cmd = send_coex_config_cmd_tlv,
Kiran Kumar Lokeredaf91e32017-04-24 00:56:03 -070017848 .send_set_country_cmd = send_set_country_cmd_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017849 .get_target_cap_from_service_ready = extract_service_ready_tlv,
17850 .extract_hal_reg_cap = extract_hal_reg_cap_tlv,
17851 .extract_host_mem_req = extract_host_mem_req_tlv,
17852 .save_service_bitmap = save_service_bitmap_tlv,
17853 .is_service_enabled = is_service_enabled_tlv,
17854 .save_fw_version = save_fw_version_in_service_ready_tlv,
17855 .ready_extract_init_status = ready_extract_init_status_tlv,
17856 .ready_extract_mac_addr = ready_extract_mac_addr_tlv,
17857 .extract_dbglog_data_len = extract_dbglog_data_len_tlv,
17858 .extract_vdev_start_resp = extract_vdev_start_resp_tlv,
17859 .extract_tbttoffset_update_params =
17860 extract_tbttoffset_update_params_tlv,
17861 .extract_mgmt_rx_params = extract_mgmt_rx_params_tlv,
17862 .extract_vdev_stopped_param = extract_vdev_stopped_param_tlv,
17863 .extract_vdev_roam_param = extract_vdev_roam_param_tlv,
17864 .extract_vdev_scan_ev_param = extract_vdev_scan_ev_param_tlv,
Frank Liu3d5e9992017-03-15 17:51:43 +080017865#ifdef CONVERGED_TDLS_ENABLE
17866 .extract_vdev_tdls_ev_param = extract_vdev_tdls_ev_param_tlv,
17867#endif
Govind Singhe7f2f342016-05-23 12:12:52 +053017868 .extract_mgmt_tx_compl_param = extract_mgmt_tx_compl_param_tlv,
17869 .extract_swba_vdev_map = extract_swba_vdev_map_tlv,
17870 .extract_swba_tim_info = extract_swba_tim_info_tlv,
17871 .extract_swba_noa_info = extract_swba_noa_info_tlv,
Wu Gaocd3a8512017-03-13 20:17:34 +080017872#ifdef CONVERGED_P2P_ENABLE
17873 .extract_p2p_noa_ev_param = extract_p2p_noa_ev_param_tlv,
17874 .extract_p2p_lo_stop_ev_param =
17875 extract_p2p_lo_stop_ev_param_tlv,
17876#endif
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017877 .extract_offchan_data_tx_compl_param =
17878 extract_offchan_data_tx_compl_param_tlv,
Govind Singhe7f2f342016-05-23 12:12:52 +053017879 .extract_peer_sta_kickout_ev = extract_peer_sta_kickout_ev_tlv,
17880 .extract_all_stats_count = extract_all_stats_counts_tlv,
17881 .extract_pdev_stats = extract_pdev_stats_tlv,
17882 .extract_pdev_ext_stats = extract_pdev_ext_stats_tlv,
17883 .extract_vdev_stats = extract_vdev_stats_tlv,
17884 .extract_peer_stats = extract_peer_stats_tlv,
17885 .extract_bcnflt_stats = extract_bcnflt_stats_tlv,
17886 .extract_peer_extd_stats = extract_peer_extd_stats_tlv,
17887 .extract_chan_stats = extract_chan_stats_tlv,
17888 .extract_profile_ctx = extract_profile_ctx_tlv,
17889 .extract_profile_data = extract_profile_data_tlv,
17890 .extract_chan_info_event = extract_chan_info_event_tlv,
17891 .extract_channel_hopping_event = extract_channel_hopping_event_tlv,
Anurag Chouhan459e0152016-07-22 20:19:54 +053017892 .send_fw_test_cmd = send_fw_test_cmd_tlv,
Padma, Santhosh Kumar8394bae2016-09-11 18:24:59 +053017893 .send_encrypt_decrypt_send_cmd =
17894 send_encrypt_decrypt_send_cmd_tlv,
Manikandan Mohan31a13e22016-12-13 13:14:06 -080017895 .send_sar_limit_cmd = send_sar_limit_cmd_tlv,
Govind Singh09523e22016-09-12 12:29:21 +053017896 .send_power_dbg_cmd = send_power_dbg_cmd_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053017897 .send_multiple_vdev_restart_req_cmd =
17898 send_multiple_vdev_restart_req_cmd_tlv,
Kiran Venkatappa06520822016-08-10 23:55:40 +053017899 .extract_service_ready_ext = extract_service_ready_ext_tlv,
17900 .extract_hw_mode_cap_service_ready_ext =
17901 extract_hw_mode_cap_service_ready_ext_tlv,
17902 .extract_mac_phy_cap_service_ready_ext =
17903 extract_mac_phy_cap_service_ready_ext_tlv,
17904 .extract_reg_cap_service_ready_ext =
17905 extract_reg_cap_service_ready_ext_tlv,
Sathish Kumar27ee0a32017-01-24 17:51:26 +053017906 .extract_pdev_utf_event = extract_pdev_utf_event_tlv,
Sarada Prasanna Garnayak17b9e9e2017-01-05 19:30:07 +053017907 .wmi_set_htc_tx_tag = wmi_set_htc_tx_tag_tlv,
Kiran Venkatappafea8a802016-12-29 18:09:32 +053017908 .extract_dcs_interference_type = extract_dcs_interference_type_tlv,
17909 .extract_dcs_cw_int = extract_dcs_cw_int_tlv,
17910 .extract_dcs_im_tgt_stats = extract_dcs_im_tgt_stats_tlv,
Kiran Venkatappac813ec92016-12-29 22:07:14 +053017911 .extract_fips_event_data = extract_fips_event_data_tlv,
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053017912 .send_pdev_fips_cmd = send_pdev_fips_cmd_tlv,
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017913 .extract_peer_delete_response_event =
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053017914 extract_peer_delete_response_event_tlv,
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053017915 .is_management_record = is_management_record_tlv,
Sathish Kumar45e991b2017-02-27 10:35:40 +053017916 .extract_pdev_csa_switch_count_status =
17917 extract_pdev_csa_switch_count_status_tlv,
Sathish Kumard3ab1002017-02-07 17:10:59 +053017918 .extract_pdev_tpc_ev_param = extract_pdev_tpc_ev_param_tlv,
17919 .extract_wds_addr_event = extract_wds_addr_event_tlv,
17920 .extract_peer_sta_ps_statechange_ev =
17921 extract_peer_sta_ps_statechange_ev_tlv,
17922 .extract_inst_rssi_stats_event = extract_inst_rssi_stats_event_tlv,
Kapil Gupta54ea36e2017-02-24 15:50:03 +053017923 .send_per_roam_config_cmd = send_per_roam_config_cmd_tlv,
Arif Hussainf00be1d2017-01-07 18:21:55 -080017924 .send_dfs_phyerr_offload_en_cmd = send_dfs_phyerr_offload_en_cmd_tlv,
17925 .send_dfs_phyerr_offload_dis_cmd = send_dfs_phyerr_offload_dis_cmd_tlv,
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053017926 .extract_reg_chan_list_update_event =
Vikram Kandukuri45fc8582017-03-07 18:40:13 +053017927 extract_reg_chan_list_update_event_tlv,
17928 .extract_chainmask_tables =
17929 extract_chainmask_tables_tlv,
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053017930 .extract_thermal_stats = extract_thermal_stats_tlv,
17931 .extract_thermal_level_stats = extract_thermal_level_stats_tlv,
Arif Hussainbe58b4e2017-04-09 01:03:19 -070017932#ifdef DFS_COMPONENT_ENABLE
17933 .extract_dfs_cac_complete_event = extract_dfs_cac_complete_event_tlv,
17934 .extract_dfs_radar_detection_event =
17935 extract_dfs_radar_detection_event_tlv,
17936#endif
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053017937 .convert_pdev_id_host_to_target =
17938 convert_host_pdev_id_to_target_pdev_id_legacy,
17939 .convert_pdev_id_target_to_host =
17940 convert_target_pdev_id_to_host_pdev_id_legacy,
Govind Singh5eb51532016-03-09 11:34:12 +053017941};
17942
Govind Singhe7f2f342016-05-23 12:12:52 +053017943/**
17944 * populate_tlv_event_id() - populates wmi event ids
17945 *
17946 * @param event_ids: Pointer to hold event ids
17947 * Return: None
17948 */
17949static void populate_tlv_events_id(uint32_t *event_ids)
17950{
17951 event_ids[wmi_service_ready_event_id] = WMI_SERVICE_READY_EVENTID;
17952 event_ids[wmi_ready_event_id] = WMI_READY_EVENTID;
17953 event_ids[wmi_scan_event_id] = WMI_SCAN_EVENTID;
17954 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
17955 event_ids[wmi_chan_info_event_id] = WMI_CHAN_INFO_EVENTID;
17956 event_ids[wmi_phyerr_event_id] = WMI_PHYERR_EVENTID;
17957 event_ids[wmi_pdev_dump_event_id] = WMI_PDEV_DUMP_EVENTID;
17958 event_ids[wmi_tx_pause_event_id] = WMI_TX_PAUSE_EVENTID;
17959 event_ids[wmi_dfs_radar_event_id] = WMI_DFS_RADAR_EVENTID;
17960 event_ids[wmi_pdev_l1ss_track_event_id] = WMI_PDEV_L1SS_TRACK_EVENTID;
17961 event_ids[wmi_pdev_temperature_event_id] = WMI_PDEV_TEMPERATURE_EVENTID;
17962 event_ids[wmi_service_ready_ext_event_id] =
17963 WMI_SERVICE_READY_EXT_EVENTID;
17964 event_ids[wmi_vdev_start_resp_event_id] = WMI_VDEV_START_RESP_EVENTID;
17965 event_ids[wmi_vdev_stopped_event_id] = WMI_VDEV_STOPPED_EVENTID;
17966 event_ids[wmi_vdev_install_key_complete_event_id] =
17967 WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID;
17968 event_ids[wmi_vdev_mcc_bcn_intvl_change_req_event_id] =
17969 WMI_VDEV_MCC_BCN_INTERVAL_CHANGE_REQ_EVENTID;
17970
17971 event_ids[wmi_vdev_tsf_report_event_id] = WMI_VDEV_TSF_REPORT_EVENTID;
17972 event_ids[wmi_peer_sta_kickout_event_id] = WMI_PEER_STA_KICKOUT_EVENTID;
17973 event_ids[wmi_peer_info_event_id] = WMI_PEER_INFO_EVENTID;
17974 event_ids[wmi_peer_tx_fail_cnt_thr_event_id] =
17975 WMI_PEER_TX_FAIL_CNT_THR_EVENTID;
17976 event_ids[wmi_peer_estimated_linkspeed_event_id] =
17977 WMI_PEER_ESTIMATED_LINKSPEED_EVENTID;
17978 event_ids[wmi_peer_state_event_id] = WMI_PEER_STATE_EVENTID;
Vijay Pamidipatid814b8d2017-01-17 12:53:05 +053017979 event_ids[wmi_peer_delete_response_event_id] =
17980 WMI_PEER_DELETE_RESP_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053017981 event_ids[wmi_mgmt_rx_event_id] = WMI_MGMT_RX_EVENTID;
17982 event_ids[wmi_host_swba_event_id] = WMI_HOST_SWBA_EVENTID;
17983 event_ids[wmi_tbttoffset_update_event_id] =
17984 WMI_TBTTOFFSET_UPDATE_EVENTID;
17985 event_ids[wmi_offload_bcn_tx_status_event_id] =
17986 WMI_OFFLOAD_BCN_TX_STATUS_EVENTID;
17987 event_ids[wmi_offload_prob_resp_tx_status_event_id] =
17988 WMI_OFFLOAD_PROB_RESP_TX_STATUS_EVENTID;
17989 event_ids[wmi_mgmt_tx_completion_event_id] =
17990 WMI_MGMT_TX_COMPLETION_EVENTID;
17991
17992 event_ids[wmi_tx_delba_complete_event_id] =
17993 WMI_TX_DELBA_COMPLETE_EVENTID;
17994 event_ids[wmi_tx_addba_complete_event_id] =
17995 WMI_TX_ADDBA_COMPLETE_EVENTID;
17996 event_ids[wmi_ba_rsp_ssn_event_id] = WMI_BA_RSP_SSN_EVENTID;
17997
17998 event_ids[wmi_aggr_state_trig_event_id] = WMI_AGGR_STATE_TRIG_EVENTID;
17999
18000 event_ids[wmi_roam_event_id] = WMI_ROAM_EVENTID;
18001 event_ids[wmi_profile_match] = WMI_PROFILE_MATCH;
18002
18003 event_ids[wmi_roam_synch_event_id] = WMI_ROAM_SYNCH_EVENTID;
18004
18005 event_ids[wmi_p2p_disc_event_id] = WMI_P2P_DISC_EVENTID;
18006
18007 event_ids[wmi_p2p_noa_event_id] = WMI_P2P_NOA_EVENTID;
Wu Gao84ed3402017-03-15 19:12:20 +080018008 event_ids[wmi_p2p_lo_stop_event_id] =
18009 WMI_P2P_LISTEN_OFFLOAD_STOPPED_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018010 event_ids[wmi_pdev_resume_event_id] = WMI_PDEV_RESUME_EVENTID;
18011 event_ids[wmi_wow_wakeup_host_event_id] = WMI_WOW_WAKEUP_HOST_EVENTID;
18012 event_ids[wmi_do_wow_disable_ack_event_id] =
18013 WMI_D0_WOW_DISABLE_ACK_EVENTID;
18014 event_ids[wmi_wow_initial_wakeup_event_id] =
18015 WMI_WOW_INITIAL_WAKEUP_EVENTID;
18016
18017 event_ids[wmi_rtt_meas_report_event_id] =
18018 WMI_RTT_MEASUREMENT_REPORT_EVENTID;
18019 event_ids[wmi_tsf_meas_report_event_id] =
18020 WMI_TSF_MEASUREMENT_REPORT_EVENTID;
18021 event_ids[wmi_rtt_error_report_event_id] = WMI_RTT_ERROR_REPORT_EVENTID;
18022 event_ids[wmi_stats_ext_event_id] = WMI_STATS_EXT_EVENTID;
18023 event_ids[wmi_iface_link_stats_event_id] = WMI_IFACE_LINK_STATS_EVENTID;
18024 event_ids[wmi_peer_link_stats_event_id] = WMI_PEER_LINK_STATS_EVENTID;
18025 event_ids[wmi_radio_link_stats_link] = WMI_RADIO_LINK_STATS_EVENTID;
18026 event_ids[wmi_update_fw_mem_dump_event_id] =
18027 WMI_UPDATE_FW_MEM_DUMP_EVENTID;
18028 event_ids[wmi_diag_event_id_log_supported_event_id] =
18029 WMI_DIAG_EVENT_LOG_SUPPORTED_EVENTID;
18030 event_ids[wmi_nlo_match_event_id] = WMI_NLO_MATCH_EVENTID;
18031 event_ids[wmi_nlo_scan_complete_event_id] =
18032 WMI_NLO_SCAN_COMPLETE_EVENTID;
18033 event_ids[wmi_apfind_event_id] = WMI_APFIND_EVENTID;
18034 event_ids[wmi_passpoint_match_event_id] = WMI_PASSPOINT_MATCH_EVENTID;
18035
18036 event_ids[wmi_gtk_offload_status_event_id] =
18037 WMI_GTK_OFFLOAD_STATUS_EVENTID;
18038 event_ids[wmi_gtk_rekey_fail_event_id] = WMI_GTK_REKEY_FAIL_EVENTID;
18039 event_ids[wmi_csa_handling_event_id] = WMI_CSA_HANDLING_EVENTID;
18040 event_ids[wmi_chatter_pc_query_event_id] = WMI_CHATTER_PC_QUERY_EVENTID;
18041
18042 event_ids[wmi_echo_event_id] = WMI_ECHO_EVENTID;
18043
18044 event_ids[wmi_pdev_utf_event_id] = WMI_PDEV_UTF_EVENTID;
18045
18046 event_ids[wmi_dbg_msg_event_id] = WMI_DEBUG_MESG_EVENTID;
18047 event_ids[wmi_update_stats_event_id] = WMI_UPDATE_STATS_EVENTID;
18048 event_ids[wmi_debug_print_event_id] = WMI_DEBUG_PRINT_EVENTID;
18049 event_ids[wmi_dcs_interference_event_id] = WMI_DCS_INTERFERENCE_EVENTID;
18050 event_ids[wmi_pdev_qvit_event_id] = WMI_PDEV_QVIT_EVENTID;
18051 event_ids[wmi_wlan_profile_data_event_id] =
18052 WMI_WLAN_PROFILE_DATA_EVENTID;
18053 event_ids[wmi_pdev_ftm_intg_event_id] = WMI_PDEV_FTM_INTG_EVENTID;
18054 event_ids[wmi_wlan_freq_avoid_event_id] = WMI_WLAN_FREQ_AVOID_EVENTID;
18055 event_ids[wmi_vdev_get_keepalive_event_id] =
18056 WMI_VDEV_GET_KEEPALIVE_EVENTID;
18057 event_ids[wmi_thermal_mgmt_event_id] = WMI_THERMAL_MGMT_EVENTID;
18058
18059 event_ids[wmi_diag_container_event_id] =
18060 WMI_DIAG_DATA_CONTAINER_EVENTID;
18061
18062 event_ids[wmi_host_auto_shutdown_event_id] =
18063 WMI_HOST_AUTO_SHUTDOWN_EVENTID;
18064
18065 event_ids[wmi_update_whal_mib_stats_event_id] =
18066 WMI_UPDATE_WHAL_MIB_STATS_EVENTID;
18067
18068 /*update ht/vht info based on vdev (rx and tx NSS and preamble) */
18069 event_ids[wmi_update_vdev_rate_stats_event_id] =
18070 WMI_UPDATE_VDEV_RATE_STATS_EVENTID;
18071
18072 event_ids[wmi_diag_event_id] = WMI_DIAG_EVENTID;
18073
18074 /** Set OCB Sched Response, deprecated */
18075 event_ids[wmi_ocb_set_sched_event_id] = WMI_OCB_SET_SCHED_EVENTID;
18076
18077 event_ids[wmi_dbg_mesg_flush_complete_event_id] =
18078 WMI_DEBUG_MESG_FLUSH_COMPLETE_EVENTID;
18079 event_ids[wmi_rssi_breach_event_id] = WMI_RSSI_BREACH_EVENTID;
18080
18081 /* GPIO Event */
18082 event_ids[wmi_gpio_input_event_id] = WMI_GPIO_INPUT_EVENTID;
18083 event_ids[wmi_uploadh_event_id] = WMI_UPLOADH_EVENTID;
18084
18085 event_ids[wmi_captureh_event_id] = WMI_CAPTUREH_EVENTID;
18086 event_ids[wmi_rfkill_state_change_event_id] =
18087 WMI_RFKILL_STATE_CHANGE_EVENTID;
18088
18089 /* TDLS Event */
18090 event_ids[wmi_tdls_peer_event_id] = WMI_TDLS_PEER_EVENTID;
18091
18092 event_ids[wmi_batch_scan_enabled_event_id] =
18093 WMI_BATCH_SCAN_ENABLED_EVENTID;
18094 event_ids[wmi_batch_scan_result_event_id] =
18095 WMI_BATCH_SCAN_RESULT_EVENTID;
18096 /* OEM Event */
18097 event_ids[wmi_oem_cap_event_id] = WMI_OEM_CAPABILITY_EVENTID;
18098 event_ids[wmi_oem_meas_report_event_id] =
18099 WMI_OEM_MEASUREMENT_REPORT_EVENTID;
18100 event_ids[wmi_oem_report_event_id] = WMI_OEM_ERROR_REPORT_EVENTID;
18101
18102 /* NAN Event */
18103 event_ids[wmi_nan_event_id] = WMI_NAN_EVENTID;
18104
18105 /* LPI Event */
18106 event_ids[wmi_lpi_result_event_id] = WMI_LPI_RESULT_EVENTID;
18107 event_ids[wmi_lpi_status_event_id] = WMI_LPI_STATUS_EVENTID;
18108 event_ids[wmi_lpi_handoff_event_id] = WMI_LPI_HANDOFF_EVENTID;
18109
18110 /* ExtScan events */
18111 event_ids[wmi_extscan_start_stop_event_id] =
18112 WMI_EXTSCAN_START_STOP_EVENTID;
18113 event_ids[wmi_extscan_operation_event_id] =
18114 WMI_EXTSCAN_OPERATION_EVENTID;
18115 event_ids[wmi_extscan_table_usage_event_id] =
18116 WMI_EXTSCAN_TABLE_USAGE_EVENTID;
18117 event_ids[wmi_extscan_cached_results_event_id] =
18118 WMI_EXTSCAN_CACHED_RESULTS_EVENTID;
18119 event_ids[wmi_extscan_wlan_change_results_event_id] =
18120 WMI_EXTSCAN_WLAN_CHANGE_RESULTS_EVENTID;
18121 event_ids[wmi_extscan_hotlist_match_event_id] =
18122 WMI_EXTSCAN_HOTLIST_MATCH_EVENTID;
18123 event_ids[wmi_extscan_capabilities_event_id] =
18124 WMI_EXTSCAN_CAPABILITIES_EVENTID;
18125 event_ids[wmi_extscan_hotlist_ssid_match_event_id] =
18126 WMI_EXTSCAN_HOTLIST_SSID_MATCH_EVENTID;
18127
18128 /* mDNS offload events */
18129 event_ids[wmi_mdns_stats_event_id] = WMI_MDNS_STATS_EVENTID;
18130
18131 /* SAP Authentication offload events */
18132 event_ids[wmi_sap_ofl_add_sta_event_id] = WMI_SAP_OFL_ADD_STA_EVENTID;
18133 event_ids[wmi_sap_ofl_del_sta_event_id] = WMI_SAP_OFL_DEL_STA_EVENTID;
18134
18135 /** Out-of-context-of-bss (OCB) events */
18136 event_ids[wmi_ocb_set_config_resp_event_id] =
18137 WMI_OCB_SET_CONFIG_RESP_EVENTID;
18138 event_ids[wmi_ocb_get_tsf_timer_resp_event_id] =
18139 WMI_OCB_GET_TSF_TIMER_RESP_EVENTID;
18140 event_ids[wmi_dcc_get_stats_resp_event_id] =
18141 WMI_DCC_GET_STATS_RESP_EVENTID;
18142 event_ids[wmi_dcc_update_ndl_resp_event_id] =
18143 WMI_DCC_UPDATE_NDL_RESP_EVENTID;
18144 event_ids[wmi_dcc_stats_event_id] = WMI_DCC_STATS_EVENTID;
18145 /* System-On-Chip events */
18146 event_ids[wmi_soc_set_hw_mode_resp_event_id] =
18147 WMI_SOC_SET_HW_MODE_RESP_EVENTID;
18148 event_ids[wmi_soc_hw_mode_transition_event_id] =
18149 WMI_SOC_HW_MODE_TRANSITION_EVENTID;
18150 event_ids[wmi_soc_set_dual_mac_config_resp_event_id] =
18151 WMI_SOC_SET_DUAL_MAC_CONFIG_RESP_EVENTID;
Nandha Kishore Easwarandf989dc2017-01-09 21:33:00 +053018152 event_ids[wmi_pdev_fips_event_id] = WMI_PDEV_FIPS_EVENTID;
Sathish Kumar45e991b2017-02-27 10:35:40 +053018153 event_ids[wmi_pdev_csa_switch_count_status_event_id] =
18154 WMI_PDEV_CSA_SWITCH_COUNT_STATUS_EVENTID;
Baila, Shashikala Prabhu41509022017-03-17 10:21:14 +053018155 event_ids[wmi_reg_chan_list_cc_event_id] = WMI_REG_CHAN_LIST_CC_EVENTID;
Sathish Kumarf91f5a92017-03-22 15:37:26 +053018156 event_ids[wmi_inst_rssi_stats_event_id] = WMI_INST_RSSI_STATS_EVENTID;
18157 event_ids[wmi_pdev_tpc_config_event_id] = WMI_PDEV_TPC_CONFIG_EVENTID;
18158 event_ids[wmi_peer_sta_ps_statechg_event_id] =
18159 WMI_PEER_STA_PS_STATECHG_EVENTID;
18160 event_ids[wmi_pdev_channel_hopping_event_id] =
18161 WMI_PDEV_CHANNEL_HOPPING_EVENTID;
Kiran Venkatappac13fc7b2017-03-19 22:58:09 +053018162 event_ids[wmi_offchan_data_tx_completion_event] =
18163 WMI_OFFCHAN_DATA_TX_COMPLETION_EVENTID;
Arif Hussainbe58b4e2017-04-09 01:03:19 -070018164 event_ids[wmi_dfs_cac_complete_id] = WMI_VDEV_DFS_CAC_COMPLETE_EVENTID;
18165 event_ids[wmi_dfs_radar_detection_event_id] =
18166 WMI_PDEV_DFS_RADAR_DETECTION_EVENTID;
Om Prakash Tripathic569cdb2017-04-19 16:57:31 +053018167 event_ids[wmi_tt_stats_event_id] = WMI_THERM_THROT_STATS_EVENTID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018168}
18169
Soumya Bhat488092d2017-03-22 14:41:01 +053018170#ifndef CONFIG_MCL
18171/**
18172 * populate_tlv_service() - populates wmi services
18173 *
18174 * @param wmi_service: Pointer to hold wmi_service
18175 * Return: None
18176 */
18177static void populate_tlv_service(uint32_t *wmi_service)
18178{
18179 wmi_service[wmi_service_beacon_offload] = WMI_SERVICE_BEACON_OFFLOAD;
18180 wmi_service[wmi_service_scan_offload] = WMI_SERVICE_SCAN_OFFLOAD;
18181 wmi_service[wmi_service_roam_scan_offload] =
18182 WMI_SERVICE_ROAM_SCAN_OFFLOAD;
18183 wmi_service[wmi_service_bcn_miss_offload] =
18184 WMI_SERVICE_BCN_MISS_OFFLOAD;
18185 wmi_service[wmi_service_sta_pwrsave] = WMI_SERVICE_STA_PWRSAVE;
18186 wmi_service[wmi_service_sta_advanced_pwrsave] =
18187 WMI_SERVICE_STA_ADVANCED_PWRSAVE;
18188 wmi_service[wmi_service_ap_uapsd] = WMI_SERVICE_AP_UAPSD;
18189 wmi_service[wmi_service_ap_dfs] = WMI_SERVICE_AP_DFS;
18190 wmi_service[wmi_service_11ac] = WMI_SERVICE_11AC;
18191 wmi_service[wmi_service_blockack] = WMI_SERVICE_BLOCKACK;
18192 wmi_service[wmi_service_phyerr] = WMI_SERVICE_PHYERR;
18193 wmi_service[wmi_service_bcn_filter] = WMI_SERVICE_BCN_FILTER;
18194 wmi_service[wmi_service_rtt] = WMI_SERVICE_RTT;
18195 wmi_service[wmi_service_wow] = WMI_SERVICE_WOW;
18196 wmi_service[wmi_service_ratectrl_cache] = WMI_SERVICE_RATECTRL_CACHE;
18197 wmi_service[wmi_service_iram_tids] = WMI_SERVICE_IRAM_TIDS;
18198 wmi_service[wmi_service_arpns_offload] = WMI_SERVICE_ARPNS_OFFLOAD;
18199 wmi_service[wmi_service_nlo] = WMI_SERVICE_NLO;
18200 wmi_service[wmi_service_gtk_offload] = WMI_SERVICE_GTK_OFFLOAD;
18201 wmi_service[wmi_service_scan_sch] = WMI_SERVICE_SCAN_SCH;
18202 wmi_service[wmi_service_csa_offload] = WMI_SERVICE_CSA_OFFLOAD;
18203 wmi_service[wmi_service_chatter] = WMI_SERVICE_CHATTER;
18204 wmi_service[wmi_service_coex_freqavoid] = WMI_SERVICE_COEX_FREQAVOID;
18205 wmi_service[wmi_service_packet_power_save] =
18206 WMI_SERVICE_PACKET_POWER_SAVE;
18207 wmi_service[wmi_service_force_fw_hang] = WMI_SERVICE_FORCE_FW_HANG;
18208 wmi_service[wmi_service_gpio] = WMI_SERVICE_GPIO;
18209 wmi_service[wmi_service_sta_dtim_ps_modulated_dtim] =
18210 WMI_SERVICE_STA_DTIM_PS_MODULATED_DTIM;
18211 wmi_service[wmi_sta_uapsd_basic_auto_trig] =
18212 WMI_STA_UAPSD_BASIC_AUTO_TRIG;
18213 wmi_service[wmi_sta_uapsd_var_auto_trig] = WMI_STA_UAPSD_VAR_AUTO_TRIG;
18214 wmi_service[wmi_service_sta_keep_alive] = WMI_SERVICE_STA_KEEP_ALIVE;
18215 wmi_service[wmi_service_tx_encap] = WMI_SERVICE_TX_ENCAP;
18216 wmi_service[wmi_service_ap_ps_detect_out_of_sync] =
18217 WMI_SERVICE_AP_PS_DETECT_OUT_OF_SYNC;
18218 wmi_service[wmi_service_early_rx] = WMI_SERVICE_EARLY_RX;
18219 wmi_service[wmi_service_sta_smps] = WMI_SERVICE_STA_SMPS;
18220 wmi_service[wmi_service_fwtest] = WMI_SERVICE_FWTEST;
18221 wmi_service[wmi_service_sta_wmmac] = WMI_SERVICE_STA_WMMAC;
18222 wmi_service[wmi_service_tdls] = WMI_SERVICE_TDLS;
18223 wmi_service[wmi_service_burst] = WMI_SERVICE_BURST;
18224 wmi_service[wmi_service_mcc_bcn_interval_change] =
18225 WMI_SERVICE_MCC_BCN_INTERVAL_CHANGE;
18226 wmi_service[wmi_service_adaptive_ocs] = WMI_SERVICE_ADAPTIVE_OCS;
18227 wmi_service[wmi_service_ba_ssn_support] = WMI_SERVICE_BA_SSN_SUPPORT;
18228 wmi_service[wmi_service_filter_ipsec_natkeepalive] =
18229 WMI_SERVICE_FILTER_IPSEC_NATKEEPALIVE;
18230 wmi_service[wmi_service_wlan_hb] = WMI_SERVICE_WLAN_HB;
18231 wmi_service[wmi_service_lte_ant_share_support] =
18232 WMI_SERVICE_LTE_ANT_SHARE_SUPPORT;
18233 wmi_service[wmi_service_batch_scan] = WMI_SERVICE_BATCH_SCAN;
18234 wmi_service[wmi_service_qpower] = WMI_SERVICE_QPOWER;
18235 wmi_service[wmi_service_plmreq] = WMI_SERVICE_PLMREQ;
18236 wmi_service[wmi_service_thermal_mgmt] = WMI_SERVICE_THERMAL_MGMT;
18237 wmi_service[wmi_service_rmc] = WMI_SERVICE_RMC;
18238 wmi_service[wmi_service_mhf_offload] = WMI_SERVICE_MHF_OFFLOAD;
18239 wmi_service[wmi_service_coex_sar] = WMI_SERVICE_COEX_SAR;
18240 wmi_service[wmi_service_bcn_txrate_override] =
18241 WMI_SERVICE_BCN_TXRATE_OVERRIDE;
18242 wmi_service[wmi_service_nan] = WMI_SERVICE_NAN;
18243 wmi_service[wmi_service_l1ss_stat] = WMI_SERVICE_L1SS_STAT;
18244 wmi_service[wmi_service_estimate_linkspeed] =
18245 WMI_SERVICE_ESTIMATE_LINKSPEED;
18246 wmi_service[wmi_service_obss_scan] = WMI_SERVICE_OBSS_SCAN;
18247 wmi_service[wmi_service_tdls_offchan] = WMI_SERVICE_TDLS_OFFCHAN;
18248 wmi_service[wmi_service_tdls_uapsd_buffer_sta] =
18249 WMI_SERVICE_TDLS_UAPSD_BUFFER_STA;
18250 wmi_service[wmi_service_tdls_uapsd_sleep_sta] =
18251 WMI_SERVICE_TDLS_UAPSD_SLEEP_STA;
18252 wmi_service[wmi_service_ibss_pwrsave] = WMI_SERVICE_IBSS_PWRSAVE;
18253 wmi_service[wmi_service_lpass] = WMI_SERVICE_LPASS;
18254 wmi_service[wmi_service_extscan] = WMI_SERVICE_EXTSCAN;
18255 wmi_service[wmi_service_d0wow] = WMI_SERVICE_D0WOW;
18256 wmi_service[wmi_service_hsoffload] = WMI_SERVICE_HSOFFLOAD;
18257 wmi_service[wmi_service_roam_ho_offload] = WMI_SERVICE_ROAM_HO_OFFLOAD;
18258 wmi_service[wmi_service_rx_full_reorder] = WMI_SERVICE_RX_FULL_REORDER;
18259 wmi_service[wmi_service_dhcp_offload] = WMI_SERVICE_DHCP_OFFLOAD;
18260 wmi_service[wmi_service_sta_rx_ipa_offload_support] =
18261 WMI_SERVICE_STA_RX_IPA_OFFLOAD_SUPPORT;
18262 wmi_service[wmi_service_mdns_offload] = WMI_SERVICE_MDNS_OFFLOAD;
18263 wmi_service[wmi_service_sap_auth_offload] =
18264 WMI_SERVICE_SAP_AUTH_OFFLOAD;
18265 wmi_service[wmi_service_dual_band_simultaneous_support] =
18266 WMI_SERVICE_DUAL_BAND_SIMULTANEOUS_SUPPORT;
18267 wmi_service[wmi_service_ocb] = WMI_SERVICE_OCB;
18268 wmi_service[wmi_service_ap_arpns_offload] =
18269 WMI_SERVICE_AP_ARPNS_OFFLOAD;
18270 wmi_service[wmi_service_per_band_chainmask_support] =
18271 WMI_SERVICE_PER_BAND_CHAINMASK_SUPPORT;
18272 wmi_service[wmi_service_packet_filter_offload] =
18273 WMI_SERVICE_PACKET_FILTER_OFFLOAD;
18274 wmi_service[wmi_service_mgmt_tx_htt] = WMI_SERVICE_MGMT_TX_HTT;
18275 wmi_service[wmi_service_mgmt_tx_wmi] = WMI_SERVICE_MGMT_TX_WMI;
18276 wmi_service[wmi_service_ext_msg] = WMI_SERVICE_EXT_MSG;
18277 wmi_service[wmi_service_mawc] = WMI_SERVICE_MAWC;
18278 wmi_service[wmi_service_multiple_vdev_restart] =
18279 WMI_SERVICE_MULTIPLE_VDEV_RESTART;
18280
18281 wmi_service[wmi_service_roam_offload] = WMI_SERVICE_UNAVAILABLE;
18282 wmi_service[wmi_service_ratectrl] = WMI_SERVICE_UNAVAILABLE;
18283 wmi_service[wmi_service_smart_antenna_sw_support] =
18284 WMI_SERVICE_UNAVAILABLE;
18285 wmi_service[wmi_service_smart_antenna_hw_support] =
18286 WMI_SERVICE_UNAVAILABLE;
18287 wmi_service[wmi_service_enhanced_proxy_sta] = WMI_SERVICE_UNAVAILABLE;
18288 wmi_service[wmi_service_tt] = WMI_SERVICE_UNAVAILABLE;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018289 wmi_service[wmi_service_atf] = WMI_SERVICE_ATF;
Soumya Bhat488092d2017-03-22 14:41:01 +053018290 wmi_service[wmi_service_peer_caching] = WMI_SERVICE_UNAVAILABLE;
18291 wmi_service[wmi_service_coex_gpio] = WMI_SERVICE_UNAVAILABLE;
18292 wmi_service[wmi_service_aux_spectral_intf] = WMI_SERVICE_UNAVAILABLE;
18293 wmi_service[wmi_service_aux_chan_load_intf] = WMI_SERVICE_UNAVAILABLE;
18294 wmi_service[wmi_service_bss_channel_info_64] = WMI_SERVICE_UNAVAILABLE;
18295 wmi_service[wmi_service_ext_res_cfg_support] = WMI_SERVICE_UNAVAILABLE;
18296 wmi_service[wmi_service_mesh] = WMI_SERVICE_UNAVAILABLE;
18297 wmi_service[wmi_service_restrt_chnl_support] = WMI_SERVICE_UNAVAILABLE;
Soumya Bhat488092d2017-03-22 14:41:01 +053018298 wmi_service[wmi_service_peer_stats] = WMI_SERVICE_UNAVAILABLE;
18299 wmi_service[wmi_service_mesh_11s] = WMI_SERVICE_UNAVAILABLE;
18300 wmi_service[wmi_service_periodic_chan_stat_support] =
18301 WMI_SERVICE_UNAVAILABLE;
18302 wmi_service[wmi_service_tx_mode_push_only] = WMI_SERVICE_UNAVAILABLE;
18303 wmi_service[wmi_service_tx_mode_push_pull] = WMI_SERVICE_UNAVAILABLE;
18304 wmi_service[wmi_service_tx_mode_dynamic] = WMI_SERVICE_UNAVAILABLE;
18305 wmi_service[wmi_service_btcoex_duty_cycle] = WMI_SERVICE_UNAVAILABLE;
18306 wmi_service[wmi_service_4_wire_coex_support] = WMI_SERVICE_UNAVAILABLE;
18307 wmi_service[wmi_service_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
Kiran Venkatappa95c82a62017-05-10 14:34:17 +053018308 wmi_service[wmi_service_peer_assoc_conf] = WMI_SERVICE_PEER_ASSOC_CONF;
18309 wmi_service[wmi_service_egap] = WMI_SERVICE_EGAP;
18310 wmi_service[wmi_service_sta_pmf_offload] = WMI_SERVICE_STA_PMF_OFFLOAD;
18311 wmi_service[wmi_service_unified_wow_capability] =
18312 WMI_SERVICE_UNIFIED_WOW_CAPABILITY;
18313 wmi_service[wmi_service_enterprise_mesh] = WMI_SERVICE_ENTERPRISE_MESH;
18314 wmi_service[wmi_service_bpf_offload] = WMI_SERVICE_BPF_OFFLOAD;
18315 wmi_service[wmi_service_sync_delete_cmds] =
18316 WMI_SERVICE_SYNC_DELETE_CMDS;
18317 wmi_service[wmi_service_ratectrl_limit_max_min_rates] =
18318 WMI_SERVICE_RATECTRL_LIMIT_MAX_MIN_RATES;
18319 wmi_service[wmi_service_nan_data] = WMI_SERVICE_NAN_DATA;
18320 wmi_service[wmi_service_nan_rtt] = WMI_SERVICE_NAN_RTT;
18321 wmi_service[wmi_service_11ax] = WMI_SERVICE_11AX;
18322 wmi_service[wmi_service_deprecated_replace] =
18323 WMI_SERVICE_DEPRECATED_REPLACE;
18324 wmi_service[wmi_service_tdls_conn_tracker_in_host_mode] =
18325 WMI_SERVICE_TDLS_CONN_TRACKER_IN_HOST_MODE;
18326 wmi_service[wmi_service_enhanced_mcast_filter] =
18327 WMI_SERVICE_ENHANCED_MCAST_FILTER;
18328 wmi_service[wmi_service_half_rate_quarter_rate_support] =
18329 WMI_SERVICE_HALF_RATE_QUARTER_RATE_SUPPORT;
18330 wmi_service[wmi_service_vdev_rx_filter] = WMI_SERVICE_VDEV_RX_FILTER;
18331 wmi_service[wmi_service_p2p_listen_offload_support] =
18332 WMI_SERVICE_P2P_LISTEN_OFFLOAD_SUPPORT;
18333 wmi_service[wmi_service_mark_first_wakeup_packet] =
18334 WMI_SERVICE_MARK_FIRST_WAKEUP_PACKET;
18335 wmi_service[wmi_service_multiple_mcast_filter_set] =
18336 WMI_SERVICE_MULTIPLE_MCAST_FILTER_SET;
18337 wmi_service[wmi_service_host_managed_rx_reorder] =
18338 WMI_SERVICE_HOST_MANAGED_RX_REORDER;
18339 wmi_service[wmi_service_flash_rdwr_support] =
18340 WMI_SERVICE_FLASH_RDWR_SUPPORT;
18341 wmi_service[wmi_service_wlan_stats_report] =
18342 WMI_SERVICE_WLAN_STATS_REPORT;
18343 wmi_service[wmi_service_tx_msdu_id_new_partition_support] =
18344 WMI_SERVICE_TX_MSDU_ID_NEW_PARTITION_SUPPORT;
18345 wmi_service[wmi_service_dfs_phyerr_offload] =
18346 WMI_SERVICE_DFS_PHYERR_OFFLOAD;
18347 wmi_service[wmi_service_rcpi_support] = WMI_SERVICE_RCPI_SUPPORT;
18348 wmi_service[wmi_service_fw_mem_dump_support] =
18349 WMI_SERVICE_FW_MEM_DUMP_SUPPORT;
18350 wmi_service[wmi_service_peer_stats_info] = WMI_SERVICE_PEER_STATS_INFO;
18351 wmi_service[wmi_service_regulatory_db] = WMI_SERVICE_REGULATORY_DB;
18352 wmi_service[wmi_service_11d_offload] = WMI_SERVICE_11D_OFFLOAD;
18353 wmi_service[wmi_service_hw_data_filtering] =
18354 WMI_SERVICE_HW_DATA_FILTERING;
18355 wmi_service[wmi_service_pkt_routing] = WMI_SERVICE_PKT_ROUTING;
18356 wmi_service[wmi_service_offchan_tx_wmi] = WMI_SERVICE_OFFCHAN_TX_WMI;
Soumya Bhat488092d2017-03-22 14:41:01 +053018357}
18358
Govind Singhe7f2f342016-05-23 12:12:52 +053018359/**
18360 * populate_pdev_param_tlv() - populates pdev params
18361 *
18362 * @param pdev_param: Pointer to hold pdev params
18363 * Return: None
18364 */
18365static void populate_pdev_param_tlv(uint32_t *pdev_param)
18366{
18367 pdev_param[wmi_pdev_param_tx_chain_mask] = WMI_PDEV_PARAM_TX_CHAIN_MASK;
18368 pdev_param[wmi_pdev_param_rx_chain_mask] = WMI_PDEV_PARAM_RX_CHAIN_MASK;
18369 pdev_param[wmi_pdev_param_txpower_limit2g] =
18370 WMI_PDEV_PARAM_TXPOWER_LIMIT2G;
18371 pdev_param[wmi_pdev_param_txpower_limit5g] =
18372 WMI_PDEV_PARAM_TXPOWER_LIMIT5G;
18373 pdev_param[wmi_pdev_param_txpower_scale] = WMI_PDEV_PARAM_TXPOWER_SCALE;
18374 pdev_param[wmi_pdev_param_beacon_gen_mode] =
18375 WMI_PDEV_PARAM_BEACON_GEN_MODE;
18376 pdev_param[wmi_pdev_param_beacon_tx_mode] =
18377 WMI_PDEV_PARAM_BEACON_TX_MODE;
18378 pdev_param[wmi_pdev_param_resmgr_offchan_mode] =
18379 WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE;
18380 pdev_param[wmi_pdev_param_protection_mode] =
18381 WMI_PDEV_PARAM_PROTECTION_MODE;
18382 pdev_param[wmi_pdev_param_dynamic_bw] = WMI_PDEV_PARAM_DYNAMIC_BW;
18383 pdev_param[wmi_pdev_param_non_agg_sw_retry_th] =
18384 WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH;
18385 pdev_param[wmi_pdev_param_agg_sw_retry_th] =
18386 WMI_PDEV_PARAM_AGG_SW_RETRY_TH;
18387 pdev_param[wmi_pdev_param_sta_kickout_th] =
18388 WMI_PDEV_PARAM_STA_KICKOUT_TH;
18389 pdev_param[wmi_pdev_param_ac_aggrsize_scaling] =
18390 WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING;
18391 pdev_param[wmi_pdev_param_ltr_enable] = WMI_PDEV_PARAM_LTR_ENABLE;
18392 pdev_param[wmi_pdev_param_ltr_ac_latency_be] =
18393 WMI_PDEV_PARAM_LTR_AC_LATENCY_BE;
18394 pdev_param[wmi_pdev_param_ltr_ac_latency_bk] =
18395 WMI_PDEV_PARAM_LTR_AC_LATENCY_BK;
18396 pdev_param[wmi_pdev_param_ltr_ac_latency_vi] =
18397 WMI_PDEV_PARAM_LTR_AC_LATENCY_VI;
18398 pdev_param[wmi_pdev_param_ltr_ac_latency_vo] =
18399 WMI_PDEV_PARAM_LTR_AC_LATENCY_VO;
18400 pdev_param[wmi_pdev_param_ltr_ac_latency_timeout] =
18401 WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT;
18402 pdev_param[wmi_pdev_param_ltr_sleep_override] =
18403 WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE;
18404 pdev_param[wmi_pdev_param_ltr_rx_override] =
18405 WMI_PDEV_PARAM_LTR_RX_OVERRIDE;
18406 pdev_param[wmi_pdev_param_ltr_tx_activity_timeout] =
18407 WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT;
18408 pdev_param[wmi_pdev_param_l1ss_enable] = WMI_PDEV_PARAM_L1SS_ENABLE;
18409 pdev_param[wmi_pdev_param_dsleep_enable] = WMI_PDEV_PARAM_DSLEEP_ENABLE;
18410 pdev_param[wmi_pdev_param_pcielp_txbuf_flush] =
18411 WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH;
18412 pdev_param[wmi_pdev_param_pcielp_txbuf_watermark] =
18413 WMI_PDEV_PARAM_PCIELP_TXBUF_WATERMARK;
18414 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_en] =
18415 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN;
18416 pdev_param[wmi_pdev_param_pcielp_txbuf_tmo_value] =
18417 WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE;
18418 pdev_param[wmi_pdev_param_pdev_stats_update_period] =
18419 WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD;
18420 pdev_param[wmi_pdev_param_vdev_stats_update_period] =
18421 WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD;
18422 pdev_param[wmi_pdev_param_peer_stats_update_period] =
18423 WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD;
18424 pdev_param[wmi_pdev_param_bcnflt_stats_update_period] =
18425 WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD;
18426 pdev_param[wmi_pdev_param_pmf_qos] = WMI_PDEV_PARAM_PMF_QOS;
18427 pdev_param[wmi_pdev_param_arp_ac_override] =
18428 WMI_PDEV_PARAM_ARP_AC_OVERRIDE;
18429 pdev_param[wmi_pdev_param_dcs] = WMI_PDEV_PARAM_DCS;
18430 pdev_param[wmi_pdev_param_ani_enable] = WMI_PDEV_PARAM_ANI_ENABLE;
18431 pdev_param[wmi_pdev_param_ani_poll_period] =
18432 WMI_PDEV_PARAM_ANI_POLL_PERIOD;
18433 pdev_param[wmi_pdev_param_ani_listen_period] =
18434 WMI_PDEV_PARAM_ANI_LISTEN_PERIOD;
18435 pdev_param[wmi_pdev_param_ani_ofdm_level] =
18436 WMI_PDEV_PARAM_ANI_OFDM_LEVEL;
18437 pdev_param[wmi_pdev_param_ani_cck_level] = WMI_PDEV_PARAM_ANI_CCK_LEVEL;
18438 pdev_param[wmi_pdev_param_dyntxchain] = WMI_PDEV_PARAM_DYNTXCHAIN;
18439 pdev_param[wmi_pdev_param_proxy_sta] = WMI_PDEV_PARAM_PROXY_STA;
18440 pdev_param[wmi_pdev_param_idle_ps_config] =
18441 WMI_PDEV_PARAM_IDLE_PS_CONFIG;
18442 pdev_param[wmi_pdev_param_power_gating_sleep] =
18443 WMI_PDEV_PARAM_POWER_GATING_SLEEP;
18444 pdev_param[wmi_pdev_param_rfkill_enable] = WMI_PDEV_PARAM_RFKILL_ENABLE;
18445 pdev_param[wmi_pdev_param_burst_dur] = WMI_PDEV_PARAM_BURST_DUR;
18446 pdev_param[wmi_pdev_param_burst_enable] = WMI_PDEV_PARAM_BURST_ENABLE;
18447 pdev_param[wmi_pdev_param_hw_rfkill_config] =
18448 WMI_PDEV_PARAM_HW_RFKILL_CONFIG;
18449 pdev_param[wmi_pdev_param_low_power_rf_enable] =
18450 WMI_PDEV_PARAM_LOW_POWER_RF_ENABLE;
18451 pdev_param[wmi_pdev_param_l1ss_track] = WMI_PDEV_PARAM_L1SS_TRACK;
18452 pdev_param[wmi_pdev_param_hyst_en] = WMI_PDEV_PARAM_HYST_EN;
18453 pdev_param[wmi_pdev_param_power_collapse_enable] =
18454 WMI_PDEV_PARAM_POWER_COLLAPSE_ENABLE;
18455 pdev_param[wmi_pdev_param_led_sys_state] = WMI_PDEV_PARAM_LED_SYS_STATE;
18456 pdev_param[wmi_pdev_param_led_enable] = WMI_PDEV_PARAM_LED_ENABLE;
18457 pdev_param[wmi_pdev_param_audio_over_wlan_latency] =
18458 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_LATENCY;
18459 pdev_param[wmi_pdev_param_audio_over_wlan_enable] =
18460 WMI_PDEV_PARAM_AUDIO_OVER_WLAN_ENABLE;
18461 pdev_param[wmi_pdev_param_whal_mib_stats_update_enable] =
18462 WMI_PDEV_PARAM_WHAL_MIB_STATS_UPDATE_ENABLE;
18463 pdev_param[wmi_pdev_param_vdev_rate_stats_update_period] =
18464 WMI_PDEV_PARAM_VDEV_RATE_STATS_UPDATE_PERIOD;
18465 pdev_param[wmi_pdev_param_cts_cbw] = WMI_PDEV_PARAM_CTS_CBW;
18466 pdev_param[wmi_pdev_param_wnts_config] = WMI_PDEV_PARAM_WNTS_CONFIG;
18467 pdev_param[wmi_pdev_param_adaptive_early_rx_enable] =
18468 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_ENABLE;
18469 pdev_param[wmi_pdev_param_adaptive_early_rx_min_sleep_slop] =
18470 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_MIN_SLEEP_SLOP;
18471 pdev_param[wmi_pdev_param_adaptive_early_rx_inc_dec_step] =
18472 WMI_PDEV_PARAM_ADAPTIVE_EARLY_RX_INC_DEC_STEP;
18473 pdev_param[wmi_pdev_param_early_rx_fix_sleep_slop] =
18474 WMI_PDEV_PARAM_EARLY_RX_FIX_SLEEP_SLOP;
18475 pdev_param[wmi_pdev_param_bmiss_based_adaptive_bto_enable] =
18476 WMI_PDEV_PARAM_BMISS_BASED_ADAPTIVE_BTO_ENABLE;
18477 pdev_param[wmi_pdev_param_bmiss_bto_min_bcn_timeout] =
18478 WMI_PDEV_PARAM_BMISS_BTO_MIN_BCN_TIMEOUT;
18479 pdev_param[wmi_pdev_param_bmiss_bto_inc_dec_step] =
18480 WMI_PDEV_PARAM_BMISS_BTO_INC_DEC_STEP;
18481 pdev_param[wmi_pdev_param_bto_fix_bcn_timeout] =
18482 WMI_PDEV_PARAM_BTO_FIX_BCN_TIMEOUT;
18483 pdev_param[wmi_pdev_param_ce_based_adaptive_bto_enable] =
18484 WMI_PDEV_PARAM_CE_BASED_ADAPTIVE_BTO_ENABLE;
18485 pdev_param[wmi_pdev_param_ce_bto_combo_ce_value] =
18486 WMI_PDEV_PARAM_CE_BTO_COMBO_CE_VALUE;
18487 pdev_param[wmi_pdev_param_tx_chain_mask_2g] =
18488 WMI_PDEV_PARAM_TX_CHAIN_MASK_2G;
18489 pdev_param[wmi_pdev_param_rx_chain_mask_2g] =
18490 WMI_PDEV_PARAM_RX_CHAIN_MASK_2G;
18491 pdev_param[wmi_pdev_param_tx_chain_mask_5g] =
18492 WMI_PDEV_PARAM_TX_CHAIN_MASK_5G;
18493 pdev_param[wmi_pdev_param_rx_chain_mask_5g] =
18494 WMI_PDEV_PARAM_RX_CHAIN_MASK_5G;
18495 pdev_param[wmi_pdev_param_tx_chain_mask_cck] =
18496 WMI_PDEV_PARAM_TX_CHAIN_MASK_CCK;
18497 pdev_param[wmi_pdev_param_tx_chain_mask_1ss] =
18498 WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS;
18499 pdev_param[wmi_pdev_param_rx_filter] = WMI_UNAVAILABLE_PARAM;
18500 pdev_param[wmi_pdev_set_mcast_to_ucast_tid] = WMI_UNAVAILABLE_PARAM;
18501 pdev_param[wmi_pdev_param_mgmt_retry_limit] = WMI_UNAVAILABLE_PARAM;
18502 pdev_param[wmi_pdev_param_aggr_burst] = WMI_UNAVAILABLE_PARAM;
18503 pdev_param[wmi_pdev_peer_sta_ps_statechg_enable] =
18504 WMI_UNAVAILABLE_PARAM;
18505 pdev_param[wmi_pdev_param_proxy_sta_mode] = WMI_UNAVAILABLE_PARAM;
18506 pdev_param[wmi_pdev_param_mu_group_policy] = WMI_UNAVAILABLE_PARAM;
18507 pdev_param[wmi_pdev_param_noise_detection] = WMI_UNAVAILABLE_PARAM;
18508 pdev_param[wmi_pdev_param_noise_threshold] = WMI_UNAVAILABLE_PARAM;
18509 pdev_param[wmi_pdev_param_dpd_enable] = WMI_UNAVAILABLE_PARAM;
18510 pdev_param[wmi_pdev_param_set_mcast_bcast_echo] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018511 pdev_param[wmi_pdev_param_atf_strict_sch] =
18512 WMI_PDEV_PARAM_ATF_STRICT_SCH;
18513 pdev_param[wmi_pdev_param_atf_sched_duration] =
18514 WMI_PDEV_PARAM_ATF_SCHED_DURATION;
Govind Singhe7f2f342016-05-23 12:12:52 +053018515 pdev_param[wmi_pdev_param_ant_plzn] = WMI_UNAVAILABLE_PARAM;
18516 pdev_param[wmi_pdev_param_sensitivity_level] = WMI_UNAVAILABLE_PARAM;
18517 pdev_param[wmi_pdev_param_signed_txpower_2g] = WMI_UNAVAILABLE_PARAM;
18518 pdev_param[wmi_pdev_param_signed_txpower_5g] = WMI_UNAVAILABLE_PARAM;
18519 pdev_param[wmi_pdev_param_enable_per_tid_amsdu] = WMI_UNAVAILABLE_PARAM;
18520 pdev_param[wmi_pdev_param_enable_per_tid_ampdu] = WMI_UNAVAILABLE_PARAM;
18521 pdev_param[wmi_pdev_param_cca_threshold] = WMI_UNAVAILABLE_PARAM;
18522 pdev_param[wmi_pdev_param_rts_fixed_rate] = WMI_UNAVAILABLE_PARAM;
18523 pdev_param[wmi_pdev_param_cal_period] = WMI_UNAVAILABLE_PARAM;
18524 pdev_param[wmi_pdev_param_pdev_reset] = WMI_UNAVAILABLE_PARAM;
18525 pdev_param[wmi_pdev_param_wapi_mbssid_offset] = WMI_UNAVAILABLE_PARAM;
18526 pdev_param[wmi_pdev_param_arp_srcaddr] = WMI_UNAVAILABLE_PARAM;
18527 pdev_param[wmi_pdev_param_arp_dstaddr] = WMI_UNAVAILABLE_PARAM;
18528 pdev_param[wmi_pdev_param_txpower_decr_db] = WMI_UNAVAILABLE_PARAM;
18529 pdev_param[wmi_pdev_param_rx_batchmode] = WMI_UNAVAILABLE_PARAM;
18530 pdev_param[wmi_pdev_param_packet_aggr_delay] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018531 pdev_param[wmi_pdev_param_atf_obss_noise_sch] =
18532 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCH;
Govind Singhe7f2f342016-05-23 12:12:52 +053018533 pdev_param[wmi_pdev_param_atf_obss_noise_scaling_factor] =
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018534 WMI_PDEV_PARAM_ATF_OBSS_NOISE_SCALING_FACTOR;
Govind Singhe7f2f342016-05-23 12:12:52 +053018535 pdev_param[wmi_pdev_param_cust_txpower_scale] = WMI_UNAVAILABLE_PARAM;
Subrat Mishraa1c92f52017-04-03 12:32:42 +053018536 pdev_param[wmi_pdev_param_atf_dynamic_enable] =
18537 WMI_PDEV_PARAM_ATF_DYNAMIC_ENABLE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018538 pdev_param[wmi_pdev_param_atf_ssid_group_policy] =
18539 WMI_UNAVAILABLE_PARAM;
18540 pdev_param[wmi_pdev_param_igmpmld_override] = WMI_UNAVAILABLE_PARAM;
18541 pdev_param[wmi_pdev_param_igmpmld_tid] = WMI_UNAVAILABLE_PARAM;
18542 pdev_param[wmi_pdev_param_antenna_gain] = WMI_UNAVAILABLE_PARAM;
18543 pdev_param[wmi_pdev_param_block_interbss] = WMI_UNAVAILABLE_PARAM;
18544 pdev_param[wmi_pdev_param_set_disable_reset_cmdid] =
18545 WMI_UNAVAILABLE_PARAM;
18546 pdev_param[wmi_pdev_param_set_msdu_ttl_cmdid] = WMI_UNAVAILABLE_PARAM;
18547 pdev_param[wmi_pdev_param_txbf_sound_period_cmdid] =
18548 WMI_UNAVAILABLE_PARAM;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053018549 pdev_param[wmi_pdev_param_set_burst_mode_cmdid] =
18550 WMI_PDEV_PARAM_SET_BURST_MODE_CMDID;
Govind Singhe7f2f342016-05-23 12:12:52 +053018551 pdev_param[wmi_pdev_param_en_stats] = WMI_UNAVAILABLE_PARAM;
Venkateswara Swamy Bandaru21cc1ca2017-02-24 17:09:46 +053018552 pdev_param[wmi_pdev_param_mesh_mcast_enable] =
18553 WMI_PDEV_PARAM_MESH_MCAST_ENABLE;
Sathish Kumara059f412017-03-22 19:10:28 +053018554 pdev_param[wmi_pdev_param_set_promisc_mode_cmdid] =
18555 WMI_PDEV_PARAM_SET_PROMISC_MODE_CMDID;
18556 pdev_param[wmi_pdev_param_set_ppdu_duration_cmdid] =
18557 WMI_PDEV_PARAM_SET_PPDU_DURATION_CMDID;
18558 pdev_param[wmi_pdev_param_igmpmld_ac_override] =
18559 WMI_PDEV_PARAM_IGMPMLD_AC_OVERRIDE;
18560 pdev_param[wmi_pdev_param_remove_mcast2ucast_buffer] =
18561 WMI_PDEV_PARAM_REMOVE_MCAST2UCAST_BUFFER;
18562 pdev_param[wmi_pdev_param_set_mcast2ucast_buffer] =
18563 WMI_PDEV_PARAM_SET_MCAST2UCAST_BUFFER;
18564 pdev_param[wmi_pdev_param_set_mcast2ucast_mode] =
18565 WMI_PDEV_PARAM_SET_MCAST2UCAST_MODE;
18566 pdev_param[wmi_pdev_param_smart_antenna_default_antenna] =
18567 WMI_PDEV_PARAM_SMART_ANTENNA_DEFAULT_ANTENNA;
18568 pdev_param[wmi_pdev_param_fast_channel_reset] =
18569 WMI_PDEV_PARAM_FAST_CHANNEL_RESET;
18570 pdev_param[wmi_pdev_param_rx_decap_mode] = WMI_PDEV_PARAM_RX_DECAP_MODE;
Govind Singhe7f2f342016-05-23 12:12:52 +053018571}
18572
18573/**
18574 * populate_vdev_param_tlv() - populates vdev params
18575 *
18576 * @param vdev_param: Pointer to hold vdev params
18577 * Return: None
18578 */
18579static void populate_vdev_param_tlv(uint32_t *vdev_param)
18580{
18581 vdev_param[wmi_vdev_param_rts_threshold] = WMI_VDEV_PARAM_RTS_THRESHOLD;
18582 vdev_param[wmi_vdev_param_fragmentation_threshold] =
18583 WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD;
18584 vdev_param[wmi_vdev_param_beacon_interval] =
18585 WMI_VDEV_PARAM_BEACON_INTERVAL;
18586 vdev_param[wmi_vdev_param_listen_interval] =
18587 WMI_VDEV_PARAM_LISTEN_INTERVAL;
18588 vdev_param[wmi_vdev_param_multicast_rate] =
18589 WMI_VDEV_PARAM_MULTICAST_RATE;
18590 vdev_param[wmi_vdev_param_mgmt_tx_rate] = WMI_VDEV_PARAM_MGMT_TX_RATE;
18591 vdev_param[wmi_vdev_param_slot_time] = WMI_VDEV_PARAM_SLOT_TIME;
18592 vdev_param[wmi_vdev_param_preamble] = WMI_VDEV_PARAM_PREAMBLE;
18593 vdev_param[wmi_vdev_param_swba_time] = WMI_VDEV_PARAM_SWBA_TIME;
18594 vdev_param[wmi_vdev_stats_update_period] = WMI_VDEV_STATS_UPDATE_PERIOD;
18595 vdev_param[wmi_vdev_pwrsave_ageout_time] = WMI_VDEV_PWRSAVE_AGEOUT_TIME;
18596 vdev_param[wmi_vdev_host_swba_interval] = WMI_VDEV_HOST_SWBA_INTERVAL;
18597 vdev_param[wmi_vdev_param_dtim_period] = WMI_VDEV_PARAM_DTIM_PERIOD;
18598 vdev_param[wmi_vdev_oc_scheduler_air_time_limit] =
18599 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT;
18600 vdev_param[wmi_vdev_param_wds] = WMI_VDEV_PARAM_WDS;
18601 vdev_param[wmi_vdev_param_atim_window] = WMI_VDEV_PARAM_ATIM_WINDOW;
18602 vdev_param[wmi_vdev_param_bmiss_count_max] =
18603 WMI_VDEV_PARAM_BMISS_COUNT_MAX;
18604 vdev_param[wmi_vdev_param_bmiss_first_bcnt] =
18605 WMI_VDEV_PARAM_BMISS_FIRST_BCNT;
18606 vdev_param[wmi_vdev_param_bmiss_final_bcnt] =
18607 WMI_VDEV_PARAM_BMISS_FINAL_BCNT;
18608 vdev_param[wmi_vdev_param_feature_wmm] = WMI_VDEV_PARAM_FEATURE_WMM;
18609 vdev_param[wmi_vdev_param_chwidth] = WMI_VDEV_PARAM_CHWIDTH;
18610 vdev_param[wmi_vdev_param_chextoffset] = WMI_VDEV_PARAM_CHEXTOFFSET;
18611 vdev_param[wmi_vdev_param_disable_htprotection] =
18612 WMI_VDEV_PARAM_DISABLE_HTPROTECTION;
18613 vdev_param[wmi_vdev_param_sta_quickkickout] =
18614 WMI_VDEV_PARAM_STA_QUICKKICKOUT;
18615 vdev_param[wmi_vdev_param_mgmt_rate] = WMI_VDEV_PARAM_MGMT_RATE;
18616 vdev_param[wmi_vdev_param_protection_mode] =
18617 WMI_VDEV_PARAM_PROTECTION_MODE;
18618 vdev_param[wmi_vdev_param_fixed_rate] = WMI_VDEV_PARAM_FIXED_RATE;
18619 vdev_param[wmi_vdev_param_sgi] = WMI_VDEV_PARAM_SGI;
18620 vdev_param[wmi_vdev_param_ldpc] = WMI_VDEV_PARAM_LDPC;
18621 vdev_param[wmi_vdev_param_tx_stbc] = WMI_VDEV_PARAM_TX_STBC;
18622 vdev_param[wmi_vdev_param_rx_stbc] = WMI_VDEV_PARAM_RX_STBC;
18623 vdev_param[wmi_vdev_param_intra_bss_fwd] = WMI_VDEV_PARAM_INTRA_BSS_FWD;
18624 vdev_param[wmi_vdev_param_def_keyid] = WMI_VDEV_PARAM_DEF_KEYID;
18625 vdev_param[wmi_vdev_param_nss] = WMI_VDEV_PARAM_NSS;
18626 vdev_param[wmi_vdev_param_bcast_data_rate] =
18627 WMI_VDEV_PARAM_BCAST_DATA_RATE;
18628 vdev_param[wmi_vdev_param_mcast_data_rate] =
18629 WMI_VDEV_PARAM_MCAST_DATA_RATE;
18630 vdev_param[wmi_vdev_param_mcast_indicate] =
18631 WMI_VDEV_PARAM_MCAST_INDICATE;
18632 vdev_param[wmi_vdev_param_dhcp_indicate] =
18633 WMI_VDEV_PARAM_DHCP_INDICATE;
18634 vdev_param[wmi_vdev_param_unknown_dest_indicate] =
18635 WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE;
18636 vdev_param[wmi_vdev_param_ap_keepalive_min_idle_inactive_time_secs] =
18637 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
18638 vdev_param[wmi_vdev_param_ap_keepalive_max_idle_inactive_time_secs] =
18639 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
18640 vdev_param[wmi_vdev_param_ap_keepalive_max_unresponsive_time_secs] =
18641 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
18642 vdev_param[wmi_vdev_param_ap_enable_nawds] =
18643 WMI_VDEV_PARAM_AP_ENABLE_NAWDS;
18644 vdev_param[wmi_vdev_param_enable_rtscts] = WMI_VDEV_PARAM_ENABLE_RTSCTS;
18645 vdev_param[wmi_vdev_param_txbf] = WMI_VDEV_PARAM_TXBF;
18646 vdev_param[wmi_vdev_param_packet_powersave] =
18647 WMI_VDEV_PARAM_PACKET_POWERSAVE;
18648 vdev_param[wmi_vdev_param_drop_unencry] = WMI_VDEV_PARAM_DROP_UNENCRY;
18649 vdev_param[wmi_vdev_param_tx_encap_type] = WMI_VDEV_PARAM_TX_ENCAP_TYPE;
18650 vdev_param[wmi_vdev_param_ap_detect_out_of_sync_sleeping_sta_time_secs] =
18651 WMI_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS;
18652 vdev_param[wmi_vdev_param_early_rx_adjust_enable] =
18653 WMI_VDEV_PARAM_EARLY_RX_ADJUST_ENABLE;
18654 vdev_param[wmi_vdev_param_early_rx_tgt_bmiss_num] =
18655 WMI_VDEV_PARAM_EARLY_RX_TGT_BMISS_NUM;
18656 vdev_param[wmi_vdev_param_early_rx_bmiss_sample_cycle] =
18657 WMI_VDEV_PARAM_EARLY_RX_BMISS_SAMPLE_CYCLE;
18658 vdev_param[wmi_vdev_param_early_rx_slop_step] =
18659 WMI_VDEV_PARAM_EARLY_RX_SLOP_STEP;
18660 vdev_param[wmi_vdev_param_early_rx_init_slop] =
18661 WMI_VDEV_PARAM_EARLY_RX_INIT_SLOP;
18662 vdev_param[wmi_vdev_param_early_rx_adjust_pause] =
18663 WMI_VDEV_PARAM_EARLY_RX_ADJUST_PAUSE;
18664 vdev_param[wmi_vdev_param_tx_pwrlimit] = WMI_VDEV_PARAM_TX_PWRLIMIT;
18665 vdev_param[wmi_vdev_param_snr_num_for_cal] =
18666 WMI_VDEV_PARAM_SNR_NUM_FOR_CAL;
18667 vdev_param[wmi_vdev_param_roam_fw_offload] =
18668 WMI_VDEV_PARAM_ROAM_FW_OFFLOAD;
18669 vdev_param[wmi_vdev_param_enable_rmc] = WMI_VDEV_PARAM_ENABLE_RMC;
18670 vdev_param[wmi_vdev_param_ibss_max_bcn_lost_ms] =
18671 WMI_VDEV_PARAM_IBSS_MAX_BCN_LOST_MS;
18672 vdev_param[wmi_vdev_param_max_rate] = WMI_VDEV_PARAM_MAX_RATE;
18673 vdev_param[wmi_vdev_param_early_rx_drift_sample] =
18674 WMI_VDEV_PARAM_EARLY_RX_DRIFT_SAMPLE;
18675 vdev_param[wmi_vdev_param_set_ibss_tx_fail_cnt_thr] =
18676 WMI_VDEV_PARAM_SET_IBSS_TX_FAIL_CNT_THR;
18677 vdev_param[wmi_vdev_param_ebt_resync_timeout] =
18678 WMI_VDEV_PARAM_EBT_RESYNC_TIMEOUT;
18679 vdev_param[wmi_vdev_param_aggr_trig_event_enable] =
18680 WMI_VDEV_PARAM_AGGR_TRIG_EVENT_ENABLE;
18681 vdev_param[wmi_vdev_param_is_ibss_power_save_allowed] =
18682 WMI_VDEV_PARAM_IS_IBSS_POWER_SAVE_ALLOWED;
18683 vdev_param[wmi_vdev_param_is_power_collapse_allowed] =
18684 WMI_VDEV_PARAM_IS_POWER_COLLAPSE_ALLOWED;
18685 vdev_param[wmi_vdev_param_is_awake_on_txrx_enabled] =
18686 WMI_VDEV_PARAM_IS_AWAKE_ON_TXRX_ENABLED;
18687 vdev_param[wmi_vdev_param_inactivity_cnt] =
18688 WMI_VDEV_PARAM_INACTIVITY_CNT;
18689 vdev_param[wmi_vdev_param_txsp_end_inactivity_time_ms] =
18690 WMI_VDEV_PARAM_TXSP_END_INACTIVITY_TIME_MS;
18691 vdev_param[wmi_vdev_param_dtim_policy] = WMI_VDEV_PARAM_DTIM_POLICY;
18692 vdev_param[wmi_vdev_param_ibss_ps_warmup_time_secs] =
18693 WMI_VDEV_PARAM_IBSS_PS_WARMUP_TIME_SECS;
18694 vdev_param[wmi_vdev_param_ibss_ps_1rx_chain_in_atim_window_enable] =
18695 WMI_VDEV_PARAM_IBSS_PS_1RX_CHAIN_IN_ATIM_WINDOW_ENABLE;
18696 vdev_param[wmi_vdev_param_rx_leak_window] =
18697 WMI_VDEV_PARAM_RX_LEAK_WINDOW;
18698 vdev_param[wmi_vdev_param_stats_avg_factor] =
18699 WMI_VDEV_PARAM_STATS_AVG_FACTOR;
18700 vdev_param[wmi_vdev_param_disconnect_th] = WMI_VDEV_PARAM_DISCONNECT_TH;
18701 vdev_param[wmi_vdev_param_rtscts_rate] = WMI_VDEV_PARAM_RTSCTS_RATE;
18702 vdev_param[wmi_vdev_param_mcc_rtscts_protection_enable] =
18703 WMI_VDEV_PARAM_MCC_RTSCTS_PROTECTION_ENABLE;
18704 vdev_param[wmi_vdev_param_mcc_broadcast_probe_enable] =
18705 WMI_VDEV_PARAM_MCC_BROADCAST_PROBE_ENABLE;
Kiran Venkatappa0663f212016-12-13 16:50:59 +053018706 vdev_param[wmi_vdev_param_mgmt_tx_power] = WMI_VDEV_PARAM_MGMT_TX_POWER;
18707 vdev_param[wmi_vdev_param_beacon_rate] = WMI_VDEV_PARAM_BEACON_RATE;
Kalyan Tallapragadad9a6abd2017-01-30 14:25:27 +053018708 vdev_param[wmi_vdev_param_rx_decap_type] = WMI_VDEV_PARAM_RX_DECAP_TYPE;
Kris Muthusamye4b6b1c2017-02-20 20:21:04 -080018709 vdev_param[wmi_vdev_param_he_dcm_enable] = WMI_VDEV_PARAM_HE_DCM;
18710 vdev_param[wmi_vdev_param_he_range_ext_enable] =
18711 WMI_VDEV_PARAM_HE_RANGE_EXT;
18712 vdev_param[wmi_vdev_param_he_bss_color] = WMI_VDEV_PARAM_BSS_COLOR;
18713 vdev_param[wmi_vdev_param_set_hemu_mode] = WMI_VDEV_PARAM_SET_HEMU_MODE;
Kiran Venkatappa1f9d67d2017-03-13 15:11:44 +053018714 vdev_param[wmi_vdev_param_sensor_ap] = WMI_VDEV_PARAM_SENSOR_AP;
18715 vdev_param[wmi_vdev_param_dtim_enable_cts] =
18716 WMI_VDEV_PARAM_DTIM_ENABLE_CTS;
18717 vdev_param[wmi_vdev_param_atf_ssid_sched_policy] =
18718 WMI_VDEV_PARAM_ATF_SSID_SCHED_POLICY;
18719 vdev_param[wmi_vdev_param_disable_dyn_bw_rts] =
18720 WMI_VDEV_PARAM_DISABLE_DYN_BW_RTS;
Sathish Kumar2ac40702017-03-22 19:18:45 +053018721 vdev_param[wmi_vdev_param_mcast2ucast_set] =
18722 WMI_VDEV_PARAM_MCAST2UCAST_SET;
18723 vdev_param[wmi_vdev_param_rc_num_retries] =
18724 WMI_VDEV_PARAM_RC_NUM_RETRIES;
18725 vdev_param[wmi_vdev_param_cabq_maxdur] = WMI_VDEV_PARAM_CABQ_MAXDUR;
18726 vdev_param[wmi_vdev_param_mfptest_set] = WMI_VDEV_PARAM_MFPTEST_SET;
18727 vdev_param[wmi_vdev_param_rts_fixed_rate] =
18728 WMI_VDEV_PARAM_RTS_FIXED_RATE;
18729 vdev_param[wmi_vdev_param_vht_sgimask] = WMI_VDEV_PARAM_VHT_SGIMASK;
18730 vdev_param[wmi_vdev_param_vht80_ratemask] =
18731 WMI_VDEV_PARAM_VHT80_RATEMASK;
18732 vdev_param[wmi_vdev_param_proxy_sta] = WMI_VDEV_PARAM_PROXY_STA;
18733 vdev_param[wmi_vdev_param_bw_nss_ratemask] =
18734 WMI_VDEV_PARAM_BW_NSS_RATEMASK;
Govind Singhe7f2f342016-05-23 12:12:52 +053018735}
18736#endif
18737
Govind Singh5eb51532016-03-09 11:34:12 +053018738/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018739 * populate_target_defines_tlv() - Populate target defines and params
18740 * @wmi_handle: pointer to wmi handle
Govind Singh5eb51532016-03-09 11:34:12 +053018741 *
Govind Singhe7d9f3e2016-04-15 13:58:27 +053018742 * Return: None
Govind Singh5eb51532016-03-09 11:34:12 +053018743 */
Kiran Venkatappa1d5f5ab2016-08-09 22:52:35 +053018744#ifndef CONFIG_MCL
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018745static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
Govind Singhe7f2f342016-05-23 12:12:52 +053018746{
Govind Singhe7f2f342016-05-23 12:12:52 +053018747 populate_tlv_service(wmi_handle->services);
Govind Singhe7f2f342016-05-23 12:12:52 +053018748 populate_pdev_param_tlv(wmi_handle->pdev_param);
18749 populate_vdev_param_tlv(wmi_handle->vdev_param);
18750}
18751#else
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018752static void populate_target_defines_tlv(struct wmi_unified *wmi_handle)
18753{ }
18754#endif
18755
18756/**
Kiran Venkatappa1241bb82017-05-10 16:24:51 +053018757 * convert_host_pdev_id_to_target_pdev_id() - Convert pdev_id from
18758 * host to target defines.
18759 * @param pdev_id: host pdev_id to be converted.
18760 * Return: target pdev_id after conversion.
18761 */
18762static uint32_t convert_host_pdev_id_to_target_pdev_id(uint32_t pdev_id)
18763{
18764 switch (pdev_id) {
18765 case WMI_HOST_PDEV_ID_SOC:
18766 return WMI_PDEV_ID_SOC;
18767 case WMI_HOST_PDEV_ID_0:
18768 return WMI_PDEV_ID_1ST;
18769 case WMI_HOST_PDEV_ID_1:
18770 return WMI_PDEV_ID_2ND;
18771 case WMI_HOST_PDEV_ID_2:
18772 return WMI_PDEV_ID_3RD;
18773 }
18774
18775 QDF_ASSERT(0);
18776
18777 return WMI_PDEV_ID_SOC;
18778}
18779
18780/**
18781 * convert_target_pdev_id_to_host_pdev_id() - Convert pdev_id from
18782 * target to host defines.
18783 * @param pdev_id: target pdev_id to be converted.
18784 * Return: host pdev_id after conversion.
18785 */
18786static uint32_t convert_target_pdev_id_to_host_pdev_id(uint32_t pdev_id)
18787{
18788 switch (pdev_id) {
18789 case WMI_PDEV_ID_SOC:
18790 return WMI_HOST_PDEV_ID_SOC;
18791 case WMI_PDEV_ID_1ST:
18792 return WMI_HOST_PDEV_ID_0;
18793 case WMI_PDEV_ID_2ND:
18794 return WMI_HOST_PDEV_ID_1;
18795 case WMI_PDEV_ID_3RD:
18796 return WMI_HOST_PDEV_ID_2;
18797 }
18798
18799 QDF_ASSERT(0);
18800
18801 return WMI_HOST_PDEV_ID_SOC;
18802}
18803
18804/**
18805 * wmi_tlv_pdev_id_conversion_enable() - Enable pdev_id conversion
18806 *
18807 * Return None.
18808 */
18809void wmi_tlv_pdev_id_conversion_enable(wmi_unified_t wmi_handle)
18810{
18811 wmi_handle->ops->convert_pdev_id_host_to_target =
18812 convert_host_pdev_id_to_target_pdev_id;
18813 wmi_handle->ops->convert_pdev_id_target_to_host =
18814 convert_target_pdev_id_to_host_pdev_id;
18815}
18816/**
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018817 * wmi_tlv_attach() - Attach TLV APIs
18818 *
18819 * Return: None
18820 */
Govind Singhe7d9f3e2016-04-15 13:58:27 +053018821void wmi_tlv_attach(wmi_unified_t wmi_handle)
Govind Singh5eb51532016-03-09 11:34:12 +053018822{
Govind Singhe7d9f3e2016-04-15 13:58:27 +053018823 wmi_handle->ops = &tlv_ops;
Govind Singhecf03cd2016-05-12 12:45:51 +053018824#ifdef WMI_INTERFACE_EVENT_LOGGING
18825 wmi_handle->log_info.buf_offset_command = 2;
18826 wmi_handle->log_info.buf_offset_event = 4;
Govind Singhecf03cd2016-05-12 12:45:51 +053018827#endif
Soumya Bhat488092d2017-03-22 14:41:01 +053018828 populate_tlv_events_id(wmi_handle->wmi_events);
Kiran Venkatappa5bffce52017-02-10 16:57:59 +053018829 populate_target_defines_tlv(wmi_handle);
Govind Singh5eb51532016-03-09 11:34:12 +053018830}