xref: /wlan-driver/qcacld-3.0/components/coex/core/inc/wlan_coex_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 /*
19  * DOC: contains declarations for coex core functions
20  */
21 
22 #ifndef _WLAN_COEX_MAIN_API_H_
23 #define _WLAN_COEX_MAIN_API_H_
24 
25 #ifdef FEATURE_COEX
26 #include "wlan_coex_ucfg_api.h"
27 #include "wmi_unified_param.h"
28 #include "wlan_objmgr_psoc_obj.h"
29 #include "wlan_objmgr_vdev_obj.h"
30 
31 #define coex_err(params...) \
32 	QDF_TRACE_ERROR(QDF_MODULE_ID_COEX, params)
33 #define coex_info(params...) \
34 	QDF_TRACE_INFO(QDF_MODULE_ID_COEX, params)
35 #define coex_debug(params...) \
36 	QDF_TRACE_DEBUG(QDF_MODULE_ID_COEX, params)
37 
38 #ifdef WLAN_FEATURE_DBAM_CONFIG
39 /**
40  * struct wlan_coex_callback - coex dbam callback structure
41  * @set_dbam_config_cb: callback for set_dbam_config
42  * @set_dbam_config_ctx: context for set_dbam_config callback
43  */
44 struct wlan_coex_callback {
45 	void (*set_dbam_config_cb)(void *ctx, enum coex_dbam_comp_status *rsp);
46 	void *set_dbam_config_ctx;
47 };
48 #endif
49 
50 /**
51  * struct coex_psoc_obj - coex object definition
52  * @btc_chain_mode: BT Coex chain mode.
53  * @coex_config_updated: callback functions for each config type, which will
54  *  be called when config is updated.
55  * @cb: structure to dbam callback
56  */
57 struct coex_psoc_obj {
58 	enum coex_btc_chain_mode btc_chain_mode;
59 	update_coex_cb coex_config_updated[COEX_CONFIG_TYPE_MAX];
60 #ifdef WLAN_FEATURE_DBAM_CONFIG
61 	struct wlan_coex_callback cb;
62 #endif
63 };
64 
65 /**
66  * wlan_psoc_get_coex_obj() - private API to get coex object from psoc
67  * @psoc: psoc object
68  *
69  * Return: coex object
70  */
71 #define wlan_psoc_get_coex_obj(psoc) \
72 	wlan_psoc_get_coex_obj_fl(psoc, __func__, __LINE__)
73 
74 static inline struct coex_psoc_obj *
wlan_psoc_get_coex_obj_fl(struct wlan_objmgr_psoc * psoc,const char * func,uint32_t line)75 wlan_psoc_get_coex_obj_fl(struct wlan_objmgr_psoc *psoc,
76 			  const char *func, uint32_t line)
77 {
78 	struct coex_psoc_obj *psoc_obj;
79 
80 	psoc_obj = (struct coex_psoc_obj *)
81 		wlan_objmgr_psoc_get_comp_private_obj(psoc,
82 						      WLAN_UMAC_COMP_COEX);
83 	if (!psoc_obj) {
84 		coex_err("%s:%u, Failed to get coex psoc object", func, line);
85 		return NULL;
86 	}
87 	return psoc_obj;
88 }
89 
90 /**
91  * wlan_coex_psoc_init() - API to initialize coex component
92  * @psoc: soc context
93  *
94  * Return: QDF_STATUS
95  */
96 QDF_STATUS
97 wlan_coex_psoc_init(struct wlan_objmgr_psoc *psoc);
98 
99 /**
100  * wlan_coex_psoc_deinit() - API to deinitialize coex component
101  * @psoc: soc context
102  *
103  * Return: QDF_STATUS
104  */
105 QDF_STATUS
106 wlan_coex_psoc_deinit(struct wlan_objmgr_psoc *psoc);
107 
108 /**
109  * wlan_coex_config_send() - private API to send coex config
110  * @vdev: pointer to vdev object
111  * @param: parameters of coex config
112  *
113  * Return: status of operation
114  */
115 QDF_STATUS wlan_coex_config_send(struct wlan_objmgr_vdev *vdev,
116 				 struct coex_config_params *param);
117 
118 /**
119  * wlan_coex_multi_config_send() - API to send coex multiple configure
120  * @vdev: pointer to vdev object
121  * @param: parameters of coex multiple config
122  *
123  * QDF_STATUS
124  */
125 QDF_STATUS wlan_coex_multi_config_send(struct wlan_objmgr_vdev *vdev,
126 				       struct coex_multi_config *param);
127 
128 /**
129  * wlan_coex_config_updated() - private API to notify that coex config
130  * is updated.
131  * @vdev: pointer to vdev object
132  * @type: type of coex config
133  *
134  * Return: status of operation
135  */
136 QDF_STATUS
137 wlan_coex_config_updated(struct wlan_objmgr_vdev *vdev, uint8_t type);
138 
139 /**
140  * wlan_coex_psoc_created_notification() - PSOC obj create callback
141  * @psoc: PSOC object
142  * @arg_list: Variable argument list
143  *
144  * This callback is registered with object manager during initialization to
145  * get notified when the object is created.
146  *
147  * Return: Success or Failure
148  */
149 QDF_STATUS wlan_coex_psoc_created_notification(struct wlan_objmgr_psoc *psoc,
150 					       void *arg_list);
151 
152 /**
153  * wlan_coex_psoc_destroyed_notification() - PSOC obj delete callback
154  * @psoc: PSOC object
155  * @arg_list: Variable argument list
156  *
157  * This callback is registered with object manager during initialization to
158  * get notified when the object is deleted.
159  *
160  * Return: Success or Failure
161  */
162 QDF_STATUS wlan_coex_psoc_destroyed_notification(struct wlan_objmgr_psoc *psoc,
163 						 void *arg_list);
164 
165 /**
166  * wlan_coex_psoc_set_btc_chain_mode() - private API to set BT coex chain mode
167  * for psoc
168  * @psoc: pointer to psoc object
169  * @val: BT coex chain mode
170  *
171  * Return : status of operation
172  */
173 QDF_STATUS
174 wlan_coex_psoc_set_btc_chain_mode(struct wlan_objmgr_psoc *psoc,
175 				  enum coex_btc_chain_mode val);
176 
177 /**
178  * wlan_coex_psoc_get_btc_chain_mode() - private API to get BT coex chain mode
179  * from psoc
180  * @psoc: pointer to psoc object
181  * @val: pointer to BT coex chain mode
182  *
183  * Return : status of operation
184  */
185 QDF_STATUS
186 wlan_coex_psoc_get_btc_chain_mode(struct wlan_objmgr_psoc *psoc,
187 				  enum coex_btc_chain_mode *val);
188 #endif
189 
190 #ifdef WLAN_FEATURE_DBAM_CONFIG
191 /**
192  * wlan_dbam_config_send() - private API to send dbam config
193  * @vdev: pointer to vdev object
194  * @param: parameters of dbam config
195  *
196  * Return: QDF_STATUS of operation
197  */
198 QDF_STATUS wlan_dbam_config_send(struct wlan_objmgr_vdev *vdev,
199 				 struct coex_dbam_config_params *param);
200 
201 static inline struct wlan_lmac_if_dbam_rx_ops *
wlan_psoc_get_dbam_rx_ops(struct wlan_objmgr_psoc * psoc)202 wlan_psoc_get_dbam_rx_ops(struct wlan_objmgr_psoc *psoc)
203 {
204 	struct wlan_lmac_if_rx_ops *rx_ops;
205 
206 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
207 	if (!rx_ops) {
208 		coex_err("rx_ops is NULL");
209 		return NULL;
210 	}
211 
212 	return &rx_ops->dbam_rx_ops;
213 }
214 
215 static inline struct wlan_lmac_if_dbam_tx_ops *
wlan_psoc_get_dbam_tx_ops(struct wlan_objmgr_psoc * psoc)216 wlan_psoc_get_dbam_tx_ops(struct wlan_objmgr_psoc *psoc)
217 {
218 	struct wlan_lmac_if_tx_ops *tx_ops;
219 
220 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
221 	if (!tx_ops) {
222 		coex_err("tx_ops is NULL");
223 		return NULL;
224 	}
225 
226 	return &tx_ops->dbam_tx_ops;
227 }
228 
229 /**
230  * wlan_dbam_attach() - Attach dbam handler
231  * @psoc: psoc pointer
232  *
233  * This function gets called to register dbam FW events handler
234  *
235  * Return: QDF_STATUS
236  */
237 QDF_STATUS wlan_dbam_attach(struct wlan_objmgr_psoc *psoc);
238 
239 /**
240  * wlan_dbam_detach() - Detach dbam handler
241  * @psoc: psoc pointer
242  *
243  * This function gets called to unregister dbam FW events handler
244  *
245  * Return: QDF_STATUS
246  */
247 QDF_STATUS wlan_dbam_detach(struct wlan_objmgr_psoc *psoc);
248 #endif /* WLAN_FEATURE_DBAM_CONFIG */
249 #endif
250