1 /*
2  * Copyright (c) 2016-2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 #include <osdep.h>
19 #include <wmi.h>
20 #include <wmi_unified_priv.h>
21 #include "wmi_unified_bcn_api.h"
22 
23 /**
24  * send_bcn_buf_ll_cmd_tlv() - prepare and send beacon buffer to fw for LL
25  * @wmi_handle: wmi handle
26  * @param: bcn ll cmd parameter
27  *
28  * Return: QDF_STATUS_SUCCESS for success otherwise failure
29  */
send_bcn_buf_ll_cmd_tlv(wmi_unified_t wmi_handle,wmi_bcn_send_from_host_cmd_fixed_param * param)30 static QDF_STATUS send_bcn_buf_ll_cmd_tlv(
31 		wmi_unified_t wmi_handle,
32 		wmi_bcn_send_from_host_cmd_fixed_param *param)
33 {
34 	wmi_bcn_send_from_host_cmd_fixed_param *cmd;
35 	wmi_buf_t wmi_buf;
36 	QDF_STATUS ret;
37 
38 	wmi_buf = wmi_buf_alloc(wmi_handle, sizeof(*cmd));
39 	if (!wmi_buf)
40 		return QDF_STATUS_E_FAILURE;
41 
42 	cmd = (wmi_bcn_send_from_host_cmd_fixed_param *)wmi_buf_data(wmi_buf);
43 	WMITLV_SET_HDR(&cmd->tlv_header,
44 		       WMITLV_TAG_STRUC_wmi_bcn_send_from_host_cmd_fixed_param,
45 		       WMITLV_GET_STRUCT_TLVLEN
46 			       (wmi_bcn_send_from_host_cmd_fixed_param));
47 	cmd->vdev_id = param->vdev_id;
48 	cmd->data_len = param->data_len;
49 	cmd->frame_ctrl = param->frame_ctrl;
50 	cmd->frag_ptr = param->frag_ptr;
51 	cmd->dtim_flag = param->dtim_flag;
52 
53 	wmi_mtrace(WMI_PDEV_SEND_BCN_CMDID, cmd->vdev_id, 0);
54 	ret = wmi_unified_cmd_send(wmi_handle, wmi_buf, sizeof(*cmd),
55 				   WMI_PDEV_SEND_BCN_CMDID);
56 
57 	if (QDF_IS_STATUS_ERROR(ret)) {
58 		wmi_err("Failed to send WMI_PDEV_SEND_BCN_CMDID command");
59 		wmi_buf_free(wmi_buf);
60 	}
61 
62 	return ret;
63 }
64 
wmi_bcn_attach_tlv(wmi_unified_t wmi_handle)65 void wmi_bcn_attach_tlv(wmi_unified_t wmi_handle)
66 {
67 	struct wmi_ops *ops = wmi_handle->ops;
68 
69 	ops->send_bcn_buf_ll_cmd = send_bcn_buf_ll_cmd_tlv;
70 }
71