1  /*
2   * Copyright (c) 2021, The Linux Foundation. All rights reserved.
3   * Copyright (c) 2022-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 : lim_mlo.h
20   *
21   * WLAN Host Device Driver file for 802.11be (Extremely High Throughput)
22   * support.
23   *
24   */
25  
26  #if !defined(LIM_MLO_H)
27  #define LIM_MLO_H
28  
29  #include "ani_global.h"
30  #include "lim_session.h"
31  #include <wlan_mlo_mgr_public_structs.h>
32  
33  #ifdef WLAN_FEATURE_11BE_MLO
34  
35  /**
36   * lim_update_partner_link_info - Update partner link information
37   *
38   * This function is triggered from mlo mgr
39   *
40   * @vdev: vdev pointer
41   *
42   * Return: QDF_STATUS_SUCCESS on successful update link info else failure.
43   */
44  QDF_STATUS lim_partner_link_info_change(struct wlan_objmgr_vdev *vdev);
45  
46  /**
47   * lim_mlo_free_vdev_ref() - release vdev reference
48   * @vdev: vdev obj
49   *
50   * Return: void
51   */
52  void lim_mlo_release_vdev_ref(struct wlan_objmgr_vdev *vdev);
53  
54  /**
55   * pe_find_partner_session_by_link_id() - Get partner session by link id
56   * @session: pe session
57   * @link_id: link id
58   *
59   * Return: partner session
60   */
61  struct pe_session *pe_find_partner_session_by_link_id(
62  		struct pe_session *session, uint8_t link_id);
63  
64  /**
65   * lim_get_mlo_vdev_list() - Get mlo vdev list
66   * @session: pe session
67   * @vdev_count: vdev count
68   * @wlan_vdev_list: vdev list
69   *
70   * Return: void
71   */
72  void lim_get_mlo_vdev_list(struct pe_session *session, uint16_t *vdev_count,
73  			   struct wlan_objmgr_vdev **wlan_vdev_list);
74  
75  /**
76   * lim_mlo_roam_peer_disconn_del - trigger mlo to delete partner peer
77   *                                 This API is only for MLO STA roam.
78   * @vdev: vdev pointer
79   *
80   * Return: void
81   */
82  void lim_mlo_roam_peer_disconn_del(struct wlan_objmgr_vdev *vdev);
83  
84  /**
85   * lim_mlo_notify_peer_disconn - trigger mlo to delete partner peer
86   * @pe_session: pe session
87   * @sta_ds: Pointer to internal STA Datastructure
88   *
89   * Return: void
90   */
91  void lim_mlo_notify_peer_disconn(struct pe_session *pe_session,
92  				 tpDphHashNode sta_ds);
93  
94  /**
95   * lim_mlo_sta_notify_peer_disconn - trigger mlo to delete partner peer
96   *                                   This API is only for MLO STA.
97   * @pe_session: pe session
98   *
99   * Return: void
100   */
101  void lim_mlo_sta_notify_peer_disconn(struct pe_session *pe_session);
102  
103  /**
104   * lim_mlo_cleanup_partner_peer() - cleanup given peer which is partner peer
105   *                                  of mlo connection.
106   *
107   * This function is triggered from mlo mgr.
108   *
109   * @peer: pointer to peer to be cleanup
110   *
111   * Return: void
112   */
113  void lim_mlo_cleanup_partner_peer(struct wlan_objmgr_peer *peer);
114  
115  /**
116   * lim_mlo_set_mld_mac_peer() - set mld mac
117   * @sta_ds: Pointer to internal STA Datastructure
118   * @peer_mld_addr: peer mld mac addr
119   *
120   * Return: void
121   */
122  void lim_mlo_set_mld_mac_peer(tpDphHashNode sta_ds,
123  			      uint8_t peer_mld_addr[QDF_MAC_ADDR_SIZE]);
124  
125  /**
126   * lim_is_mlo_conn() - whether it is mlo connection
127   * @session: pe session
128   * @sta_ds: Pointer to internal STA Datastructure
129   *
130   * Return: true if it is mlo connection
131   */
132  bool lim_is_mlo_conn(struct pe_session *session, tpDphHashNode sta_ds);
133  
134  /**
135   * lim_is_mlo_recv_assoc() - whether it received assoc frame or not
136   * @sta_ds: Pointer to internal STA Datastructure
137   *
138   * Return: true if this peer corresponding link received assoc frame
139   */
140  bool lim_is_mlo_recv_assoc(tpDphHashNode sta_ds);
141  
142  /**
143   * lim_set_mlo_recv_assoc() - set received assoc frame flag
144   * @sta_ds: Pointer to internal STA Datastructure
145   * @mlo_recv_assoc_frm: true if it received assoc frame
146   *
147   * Return: void
148   */
149  void lim_set_mlo_recv_assoc(tpDphHashNode sta_ds, bool mlo_recv_assoc_frm);
150  
151  /**
152   * lim_mlo_proc_assoc_req_frm() - process assoc frame for mlo partner link
153   *
154   * This function is triggered by mlo mgr
155   *
156   * @vdev: pointer to vdev
157   * @ml_peer: pointer to ml_peer
158   * @link_addr: link addr
159   * @frm_buf: assoc req buffer
160   *
161   * This function is called from mlo mgr.
162   *
163   * Return: QDF_STATUS
164   */
165  QDF_STATUS lim_mlo_proc_assoc_req_frm(struct wlan_objmgr_vdev *vdev,
166  				      struct wlan_mlo_peer_context *ml_peer,
167  				      struct qdf_mac_addr *link_addr,
168  				      qdf_nbuf_t buf);
169  
170  /**
171   * lim_mlo_ap_sta_assoc_suc() - process add sta rsp for mlo connection
172   * @peer: pointer to peer to handle add sta response
173   *
174   * This function is triggered from mlo mgr.
175   *
176   * Return: void
177   */
178  void lim_mlo_ap_sta_assoc_suc(struct wlan_objmgr_peer *peer);
179  
180  /**
181   * lim_ap_mlo_sta_peer_ind() - Indicate mlo mgr after receiving sta rsp
182   *
183   * @mac: pointer to mac_context
184   * @pe_session: pe session
185   * @sta_ds: Pointer to internal STA Datastructure
186   * @add_sta_rsp_status: add sta rsp status
187   *
188   * Return: void
189   */
190  void lim_ap_mlo_sta_peer_ind(struct mac_context *mac,
191  			     struct pe_session *pe_session,
192  			     tpDphHashNode sta,
193  			     bool add_sta_rsp_status);
194  
195  /**
196   * lim_mlo_partner_auth_type: update auth type from partner
197   * @session: pe session
198   * @partner_peer_idx: aid
199   * @auth_type: auth type to update
200   *
201   * Return: true if auth type is gotten successfully
202   */
203  bool lim_mlo_partner_auth_type(struct pe_session *session,
204  			       uint16_t partner_peer_idx,
205  			       tAniAuthType *auth_type);
206  
207  /**
208   * lim_mlo_ap_sta_assoc_fail() - process add sta rsp fail for mlo connection
209   * @peer: pointer to peer to handle add sta response
210   *
211   * This function is triggered from mlo mgr.
212   *
213   * Return: void
214   */
215  void lim_mlo_ap_sta_assoc_fail(struct wlan_objmgr_peer *peer);
216  
217  /**
218   * lim_mlo_delete_link_peer() - notify mlo mgr peer obj is deleted
219   * @pe_session: pe session
220   * @sta_ds: Pointer to internal STA Datastructure
221   *
222   * Return: void
223   */
224  void lim_mlo_delete_link_peer(struct pe_session *pe_session,
225  			      tpDphHashNode sta_ds);
226  
227  /**
228   * lim_mlo_assoc_ind_upper_layer() - indicate assoc confirm to upper layer
229   *                                   for mlo partner link
230   * @mac: pointer to mac_context
231   * @pe_session: pe session
232   * @mlo_info: mlo partner information
233   *
234   * Return: QDF_STATUS
235   */
236  QDF_STATUS lim_mlo_assoc_ind_upper_layer(struct mac_context *mac,
237  					 struct pe_session *pe_session,
238  					 struct mlo_partner_info *mlo_info);
239  void lim_mlo_save_mlo_info(tpDphHashNode sta_ds,
240  			   struct mlo_partner_info *mlo_info);
241  
242  /**
243   * lim_add_frag_ie_for_sta_profile() - add frag IE if STA prof len more than 255
244   * @data: sta profile ie data
245   * @len: the length of the data
246   *
247   * Return: QDF_STATUS
248   */
249  QDF_STATUS lim_add_frag_ie_for_sta_profile(uint8_t *data, uint16_t *len);
250  
251  /**
252   * lim_fill_complete_mlo_ie() - fill mlo ie to target buffer
253   * @session: pointer to pe_session
254   * @total_len: the total bytes to fill target buffer
255   * @target: the buffer to fill data
256   *
257   * It also will insert the frag IE WLAN_ELEMID_FRAGMENT if the ML IE's length
258   * more than 255 bytes.
259   *
260   * Return: QDF_STATUS
261   */
262  QDF_STATUS lim_fill_complete_mlo_ie(struct pe_session *session,
263  				    uint16_t total_len, uint8_t *target);
264  
265  /**
266   * lim_caculate_mlo_ie_length() - calculate the ML IE length
267   * @mlo_ie: the pointer to wlan_mlo_ie
268   *
269   * It tries to add the len of frag IE WLAN_ELEMID_FRAGMENT if the ML IE
270   * length more than 255 bytes.
271   *
272   * Return: QDF_STATUS
273   */
274  uint16_t lim_caculate_mlo_ie_length(struct wlan_mlo_ie *mlo_ie);
275  
276  /**
277   * lim_fill_assoc_req_mlo_ie() - Prepare ML IE for assoc req frame
278   * @mac_ctx: pointer to mac_context
279   * @session: pointer to pe_session
280   * @frm: pointer to tDot11fAssocRequest
281   *
282   * Return: the actual ML IE length
283   */
284  uint16_t
285  lim_fill_assoc_req_mlo_ie(struct mac_context *mac_ctx,
286  			  struct pe_session *session,
287  			  tDot11fAssocRequest *frm);
288  
289  /**
290   * lim_send_assoc_rsq_mgmt_frame_mlo() - Prepare ML IE for assoc rsq frame
291   * @mac_ctx: pointer to mac_context
292   * @session: pointer to pe_session
293   * @sta: pointer to tpDphHashNode
294   * @frm: pointer to tDot11fAssocRequest
295   *
296   * Return: the actual ML IE length
297   */
298  uint16_t
299  lim_send_assoc_rsp_mgmt_frame_mlo(struct mac_context *mac_ctx,
300  				  struct pe_session *session,
301  				  tpDphHashNode sta,
302  				  tDot11fAssocResponse *frm);
303  
304  /**
305   * lim_send_bcn_frame_mlo() - Prepare ML IE for beacon frame
306   * @mac_ctx: pointer to mac_context
307   * @session: pointer to pe_session
308   *
309   * Return: the actual ML IE length
310   */
311  uint16_t
312  lim_send_bcn_frame_mlo(struct mac_context *mac_ctx, struct pe_session *session);
313  
314  /**
315   * lim_send_probe_req_frame_mlo() - Prepare ML IE for probe req frame
316   * @mac_ctx: pointer to mac_context
317   * @session: pointer to pe_session
318   *
319   * Return: the actual ML IE length
320   */
321  uint16_t
322  lim_send_probe_req_frame_mlo(struct mac_context *mac_ctx,
323  			     struct pe_session *session);
324  
325  /**
326   * lim_send_tdls_mgmt_frame_mlo() - Prepare ML IE for tdls mgmt frame
327   * @mac_ctx: pointer to mac_context
328   * @session: pointer to pe_session
329   *
330   * Return: the actual ML IE length
331   */
332  uint16_t lim_send_tdls_mgmt_frame_mlo(struct mac_context *mac_ctx,
333  				      struct pe_session *session);
334  
335  /**
336   * lim_get_frame_mlo_ie_len() - get ML IE length
337   * @session: pointer to pe_session
338   *
339   * Return: the actual ML IE length
340   */
341  uint16_t lim_get_frame_mlo_ie_len(struct pe_session *session);
342  
343  /**
344   * lim_store_mlo_ie_raw_info() - store the ML IE raw info
345   * @ie: pointer the ML IE
346   * @sta_prof_ie: pointer to the first per STA prof
347   * @total_len: the length of ML IE
348   * @mlo_ie: the pointer to wlan_mlo_ie
349   *
350   * Return: QDF_STATUS
351   */
352  QDF_STATUS lim_store_mlo_ie_raw_info(uint8_t *ie, uint8_t *sta_prof_ie,
353  				     uint32_t total_len,
354  				     struct wlan_mlo_ie *mlo_ie);
355  
356  /**
357   * lim_is_ml_peer_state_disconn() - Check if ML peer state is
358   * ML_PEER_DISCONN_INITIATED
359   * @mac_ctx: pointer to mac_context
360   * @session: pointer to pe_session
361   * @mac_addr: peer mac address
362   *
363   * Return: True if state is ML_PEER_DISCONN_INITIATED, else False
364   */
365  bool lim_is_ml_peer_state_disconn(struct mac_context *mac_ctx,
366  				  struct pe_session *session,
367  				  uint8_t *mac_addr);
368  
369  bool lim_is_emlsr_band_supported(struct pe_session *session);
370  
371  /**
372   * lim_cu_info_from_rnr_per_link_id() - get the cu info from rnr per link id
373   * @rnr: rnr element
374   * @linkid: link id
375   * @bpcc: pointer to save BSS parameters change count
376   * @aui: pointer to save all updates included flag
377   *
378   * Return: QDF_STATUS
379   */
380  QDF_STATUS lim_cu_info_from_rnr_per_link_id(const uint8_t *rnr,
381  					    uint8_t linkid, uint8_t *bpcc,
382  					    uint8_t *aui);
383  
384  /**
385   * lim_get_bpcc_from_mlo_ie() - get the bpcc from mlo_ie info
386   * @bcn: the pointer to tSchBeaconStruct
387   * @bpcc: pbcc pointer to save the fetched value
388   *
389   * Return: QDF_STATUS
390   */
391  QDF_STATUS lim_get_bpcc_from_mlo_ie(tSchBeaconStruct *bcn,
392  				    uint8_t *bpcc);
393  
394  /**
395   * lim_check_cu_happens() - check whether cu happens
396   * @vdev: vdev object
397   * @new_bpcc: the new bpcc
398   *
399   * Return: bool
400   */
401  bool lim_check_cu_happens(struct wlan_objmgr_vdev *vdev, uint8_t new_bpcc);
402  #else
lim_mlo_roam_peer_disconn_del(struct wlan_objmgr_vdev * vdev)403  static inline void lim_mlo_roam_peer_disconn_del(struct wlan_objmgr_vdev *vdev)
404  {
405  }
lim_mlo_notify_peer_disconn(struct pe_session * pe_session,tpDphHashNode sta_ds)406  static inline void lim_mlo_notify_peer_disconn(struct pe_session *pe_session,
407  					       tpDphHashNode sta_ds)
408  {
409  }
410  
lim_mlo_sta_notify_peer_disconn(struct pe_session * pe_session)411  static inline void lim_mlo_sta_notify_peer_disconn(
412  						struct pe_session *pe_session)
413  {
414  }
415  
lim_mlo_set_mld_mac_peer(tpDphHashNode sta_ds,uint8_t peer_mld_addr[QDF_MAC_ADDR_SIZE])416  static inline void lim_mlo_set_mld_mac_peer(
417  				tpDphHashNode sta_ds,
418  				uint8_t peer_mld_addr[QDF_MAC_ADDR_SIZE])
419  {
420  }
421  
lim_mlo_cleanup_partner_peer(struct vdev_mlme_obj * vdev_mlme,struct wlan_objmgr_peer * peer)422  static inline void lim_mlo_cleanup_partner_peer(struct vdev_mlme_obj *vdev_mlme,
423  						struct wlan_objmgr_peer *peer)
424  {
425  }
426  
lim_is_mlo_conn(struct pe_session * session,tpDphHashNode sta_ds)427  static inline bool lim_is_mlo_conn(struct pe_session *session,
428  				   tpDphHashNode sta_ds)
429  {
430  	return false;
431  }
432  
lim_is_mlo_recv_assoc(tpDphHashNode sta_ds)433  static inline bool lim_is_mlo_recv_assoc(tpDphHashNode sta_ds)
434  {
435  	return false;
436  }
437  
lim_set_mlo_recv_assoc(tpDphHashNode sta_ds,bool mlo_recv_assoc_frm)438  static inline void lim_set_mlo_recv_assoc(tpDphHashNode sta_ds,
439  					  bool mlo_recv_assoc_frm)
440  {
441  }
442  
lim_mlo_partner_auth_type(struct pe_session * session,uint16_t partner_peer_idx,tAniAuthType * auth_type)443  static inline bool lim_mlo_partner_auth_type(struct pe_session *session,
444  					     uint16_t partner_peer_idx,
445  					     tAniAuthType *auth_type)
446  {
447  	return false;
448  }
449  
lim_ap_mlo_sta_peer_ind(struct mac_context * mac,struct pe_session * pe_session,tpDphHashNode sta,bool add_sta_rsp_status)450  static inline void lim_ap_mlo_sta_peer_ind(struct mac_context *mac,
451  					   struct pe_session *pe_session,
452  					   tpDphHashNode sta,
453  					   bool add_sta_rsp_status)
454  {
455  }
456  
lim_mlo_delete_link_peer(struct pe_session * pe_session,tpDphHashNode sta_ds)457  static inline void lim_mlo_delete_link_peer(struct pe_session *pe_session,
458  					    tpDphHashNode sta_ds)
459  {
460  }
461  
lim_mlo_assoc_ind_upper_layer(struct mac_context * mac,struct pe_session * pe_session,struct mlo_partner_info * mlo_info)462  static inline QDF_STATUS lim_mlo_assoc_ind_upper_layer(
463  					struct mac_context *mac,
464  					struct pe_session *pe_session,
465  					struct mlo_partner_info *mlo_info)
466  {
467  	return QDF_STATUS_SUCCESS;
468  }
469  
lim_mlo_save_mlo_info(tpDphHashNode sta_ds,struct mlo_partner_info * mlo_info)470  static inline void lim_mlo_save_mlo_info(tpDphHashNode sta_ds,
471  					 struct mlo_partner_info *mlo_info)
472  {
473  }
474  
475  static inline
lim_add_frag_ie_for_sta_profile(uint8_t * data,uint16_t * len)476  QDF_STATUS lim_add_frag_ie_for_sta_profile(uint8_t *data, uint16_t *len)
477  {
478  	return QDF_STATUS_SUCCESS;
479  }
480  
481  static inline
lim_fill_complete_mlo_ie(struct pe_session * session,uint16_t total_len,uint8_t * target)482  QDF_STATUS lim_fill_complete_mlo_ie(struct pe_session *session,
483  				    uint16_t total_len, uint8_t *target)
484  {
485  	return QDF_STATUS_SUCCESS;
486  }
487  
488  static inline uint16_t
lim_fill_assoc_req_mlo_ie(struct mac_context * mac_ctx,struct pe_session * session,tDot11fAssocRequest * frm)489  lim_fill_assoc_req_mlo_ie(struct mac_context *mac_ctx,
490  			  struct pe_session *session,
491  			  tDot11fAssocRequest *frm)
492  {
493  	return 0;
494  }
495  
496  static inline uint16_t
lim_send_assoc_rsp_mgmt_frame_mlo(struct mac_context * mac_ctx,struct pe_session * session,tpDphHashNode sta,tDot11fAssocResponse * frm)497  lim_send_assoc_rsp_mgmt_frame_mlo(struct mac_context *mac_ctx,
498  				  struct pe_session *session,
499  				  tpDphHashNode sta,
500  				  tDot11fAssocResponse *frm)
501  {
502  	return 0;
503  }
504  
505  static inline uint16_t
lim_send_probe_req_frame_mlo(struct mac_context * mac_ctx,struct pe_session * session)506  lim_send_probe_req_frame_mlo(struct mac_context *mac_ctx,
507  			     struct pe_session *session)
508  {
509  	return 0;
510  }
511  
512  static inline uint16_t
lim_send_bcn_frame_mlo(struct mac_context * mac_ctx,struct pe_session * session)513  lim_send_bcn_frame_mlo(struct mac_context *mac_ctx, struct pe_session *session)
514  {
515  	return 0;
516  }
517  
518  static inline uint16_t
lim_send_tdls_mgmt_frame_mlo(struct mac_context * mac_ctx,struct pe_session * session)519  lim_send_tdls_mgmt_frame_mlo(struct mac_context *mac_ctx,
520  			     struct pe_session *session)
521  {
522  	return 0;
523  }
524  
525  static inline
lim_get_frame_mlo_ie_len(struct pe_session * session)526  uint16_t lim_get_frame_mlo_ie_len(struct pe_session *session)
527  {
528  	return 0;
529  }
530  
531  static inline
lim_is_ml_peer_state_disconn(struct mac_context * mac_ctx,struct pe_session * session,uint8_t * mac_addr)532  bool lim_is_ml_peer_state_disconn(struct mac_context *mac_ctx,
533  				  struct pe_session *session,
534  				  uint8_t *mac_addr)
535  {
536  	return false;
537  }
538  
539  static inline
lim_is_emlsr_band_supported(struct pe_session * session)540  bool lim_is_emlsr_band_supported(struct pe_session *session)
541  {
542  	return false;
543  }
544  
545  static inline
lim_cu_info_from_rnr_per_link_id(const uint8_t * rnr,uint8_t linkid,uint8_t * bpcc,uint8_t * aui)546  QDF_STATUS lim_cu_info_from_rnr_per_link_id(const uint8_t *rnr, uint8_t linkid,
547  					    uint8_t *bpcc, uint8_t *aui)
548  {
549  	return QDF_STATUS_E_INVAL;
550  }
551  
552  static inline
lim_get_bpcc_from_mlo_ie(tSchBeaconStruct * bcn,uint8_t * bpcc)553  QDF_STATUS lim_get_bpcc_from_mlo_ie(tSchBeaconStruct *bcn,
554  				    uint8_t *bpcc)
555  {
556  	return QDF_STATUS_E_INVAL;
557  }
558  
559  static inline
lim_check_cu_happens(struct wlan_objmgr_vdev * vdev,uint8_t nbpcc)560  bool lim_check_cu_happens(struct wlan_objmgr_vdev *vdev, uint8_t nbpcc)
561  {
562  	return true;
563  }
564  #endif
565  #endif
566