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