xref: /wlan-dirver/qca-wifi-host-cmn/umac/cmn_services/mgmt_txrx/core/src/wlan_mgmt_txrx_rx_reo_i.h (revision 70a19e16789e308182f63b15c75decec7bf0b342)
1 /*
2  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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: wlan_mgmt_txrx_rx_reo_i.h
20  *  This file contains mgmt rx re-ordering related APIs
21  */
22 
23 #ifndef _WLAN_MGMT_TXRX_RX_REO_I_H
24 #define _WLAN_MGMT_TXRX_RX_REO_I_H
25 
26 #ifdef WLAN_MGMT_RX_REO_SUPPORT
27 #include <qdf_list.h>
28 #include <qdf_timer.h>
29 #include <qdf_lock.h>
30 #include <qdf_nbuf.h>
31 #include <qdf_threads.h>
32 #include <qdf_defer.h>
33 #include <wlan_mgmt_txrx_rx_reo_utils_api.h>
34 #include <wlan_mgmt_txrx_rx_reo_public_structs.h>
35 #include <wlan_objmgr_pdev_obj.h>
36 #include <wlan_objmgr_psoc_obj.h>
37 #include <wlan_mlo_mgr_public_structs.h>
38 
39 #define MGMT_RX_REO_LIST_MAX_SIZE             (100)
40 #define MGMT_RX_REO_LIST_TIMEOUT_US           (500 * USEC_PER_MSEC)
41 #define MGMT_RX_REO_AGEOUT_TIMER_PERIOD_MS    (250)
42 #define MGMT_RX_REO_GLOBAL_MGMT_RX_INACTIVITY_TIMEOUT   (10 * 60 * MSEC_PER_SEC)
43 #define MGMT_RX_REO_STATUS_WAIT_FOR_FRAME_ON_OTHER_LINKS         (BIT(0))
44 #define MGMT_RX_REO_STATUS_AGED_OUT                              (BIT(1))
45 #define MGMT_RX_REO_STATUS_OLDER_THAN_LATEST_AGED_OUT_FRAME      (BIT(2))
46 #define MGMT_RX_REO_STATUS_LIST_MAX_SIZE_EXCEEDED                (BIT(3))
47 
48 #define MGMT_RX_REO_INVALID_LINK_ID   (-1)
49 
50 /* Reason to release an entry from the reorder list */
51 #define MGMT_RX_REO_LIST_ENTRY_RELEASE_REASON_ZERO_WAIT_COUNT           (BIT(0))
52 #define MGMT_RX_REO_LIST_ENTRY_RELEASE_REASON_AGED_OUT                  (BIT(1))
53 #define MGMT_RX_REO_LIST_ENTRY_RELEASE_REASON_OLDER_THAN_AGED_OUT_FRAME (BIT(2))
54 #define MGMT_RX_REO_LIST_ENTRY_RELEASE_REASON_LIST_MAX_SIZE_EXCEEDED    (BIT(3))
55 #define MGMT_RX_REO_RELEASE_REASON_MAX      \
56 	(MGMT_RX_REO_LIST_ENTRY_RELEASE_REASON_LIST_MAX_SIZE_EXCEEDED << 1)
57 
58 #define MGMT_RX_REO_LIST_ENTRY_IS_WAITING_FOR_FRAME_ON_OTHER_LINK(entry)   \
59 	((entry)->status & MGMT_RX_REO_STATUS_WAIT_FOR_FRAME_ON_OTHER_LINKS)
60 #define MGMT_RX_REO_LIST_ENTRY_IS_AGED_OUT(entry)   \
61 	((entry)->status & MGMT_RX_REO_STATUS_AGED_OUT)
62 #define MGMT_RX_REO_LIST_ENTRY_IS_OLDER_THAN_LATEST_AGED_OUT_FRAME(entry)  \
63 	((entry)->status & MGMT_RX_REO_STATUS_OLDER_THAN_LATEST_AGED_OUT_FRAME)
64 #define MGMT_RX_REO_LIST_ENTRY_IS_MAX_SIZE_EXCEEDED(entry)  \
65 	((entry)->status & MGMT_RX_REO_STATUS_LIST_MAX_SIZE_EXCEEDED)
66 
67 #ifdef WLAN_MGMT_RX_REO_DEBUG_SUPPORT
68 #define MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_BOARDER_MAX_SIZE   (816)
69 #define MGMT_RX_REO_EGRESS_FRAME_DELIVERY_REASON_STATS_BOARDER_A_MAX_SIZE  (66)
70 #define MGMT_RX_REO_EGRESS_FRAME_DELIVERY_REASON_STATS_BOARDER_B_MAX_SIZE  (73)
71 #define MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_FLAG_MAX_SIZE   (3)
72 #define MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_WAIT_COUNT_MAX_SIZE   (69)
73 #define MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_PER_LINK_SNAPSHOTS_MAX_SIZE   (94)
74 #define MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_SNAPSHOT_MAX_SIZE     (22)
75 #define MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_PRINT_MAX_FRAMES     (0)
76 
77 #define MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_BOARDER_MAX_SIZE   (785)
78 #define MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_FLAG_MAX_SIZE   (13)
79 #define MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_WAIT_COUNT_MAX_SIZE   (69)
80 #define MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_PER_LINK_SNAPSHOTS_MAX_SIZE   (94)
81 #define MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_SNAPSHOT_MAX_SIZE     (22)
82 #define MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_PRINT_MAX_FRAMES     (0)
83 #endif /* WLAN_MGMT_RX_REO_DEBUG_SUPPORT*/
84 
85 /*
86  * struct mgmt_rx_reo_pdev_info - Pdev information required by the Management
87  * Rx REO module
88  * @host_snapshot: Latest snapshot seen at the Host.
89  * It considers both MGMT Rx and MGMT FW consumed.
90  * @last_valid_shared_snapshot: Array of last valid snapshots(for snapshots
91  * shared between host and target)
92  * @host_target_shared_snapshot_info: Array of meta information related to
93  * snapshots(for snapshots shared between host and target)
94  * @filter: MGMT Rx REO filter
95  * @init_complete: Flag to indicate initialization completion of the
96  * mgmt_rx_reo_pdev_info object
97  */
98 struct mgmt_rx_reo_pdev_info {
99 	struct mgmt_rx_reo_snapshot_params host_snapshot;
100 	struct mgmt_rx_reo_snapshot_params last_valid_shared_snapshot
101 				[MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
102 	struct mgmt_rx_reo_snapshot_info host_target_shared_snapshot_info
103 				[MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
104 	struct mgmt_rx_reo_filter filter;
105 	struct mgmt_rx_reo_shared_snapshot raw_snapshots[MAX_MLO_LINKS]
106 			[MGMT_RX_REO_SHARED_SNAPSHOT_MAX]
107 			[MGMT_RX_REO_SNAPSHOT_READ_RETRY_LIMIT]
108 			[MGMT_RX_REO_SNAPSHOT_B2B_READ_SWAR_RETRY_LIMIT];
109 	bool init_complete;
110 };
111 
112 /**
113  * mgmt_rx_reo_attach() - Initializes the per pdev data structures related to
114  * management rx-reorder module
115  * @pdev: pointer to pdev object
116  *
117  * Return: QDF_STATUS
118  */
119 QDF_STATUS
120 mgmt_rx_reo_attach(struct wlan_objmgr_pdev *pdev);
121 
122 /**
123  * mgmt_rx_reo_detach() - Clears the per pdev data structures related to
124  * management rx-reorder module
125  * @pdev: pointer to pdev object
126  *
127  * Return: QDF_STATUS
128  */
129 QDF_STATUS
130 mgmt_rx_reo_detach(struct wlan_objmgr_pdev *pdev);
131 
132 /**
133  * mgmt_rx_reo_pdev_obj_create_notification() - pdev create handler for
134  * management rx-reorder module
135  * @pdev: pointer to pdev object
136  * @mgmt_txrx_pdev_ctx: pdev private object of mgmt txrx module
137  *
138  * This function gets called from object manager when pdev is being created and
139  * creates management rx-reorder pdev context
140  *
141  * Return: QDF_STATUS
142  */
143 QDF_STATUS
144 mgmt_rx_reo_pdev_obj_create_notification(
145 	struct wlan_objmgr_pdev *pdev,
146 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx);
147 
148 /**
149  * mgmt_rx_reo_pdev_obj_destroy_notification() - pdev destroy handler for
150  * management rx-reorder feature
151  * @pdev: pointer to pdev object
152  * @mgmt_txrx_pdev_ctx: pdev private object of mgmt txrx module
153  *
154  * This function gets called from object manager when pdev is being destroyed
155  * and destroys management rx-reorder pdev context
156  *
157  * Return: QDF_STATUS
158  */
159 QDF_STATUS
160 mgmt_rx_reo_pdev_obj_destroy_notification(
161 	struct wlan_objmgr_pdev *pdev,
162 	struct mgmt_txrx_priv_pdev_context *mgmt_txrx_pdev_ctx);
163 
164 /**
165  * mgmt_rx_reo_psoc_obj_create_notification() - psoc create handler for
166  * management rx-reorder module
167  * @psoc: pointer to psoc object
168  *
169  * This function gets called from object manager when psoc is being created.
170  *
171  * Return: QDF_STATUS
172  */
173 QDF_STATUS
174 mgmt_rx_reo_psoc_obj_create_notification(struct wlan_objmgr_psoc *psoc);
175 
176 /**
177  * mgmt_rx_reo_psoc_obj_destroy_notification() - psoc destroy handler for
178  * management rx-reorder feature
179  * @psoc: pointer to psoc object
180  *
181  * This function gets called from object manager when psoc is being destroyed.
182  *
183  * Return: QDF_STATUS
184  */
185 QDF_STATUS
186 mgmt_rx_reo_psoc_obj_destroy_notification(struct wlan_objmgr_psoc *psoc);
187 
188 /**
189  * enum mgmt_rx_reo_frame_descriptor_type - Enumeration for management frame
190  * descriptor type.
191  * @MGMT_RX_REO_FRAME_DESC_HOST_CONSUMED_FRAME: Management frame to be consumed
192  * by host.
193  * @MGMT_RX_REO_FRAME_DESC_FW_CONSUMED_FRAME: Management frame consumed by FW
194  * @MGMT_RX_REO_FRAME_DESC_ERROR_FRAME: Management frame which got dropped
195  * at host due to any error
196  * @MGMT_RX_REO_FRAME_DESC_TYPE_MAX: Maximum number of frame types
197  */
198 enum mgmt_rx_reo_frame_descriptor_type {
199 	MGMT_RX_REO_FRAME_DESC_HOST_CONSUMED_FRAME = 0,
200 	MGMT_RX_REO_FRAME_DESC_FW_CONSUMED_FRAME,
201 	MGMT_RX_REO_FRAME_DESC_ERROR_FRAME,
202 	MGMT_RX_REO_FRAME_DESC_TYPE_MAX,
203 };
204 
205 /**
206  * struct mgmt_rx_reo_global_ts_info - This structure holds the global time
207  * stamp information of a frame.
208  * @valid: Indicates whether global time stamp is valid
209  * @global_ts: Global time stamp value
210  * @start_ts: Start time stamp value
211  * @end_ts: End time stamp value
212  */
213 struct mgmt_rx_reo_global_ts_info {
214 	bool valid;
215 	uint32_t global_ts;
216 	uint32_t start_ts;
217 	uint32_t end_ts;
218 };
219 
220 /**
221  * struct mgmt_rx_reo_list – Linked list used to reorder the management frames
222  * received. Each list entry would correspond to a management frame. List
223  * entries would be sorted in the same order in which they are received by MAC
224  * HW.
225  * @list: List used for reordering
226  * @list_lock: Lock to protect the list
227  * @max_list_size: Maximum size of the reorder list
228  * @list_entry_timeout_us: Time out value(microsecond) for the reorder list
229  * entries
230  * @ageout_timer: Periodic timer to age-out the list entries
231  * @global_mgmt_rx_inactivity_timer: Global management Rx inactivity timer
232  * @ts_last_released_frame: Stores the global time stamp for the last frame
233  * removed from the reorder list
234  */
235 struct mgmt_rx_reo_list {
236 	qdf_list_t list;
237 	qdf_spinlock_t list_lock;
238 	uint32_t max_list_size;
239 	uint32_t list_entry_timeout_us;
240 	qdf_timer_t ageout_timer;
241 	qdf_timer_t global_mgmt_rx_inactivity_timer;
242 	struct mgmt_rx_reo_global_ts_info ts_last_released_frame;
243 };
244 
245 /*
246  * struct mgmt_rx_reo_wait_count - Wait count for a mgmt frame
247  * @per_link_count: Array of wait counts for all MLO links. Each array entry
248  * holds the number of frames this mgmt frame should wait for on that
249  * particular link.
250  * @total_count: Sum of entries in @per_link_count
251  */
252 struct mgmt_rx_reo_wait_count {
253 	unsigned int per_link_count[MAX_MLO_LINKS];
254 	unsigned long long int total_count;
255 };
256 
257 /**
258  * struct mgmt_rx_reo_list_entry - Entry in the Management reorder list
259  * @node: List node
260  * @nbuf: nbuf corresponding to this frame
261  * @rx_params: Management rx event parameters
262  * @wait_count: Wait counts for the frame
263  * @initial_wait_count: Wait count when the frame is queued
264  * @insertion_ts: Host time stamp when this entry is inserted to the list.
265  * @removal_ts: Host time stamp when this entry is removed from the list
266  * @ingress_timestamp: Host time stamp when this frame has arrived reorder
267  * module
268  * @egress_timestamp: Host time stamp when this frame has exited reorder
269  * module
270  * @status: Status for this entry
271  * @pdev: Pointer to pdev object corresponding to this frame
272  * @release_reason: Release reason
273  * @is_delivered: Indicates whether the frame is delivered successfully
274  * @is_premature_delivery: Indicates whether the frame is delivered
275  * prematurely
276  * @is_parallel_rx: Indicates that this frame is received in parallel to the
277  * last frame which is delivered to the upper layer.
278  * @shared_snapshots: snapshots shared b/w host and target
279  * @host_snapshot: host snapshot
280  */
281 struct mgmt_rx_reo_list_entry {
282 	qdf_list_node_t node;
283 	qdf_nbuf_t nbuf;
284 	struct mgmt_rx_event_params *rx_params;
285 	struct mgmt_rx_reo_wait_count wait_count;
286 	struct mgmt_rx_reo_wait_count initial_wait_count;
287 	uint64_t insertion_ts;
288 	uint64_t removal_ts;
289 	uint64_t ingress_timestamp;
290 	uint64_t egress_timestamp;
291 	uint32_t status;
292 	struct wlan_objmgr_pdev *pdev;
293 	uint8_t release_reason;
294 	bool is_delivered;
295 	bool is_premature_delivery;
296 	bool is_parallel_rx;
297 	struct mgmt_rx_reo_snapshot_params shared_snapshots
298 			[MAX_MLO_LINKS][MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
299 	struct mgmt_rx_reo_snapshot_params host_snapshot[MAX_MLO_LINKS];
300 };
301 
302 #ifdef WLAN_MGMT_RX_REO_SIM_SUPPORT
303 
304 #define MGMT_RX_REO_SIM_INTER_FRAME_DELAY_MIN             (300 * USEC_PER_MSEC)
305 #define MGMT_RX_REO_SIM_INTER_FRAME_DELAY_MIN_MAX_DELTA   (200 * USEC_PER_MSEC)
306 
307 #define MGMT_RX_REO_SIM_DELAY_MAC_HW_TO_FW_MIN            (1000 * USEC_PER_MSEC)
308 #define MGMT_RX_REO_SIM_DELAY_MAC_HW_TO_FW_MIN_MAX_DELTA  (500 * USEC_PER_MSEC)
309 
310 #define MGMT_RX_REO_SIM_DELAY_FW_TO_HOST_MIN              (1000 * USEC_PER_MSEC)
311 #define MGMT_RX_REO_SIM_DELAY_FW_TO_HOST_MIN_MAX_DELTA    (500 * USEC_PER_MSEC)
312 
313 #define MGMT_RX_REO_SIM_PERCENTAGE_FW_CONSUMED_FRAMES  (10)
314 #define MGMT_RX_REO_SIM_PERCENTAGE_ERROR_FRAMES        (10)
315 
316 #define MGMT_RX_REO_SIM_PENDING_FRAME_LIST_MAX_SIZE    (1000)
317 #define MGMT_RX_REO_SIM_STALE_FRAME_LIST_MAX_SIZE      \
318 				(MGMT_RX_REO_SIM_PENDING_FRAME_LIST_MAX_SIZE)
319 #define MGMT_RX_REO_SIM_STALE_FRAME_TEMP_LIST_MAX_SIZE (100)
320 
321 /**
322  * struct mgmt_rx_frame_params - Parameters associated with a management frame.
323  * This structure is used by the simulation framework.
324  * @link_id: MLO HW link id
325  * @mgmt_pkt_ctr: Management packet counter
326  * @global_timestamp: Global time stamp in micro seconds
327  */
328 struct mgmt_rx_frame_params {
329 	uint8_t link_id;
330 	uint16_t mgmt_pkt_ctr;
331 	uint32_t global_timestamp;
332 };
333 
334 /**
335  * struct mgmt_rx_reo_master_frame_list - List which contains all the
336  * management frames received and not yet consumed by FW/Host. Order of frames
337  * in the list is same as the order in which they are received in the air.
338  * This is used by the simulation framework to confirm that the outcome of
339  * reordering is correct.
340  * @pending_list: List which contains all the frames received after the
341  * last frame delivered to upper layer. These frames will eventually reach host.
342  * @stale_list: List which contains all the stale management frames which
343  * are not yet consumed by FW/Host. Stale management frames are the frames which
344  * are older than last delivered frame to upper layer.
345  * @lock: Spin lock to protect pending frame list and stale frame list.
346  */
347 struct mgmt_rx_reo_master_frame_list {
348 	qdf_list_t pending_list;
349 	qdf_list_t stale_list;
350 	qdf_spinlock_t lock;
351 };
352 
353 /**
354  * struct mgmt_rx_reo_pending_frame_list_entry - Structure used to represent an
355  * entry in the pending frame list.
356  * @params: parameters related to the management frame
357  * @node: linked list node
358  */
359 struct mgmt_rx_reo_pending_frame_list_entry {
360 	struct mgmt_rx_frame_params params;
361 	qdf_list_node_t node;
362 };
363 
364 /**
365  * struct mgmt_rx_reo_stale_frame_list_entry - Structure used to represent an
366  * entry in the stale frame list.
367  * @params: parameters related to the management frame
368  * @node: linked list node
369  */
370 struct mgmt_rx_reo_stale_frame_list_entry {
371 	struct mgmt_rx_frame_params params;
372 	qdf_list_node_t node;
373 };
374 
375 /**
376  * struct mgmt_rx_frame_mac_hw - Structure used to represent the management
377  * frame at MAC HW level
378  * @params: parameters related to the management frame
379  * @frame_handler_fw: Work structure to queue the frame to the FW
380  * @sim_context: pointer management rx-reorder simulation context
381  */
382 struct mgmt_rx_frame_mac_hw {
383 	struct mgmt_rx_frame_params params;
384 	qdf_work_t frame_handler_fw;
385 	struct mgmt_rx_reo_sim_context *sim_context;
386 };
387 
388 /**
389  * struct mgmt_rx_frame_fw - Structure used to represent the management
390  * frame at FW level
391  * @params: parameters related to the management frame
392  * @is_consumed_by_fw: indicates whether the frame is consumed by FW
393  * @frame_handler_host: Work structure to queue the frame to the host
394  * @sim_context: pointer management rx-reorder simulation context
395  */
396 struct mgmt_rx_frame_fw {
397 	struct mgmt_rx_frame_params params;
398 	bool is_consumed_by_fw;
399 	qdf_work_t frame_handler_host;
400 	struct mgmt_rx_reo_sim_context *sim_context;
401 };
402 
403 /**
404  * struct mgmt_rx_reo_sim_mac_hw - Structure used to represent the MAC HW
405  * @mgmt_pkt_ctr: Stores the last management packet counter for all the links
406  */
407 struct mgmt_rx_reo_sim_mac_hw {
408 	uint16_t mgmt_pkt_ctr[MAX_MLO_LINKS];
409 };
410 
411 /**
412  * struct mgmt_rx_reo_sim_link_id_to_pdev_map - Map from link id to pdev
413  * object. This is used for simulation purpose only.
414  * @map: link id to pdev map. Link id is the array index.
415  * @lock: lock used to protect this structure
416  * @num_mlo_links: Total number of MLO HW links. In case of simulation all the
417  * pdevs are assumed to have MLO capability and number of MLO links is same as
418  * the number of pdevs in the system.
419  * @valid_link_list: List of valid link id values
420  */
421 struct mgmt_rx_reo_sim_link_id_to_pdev_map {
422 	struct wlan_objmgr_pdev *map[MAX_MLO_LINKS];
423 	qdf_spinlock_t lock;
424 	uint8_t num_mlo_links;
425 	int8_t valid_link_list[MAX_MLO_LINKS];
426 };
427 
428 /**
429  * struct mgmt_rx_reo_mac_hw_simulator - Structure which stores the members
430  * required for the MAC HW simulation
431  * @mac_hw_info: MAC HW info
432  * @mac_hw_thread: kthread which simulates MAC HW
433  */
434 struct mgmt_rx_reo_mac_hw_simulator {
435 	struct mgmt_rx_reo_sim_mac_hw mac_hw_info;
436 	qdf_thread_t *mac_hw_thread;
437 };
438 
439 /**
440  * struct mgmt_rx_reo_sim_context - Management rx-reorder simulation context
441  * @host_mgmt_frame_handler: Per link work queue to simulate the host layer
442  * @fw_mgmt_frame_handler: Per link work queue to simulate the FW layer
443  * @master_frame_list: List used to store information about all the management
444  * frames
445  * @mac_hw_sim:  MAC HW simulation object
446  * @snapshot: snapshots required for reo algorithm
447  * @link_id_to_pdev_map: link_id to pdev object map
448  * @mlo_grp_id: MLO group id which it belongs to
449  */
450 struct mgmt_rx_reo_sim_context {
451 	struct workqueue_struct *host_mgmt_frame_handler[MAX_MLO_LINKS];
452 	struct workqueue_struct *fw_mgmt_frame_handler[MAX_MLO_LINKS];
453 	struct mgmt_rx_reo_master_frame_list master_frame_list;
454 	struct mgmt_rx_reo_mac_hw_simulator mac_hw_sim;
455 	struct mgmt_rx_reo_shared_snapshot snapshot[MAX_MLO_LINKS]
456 					    [MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
457 	struct mgmt_rx_reo_sim_link_id_to_pdev_map link_id_to_pdev_map;
458 	uint8_t mlo_grp_id;
459 };
460 #endif /* WLAN_MGMT_RX_REO_SIM_SUPPORT */
461 
462 #ifdef WLAN_MGMT_RX_REO_DEBUG_SUPPORT
463 /**
464  * struct reo_ingress_debug_frame_info - Debug information about a frame
465  * entering reorder algorithm
466  * @link_id: link id
467  * @mgmt_pkt_ctr: management packet counter
468  * @global_timestamp: MLO global time stamp
469  * @start_timestamp: start time stamp of the frame
470  * @end_timestamp: end time stamp of the frame
471  * @duration_us: duration of the frame in us
472  * @desc_type: Type of the frame descriptor
473  * @frame_type: frame type
474  * @frame_subtype: frame sub type
475  * @ingress_timestamp: Host time stamp when the frames enters the reorder
476  * algorithm
477  * @ingress_duration: Duration in us for processing the incoming frame.
478  * ingress_duration = Time stamp at which reorder list update is done -
479  * Time stamp at which frame has entered the reorder module
480  * @wait_count: Wait count calculated for the current frame
481  * @is_queued: Indicates whether this frame is queued to reorder list
482  * @is_stale: Indicates whether this frame is stale.
483  * @is_parallel_rx: Indicates that this frame is received in parallel to the
484  * last frame which is delivered to the upper layer.
485  * @zero_wait_count_rx: Indicates whether this frame's wait count was
486  * zero when received by host
487  * @immediate_delivery: Indicates whether this frame can be delivered
488  * immediately to the upper layers
489  * @is_error: Indicates whether any error occurred during processing this frame
490  * @ts_last_released_frame: Stores the global time stamp for the last frame
491  * removed from the reorder list
492  * @list_size_rx: Size of the reorder list when this frame is received (before
493  * updating the list based on this frame).
494  * @list_insertion_pos: Position in the reorder list where this frame is going
495  * to get inserted (Applicable for only host consumed frames)
496  * @shared_snapshots: snapshots shared b/w host and target
497  * @host_snapshot: host snapshot
498  * @cpu_id: CPU index
499  * @reo_required: Indicates whether reorder is required for the current frame.
500  * If reorder is not required, current frame will just be used for updating the
501  * wait count of frames already part of the reorder list.
502  */
503 struct reo_ingress_debug_frame_info {
504 	uint8_t link_id;
505 	uint16_t mgmt_pkt_ctr;
506 	uint32_t global_timestamp;
507 	uint32_t start_timestamp;
508 	uint32_t end_timestamp;
509 	uint32_t duration_us;
510 	enum mgmt_rx_reo_frame_descriptor_type desc_type;
511 	uint8_t frame_type;
512 	uint8_t frame_subtype;
513 	uint64_t ingress_timestamp;
514 	uint64_t ingress_duration;
515 	struct mgmt_rx_reo_wait_count wait_count;
516 	bool is_queued;
517 	bool is_stale;
518 	bool is_parallel_rx;
519 	bool zero_wait_count_rx;
520 	bool immediate_delivery;
521 	bool is_error;
522 	struct mgmt_rx_reo_global_ts_info ts_last_released_frame;
523 	int16_t list_size_rx;
524 	int16_t list_insertion_pos;
525 	struct mgmt_rx_reo_snapshot_params shared_snapshots
526 			[MAX_MLO_LINKS][MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
527 	struct mgmt_rx_reo_snapshot_params host_snapshot[MAX_MLO_LINKS];
528 	int cpu_id;
529 	bool reo_required;
530 };
531 
532 /**
533  * struct reo_egress_debug_frame_info - Debug information about a frame
534  * leaving the reorder module
535  * @is_delivered: Indicates whether the frame is delivered to upper layers
536  * @is_premature_delivery: Indicates whether the frame is delivered
537  * prematurely
538  * @link_id: link id
539  * @mgmt_pkt_ctr: management packet counter
540  * @global_timestamp: MLO global time stamp
541  * @ingress_timestamp: Host time stamp when the frame enters the reorder module
542  * @insertion_ts: Host time stamp when the frame is inserted into the reorder
543  * list
544  * @egress_timestamp: Host time stamp just before delivery of the frame to upper
545  * layer
546  * @egress_duration: Duration in us taken by the upper layer to process
547  * the frame.
548  * @removal_ts: Host time stamp when this entry is removed from the list
549  * @initial_wait_count: Wait count when the frame is queued
550  * @final_wait_count: Wait count when frame is released to upper layer
551  * @release_reason: Reason for delivering the frame to upper layers
552  * @shared_snapshots: snapshots shared b/w host and target
553  * @host_snapshot: host snapshot
554  * @cpu_id: CPU index
555  */
556 struct reo_egress_debug_frame_info {
557 	bool is_delivered;
558 	bool is_premature_delivery;
559 	uint8_t link_id;
560 	uint16_t mgmt_pkt_ctr;
561 	uint32_t global_timestamp;
562 	uint64_t ingress_timestamp;
563 	uint64_t insertion_ts;
564 	uint64_t egress_timestamp;
565 	uint64_t egress_duration;
566 	uint64_t removal_ts;
567 	struct mgmt_rx_reo_wait_count initial_wait_count;
568 	struct mgmt_rx_reo_wait_count final_wait_count;
569 	uint8_t release_reason;
570 	struct mgmt_rx_reo_snapshot_params shared_snapshots
571 			[MAX_MLO_LINKS][MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
572 	struct mgmt_rx_reo_snapshot_params host_snapshot[MAX_MLO_LINKS];
573 	int cpu_id;
574 };
575 
576 /**
577  * struct reo_ingress_frame_stats - Structure to store statistics related to
578  * incoming frames
579  * @ingress_count: Number of frames entering reo module
580  * @queued_count: Number of frames queued to reorder list
581  * @zero_wait_count_rx_count: Number of frames for which wait count is
582  * zero when received at host
583  * @immediate_delivery_count: Number of frames which can be delivered
584  * immediately to the upper layers without reordering. A frame can be
585  * immediately delivered if it has wait count of zero on reception at host
586  * and the global time stamp is less than or equal to the global time
587  * stamp of all the frames in the reorder list. Such frames would get
588  * inserted to the head of the reorder list and gets delivered immediately
589  * to the upper layers.
590  * @stale_count: Number of stale frames. Any frame older than the
591  * last frame delivered to upper layer is a stale frame.
592  * @error_count: Number of frames dropped due to error occurred
593  * within the reorder module
594  */
595 struct reo_ingress_frame_stats {
596 	uint64_t ingress_count
597 		[MAX_MLO_LINKS][MGMT_RX_REO_FRAME_DESC_TYPE_MAX];
598 	uint64_t queued_count[MAX_MLO_LINKS];
599 	uint64_t zero_wait_count_rx_count[MAX_MLO_LINKS];
600 	uint64_t immediate_delivery_count[MAX_MLO_LINKS];
601 	uint64_t stale_count[MAX_MLO_LINKS]
602 			    [MGMT_RX_REO_FRAME_DESC_TYPE_MAX];
603 	uint64_t error_count[MAX_MLO_LINKS]
604 			    [MGMT_RX_REO_FRAME_DESC_TYPE_MAX];
605 };
606 
607 /**
608  * struct reo_egress_frame_stats - Structure to store statistics related to
609  * outgoing frames
610  * @delivery_attempts_count: Number of attempts to deliver management
611  * frames to upper layers
612  * @delivery_success_count: Number of successful management frame
613  * deliveries to upper layer
614  * @premature_delivery_count:  Number of frames delivered
615  * prematurely. Premature delivery is the delivery of a management frame
616  * to the upper layers even before its wait count is reaching zero.
617  * @delivery_count: Number frames delivered successfully for
618  * each link and release  reason.
619  */
620 struct reo_egress_frame_stats {
621 	uint64_t delivery_attempts_count[MAX_MLO_LINKS];
622 	uint64_t delivery_success_count[MAX_MLO_LINKS];
623 	uint64_t premature_delivery_count[MAX_MLO_LINKS];
624 	uint64_t delivery_count[MAX_MLO_LINKS]
625 			       [MGMT_RX_REO_RELEASE_REASON_MAX];
626 };
627 
628 /**
629  * struct reo_ingress_debug_info - Circular array to store the
630  * debug information about the frames entering the reorder algorithm.
631  * @frame_list: Circular array to store the debug info about frames
632  * @frame_list_size: Size of circular array @frame_list
633  * @next_index: The index at which information about next frame will be logged
634  * @wrap_aroud: Flag to indicate whether wrap around occurred when logging
635  * debug information to @frame_list
636  * @stats: Stats related to incoming frames
637  * @boarder: boarder string
638  */
639 struct reo_ingress_debug_info {
640 	struct reo_ingress_debug_frame_info *frame_list;
641 	uint16_t frame_list_size;
642 	int next_index;
643 	bool wrap_aroud;
644 	struct reo_ingress_frame_stats stats;
645 	char boarder[MGMT_RX_REO_INGRESS_FRAME_DEBUG_INFO_BOARDER_MAX_SIZE + 1];
646 };
647 
648 /**
649  * struct reo_egress_debug_info - Circular array to store the
650  * debug information about the frames leaving the reorder module.
651  * @frame_list: Circular array to store the debug info
652  * @frame_list_size: Size of circular array @frame_list
653  * @next_index: The index at which information about next frame will be logged
654  * @wrap_aroud: Flag to indicate whether wrap around occurred when logging
655  * debug information to @frame_list
656  * @stats: Stats related to outgoing frames
657  * @boarder: boarder string
658  */
659 struct reo_egress_debug_info {
660 	struct reo_egress_debug_frame_info *frame_list;
661 	uint16_t frame_list_size;
662 	int next_index;
663 	bool wrap_aroud;
664 	struct reo_egress_frame_stats stats;
665 	char boarder[MGMT_RX_REO_EGRESS_FRAME_DEBUG_INFO_BOARDER_MAX_SIZE + 1];
666 };
667 #endif /* WLAN_MGMT_RX_REO_DEBUG_SUPPORT */
668 
669 /**
670  * struct mgmt_rx_reo_context - This structure holds the info required for
671  * management rx-reordering. Reordering is done across all the psocs.
672  * So there should be only one instance of this structure defined.
673  * @reo_list: Linked list used for reordering
674  * @reo_algo_entry_lock: Spin lock to protect reo algorithm entry critical
675  * section execution
676  * @frame_release_lock: Spin lock to serialize the frame delivery to the
677  * upper layers. This could prevent race conditions like the one given in
678  * the following example.
679  * Lets take an example of 2 links (Link A & B) and each has received
680  * a management frame A1(deauth) and B1(auth) such that MLO global time
681  * stamp of A1 < MLO global time stamp of B1. Host is concurrently
682  * executing "mgmt_rx_reo_list_release_entries" for A1 and B1 in
683  * 2 different CPUs. It is possible that frame B1 gets processed by
684  * upper layers before frame A1 and this could result in unwanted
685  * disconnection. Hence it is required to serialize the delivery
686  * of management frames to upper layers in the strict order of MLO
687  * global time stamp.
688  * @sim_context: Management rx-reorder simulation context
689  * @ingress_debug_info_init_count: Initialization count of
690  * object @ingress_frame_debug_info
691  * @ingress_frame_debug_info: Debug object to log incoming frames
692  * @egress_frame_debug_info: Debug object to log outgoing frames
693  * @egress_debug_info_init_count: Initialization count of
694  * object @egress_frame_debug_info
695  * @simulation_in_progress: Flag to indicate whether simulation is
696  * in progress
697  * @mlo_grp_id: MLO Group ID which it belongs to
698  */
699 struct mgmt_rx_reo_context {
700 	struct mgmt_rx_reo_list reo_list;
701 	qdf_spinlock_t reo_algo_entry_lock;
702 	qdf_spinlock_t frame_release_lock;
703 #ifdef WLAN_MGMT_RX_REO_SIM_SUPPORT
704 	struct mgmt_rx_reo_sim_context sim_context;
705 #endif /* WLAN_MGMT_RX_REO_SIM_SUPPORT */
706 #ifdef WLAN_MGMT_RX_REO_DEBUG_SUPPORT
707 	qdf_atomic_t ingress_debug_info_init_count;
708 	struct  reo_ingress_debug_info ingress_frame_debug_info;
709 	qdf_atomic_t egress_debug_info_init_count;
710 	struct  reo_egress_debug_info egress_frame_debug_info;
711 #endif /* WLAN_MGMT_RX_REO_DEBUG_SUPPORT */
712 	bool simulation_in_progress;
713 	uint8_t mlo_grp_id;
714 };
715 
716 /**
717  * struct mgmt_rx_reo_frame_descriptor - Frame Descriptor used to describe
718  * a management frame in mgmt rx reo module.
719  * @type: Frame descriptor type
720  * @frame_type: frame type
721  * @frame_subtype: frame subtype
722  * @nbuf: nbuf corresponding to this frame
723  * @rx_params: Management rx event parameters
724  * @wait_count: Wait counts for the frame
725  * @ingress_timestamp: Host time stamp when the frames enters the reorder
726  * algorithm
727  * @is_stale: Indicates whether this frame is stale. Any frame older than the
728  * last frame delivered to upper layer is a stale frame. Stale frames should not
729  * be delivered to the upper layers. These frames can be discarded after
730  * updating the host snapshot and wait counts of entries currently residing in
731  * the reorder list.
732  * @zero_wait_count_rx: Indicates whether this frame's wait count was
733  * zero when received by host
734  * @immediate_delivery: Indicates whether this frame can be delivered
735  * immediately to the upper layers
736  * @list_size_rx: Size of the reorder list when this frame is received (before
737  * updating the list based on this frame).
738  * @list_insertion_pos: Position in the reorder list where this frame is going
739  * to get inserted (Applicable for only host consumed frames)
740  * @shared_snapshots: snapshots shared b/w host and target
741  * @host_snapshot: host snapshot
742  * @is_parallel_rx: Indicates that this frame is received in parallel to the
743  * last frame which is delivered to the upper layer.
744  * @pkt_ctr_delta: Packet counter delta of the current and last frame
745  * @reo_required: Indicates whether reorder is required for the current frame.
746  * If reorder is not required, current frame will just be used for updating the
747  * wait count of frames already part of the reorder list.
748  */
749 struct mgmt_rx_reo_frame_descriptor {
750 	enum mgmt_rx_reo_frame_descriptor_type type;
751 	uint8_t frame_type;
752 	uint8_t frame_subtype;
753 	qdf_nbuf_t nbuf;
754 	struct mgmt_rx_event_params *rx_params;
755 	struct mgmt_rx_reo_wait_count wait_count;
756 	uint64_t ingress_timestamp;
757 	bool is_stale;
758 	bool zero_wait_count_rx;
759 	bool immediate_delivery;
760 	int16_t list_size_rx;
761 	int16_t list_insertion_pos;
762 	struct mgmt_rx_reo_snapshot_params shared_snapshots
763 			[MAX_MLO_LINKS][MGMT_RX_REO_SHARED_SNAPSHOT_MAX];
764 	struct mgmt_rx_reo_snapshot_params host_snapshot[MAX_MLO_LINKS];
765 	bool is_parallel_rx;
766 	int pkt_ctr_delta;
767 	bool reo_required;
768 };
769 
770 /**
771  * mgmt_rx_reo_get_context_from_reo_list() - Helper API to get pointer to
772  * management rx reorder context from pointer to management reorder list
773  * @reo_list: Pointer to management rx reorder list
774  *
775  * Return: Pointer to management rx reorder context
776  */
777 static inline struct mgmt_rx_reo_context *
778 mgmt_rx_reo_get_context_from_reo_list(const struct mgmt_rx_reo_list *reo_list) {
779 	qdf_assert_always(reo_list);
780 
781 	return qdf_container_of(reo_list, struct mgmt_rx_reo_context,
782 				reo_list);
783 }
784 
785 /**
786  * mgmt_rx_reo_get_global_ts() - Helper API to get global time stamp
787  * corresponding to the mgmt rx event
788  * @rx_params: Management rx event params
789  *
790  * Return: global time stamp corresponding to the mgmt rx event
791  */
792 static inline uint32_t
793 mgmt_rx_reo_get_global_ts(struct mgmt_rx_event_params *rx_params)
794 {
795 	qdf_assert_always(rx_params);
796 	qdf_assert_always(rx_params->reo_params);
797 
798 	return rx_params->reo_params->global_timestamp;
799 }
800 
801 /**
802  * mgmt_rx_reo_get_start_ts() - Helper API to get start time stamp of the frame
803  * @rx_params: Management rx event params
804  *
805  * Return: start time stamp of the frame
806  */
807 static inline uint32_t
808 mgmt_rx_reo_get_start_ts(struct mgmt_rx_event_params *rx_params)
809 {
810 	qdf_assert_always(rx_params);
811 	qdf_assert_always(rx_params->reo_params);
812 
813 	return rx_params->reo_params->start_timestamp;
814 }
815 
816 /**
817  * mgmt_rx_reo_get_end_ts() - Helper API to get end time stamp of the frame
818  * @rx_params: Management rx event params
819  *
820  * Return: end time stamp of the frame
821  */
822 static inline uint32_t
823 mgmt_rx_reo_get_end_ts(struct mgmt_rx_event_params *rx_params)
824 {
825 	qdf_assert_always(rx_params);
826 	qdf_assert_always(rx_params->reo_params);
827 
828 	return rx_params->reo_params->end_timestamp;
829 }
830 
831 /**
832  * mgmt_rx_reo_get_duration_us() - Helper API to get the duration of the frame
833  * in us
834  * @rx_params: Management rx event params
835  *
836  * Return: Duration of the frame in us
837  */
838 static inline uint32_t
839 mgmt_rx_reo_get_duration_us(struct mgmt_rx_event_params *rx_params)
840 {
841 	qdf_assert_always(rx_params);
842 	qdf_assert_always(rx_params->reo_params);
843 
844 	return rx_params->reo_params->duration_us;
845 }
846 
847 /**
848  * mgmt_rx_reo_get_pkt_counter() - Helper API to get packet counter
849  * corresponding to the mgmt rx event
850  * @rx_params: Management rx event params
851  *
852  * Return: Management packet counter corresponding to the mgmt rx event
853  */
854 static inline uint16_t
855 mgmt_rx_reo_get_pkt_counter(struct mgmt_rx_event_params *rx_params)
856 {
857 	qdf_assert_always(rx_params);
858 	qdf_assert_always(rx_params->reo_params);
859 
860 	return rx_params->reo_params->mgmt_pkt_ctr;
861 }
862 
863 /**
864  * mgmt_rx_reo_get_link_id() - Helper API to get link id corresponding to the
865  * mgmt rx event
866  * @rx_params: Management rx event params
867  *
868  * Return: link id corresponding to the mgmt rx event
869  */
870 static inline uint8_t
871 mgmt_rx_reo_get_link_id(struct mgmt_rx_event_params *rx_params)
872 {
873 	qdf_assert_always(rx_params);
874 	qdf_assert_always(rx_params->reo_params);
875 
876 	return rx_params->reo_params->link_id;
877 }
878 
879 /**
880  * mgmt_rx_reo_get_mlo_grp_id() - Helper API to get MLO Group id
881  * corresponding to the mgmt rx event
882  * @rx_params: Management rx event params
883  *
884  * Return: MLO group id corresponding to the mgmt rx event
885  */
886 static inline uint8_t
887 mgmt_rx_reo_get_mlo_grp_id(struct mgmt_rx_event_params *rx_params)
888 {
889 	qdf_assert_always(rx_params);
890 	qdf_assert_always(rx_params->reo_params);
891 
892 	return rx_params->reo_params->mlo_grp_id;
893 }
894 
895 /**
896  * mgmt_rx_reo_get_pdev_id() - Helper API to get pdev id corresponding to the
897  * mgmt rx event
898  * @rx_params: Management rx event params
899  *
900  * Return: pdev id corresponding to the mgmt rx event
901  */
902 static inline uint8_t
903 mgmt_rx_reo_get_pdev_id(struct mgmt_rx_event_params *rx_params)
904 {
905 	qdf_assert_always(rx_params);
906 	qdf_assert_always(rx_params->reo_params);
907 
908 	return rx_params->reo_params->pdev_id;
909 }
910 
911 /**
912  * mgmt_rx_reo_init_context() - Initialize the management rx-reorder context
913  * @ml_grp_id: MLO Group ID to be initialized
914  *
915  * API to initialize each global management rx-reorder context object per group
916  *
917  * Return: QDF_STATUS
918  */
919 QDF_STATUS
920 mgmt_rx_reo_init_context(uint8_t ml_grp_id);
921 
922 /**
923  * mgmt_rx_reo_deinit_context() - De initialize the management rx-reorder
924  * context
925  * @ml_grp_id: MLO Group ID to be deinitialized
926  *
927  * API to de initialize each global management rx-reorder context object per
928  * group
929  *
930  * Return: QDF_STATUS
931  */
932 QDF_STATUS
933 mgmt_rx_reo_deinit_context(uint8_t ml_grp_id);
934 
935 /**
936  * mgmt_rx_reo_is_simulation_in_progress() - API to check whether
937  * simulation is in progress
938  * @ml_grp_id: MLO group id of mgmt rx reo
939  *
940  * Return: true if simulation is in progress, else false
941  */
942 bool
943 mgmt_rx_reo_is_simulation_in_progress(uint8_t ml_grp_id);
944 
945 /**
946  * mgmt_rx_reo_print_ingress_frame_stats() - Helper API to print
947  * stats related to incoming management frames
948  * @ml_grp_id: MLO group id of mgmt rx reo
949  *
950  * This API prints stats related to management frames entering management
951  * Rx reorder module.
952  *
953  * Return: QDF_STATUS
954  */
955 QDF_STATUS
956 mgmt_rx_reo_print_ingress_frame_stats(uint8_t ml_grp_id);
957 
958 /**
959  * mgmt_rx_reo_print_ingress_frame_info() - Print the debug information
960  * about the latest frames entered the reorder module
961  * @ml_grp_id: MLO group id of mgmt rx reo
962  * @num_frames: Number of frames for which the debug information is to be
963  * printed. If @num_frames is 0, then debug information about all the frames
964  * in the ring buffer will be  printed.
965  *
966  * Return: QDF_STATUS of operation
967  */
968 QDF_STATUS
969 mgmt_rx_reo_print_ingress_frame_info(uint8_t ml_grp_id, uint16_t num_frames);
970 
971 /**
972  * mgmt_rx_reo_print_egress_frame_stats() - Helper API to print
973  * stats related to outgoing management frames
974  * @ml_grp_id: MLO group id of mgmt rx reo
975  *
976  * This API prints stats related to management frames exiting management
977  * Rx reorder module.
978  *
979  * Return: QDF_STATUS
980  */
981 QDF_STATUS
982 mgmt_rx_reo_print_egress_frame_stats(uint8_t ml_grp_id);
983 
984 /**
985  * mgmt_rx_reo_print_egress_frame_info() - Print the debug information
986  * about the latest frames leaving the reorder module
987  * @ml_grp_id: MLO group id of mgmt rx reo
988  * @num_frames: Number of frames for which the debug information is to be
989  * printed. If @num_frames is 0, then debug information about all the frames
990  * in the ring buffer will be  printed.
991  *
992  * Return: QDF_STATUS of operation
993  */
994 QDF_STATUS
995 mgmt_rx_reo_print_egress_frame_info(uint8_t ml_grp_id, uint16_t num_frames);
996 
997 #ifdef WLAN_MGMT_RX_REO_SIM_SUPPORT
998 /**
999  * mgmt_rx_reo_sim_start() - Helper API to start management Rx reorder
1000  * simulation
1001  * @ml_grp_id: MLO group id of mgmt rx reo
1002  *
1003  * This API starts the simulation framework which mimics the management frame
1004  * generation by target. MAC HW is modelled as a kthread. FW and host layers
1005  * are modelled as an ordered work queues.
1006  *
1007  * Return: QDF_STATUS
1008  */
1009 QDF_STATUS
1010 mgmt_rx_reo_sim_start(uint8_t ml_grp_id);
1011 
1012 /**
1013  * mgmt_rx_reo_sim_stop() - Helper API to stop management Rx reorder
1014  * simulation
1015  * @ml_grp_id: MLO group id of mgmt rx reo
1016  *
1017  * This API stops the simulation framework which mimics the management frame
1018  * generation by target. MAC HW is modelled as a kthread. FW and host layers
1019  * are modelled as an ordered work queues.
1020  *
1021  * Return: QDF_STATUS
1022  */
1023 QDF_STATUS
1024 mgmt_rx_reo_sim_stop(uint8_t ml_grp_id);
1025 
1026 /**
1027  * mgmt_rx_reo_sim_process_rx_frame() - API to process the management frame
1028  * in case of simulation
1029  * @pdev: pointer to pdev object
1030  * @buf: pointer to management frame buffer
1031  * @mgmt_rx_params: pointer to management frame parameters
1032  *
1033  * This API validates whether the reo algorithm has reordered frames correctly.
1034  *
1035  * Return: QDF_STATUS
1036  */
1037 QDF_STATUS
1038 mgmt_rx_reo_sim_process_rx_frame(struct wlan_objmgr_pdev *pdev,
1039 				 qdf_nbuf_t buf,
1040 				 struct mgmt_rx_event_params *mgmt_rx_params);
1041 
1042 /**
1043  * mgmt_rx_reo_sim_get_snapshot_address() - Get snapshot address
1044  * @pdev: pointer to pdev
1045  * @id: snapshot identifier
1046  * @address: pointer to snapshot address
1047  *
1048  * Helper API to get address of snapshot @id for pdev @pdev. For simulation
1049  * purpose snapshots are allocated in the simulation context object.
1050  *
1051  * Return: QDF_STATUS
1052  */
1053 QDF_STATUS
1054 mgmt_rx_reo_sim_get_snapshot_address(
1055 			struct wlan_objmgr_pdev *pdev,
1056 			enum mgmt_rx_reo_shared_snapshot_id id,
1057 			struct mgmt_rx_reo_shared_snapshot **address);
1058 
1059 /**
1060  * mgmt_rx_reo_sim_pdev_object_create_notification() - pdev create handler for
1061  * management rx-reorder simulation framework
1062  * @pdev: pointer to pdev object
1063  *
1064  * This function gets called from object manager when pdev is being created and
1065  * builds the link id to pdev map in simulation context object.
1066  *
1067  * Return: QDF_STATUS
1068  */
1069 QDF_STATUS
1070 mgmt_rx_reo_sim_pdev_object_create_notification(struct wlan_objmgr_pdev *pdev);
1071 
1072 /**
1073  * mgmt_rx_reo_sim_pdev_object_destroy_notification() - pdev destroy handler for
1074  * management rx-reorder simulation framework
1075  * @pdev: pointer to pdev object
1076  *
1077  * This function gets called from object manager when pdev is being destroyed
1078  * and destroys the link id to pdev map in simulation context.
1079  *
1080  * Return: QDF_STATUS
1081  */
1082 QDF_STATUS
1083 mgmt_rx_reo_sim_pdev_object_destroy_notification(struct wlan_objmgr_pdev *pdev);
1084 
1085 /**
1086  * mgmt_rx_reo_sim_get_mlo_link_id_from_pdev() - Helper API to get the MLO HW
1087  * link id from the pdev object.
1088  * @pdev: Pointer to pdev object
1089  *
1090  * This API is applicable for simulation only. A static map from MLO HW link id
1091  * to the pdev object is created at the init time. This API uses the map to
1092  * find the MLO HW link id for a given pdev.
1093  *
1094  * Return: On success returns the MLO HW link id corresponding to the pdev
1095  * object. On failure returns -1.
1096  */
1097 int8_t
1098 mgmt_rx_reo_sim_get_mlo_link_id_from_pdev(struct wlan_objmgr_pdev *pdev);
1099 
1100 /**
1101  * mgmt_rx_reo_sim_get_pdev_from_mlo_link_id() - Helper API to get the pdev
1102  * object from the MLO HW link id.
1103  * @mlo_link_id: MLO HW link id
1104  * @refdbgid: Reference debug id
1105  *
1106  * This API is applicable for simulation only. A static map from MLO HW link id
1107  * to the pdev object is created at the init time. This API uses the map to
1108  * find the pdev object from the MLO HW link id.
1109  *
1110  * Return: On success returns the pdev object corresponding to the MLO HW
1111  * link id. On failure returns NULL.
1112  */
1113 struct wlan_objmgr_pdev *
1114 mgmt_rx_reo_sim_get_pdev_from_mlo_link_id(uint8_t mlo_link_id,
1115 					  wlan_objmgr_ref_dbgid refdbgid);
1116 #endif /* WLAN_MGMT_RX_REO_SIM_SUPPORT */
1117 
1118 /**
1119  * is_mgmt_rx_reo_required() - Whether MGMT REO required for this frame/event
1120  * @pdev: pdev for which this frame/event is intended
1121  * @desc: Descriptor corresponding to this frame/event
1122  *
1123  * Return: true if REO is required; else false
1124  */
1125 static inline bool is_mgmt_rx_reo_required(
1126 			struct wlan_objmgr_pdev *pdev,
1127 			struct mgmt_rx_reo_frame_descriptor *desc)
1128 {
1129 	/**
1130 	 * NOTE: Implementing a simple policy based on the number of MLO vdevs
1131 	 * in the given pdev.
1132 	 */
1133 	return  wlan_pdev_get_mlo_vdev_count(pdev);
1134 }
1135 
1136 /**
1137  * wlan_mgmt_rx_reo_algo_entry() - Entry point to the MGMT Rx REO algorithm for
1138  * a given MGMT frame/event.
1139  * @pdev: pdev for which this frame/event is intended
1140  * @desc: Descriptor corresponding to this frame/event
1141  * @is_queued: Whether this frame/event is queued in the REO list
1142  *
1143  * Return: QDF_STATUS of operation
1144  */
1145 QDF_STATUS
1146 wlan_mgmt_rx_reo_algo_entry(struct wlan_objmgr_pdev *pdev,
1147 			    struct mgmt_rx_reo_frame_descriptor *desc,
1148 			    bool *is_queued);
1149 
1150 /**
1151  * mgmt_rx_reo_list_max_size_exceeded() - Helper API to check whether
1152  * list has exceeded the maximum configured size
1153  * @reo_list: Pointer to reorder list
1154  *
1155  * This API expects the caller to acquire the spin lock protecting the reorder
1156  * list.
1157  *
1158  * Return: true if reorder list has exceeded the max size
1159  */
1160 static inline bool
1161 mgmt_rx_reo_list_max_size_exceeded(struct mgmt_rx_reo_list *reo_list)
1162 {
1163 	return (qdf_list_size(&reo_list->list) > reo_list->max_list_size);
1164 }
1165 
1166 /**
1167  * mgmt_rx_reo_validate_mlo_link_info() - Validate the MLO HW link info
1168  * obtained from the global shared memory arena
1169  * @psoc: Pointer to psoc object
1170  *
1171  * Validate the following MLO HW link related information extracted from
1172  * management Rx reorder related TLVs in global shared memory arena.
1173  *         1. Number of active MLO HW links
1174  *         2. Valid MLO HW link bitmap
1175  *
1176  * Return: QDF_STATUS of operation
1177  */
1178 QDF_STATUS
1179 mgmt_rx_reo_validate_mlo_link_info(struct wlan_objmgr_psoc *psoc);
1180 #endif /* WLAN_MGMT_RX_REO_SUPPORT */
1181 #endif /* _WLAN_MGMT_TXRX_RX_REO_I_H */
1182