1 /*
2  * Copyright (c) 2019-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 
19 /**
20  * DOC:wlan_interop_issues_ap_tgt_api.c
21  *
22  * This file provide API definitions to update interop issues ap from interface
23  */
24 #include <wlan_objmgr_cmn.h>
25 #include <wlan_objmgr_pdev_obj.h>
26 #include <scheduler_api.h>
27 #include <wlan_interop_issues_ap_api.h>
28 #include <wlan_interop_issues_ap_tgt_api.h>
29 
wlan_interop_issues_ap_flush_cbk(struct scheduler_msg * msg)30 static QDF_STATUS wlan_interop_issues_ap_flush_cbk(struct scheduler_msg *msg)
31 {
32 	if (msg->bodyptr) {
33 		qdf_mem_free(msg->bodyptr);
34 		msg->bodyptr = NULL;
35 	}
36 
37 	return QDF_STATUS_SUCCESS;
38 }
39 
wlan_interop_issues_ap_info_cbk(struct scheduler_msg * msg)40 static QDF_STATUS wlan_interop_issues_ap_info_cbk(struct scheduler_msg *msg)
41 {
42 	struct wlan_interop_issues_ap_event *data;
43 	struct wlan_interop_issues_ap_callbacks *cbs;
44 	QDF_STATUS status = QDF_STATUS_SUCCESS;
45 
46 	data = msg->bodyptr;
47 	data->pdev = wlan_objmgr_get_pdev_by_id(data->psoc,
48 						data->pdev_id,
49 						WLAN_INTEROP_ISSUES_AP_ID);
50 	if (!data->pdev) {
51 		interop_issues_ap_err("pdev is null.");
52 		status = QDF_STATUS_E_FAILURE;
53 		goto err;
54 	}
55 
56 	cbs = interop_issues_ap_psoc_get_cbs(data->psoc);
57 	if (cbs && cbs->os_if_interop_issues_ap_event_handler)
58 		cbs->os_if_interop_issues_ap_event_handler(msg->bodyptr);
59 
60 	wlan_objmgr_pdev_release_ref(data->pdev, WLAN_INTEROP_ISSUES_AP_ID);
61 err:
62 	qdf_mem_free(data);
63 	msg->bodyptr = NULL;
64 	return status;
65 }
66 
tgt_interop_issues_ap_info_callback(struct wlan_objmgr_psoc * psoc,struct wlan_interop_issues_ap_event * rap)67 QDF_STATUS tgt_interop_issues_ap_info_callback(struct wlan_objmgr_psoc *psoc,
68 				      struct wlan_interop_issues_ap_event *rap)
69 {
70 	struct scheduler_msg msg = {0};
71 	QDF_STATUS status;
72 	struct wlan_interop_issues_ap_event *data;
73 
74 	data = qdf_mem_malloc(sizeof(*data));
75 	if (!data)
76 		return QDF_STATUS_E_NOMEM;
77 
78 	qdf_mem_copy(data, rap, sizeof(*data));
79 
80 	msg.bodyptr = data;
81 	msg.callback = wlan_interop_issues_ap_info_cbk;
82 	msg.flush_callback = wlan_interop_issues_ap_flush_cbk;
83 
84 	status = scheduler_post_message(QDF_MODULE_ID_INTEROP_ISSUES_AP,
85 					QDF_MODULE_ID_INTEROP_ISSUES_AP,
86 					QDF_MODULE_ID_TARGET_IF, &msg);
87 	if (QDF_IS_STATUS_ERROR(status)) {
88 		interop_issues_ap_err("scheduler msg posting failed");
89 		qdf_mem_free(msg.bodyptr);
90 		msg.bodyptr = NULL;
91 	}
92 
93 	return status;
94 }
95 
tgt_set_interop_issues_ap_req(struct wlan_objmgr_psoc * psoc,struct wlan_interop_issues_ap_info * rap)96 QDF_STATUS tgt_set_interop_issues_ap_req(struct wlan_objmgr_psoc *psoc,
97 				struct wlan_interop_issues_ap_info *rap)
98 {
99 	struct interop_issues_ap_psoc_priv_obj *obj;
100 
101 	obj = interop_issues_ap_get_psoc_priv_obj(psoc);
102 	if (!obj || !obj->tx_ops.set_rap_ps)
103 		return QDF_STATUS_E_NULL_VALUE;
104 
105 	return obj->tx_ops.set_rap_ps(psoc, rap);
106 }
107