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: contains MLO manager public file containing peer functionality
20  */
21 #ifndef _WLAN_MLO_MGR_PEER_H_
22 #define _WLAN_MLO_MGR_PEER_H_
23 
24 #include "wlan_objmgr_peer_obj.h"
25 
26 #define WLAN_LINK_ID_INVALID    0xff
27 #define WLAN_NUM_TWO_LINK_PSOC  2
28 
29 /**
30  * mlo_peer_create - Initiatiate peer create on secondary link(s)
31  * by posting a message
32  *
33  * @vdev: pointer to vdev
34  * @peer: pointer to peer context
35  * @mlo_ie: MLO information element
36  * @aid: association ID
37  *
38  * Initiate the peer on the second link
39  *
40  * Return: none
41  */
42 void mlo_peer_create(struct wlan_objmgr_vdev *vdev,
43 			       struct wlan_objmgr_peer *peer, uint8_t *mlo_ie,
44 			       uint8_t aid);
45 
46 /**
47  * mlo_get_mlpeer - Get ML peer corresponds to the MLD address
48  * @ml_dev: MLO DEV object
49  * @ml_addr: MLD MAC address
50  *
51  * This API will be used to get the ML peer associated with MLD address.
52  * It will return Null if the peer does not exist for the given MLD address.
53  *
54  * Return: Pointer to the ML peer context structure
55  */
56 struct wlan_mlo_peer_context *mlo_get_mlpeer(
57 				struct wlan_mlo_dev_context *ml_dev,
58 				const struct qdf_mac_addr *ml_addr);
59 
60 /**
61  * mlo_peer_attach - Attaches the peer by updating the MLO peer context with
62  * the new link information
63  *
64  * @vdev: pointer to vdev
65  * @peer: pointer to peer context
66  *
67  * Return: none
68  */
69 void mlo_peer_attach(struct wlan_objmgr_vdev *vdev,
70 		     struct wlan_objmgr_peer *peer);
71 
72 /**
73  * mlo_peer_setup_failed_notify - Notify MLO manager that peer setup has failed
74  * and to cleanup by deleting the partner peers
75  *
76  * @vdev: pointer to vdev
77  *
78  * This API is called in scenarios where peer create or peer assoc fails
79  *
80  * Return: none
81  */
82 void mlo_peer_setup_failed_notify(struct wlan_objmgr_vdev *vdev);
83 
84 /**
85  * mlo_peer_disconnect_notify - Notify MLO manager that peer has disconnected
86  * and to clean up by deleting partner peers
87  *
88  * @peer: pointer to peer context
89  *
90  * Return: none
91  */
92 void mlo_peer_disconnect_notify(struct wlan_objmgr_peer *peer);
93 
94 /**
95  * wlan_peer_delete_complete - Notify MLO manager that peer delete is completed
96  * and to clean up by unlinking the peer object
97  *
98  * @peer: pointer to peer context
99  *
100  * Return: none
101  */
102 void wlan_peer_delete_complete(struct wlan_objmgr_peer *peer);
103 
104 /**
105  * mlo_peer_delete - Delete the peer object
106  *
107  * @peer: pointer to peer context
108  *
109  * Return: none
110  */
111 void mlo_peer_delete(struct wlan_objmgr_peer *peer);
112 
113 /**
114  * wlan_mlo_peer_delete - Initiate deletion of MLO peer
115  *
116  * @ml_peer: pointer to ML peer context
117  *
118  * Return: none
119  */
120 void wlan_mlo_peer_delete(struct wlan_mlo_peer_context *ml_peer);
121 
122 /**
123  * is_mlo_all_peer_links_deleted - Check if all the peer links are deleted
124  *
125  * Return: true if all the peer links are deleted, false otherwise
126  */
127 bool is_mlo_all_peer_links_deleted(void);
128 
129 /**
130  * wlan_mlo_peer_is_disconnect_progress() - MLO peer is in disconnect progress
131  * @ml_peer: MLO peer
132  *
133  * This function checks whether MLO Peer is in disconnect progress
134  *
135  * Return: SUCCESS if MLO Peer is in disconnect progress
136  */
137 QDF_STATUS wlan_mlo_peer_is_disconnect_progress(
138 					struct wlan_mlo_peer_context *ml_peer);
139 
140 /**
141  * wlan_mlo_peer_is_assoc_done() - MLO peer is Assoc complete
142  * @ml_peer: MLO peer
143  *
144  * This function checks whether MLO Peer's Assoc is completed
145  *
146  * Return: SUCCESS if MLO Peer Assoc is completed
147  */
148 QDF_STATUS wlan_mlo_peer_is_assoc_done(struct wlan_mlo_peer_context *ml_peer);
149 
150 /**
151  * wlan_mlo_peer_get_assoc_peer() - get assoc peer
152  * @ml_peer: MLO peer
153  *
154  * This function returns assoc peer of MLO peer
155  *
156  * Return: assoc peer, if it is found, otherwise NULL
157  */
158 struct wlan_objmgr_peer *wlan_mlo_peer_get_assoc_peer(
159 					struct wlan_mlo_peer_context *ml_peer);
160 
161 /**
162  * wlan_mlo_peer_get_primary_link_vdev() - Get primary link vdev
163  * @ml_peer: MLO peer
164  *
165  * This function iterates through ml_peer to find primary link
166  * and returns VDEV to which primary link is attached.
167  *
168  * Return: Pointer to vdev, if primary link is found else NULL
169  */
170 struct wlan_objmgr_vdev *
171 wlan_mlo_peer_get_primary_link_vdev(struct wlan_mlo_peer_context *ml_peer);
172 
173 /**
174  * wlan_mlo_peer_get_bridge_peer() - get bridge peer
175  * @ml_peer: MLO peer
176  *
177  * This function returns bridge peer of MLO peer
178  *
179  * Return: bridge peer, if it is found, otherwise NULL
180  */
181 struct wlan_objmgr_peer *wlan_mlo_peer_get_bridge_peer(
182 					struct wlan_mlo_peer_context *ml_peer);
183 /**
184  * mlo_peer_is_assoc_peer() - check whether the peer is assoc peer
185  * @ml_peer: MLO peer
186  * @peer: Link peer
187  *
188  * This function checks whether the peer is assoc peer of MLO peer,
189  * This API doesn't have lock protection, caller needs to take the lock
190  *
191  * Return: true, if it is assoc peer
192  */
193 bool mlo_peer_is_assoc_peer(struct wlan_mlo_peer_context *ml_peer,
194 			    struct wlan_objmgr_peer *peer);
195 
196 /**
197  * wlan_mlo_peer_is_assoc_peer() - check whether the peer is assoc peer
198  * @ml_peer: MLO peer
199  * @peer: Link peer
200  *
201  * This function checks whether the peer is assoc peer of MLO peer
202  *
203  * Return: true, if it is assoc peer
204  */
205 bool wlan_mlo_peer_is_assoc_peer(struct wlan_mlo_peer_context *ml_peer,
206 				 struct wlan_objmgr_peer *peer);
207 
208 /**
209  * wlan_mlo_peer_is_link_peer() - check whether the peer is link peer
210  * @ml_peer: MLO peer
211  * @peer: Link peer
212  *
213  * This function checks whether the peer is link peer of MLO peer
214  *
215  * Return: true, if it is link peer
216  */
217 bool wlan_mlo_peer_is_link_peer(struct wlan_mlo_peer_context *ml_peer,
218 				struct wlan_objmgr_peer *peer);
219 
220 /**
221  * wlan_mlo_partner_peer_assoc_post() - Notify partner peer assoc
222  * @assoc_peer: Link peer
223  *
224  * This function notifies link peers to send peer assoc command to FW
225  *
226  * Return: void
227  */
228 void wlan_mlo_partner_peer_assoc_post(struct wlan_objmgr_peer *assoc_peer);
229 
230 /**
231  * wlan_mlo_link_peer_assoc_set() - Set Peer assoc sent flag
232  * @peer: Link peer
233  * @is_sent: indicates whether peer assoc is queued to FW
234  *
235  * This function updates that the Peer assoc commandis sent for the link peer
236  *
237  * Return: void
238  */
239 void wlan_mlo_link_peer_assoc_set(struct wlan_objmgr_peer *peer, bool is_sent);
240 
241 /**
242  * wlan_mlo_peer_get_del_hw_bitmap() - Gets peer del hw bitmap for link peer
243  * @peer: Link peer
244  * @hw_link_id_bitmap: WMI peer delete HW link bitmap
245  *
246  * This function gets hw bitmap for peer delete command, which includes
247  * hw link id of partner links for which peer assoc was not sent to FW
248  *
249  * Return: void
250  */
251 void wlan_mlo_peer_get_del_hw_bitmap(struct wlan_objmgr_peer *peer,
252 				     uint32_t *hw_link_id_bitmap);
253 
254 /**
255  * wlan_mlo_peer_deauth_init() - Initiate Deauth of MLO peer
256  * @ml_peer: MLO peer
257  * @src_peer: Source peer, if this pointer is valid, send deauth on other link
258  * @is_disassoc: to indicate, whether Disassoc to be sent instead of deauth
259  *
260  * This function initiates deauth on MLO peer and its links peers
261  *
262  * Return: void
263  */
264 void
265 wlan_mlo_peer_deauth_init(struct wlan_mlo_peer_context *ml_peer,
266 			  struct wlan_objmgr_peer *src_peer,
267 			  uint8_t is_disassoc);
268 
269 /**
270  * wlan_mlo_partner_peer_create_failed_notify() - Notify peer creation fail
271  * @ml_peer: MLO peer
272  *
273  * This function notifies about link peer creation failure
274  *
275  * Return: void
276  */
277 void wlan_mlo_partner_peer_create_failed_notify(
278 					struct wlan_mlo_peer_context *ml_peer);
279 
280 /**
281  * wlan_mlo_partner_peer_disconnect_notify() - Notify peer disconnect
282  * @src_peer: Link peer
283  *
284  * This function notifies about disconnect is being initilated on link peer
285  *
286  * Return: void
287  */
288 void wlan_mlo_partner_peer_disconnect_notify(struct wlan_objmgr_peer *src_peer);
289 
290 /**
291  * wlan_mlo_peer_create() - MLO peer create
292  * @vdev: Link VDEV
293  * @link_peer: Link peer
294  * @ml_info: ML links info
295  * @frm_buf: Assoc req buffer
296  * @aid: AID, if already allocated
297  *
298  * This function creates MLO peer and notifies other partner VDEVs to create
299  * link peers
300  *
301  * Return: SUCCESS, if MLO peer is successfully created
302  */
303 QDF_STATUS wlan_mlo_peer_create(struct wlan_objmgr_vdev *vdev,
304 				struct wlan_objmgr_peer *link_peer,
305 				struct mlo_partner_info *ml_info,
306 				qdf_nbuf_t frm_buf,
307 				uint16_t aid);
308 
309 /**
310  * wlan_mlo_peer_asreq() - MLO peer process assoc req
311  * @vdev: Link VDEV
312  * @link_peer: Link peer
313  * @ml_info: ML links info
314  * @frm_buf: Assoc req buffer
315  *
316  * This function process assoc req on existing MLO peer and notifies other
317  * partner peers to process assoc request
318  *
319  * Return: SUCCESS, if MLO peer is successfully processed
320  */
321 QDF_STATUS wlan_mlo_peer_asreq(struct wlan_objmgr_vdev *vdev,
322 			       struct wlan_objmgr_peer *link_peer,
323 			       struct mlo_partner_info *ml_info,
324 			       qdf_nbuf_t frm_buf);
325 
326 /**
327  * mlo_peer_cleanup() - Free MLO peer
328  * @ml_peer: MLO peer
329  *
330  * This function frees MLO peer and resets MLO peer associations
331  * Note, this API is ref count protected, it should be always invoked
332  * from wlan_mlo_peer_release_ref()
333  *
334  * Return: void
335  */
336 void mlo_peer_cleanup(struct wlan_mlo_peer_context *ml_peer);
337 
338 /**
339  * wlan_mlo_peer_get_ref() - Get ref of MLO peer
340  * @ml_peer: MLO peer
341  *
342  * This function gets ref of MLO peer
343  *
344  * Return: void
345  */
wlan_mlo_peer_get_ref(struct wlan_mlo_peer_context * ml_peer)346 static inline void wlan_mlo_peer_get_ref(struct wlan_mlo_peer_context *ml_peer)
347 {
348 	qdf_atomic_inc(&ml_peer->ref_cnt);
349 }
350 
351 /**
352  * wlan_mlo_peer_release_ref() - Release ref of MLO peer
353  * @ml_peer: MLO peer
354  *
355  * This function releases ref of MLO peer, if ref is 0, invokes MLO peer free
356  *
357  * Return: void
358  */
wlan_mlo_peer_release_ref(struct wlan_mlo_peer_context * ml_peer)359 static inline void wlan_mlo_peer_release_ref(
360 					struct wlan_mlo_peer_context *ml_peer)
361 {
362 	if (qdf_atomic_dec_and_test(&ml_peer->ref_cnt))
363 		mlo_peer_cleanup(ml_peer);
364 }
365 
366 /**
367  * wlan_mlo_link_peer_attach() - MLO link peer attach
368  * @ml_peer: MLO peer
369  * @peer: Link peer
370  * @frm_buf: Assoc resp buffer of non-assoc link
371  *
372  * This function attaches link peer to MLO peer
373  *
374  * Return: SUCCESS, if peer is successfully attached to MLO peer
375  */
376 QDF_STATUS wlan_mlo_link_peer_attach(struct wlan_mlo_peer_context *ml_peer,
377 				     struct wlan_objmgr_peer *peer,
378 				     qdf_nbuf_t frm_buf);
379 
380 /**
381  * wlan_mlo_link_asresp_attach() - MLO link peer assoc resp attach
382  * @ml_peer: MLO peer
383  * @peer: Link peer
384  * @frm_buf: Assoc resp buffer of non-assoc link
385  *
386  * This function attaches assoc resp of link peer to MLO peer
387  *
388  * Return: SUCCESS, if peer is successfully attached to MLO peer
389  */
390 QDF_STATUS wlan_mlo_link_asresp_attach(struct wlan_mlo_peer_context *ml_peer,
391 				       struct wlan_objmgr_peer *peer,
392 				       qdf_nbuf_t frm_buf);
393 
394 /**
395  * wlan_mlo_link_peer_delete() - MLO link peer delete
396  * @peer: Link peer
397  *
398  * This function detaches link peer from MLO peer, if this peer is last link
399  * peer, then MLO peer gets deleted
400  *
401  * Return: SUCCESS, if peer is detached from MLO peer
402  */
403 QDF_STATUS wlan_mlo_link_peer_delete(struct wlan_objmgr_peer *peer);
404 
405 /**
406  * mlo_peer_get_link_peer_assoc_req_buf() - API to get link assoc req buffer
407  * @ml_peer: Object manager peer
408  * @link_ix: link id of vdev
409  *
410  * Return: assoc req buffer
411  */
412 qdf_nbuf_t mlo_peer_get_link_peer_assoc_req_buf(
413 			struct wlan_mlo_peer_context *ml_peer,
414 			uint8_t link_ix);
415 
416 /**
417  * mlo_peer_get_link_peer_assoc_resp_buf() - get MLO link peer assoc resp buf
418  * @ml_peer: MLO peer
419  * @link_ix: Link index of the link peer
420  *
421  * This function retrieves stored assoc resp buffer of link peer
422  *
423  * Return: resp_buf, if link_peer is available
424  *         NULL, if link_peer is not present
425  */
426 qdf_nbuf_t mlo_peer_get_link_peer_assoc_resp_buf(
427 		struct wlan_mlo_peer_context *ml_peer,
428 		uint8_t link_ix);
429 
430 /**
431  * wlan_mlo_peer_free_all_link_assoc_resp_buf() - Free all assoc resp buffers
432  * @peer: Link peer
433  *
434  * This function frees all assoc resp link buffers
435  *
436  * Return: void
437  */
438 void wlan_mlo_peer_free_all_link_assoc_resp_buf(struct wlan_objmgr_peer *peer);
439 
440 /**
441  * wlan_mlo_peer_get_links_info() - get MLO peer partner links info
442  * @peer: Link peer
443  * @ml_links: structure to be filled with partner link info
444  *
445  * This function retrieves partner link info of link peer such as hw link id,
446  * vdev id
447  *
448  * Return: void
449  */
450 void wlan_mlo_peer_get_links_info(struct wlan_objmgr_peer *peer,
451 				  struct mlo_tgt_partner_info *ml_links);
452 
453 /**
454  * wlan_mlo_peer_get_primary_peer_link_id() - get vdev link ID of primary peer
455  * @peer: Link peer
456  *
457  * This function checks for the peers and returns vdev link id of the primary
458  * peer.
459  *
460  * Return: link id of primary vdev
461  */
462 uint8_t wlan_mlo_peer_get_primary_peer_link_id(struct wlan_objmgr_peer *peer);
463 
464 /**
465  * wlan_mlo_peer_get_primary_peer_link_id_by_ml_peer() - get vdev link ID of
466  * primary peer using ml peer.
467  * @ml_peer: ML peer
468  *
469  * This function checks for the peers and returns vdev link id of the primary
470  * peer.
471  *
472  * Return: link id of primary vdev
473  */
474 uint8_t wlan_mlo_peer_get_primary_peer_link_id_by_ml_peer(
475 				struct wlan_mlo_peer_context *ml_peer);
476 
477 /**
478  * wlan_mlo_peer_get_partner_links_info() - get MLO peer partner links info
479  * @peer: Link peer
480  * @ml_links: structure to be filled with partner link info
481  *
482  * This function retrieves partner link info of link peer such as link id,
483  * mac address
484  *
485  * Return: void
486  */
487 void wlan_mlo_peer_get_partner_links_info(struct wlan_objmgr_peer *peer,
488 					  struct mlo_partner_info *ml_links);
489 
490 #ifdef WLAN_MLO_MULTI_CHIP
491 /**
492  * wlan_mlo_peer_get_str_capability() - get STR capability of non-AP MLD
493  * @peer: Link peer
494  * @max_simult_links: Pointer to fill maximum simultaneous links
495  *
496  * This function retrieves maximum simultaneous links from connected ml peer,
497  *
498  * Return: void
499  */
500 void wlan_mlo_peer_get_str_capability(struct wlan_objmgr_peer *peer,
501 				      uint8_t *max_simult_links);
502 
503 /**
504  * wlan_mlo_peer_get_eml_capability() - get EML capability
505  * @peer: Link peer
506  * @is_emlsr_capable: Pointer to fill EMLSR capability
507  * @is_emlmr_capable: Pointer to fill EMLMR capability
508  *
509  * This function retrieves EML capability from connected ml peer,
510  *
511  * Return: void
512  */
513 void wlan_mlo_peer_get_eml_capability(struct wlan_objmgr_peer *peer,
514 				      uint8_t *is_emlsr_capable,
515 				      uint8_t *is_emlmr_capable);
516 #endif
517 
518 /*
519  * APIs to operations on ML peer object
520  */
521 typedef QDF_STATUS (*wlan_mlo_op_handler)(struct wlan_mlo_dev_context *ml_dev,
522 				    void *ml_peer,
523 				    void *arg);
524 
525 /**
526  * wlan_mlo_iterate_ml_peerlist() - iterate through all ml peer objects
527  * @ml_dev: MLO DEV object
528  * @handler: the handler will be called for each ml peer
529  *            the handler should be implemented to perform required operation
530  * @arg:     arguments passed by caller
531  *
532  * API to be used for performing the operations on all ML PEER objects
533  *
534  * Return: SUCCESS/FAILURE
535  */
536 QDF_STATUS wlan_mlo_iterate_ml_peerlist(struct wlan_mlo_dev_context *ml_dev,
537 					wlan_mlo_op_handler handler,
538 					void *arg);
539 
540 /**
541  * wlan_mlo_get_mlpeer_by_linkmac() - find ML peer by Link MAC address
542  * @ml_dev: MLO DEV object
543  * @link_mac:  Link peer MAC address
544  *
545  * API to get ML peer using link MAC address
546  *
547  * Return: ML peer object, if it is found
548  *         otherwise, returns NULL
549  */
550 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_linkmac(
551 				struct wlan_mlo_dev_context *ml_dev,
552 				struct qdf_mac_addr *link_mac);
553 
554 /**
555  * wlan_mlo_get_mlpeer_by_mld_mac() - find ML peer by MLD MAC address
556  * @ml_dev: MLO DEV object
557  * @mld_mac:  Peer MLD MAC address
558  *
559  * API to get ML peer using link MAC address
560  *
561  * Return: ML peer object, if it is found
562  *         otherwise, returns NULL
563  */
564 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_mld_mac(
565 				struct wlan_mlo_dev_context *ml_dev,
566 				struct qdf_mac_addr *mld_mac);
567 
568 /**
569  * mlo_get_link_vdev_from_psoc_id() - Get link vdev from psoc id
570  * @ml_dev: MLO DEV object
571  * @psoc_id: psoc_id
572  * @get_bridge_vdev: Flag to indicate bridge vdev search is needed
573  *
574  * API to get vdev using psoc_id. When get_bridg_vdev flag is passed as true,
575  * this API searches vdev from bridge vdev list. If there are no bridge
576  * vdevs present, then it searches in actual vdev list. If flag is
577  * passed as false, vdev search will be directly from actual vdev list.
578  *
579  * Return: Pointer to vdev, if it is found
580  *         otherwise, returns NULL
581  */
582 struct wlan_objmgr_vdev *mlo_get_link_vdev_from_psoc_id(
583 				struct wlan_mlo_dev_context *ml_dev,
584 				uint8_t psoc_id, bool get_bridge_vdev);
585 
586 /**
587  * wlan_mlo_get_mlpeer_by_peer_mladdr() - Get ML peer from the list of MLD's
588  *                                        using MLD MAC address
589  *
590  * @mldaddr: MAC address of the ML peer
591  * @mldev: Update corresponding ML dev context in which peer is found
592  *
593  * Return: Pointer to mlo peer context
594  */
595 struct wlan_mlo_peer_context
596 *wlan_mlo_get_mlpeer_by_peer_mladdr(struct qdf_mac_addr *mldaddr,
597 				    struct wlan_mlo_dev_context **mldev);
598 
599 /**
600  * wlan_mlo_get_mlpeer_by_aid() - find ML peer by AID
601  * @ml_dev: MLO DEV object
602  * @assoc_id:  AID
603  *
604  * API to get ML peer using AID
605  *
606  * Return: ML peer object, if it is found
607  *         otherwise, returns NULL
608  */
609 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_aid(
610 				struct wlan_mlo_dev_context *ml_dev,
611 				uint16_t assoc_id);
612 
613 /**
614  * wlan_mlo_get_mlpeer_by_ml_peerid() - find ML peer by ML peer id
615  * @ml_dev: MLO DEV object
616  * @ml_peerid:  ML Peer ID
617  *
618  * API to get ML peer using ML peer id
619  *
620  * Return: ML peer object, if it is found
621  *         otherwise, returns NULL
622  */
623 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer_by_ml_peerid(
624 				struct wlan_mlo_dev_context *ml_dev,
625 				uint16_t ml_peerid);
626 
627 /**
628  * wlan_mlo_get_mlpeer() - find ML peer by MLD MAC address
629  * @ml_dev: MLO DEV object
630  * @ml_addr: MLO MAC address
631  *
632  * API to get ML peer using MLO MAC address
633  *
634  * Return: ML peer object, if it is found
635  *         otherwise, returns NULL
636  */
637 struct wlan_mlo_peer_context *wlan_mlo_get_mlpeer(
638 				struct wlan_mlo_dev_context *ml_dev,
639 				struct qdf_mac_addr *ml_addr);
640 
641 /**
642  * mlo_dev_mlpeer_attach() - Add ML PEER to ML peer list
643  * @ml_dev: MLO DEV object
644  * @ml_peer: ML peer
645  *
646  * API to attach ML PEER to MLD PEER table
647  *
648  * Return: SUCCESS, if it attached successfully
649  *         otherwise, returns FAILURE
650  */
651 QDF_STATUS mlo_dev_mlpeer_attach(struct wlan_mlo_dev_context *ml_dev,
652 				 struct wlan_mlo_peer_context *ml_peer);
653 
654 /**
655  * mlo_dev_mlpeer_detach() - Delete ML PEER from ML peer list
656  * @ml_dev: MLO DEV object
657  * @ml_peer: ML peer
658  *
659  * API to detach ML PEER from MLD PEER table
660  *
661  * Return: SUCCESS, if it detached successfully
662  *         otherwise, returns FAILURE
663  */
664 QDF_STATUS mlo_dev_mlpeer_detach(struct wlan_mlo_dev_context *ml_dev,
665 				 struct wlan_mlo_peer_context *ml_peer);
666 
667 /**
668  * mlo_dev_mlpeer_list_init() - Initialize ML peer list
669  * @ml_dev: MLO DEV object
670  *
671  * API to initialize MLO peer list
672  *
673  * Return: SUCCESS, if initialized successfully
674  */
675 QDF_STATUS mlo_dev_mlpeer_list_init(struct wlan_mlo_dev_context *ml_dev);
676 
677 /**
678  * mlo_dev_mlpeer_list_deinit() - destroys ML peer list
679  * @ml_dev: MLO DEV object
680  *
681  * API to destroys MLO peer list
682  *
683  * Return: SUCCESS, if initialized successfully
684  */
685 QDF_STATUS mlo_dev_mlpeer_list_deinit(struct wlan_mlo_dev_context *ml_dev);
686 
687 /**
688  * wlan_peer_is_mlo() - check whether peer is MLO link peer
689  * @peer: link peer object
690  *
691  * API to check link peer is part of MLO peer or not
692  *
693  * Return: true if it MLO peer
694  *         false, if it is not MLO peer
695  */
wlan_peer_is_mlo(struct wlan_objmgr_peer * peer)696 static inline uint8_t wlan_peer_is_mlo(struct wlan_objmgr_peer *peer)
697 {
698 	return wlan_peer_mlme_flag_ext_get(peer, WLAN_PEER_FEXT_MLO);
699 }
700 
701 /**
702  * wlan_peer_set_mlo() - Set peer as MLO link peer
703  * @peer: link peer object
704  *
705  * API to set MLO peer flag in link peer is part of MLO peer
706  *
707  * Return: void
708  */
wlan_peer_set_mlo(struct wlan_objmgr_peer * peer)709 static inline void wlan_peer_set_mlo(struct wlan_objmgr_peer *peer)
710 {
711 	return wlan_peer_mlme_flag_ext_set(peer, WLAN_PEER_FEXT_MLO);
712 }
713 
714 /**
715  * wlan_peer_clear_mlo() - clear peer as MLO link peer
716  * @peer: link peer object
717  *
718  * API to clear MLO peer flag in link peer
719  *
720  * Return: void
721  */
wlan_peer_clear_mlo(struct wlan_objmgr_peer * peer)722 static inline void wlan_peer_clear_mlo(struct wlan_objmgr_peer *peer)
723 {
724 	return wlan_peer_mlme_flag_ext_clear(peer, WLAN_PEER_FEXT_MLO);
725 }
726 
727 #if defined(MESH_MODE_SUPPORT) && defined(WLAN_FEATURE_11BE_MLO)
728 /**
729  * wlan_mlo_peer_is_mesh() - Check if ml_peer is configured to operate as MESH
730  * @ml_peer: MLO peer
731  *
732  * Return: TRUE if ml peer is configured as MESH
733  */
734 bool wlan_mlo_peer_is_mesh(struct wlan_mlo_peer_context *ml_peer);
735 #else
736 static inline
wlan_mlo_peer_is_mesh(struct wlan_mlo_peer_context * ml_peer)737 bool wlan_mlo_peer_is_mesh(struct wlan_mlo_peer_context *ml_peer)
738 {
739 	return false;
740 }
741 #endif
742 
743 #ifdef UMAC_SUPPORT_MLNAWDS
744 /**
745  * wlan_mlo_peer_is_nawds() - Check if ml_peer is configured to operate as NAWDS
746  * @ml_peer: MLO peer
747  *
748  * Return TRUE if ml peer is configured as NAWDS
749  */
750 bool wlan_mlo_peer_is_nawds(struct wlan_mlo_peer_context *ml_peer);
751 #else
752 static inline
wlan_mlo_peer_is_nawds(struct wlan_mlo_peer_context * ml_peer)753 bool wlan_mlo_peer_is_nawds(struct wlan_mlo_peer_context *ml_peer)
754 {
755 	return false;
756 }
757 #endif
758 #ifdef UMAC_MLO_AUTH_DEFER
759 /**
760  * mlo_peer_link_auth_defer() - Auth request defer for MLO peer
761  * @ml_peer: ML peer
762  * @link_mac:  Link peer MAC address
763  * @auth_params: Defer Auth param
764  *
765  * This function saves Auth request params in MLO peer
766  *
767  * Return: SUCCESS if MAC address matches one of the link peers
768  *         FAILURE, if MAC address doesn't match
769  */
770 QDF_STATUS mlo_peer_link_auth_defer(struct wlan_mlo_peer_context *ml_peer,
771 				    struct qdf_mac_addr *link_mac,
772 				    struct mlpeer_auth_params *auth_params);
773 
774 /**
775  * mlo_peer_free_auth_param() - Free deferred Auth request params
776  * @auth_params: Defer Auth param
777  *
778  * This function frees Auth request params
779  *
780  * Return: void
781  */
782 void mlo_peer_free_auth_param(struct mlpeer_auth_params *auth_params);
783 #else
784 static inline void
mlo_peer_free_auth_param(struct mlpeer_auth_params * auth_params)785 mlo_peer_free_auth_param(struct mlpeer_auth_params *auth_params)
786 {
787 }
788 #endif
789 
790 /**
791  * wlan_mlo_partner_peer_delete_is_allowed() - Checks MLO peer delete is allowed
792  * @src_peer: Link peer
793  *
794  * This function checks whether MLO peer can be deleted along with link peer
795  * delete in link removal cases
796  *
797  * Return: true, if MLO peer can be deleted
798  */
799 bool wlan_mlo_partner_peer_delete_is_allowed(struct wlan_objmgr_peer *src_peer);
800 
801 /**
802  * wlan_mlo_validate_reassocreq() - Checks MLO peer reassoc processing
803  * @ml_peer: ML peer
804  *
805  * This function checks whether Reassoc from MLO peer is processed successfully
806  *
807  * Return: SUCCESS, if Reassoc processing is done
808  */
809 QDF_STATUS wlan_mlo_validate_reassocreq(struct wlan_mlo_peer_context *ml_peer);
810 
811 #ifdef QCA_SUPPORT_PRIMARY_LINK_MIGRATE
812 /**
813  * wlan_objmgr_mlo_update_primary_info() - Update is_primary flag
814  * @peer: new primary link peer object
815  *
816  * API to update is_primary flag in peer list
817  *
818  * Return: void
819  */
820 void wlan_objmgr_mlo_update_primary_info(struct wlan_objmgr_peer *peer);
821 #endif
822 
823 /**
824  * wlan_mld_get_best_primary_umac_w_rssi() - API to get primary umac using rssi
825  * @ml_peer: ml peer object
826  * @link_vdevs: list of vdevs from which new primary link is to be selected
827  * @allow_all_links: Flag to allow all links to be able to get selected as
828  * primary. This flag will be used to override primary_umac_skip ini
829  *
830  * API to get primary umac using rssi
831  *
832  * Return: primary umac psoc id
833  */
834 uint8_t
835 wlan_mld_get_best_primary_umac_w_rssi(struct wlan_mlo_peer_context *ml_peer,
836 				      struct wlan_objmgr_vdev *link_vdevs[],
837 				      bool allow_all_links);
838 
839 /**
840  * wlan_mlo_wsi_link_info_send_cmd() - Send WSI stats to FW
841  *
842  * API to send WMI commands for all radios of all PSOCs
843  *
844  * Return: SUCCESS, on sending WMI commands
845  */
846 QDF_STATUS wlan_mlo_wsi_link_info_send_cmd(void);
847 
848 /**
849  * wlan_mlo_wsi_stats_allow_cmd() - Allow WSI stats to FW
850  *
851  * API to allows WSI stats WMI commands for all radios of all PSOCs
852  *
853  * Return: void
854  */
855 void wlan_mlo_wsi_stats_allow_cmd(void);
856 
857 /**
858  * wlan_mlo_wsi_stats_block_cmd() - Block WSI stats to FW
859  *
860  * API to block WST stats WMI commands for all radios of all PSOCs
861  *
862  * Return: void
863  */
864 void wlan_mlo_wsi_stats_block_cmd(void);
865 /**
866  * wlan_mlo_peer_wsi_link_add() - Add peer to WSI info list
867  * @ml_peer: ML peer context
868  *
869  * API to add peer to WSI link stats
870  *
871  * Return: SUCCESS, if peer details added to WSI link stats
872  */
873 QDF_STATUS wlan_mlo_peer_wsi_link_add(struct wlan_mlo_peer_context *ml_peer);
874 
875 /**
876  * wlan_mlo_peer_wsi_link_delete() - Delete peer to WSI info list
877  * @ml_peer: ML peer context
878  *
879  * API to Delete peer from WSI link stats
880  *
881  * Return: SUCCESS, if peer details deleted from WSI link stats
882  */
883 QDF_STATUS wlan_mlo_peer_wsi_link_delete(struct wlan_mlo_peer_context *ml_peer);
884 
885 /**
886  * wlan_mlo_ap_vdev_add_assoc_entry() - Add mlo ap vdev assoc entry
887  * @vdev: vdev object
888  * @mld_addr: MLD mac address
889  *
890  * API to add mlo ap vdev in assoc list
891  *
892  * Return: void
893  */
894 void wlan_mlo_ap_vdev_add_assoc_entry(struct wlan_objmgr_vdev *vdev,
895 				      struct qdf_mac_addr *mld_addr);
896 
897 /**
898  * wlan_mlo_ap_vdev_del_assoc_entry() - Delete mlo ap vdev assoc entry
899  * @vdev: vdev object
900  * @mld_addr: MLD mac address
901  *
902  * API to delete mlo ap vdev in assoc list
903  *
904  * Return: void
905  */
906 void wlan_mlo_ap_vdev_del_assoc_entry(struct wlan_objmgr_vdev *vdev,
907 				      struct qdf_mac_addr *mld_addr);
908 
909 /**
910  * wlan_mlo_ap_vdev_find_assoc_entry() - Find mlo ap vdev assoc entry
911  * @vdev: vdev object
912  * @mld_addr: MLD mac address
913  *
914  * API to find mlo ap vdev in assoc list
915  *
916  * Return: sta entry
917  */
918 struct wlan_mlo_sta_entry *
919 wlan_mlo_ap_vdev_find_assoc_entry(struct wlan_objmgr_vdev *vdev,
920 				  struct qdf_mac_addr *mld_addr);
921 #endif
922