xref: /wlan-driver/qcacld-3.0/components/ocb/core/inc/wlan_ocb_main.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 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: contains ocb init/deinit public api
22  */
23 
24 #ifndef _WLAN_OCB_MAIN_API_H_
25 #define _WLAN_OCB_MAIN_API_H_
26 
27 #include <qdf_atomic.h>
28 #include <wlan_objmgr_psoc_obj.h>
29 #include <wlan_objmgr_pdev_obj.h>
30 #include <wlan_objmgr_vdev_obj.h>
31 #include <wlan_ocb_public_structs.h>
32 
33 #define ocb_alert_rl(params...) QDF_TRACE_FATAL_RL(QDF_MODULE_ID_OCB, params)
34 #define ocb_err_rl(params...) QDF_TRACE_ERROR_RL(QDF_MODULE_ID_OCB, params)
35 #define ocb_warn_rl(params...) QDF_TRACE_WARN_RL(QDF_MODULE_ID_OCB, params)
36 #define ocb_info_rl(params...) QDF_TRACE_INFO_RL(QDF_MODULE_ID_OCB, params)
37 #define ocb_debug_rl(params...) QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_OCB, params)
38 
39 #define ocb_alert(params...) \
40 	QDF_TRACE_FATAL(QDF_MODULE_ID_OCB, params)
41 #define ocb_err(params...) \
42 	QDF_TRACE_ERROR(QDF_MODULE_ID_OCB, params)
43 #define ocb_warn(params...) \
44 	QDF_TRACE_WARN(QDF_MODULE_ID_OCB, params)
45 #define ocb_notice(params...) \
46 	QDF_TRACE_INFO(QDF_MODULE_ID_OCB, params)
47 #define ocb_info(params...) \
48 	QDF_TRACE_INFO(QDF_MODULE_ID_OCB, params)
49 #define ocb_debug(params...) \
50 	QDF_TRACE_DEBUG(QDF_MODULE_ID_OCB, params)
51 
52 #define ocb_nofl_alert(params...) \
53 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_OCB, params)
54 #define ocb_nofl_err(params...) \
55 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_OCB, params)
56 #define ocb_nofl_warn(params...) \
57 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_OCB, params)
58 #define ocb_nofl_info(params...) \
59 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_OCB, params)
60 #define ocb_nofl_debug(params...) \
61 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_OCB, params)
62 
63 /**
64  * enum ocb_southbound_event - OCB south bound event type
65  * @OCB_CHANNEL_CONFIG_STATUS: set channel config response
66  * @OCB_TSF_TIMER: get TSF timer response
67  * @OCB_DCC_STATS_RESPONSE: get DCC stats response
68  * @OCB_NDL_RESPONSE: NDL update response
69  * @OCB_DCC_INDICATION: DCC stats indication
70  */
71 enum ocb_southbound_event {
72 	OCB_CHANNEL_CONFIG_STATUS,
73 	OCB_TSF_TIMER,
74 	OCB_DCC_STATS_RESPONSE,
75 	OCB_NDL_RESPONSE,
76 	OCB_DCC_INDICATION,
77 };
78 
79 /**
80  * struct ocb_pdev_obj - ocb pdev object
81  * @pdev: pdev handle
82  * @ocb_mac: MAC address for different channels
83  * @ocb_channel_count: channel count
84  * @channel_config: current channel configurations
85  * @dp_soc: psoc data path handle
86  * @dp_pdev_id: pdev data path ID
87  * @ocb_cbs: legacy callback functions
88  * @ocb_txops: tx operations for target interface
89  * @ocb_rxops: rx operations for target interface
90  */
91 struct ocb_pdev_obj {
92 	struct wlan_objmgr_pdev *pdev;
93 	struct qdf_mac_addr ocb_mac[QDF_MAX_CONCURRENCY_PERSONA];
94 	uint32_t ocb_channel_count;
95 	struct ocb_config *channel_config;
96 	void *dp_soc;
97 	uint8_t dp_pdev_id;
98 	struct ocb_callbacks ocb_cbs;
99 	struct wlan_ocb_tx_ops ocb_txops;
100 	struct wlan_ocb_rx_ops ocb_rxops;
101 };
102 
103 /**
104  * struct ocb_rx_event - event from south bound
105  * @psoc: psoc handle
106  * @vdev: vdev handle
107  * @evt_id: event ID
108  * @rsp: Union of response structs, @evt_id is the selector
109  * @channel_cfg_rsp: set channel config status
110  * @tsf_timer: get TSF timer response
111  * @ndl: NDL DCC response
112  * @dcc_stats: DCC stats
113  */
114 struct ocb_rx_event {
115 	struct wlan_objmgr_psoc *psoc;
116 	struct wlan_objmgr_vdev *vdev;
117 	uint32_t evt_id;
118 	union event {
119 		struct ocb_set_config_response channel_cfg_rsp;
120 		struct ocb_get_tsf_timer_response tsf_timer;
121 		struct ocb_dcc_update_ndl_response ndl;
122 		struct ocb_dcc_get_stats_response dcc_stats;
123 	} rsp;
124 };
125 
126 /**
127  * wlan_get_pdev_ocb_obj() - private API to get ocb pdev object
128  * @pdev: pdev object
129  *
130  * Return: ocb object
131  */
132 static inline struct ocb_pdev_obj *
wlan_get_pdev_ocb_obj(struct wlan_objmgr_pdev * pdev)133 wlan_get_pdev_ocb_obj(struct wlan_objmgr_pdev *pdev)
134 {
135 	struct ocb_pdev_obj *pdev_obj;
136 
137 	pdev_obj = (struct ocb_pdev_obj *)
138 		wlan_objmgr_pdev_get_comp_private_obj(pdev,
139 				WLAN_UMAC_COMP_OCB);
140 
141 	return pdev_obj;
142 }
143 
144 /**
145  * wlan_ocb_get_callbacks() - get legacy layer callbacks
146  * @pdev: pdev handle
147  *
148  * Return: legacy layer callbacks
149  */
150 static inline struct ocb_callbacks *
wlan_ocb_get_callbacks(struct wlan_objmgr_pdev * pdev)151 wlan_ocb_get_callbacks(struct wlan_objmgr_pdev *pdev)
152 {
153 	struct ocb_pdev_obj *pdev_obj;
154 
155 	pdev_obj = wlan_get_pdev_ocb_obj(pdev);
156 
157 	if (pdev_obj)
158 		return &pdev_obj->ocb_cbs;
159 	else
160 		return NULL;
161 }
162 
163 /**
164  * wlan_pdev_get_ocb_tx_ops() - get OCB tx operations
165  * @pdev: pdev handle
166  *
167  * Return: fps to OCB tx operations
168  */
169 static inline struct wlan_ocb_tx_ops *
wlan_pdev_get_ocb_tx_ops(struct wlan_objmgr_pdev * pdev)170 wlan_pdev_get_ocb_tx_ops(struct wlan_objmgr_pdev *pdev)
171 {
172 	struct ocb_pdev_obj *ocb_obj;
173 
174 	ocb_obj = wlan_get_pdev_ocb_obj(pdev);
175 
176 	return &ocb_obj->ocb_txops;
177 }
178 
179 /**
180  * wlan_ocb_release_rx_event() - Release OCB RX event
181  * @event: OCB RX event
182  *
183  * Return: none
184  */
wlan_ocb_release_rx_event(struct ocb_rx_event * event)185 static inline void wlan_ocb_release_rx_event(struct ocb_rx_event *event)
186 {
187 
188 	if (!event) {
189 		ocb_err("event is NULL");
190 		return;
191 	}
192 
193 	if (event->vdev)
194 		wlan_objmgr_vdev_release_ref(event->vdev, WLAN_OCB_SB_ID);
195 	if (event->psoc)
196 		wlan_objmgr_psoc_release_ref(event->psoc, WLAN_OCB_SB_ID);
197 	qdf_mem_free(event);
198 }
199 
200 /**
201  * ocb_pdev_obj_create_notification() - OCB pdev object creation notification
202  * @pdev: pdev handle
203  * @arg_list: arguments list
204  *
205  * Return: QDF_STATUS_SUCCESS on success
206  */
207 QDF_STATUS ocb_pdev_obj_create_notification(struct wlan_objmgr_pdev *pdev,
208 					    void *arg_list);
209 
210 /**
211  * ocb_pdev_obj_destroy_notification() - OCB pdev object destroy notification
212  * @pdev: pdev handle
213  * @arg_list: arguments list
214  *
215  * Return: QDF_STATUS_SUCCESS on success
216  */
217 QDF_STATUS ocb_pdev_obj_destroy_notification(struct wlan_objmgr_pdev *pdev,
218 					     void *arg_list);
219 
220 /**
221  * ocb_config_new() - Creates a new OCB configuration
222  * @num_channels: the number of channels
223  * @num_schedule: the schedule size
224  * @ndl_chan_list_len: length in bytes of the NDL chan blob
225  * @ndl_active_state_list_len: length in bytes of the active state blob
226  *
227  * Return: A pointer to the OCB configuration struct, NULL on failure.
228  */
229 struct ocb_config *ocb_config_new(uint32_t num_channels,
230 				  uint32_t num_schedule,
231 				  uint32_t ndl_chan_list_len,
232 				  uint32_t ndl_active_state_list_len);
233 
234 /**
235  * ocb_copy_config() - Backup current config parameters
236  * @src: current config parameters
237  *
238  * Return: A pointer to the OCB configuration struct, NULL on failure.
239  */
240 struct ocb_config *ocb_copy_config(struct ocb_config *src);
241 
242 /**
243  * ocb_process_evt() - API to process event from south bound
244  * @msg: south bound message
245  *
246  * Return: QDF_STATUS_SUCCESS on success
247  */
248 QDF_STATUS ocb_process_evt(struct scheduler_msg *msg);
249 
250 /**
251  * ocb_vdev_start() - start OCB vdev
252  * @ocb_obj: OCB object
253  *
254  * Return: QDF_STATUS_SUCCESS on success
255  */
256 QDF_STATUS ocb_vdev_start(struct ocb_pdev_obj *ocb_obj);
257 #endif
258