xref: /wlan-driver/qcacld-3.0/components/target_if/interop_issues_ap/src/target_if_interop_issues_ap.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: target_if_interop_issues_ap.c
22  *
23  * This file provide definition for APIs registered through lmac Tx Ops
24  */
25 
26 #include <qdf_mem.h>
27 #include <qdf_status.h>
28 #include <qdf_types.h>
29 #include <target_if.h>
30 #include <wlan_tgt_def_config.h>
31 #include <wlan_osif_priv.h>
32 #include <wlan_interop_issues_ap_tgt_api.h>
33 #include <wlan_interop_issues_ap_api.h>
34 #include <target_if_interop_issues_ap.h>
35 #include <wmi_unified_interop_issues_ap_api.h>
36 
37 /**
38  * target_if_interop_issues_ap_event_handler() - callback for event
39  * @sc: scn handle
40  * @event: firmware event
41  * @len: the event length
42  *
43  * Return: 0 or error status
44  */
target_if_interop_issues_ap_event_handler(ol_scn_t sc,uint8_t * event,uint32_t len)45 static int target_if_interop_issues_ap_event_handler(ol_scn_t sc,
46 						     uint8_t *event,
47 						     uint32_t len)
48 {
49 	struct wlan_objmgr_psoc *psoc;
50 	struct wmi_unified *wmi_handle;
51 	struct wlan_interop_issues_ap_event data = {0};
52 	int ret;
53 
54 	TARGET_IF_ENTER();
55 
56 	psoc = target_if_get_psoc_from_scn_hdl(sc);
57 	if (!psoc) {
58 		target_if_err("psoc ptr is NULL");
59 		return -EINVAL;
60 	}
61 	data.psoc = psoc;
62 
63 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
64 	if (!wmi_handle) {
65 		target_if_err("wmi_handle is null.");
66 		return -EINVAL;
67 	}
68 
69 	ret = wmi_extract_interop_issues_ap_ev_param(wmi_handle, event, &data);
70 	if (ret)
71 		return -EINVAL;
72 
73 	target_if_debug("interop issues ap macaddr: " QDF_MAC_ADDR_FMT,
74 			QDF_MAC_ADDR_REF(data.rap_addr.bytes));
75 
76 	return tgt_interop_issues_ap_info_callback(psoc, &data);
77 }
78 
79 /**
80  * target_if_interop_issues_ap_register_event_handler() - register callback
81  * @psoc: the pointer to psoc object
82  *
83  * Return: QDF_STATUS
84  */
85 QDF_STATUS
target_if_interop_issues_ap_register_event_handler(struct wlan_objmgr_psoc * psoc)86 target_if_interop_issues_ap_register_event_handler(
87 						struct wlan_objmgr_psoc *psoc)
88 {
89 	QDF_STATUS ret_val;
90 	struct wmi_unified *wmi_handle;
91 
92 	if (!psoc) {
93 		target_if_err("PSOC is NULL!");
94 		return QDF_STATUS_E_NULL_VALUE;
95 	}
96 
97 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
98 	if (!wmi_handle) {
99 		target_if_err("wmi_handle is null");
100 		return QDF_STATUS_E_INVAL;
101 	}
102 	ret_val =
103 	   wmi_unified_register_event_handler(wmi_handle,
104 				wmi_pdev_interop_issues_ap_event_id,
105 				target_if_interop_issues_ap_event_handler,
106 				WMI_RX_WORK_CTX);
107 	if (QDF_IS_STATUS_ERROR(ret_val))
108 		target_if_err("Failed to register event cb");
109 
110 	return ret_val;
111 }
112 
113 /**
114  * target_if_interop_issues_ap_unregister_event_handler() - unregister callback
115  * @psoc: the pointer to psoc object
116  *
117  * Return: QDF_STATUS
118  */
119 QDF_STATUS
target_if_interop_issues_ap_unregister_event_handler(struct wlan_objmgr_psoc * psoc)120 target_if_interop_issues_ap_unregister_event_handler(
121 						struct wlan_objmgr_psoc *psoc)
122 {
123 	struct wmi_unified *wmi_handle;
124 
125 	if (!psoc) {
126 		target_if_err("PSOC is NULL!");
127 		return QDF_STATUS_E_INVAL;
128 	}
129 
130 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
131 	if (!wmi_handle) {
132 		target_if_err("wmi_handle is null");
133 		return QDF_STATUS_E_INVAL;
134 	}
135 	wmi_unified_unregister_event_handler(wmi_handle,
136 					wmi_pdev_interop_issues_ap_event_id);
137 
138 	return QDF_STATUS_SUCCESS;
139 }
140 
141 /**
142  * target_if_set_interop_issues_ap_req() - API to send stats request to wmi
143  * @psoc: pointer to psoc object
144  * @rap: pointer to interop issues ap info
145  *
146  * Return: status of operation.
147  */
148 static QDF_STATUS
target_if_set_interop_issues_ap_req(struct wlan_objmgr_psoc * psoc,struct wlan_interop_issues_ap_info * rap)149 target_if_set_interop_issues_ap_req(struct wlan_objmgr_psoc *psoc,
150 				    struct wlan_interop_issues_ap_info *rap)
151 {
152 	struct wmi_unified *wmi_handle;
153 
154 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
155 	if (!wmi_handle) {
156 		target_if_err("wmi_handle is null.");
157 		return QDF_STATUS_E_NULL_VALUE;
158 	}
159 
160 	return wmi_unified_set_rap_ps_cmd(wmi_handle, rap);
161 }
162 
163 QDF_STATUS
target_if_interop_issues_ap_register_tx_ops(struct wlan_objmgr_psoc * psoc,struct wlan_interop_issues_ap_tx_ops * tx_ops)164 target_if_interop_issues_ap_register_tx_ops(struct wlan_objmgr_psoc *psoc,
165 				  struct wlan_interop_issues_ap_tx_ops *tx_ops)
166 {
167 	if (!tx_ops) {
168 		target_if_err("tx ops is NULL!");
169 		return QDF_STATUS_E_INVAL;
170 	}
171 
172 	tx_ops->set_rap_ps = target_if_set_interop_issues_ap_req;
173 
174 	return QDF_STATUS_SUCCESS;
175 }
176 
177 QDF_STATUS
target_if_interop_issues_ap_unregister_tx_ops(struct wlan_objmgr_psoc * psoc,struct wlan_interop_issues_ap_tx_ops * tx_ops)178 target_if_interop_issues_ap_unregister_tx_ops(struct wlan_objmgr_psoc *psoc,
179 				  struct wlan_interop_issues_ap_tx_ops *tx_ops)
180 {
181 	if (!tx_ops) {
182 		target_if_err("tx ops is NULL!");
183 		return QDF_STATUS_E_INVAL;
184 	}
185 
186 	tx_ops->set_rap_ps = NULL;
187 
188 	return QDF_STATUS_SUCCESS;
189 }
190