xref: /wlan-driver/qcacld-3.0/components/ocb/dispatcher/inc/wlan_ocb_public_structs.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 structure definitions
22  */
23 
24 #ifndef _WLAN_OCB_STRUCTS_H_
25 #define _WLAN_OCB_STRUCTS_H_
26 #include <qdf_status.h>
27 #include "qca_vendor.h"
28 
29 /* Don't add the RX stats header to packets received on this channel */
30 #define OCB_CHANNEL_FLAG_DISABLE_RX_STATS_HDR	(1 << 0)
31 
32 /* The size of the utc time in bytes. */
33 #define OCB_SIZE_UTC_TIME                       (10)
34 
35 /* The size of the utc time error in bytes. */
36 #define OCB_SIZE_UTC_TIME_ERROR                 (5)
37 
38 /**
39  * struct ocb_utc_param - parameters to set UTC time
40  * @vdev_id: vdev id
41  * @utc_time: number of nanoseconds from Jan 1st 1958
42  * @time_error: the error in the UTC time. All 1's for unknown
43  */
44 struct ocb_utc_param {
45 	uint32_t vdev_id;
46 	uint8_t utc_time[OCB_SIZE_UTC_TIME];
47 	uint8_t time_error[OCB_SIZE_UTC_TIME_ERROR];
48 };
49 
50 /**
51  * struct ocb_timing_advert_param - parameters to start/stop
52  *  timing advertisement
53  * @vdev_id: vdev id
54  * @chan_freq: frequency on which to advertise (unit in Mhz)
55  * @repeat_rate: the number of times it will send TA in 5 seconds
56  * @timestamp_offset: offset of the timestamp field in the TA frame
57  * @time_value_offset: offset of the time_value field in the TA frame
58  * @template_length: size in bytes of the TA frame
59  * @template_value: the TA frame
60  */
61 struct ocb_timing_advert_param {
62 	uint32_t vdev_id;
63 	uint32_t chan_freq;
64 	uint32_t repeat_rate;
65 	uint32_t timestamp_offset;
66 	uint32_t time_value_offset;
67 	uint32_t template_length;
68 	uint8_t *template_value;
69 };
70 
71 /**
72  * struct ocb_dcc_get_stats_param - parameters to get DCC stats
73  * @vdev_id: vdev id
74  * @channel_count: number of dcc channels
75  * @request_array_len: size in bytes of the request array
76  * @request_array: the request array
77  */
78 struct ocb_dcc_get_stats_param {
79 	uint32_t vdev_id;
80 	uint32_t channel_count;
81 	uint32_t request_array_len;
82 	void *request_array;
83 };
84 
85 /**
86  * struct ocb_dcc_update_ndl_param - parameters to update NDL
87  * @vdev_id: vdev id
88  * @channel_count: number of channels to be updated
89  * @dcc_ndl_chan_list_len: size in bytes of the ndl_chan array
90  * @dcc_ndl_chan_list: the ndl_chan array
91  * @dcc_ndl_active_state_list_len: size in bytes of the active_state array
92  * @dcc_ndl_active_state_list: the active state array
93  */
94 struct ocb_dcc_update_ndl_param {
95 	uint32_t vdev_id;
96 	uint32_t channel_count;
97 	uint32_t dcc_ndl_chan_list_len;
98 	void *dcc_ndl_chan_list;
99 	uint32_t dcc_ndl_active_state_list_len;
100 	void *dcc_ndl_active_state_list;
101 };
102 
103 /**
104  * struct ocb_config_schdl - parameters for channel scheduling
105  * @chan_freq: frequency of the channel (unit in Mhz)
106  * @total_duration: duration of the schedule (unit in ms)
107  * @guard_interval: guard interval on the start of the schedule (unit in ms)
108  */
109 struct ocb_config_schdl {
110 	uint32_t chan_freq;
111 	uint32_t total_duration;
112 	uint32_t guard_interval;
113 };
114 
115 /**
116  * struct ocb_wmm_param - WMM parameters
117  * @aifsn: AIFS number
118  * @cwmin: value of CWmin
119  * @cwmax: value of CWmax
120  */
121 struct ocb_wmm_param {
122 	uint8_t aifsn;
123 	uint8_t cwmin;
124 	uint8_t cwmax;
125 };
126 
127 /**
128  * struct ocb_config_chan - parameters to configure a channel
129  * @chan_freq: frequency of the channel (unit in MHz)
130  * @bandwidth: bandwidth of the channel, either 10 or 20 MHz
131  * @mac_address: MAC address assigned to this channel
132  * @qos_params: QoS parameters
133  * @max_pwr: maximum transmit power of the channel (dBm)
134  * @min_pwr: minimum transmit power of the channel (dBm)
135  * @reg_pwr: maximum transmit power specified by the regulatory domain (dBm)
136  * @antenna_max: maximum antenna gain specified by the regulatory domain (dB)
137  * @flags: bit0: 0 enable RX stats on this channel; 1 disable RX stats
138  *         bit1: flag to indicate TSF expiry time in TX control.
139  *               0 relative time is used. 1 absolute time is used.
140  *         bit2: Frame mode from user layer.
141  *               0 for 802.3 frame, 1 for 802.11 frame.
142  * @ch_mode: channel mode
143  */
144 struct ocb_config_chan {
145 	uint32_t chan_freq;
146 	uint32_t bandwidth;
147 	struct qdf_mac_addr mac_address;
148 	struct ocb_wmm_param qos_params[QCA_WLAN_AC_ALL];
149 	uint32_t max_pwr;
150 	uint32_t min_pwr;
151 	uint8_t reg_pwr;
152 	uint8_t antenna_max;
153 	uint16_t flags;
154 	uint32_t ch_mode;
155 };
156 
157 /**
158  * struct ocb_config - parameters for OCB vdev config
159  * @vdev_id: vdev id
160  * @channel_count: number of channels
161  * @schedule_size: size of the channel schedule
162  * @flags: reserved
163  * @channels: array of OCB channels
164  * @schedule: array of OCB schedule elements
165  * @dcc_ndl_chan_list_len: size in bytes of the ndl_chan array
166  * @dcc_ndl_chan_list: array of dcc channel info
167  * @dcc_ndl_active_state_list_len: size in bytes of the active state array
168  * @dcc_ndl_active_state_list: array of active states
169  */
170 struct ocb_config {
171 	uint32_t vdev_id;
172 	uint32_t channel_count;
173 	uint32_t schedule_size;
174 	uint32_t flags;
175 	struct ocb_config_chan *channels;
176 	struct ocb_config_schdl *schedule;
177 	uint32_t dcc_ndl_chan_list_len;
178 	void *dcc_ndl_chan_list;
179 	uint32_t dcc_ndl_active_state_list_len;
180 	void *dcc_ndl_active_state_list;
181 };
182 
183 /**
184  * enum ocb_channel_config_status - ocb config status
185  * @OCB_CHANNEL_CONFIG_SUCCESS: success
186  * @OCB_CHANNEL_CONFIG_FAIL: failure
187  * @OCB_CHANNEL_CONFIG_STATUS_MAX: place holder, not a real status
188  */
189 enum ocb_channel_config_status {
190 	OCB_CHANNEL_CONFIG_SUCCESS = 0,
191 	OCB_CHANNEL_CONFIG_FAIL,
192 	OCB_CHANNEL_CONFIG_STATUS_MAX
193 };
194 
195 /**
196  * struct ocb_set_config_response - ocb config status
197  * @status: response status. OCB_CHANNEL_CONFIG_SUCCESS for success.
198  */
199 struct ocb_set_config_response {
200 	enum ocb_channel_config_status status;
201 };
202 
203 /**
204  * struct ocb_get_tsf_timer_response - TSF timer response
205  * @vdev_id: vdev id
206  * @timer_high: higher 32-bits of the timer
207  * @timer_low: lower 32-bits of the timer
208  */
209 struct ocb_get_tsf_timer_response {
210 	uint32_t vdev_id;
211 	uint32_t timer_high;
212 	uint32_t timer_low;
213 };
214 
215 /**
216  * struct ocb_get_tsf_timer_param - parameters to get tsf timer
217  * @vdev_id: vdev id
218  */
219 struct ocb_get_tsf_timer_param {
220 	uint32_t vdev_id;
221 };
222 
223 /**
224  * struct ocb_dcc_get_stats_response - DCC stats response
225  * @vdev_id: vdev id
226  * @num_channels: number of dcc channels
227  * @channel_stats_array_len: size in bytes of the stats array
228  * @channel_stats_array: the stats array
229  */
230 struct ocb_dcc_get_stats_response {
231 	uint32_t vdev_id;
232 	uint32_t num_channels;
233 	uint32_t channel_stats_array_len;
234 	void *channel_stats_array;
235 };
236 
237 /**
238  * struct ocb_dcc_clear_stats_param - parameters to clear DCC stats
239  * @vdev_id: vdev id
240  * @dcc_stats_bitmap: bitmap of clear option
241  */
242 struct ocb_dcc_clear_stats_param {
243 	uint32_t vdev_id;
244 	uint32_t dcc_stats_bitmap;
245 };
246 
247 /**
248  * struct ocb_dcc_update_ndl_response - NDP update response
249  * @vdev_id: vdev id
250  * @status: response status
251  */
252 struct ocb_dcc_update_ndl_response {
253 	uint32_t vdev_id;
254 	uint32_t status;
255 };
256 
257 /**
258  * struct wlan_ocb_rx_ops - structure containing rx ops for OCB
259  * @ocb_set_config_status: fp to get channel config status
260  * @ocb_tsf_timer: fp to get TSF timer
261  * @ocb_dcc_ndl_update: fp to get NDL update status
262  * @ocb_dcc_stats_indicate: fp to get DCC stats
263  */
264 struct wlan_ocb_rx_ops {
265 	QDF_STATUS (*ocb_set_config_status)(struct wlan_objmgr_psoc *psoc,
266 					    uint32_t status);
267 	QDF_STATUS (*ocb_tsf_timer)(struct wlan_objmgr_psoc *psoc,
268 				struct ocb_get_tsf_timer_response *response);
269 	QDF_STATUS (*ocb_dcc_ndl_update)(struct wlan_objmgr_psoc *psoc,
270 				struct ocb_dcc_update_ndl_response *resp);
271 	QDF_STATUS (*ocb_dcc_stats_indicate)(struct wlan_objmgr_psoc *psoc,
272 		struct ocb_dcc_get_stats_response *response, bool indicate);
273 };
274 
275 /**
276  * struct wlan_ocb_tx_ops - structures containing tx ops for OCB
277  * @ocb_set_config: fp to set channel config
278  * @ocb_set_utc_time: fp to set utc time
279  * @ocb_start_timing_advert: fp to start timing advertisement
280  * @ocb_stop_timing_advert: fp to stop timing advertisement
281  * @ocb_get_tsf_timer: fp to get tsf timer
282  * @ocb_dcc_get_stats: fp to get DCC stats
283  * @ocb_dcc_clear_stats: fp to clear DCC stats
284  * @ocb_dcc_update_ndl: fp to update ndl
285  * @ocb_reg_ev_handler: fp to register event handler
286  * @ocb_unreg_ev_handler: fp to unregister event handler
287  */
288 struct wlan_ocb_tx_ops {
289 	QDF_STATUS (*ocb_set_config)(struct wlan_objmgr_psoc *psoc,
290 			struct ocb_config *config);
291 	QDF_STATUS (*ocb_set_utc_time)(struct wlan_objmgr_psoc *psoc,
292 			struct ocb_utc_param *utc);
293 	QDF_STATUS (*ocb_start_timing_advert)(struct wlan_objmgr_psoc *psoc,
294 			struct ocb_timing_advert_param *timing_advert);
295 	QDF_STATUS (*ocb_stop_timing_advert)(struct wlan_objmgr_psoc *psoc,
296 			struct ocb_timing_advert_param *timing_advert);
297 	QDF_STATUS (*ocb_get_tsf_timer)(struct wlan_objmgr_psoc *psoc,
298 			struct ocb_get_tsf_timer_param *request);
299 	QDF_STATUS (*ocb_dcc_get_stats)(struct wlan_objmgr_psoc *psoc,
300 			struct ocb_dcc_get_stats_param *get_stats_param);
301 	QDF_STATUS (*ocb_dcc_clear_stats)(struct wlan_objmgr_psoc *psoc,
302 			struct ocb_dcc_clear_stats_param *clear_stats);
303 	QDF_STATUS (*ocb_dcc_update_ndl)(struct wlan_objmgr_psoc *psoc,
304 			struct ocb_dcc_update_ndl_param *update_ndl_param);
305 	QDF_STATUS (*ocb_reg_ev_handler)(struct wlan_objmgr_psoc *psoc,
306 					 void *arg);
307 	QDF_STATUS (*ocb_unreg_ev_handler)(struct wlan_objmgr_psoc *psoc,
308 					   void *arg);
309 };
310 
311 typedef void (*ocb_sync_callback)(void *context, void *response);
312 
313 /**
314  * struct ocb_callbacks - structure containing callback to legacy driver
315  * @ocb_set_config_context: context for set channel config callback
316  * @ocb_set_config_callback: set channel config callback
317  * @ocb_get_tsf_timer_context: context for get tsf timer callback
318  * @ocb_get_tsf_timer_callback: get tsf timer callback
319  * @ocb_dcc_get_stats_context: context for get DCC stats callback
320  * @ocb_dcc_get_stats_callback: get DCC stats callback
321  * @ocb_dcc_update_ndl_context: context for NDL update callback
322  * @ocb_dcc_update_ndl_callback: NDL update callback
323  * @ocb_dcc_stats_event_context: context for DCC stats event callback
324  * @ocb_dcc_stats_event_callback: DCC stats event callback
325  * @start_ocb_vdev: start ocb callback
326  */
327 struct ocb_callbacks {
328 	void *ocb_set_config_context;
329 	ocb_sync_callback ocb_set_config_callback;
330 	void *ocb_get_tsf_timer_context;
331 	ocb_sync_callback ocb_get_tsf_timer_callback;
332 	void *ocb_dcc_get_stats_context;
333 	ocb_sync_callback ocb_dcc_get_stats_callback;
334 	void *ocb_dcc_update_ndl_context;
335 	ocb_sync_callback ocb_dcc_update_ndl_callback;
336 	void *ocb_dcc_stats_event_context;
337 	ocb_sync_callback ocb_dcc_stats_event_callback;
338 	QDF_STATUS (*start_ocb_vdev)(struct ocb_config *config);
339 };
340 #endif
341