xref: /wlan-driver/qcacld-3.0/core/mac/src/pe/lim/lim_assoc_utils.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  * This file lim_assoc_utils.h contains the utility definitions
22  * LIM uses while processing Re/Association messages.
23  * Author:        Chandra Modumudi
24  * Date:          02/13/02
25  * History:-
26  * Date           Modified by    Modification Information
27  * --------------------------------------------------------------------
28  * 05/26/10       js             WPA handling in (Re)Assoc frames
29  *
30  */
31 #ifndef __LIM_ASSOC_UTILS_H
32 #define __LIM_ASSOC_UTILS_H
33 
34 #include "sir_api.h"
35 #include "sir_debug.h"
36 
37 #include "lim_types.h"
38 #include "wlan_cm_api.h"
39 
40 #define SIZE_OF_NOA_DESCRIPTOR 13
41 #define MAX_NOA_PERIOD_IN_MICROSECS 3000000
42 
43 uint8_t lim_compare_capabilities(struct mac_context *,
44 				 tSirAssocReq *,
45 				 tSirMacCapabilityInfo *, struct pe_session *);
46 uint8_t lim_check_rx_basic_rates(struct mac_context *, tSirMacRateSet, struct pe_session *);
47 uint8_t lim_check_mcs_set(struct mac_context *mac, uint8_t *supportedMCSSet);
48 
49 /**
50  * lim_cleanup_rx_path() - Called to cleanup STA state at SP & RFP.
51  * @mac: Pointer to Global MAC structure
52  * @sta: Pointer to the per STA data structure initialized by LIM
53  *	 and maintained at DPH
54  * @pe_session: pointer to pe session
55  * @delete_peer: is peer delete allowed
56  *
57  * To circumvent RFP's handling of dummy packet when it does not
58  * have an incomplete packet for the STA to be deleted, a packet
59  * with 'more framgents' bit set will be queued to RFP's WQ before
60  * queuing 'dummy packet'.
61  * A 'dummy' BD is pushed into RFP's WQ with type=00, subtype=1010
62  * (Disassociation frame) and routing flags in BD set to eCPU's
63  * Low Priority WQ.
64  * RFP cleans up its local context for the STA id mentioned in the
65  * BD and then pushes BD to eCPU's low priority WQ.
66  *
67  * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
68  */
69 QDF_STATUS lim_cleanup_rx_path(struct mac_context *, tpDphHashNode,
70 			       struct pe_session *, bool delete_peer);
71 
72 void lim_reject_association(struct mac_context *, tSirMacAddr, uint8_t,
73 			    uint8_t, tAniAuthType, uint16_t, uint8_t,
74 			    enum wlan_status_code, struct pe_session *);
75 
76 QDF_STATUS lim_populate_peer_rate_set(struct mac_context *mac,
77 				      struct supported_rates *pRates,
78 				      uint8_t *pSupportedMCSSet,
79 				      uint8_t basicOnly,
80 				      struct pe_session *pe_session,
81 				      tDot11fIEVHTCaps *pVHTCaps,
82 				      tDot11fIEhe_cap *he_caps,
83 				      tDot11fIEeht_cap *eht_caps,
84 				      struct sDphHashNode *sta_ds,
85 				      struct bss_description *bss_desc);
86 
87 /**
88  * lim_populate_own_rate_set() - comprises the basic and extended rates read
89  *                                from CFG
90  * @mac_ctx: pointer to global mac structure
91  * @rates: pointer to supported rates
92  * @supported_mcs_set: pointer to supported mcs rates
93  * @basic_only: update only basic rates if set true
94  * @session_entry: pe session entry
95  * @vht_caps: pointer to vht capability
96  * @he_caps: pointer to HE capability
97  * @eht_caps: pointer to EHT capability
98  *
99  * This function is called by limProcessAssocRsp() or
100  * lim_add_staInIBSS()
101  * - It creates a combined rate set of 12 rates max which
102  *   comprises the basic and extended rates read from CFG
103  * - It sorts the combined rate Set and copy it in the
104  *   rate array of the pSTA descriptor
105  * - It sets the erpEnabled bit of the STA descriptor
106  * ERP bit is set iff the dph PHY mode is 11G and there is at least
107  * an A rate in the supported or extended rate sets
108  *
109  * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE.
110  */
111 QDF_STATUS lim_populate_own_rate_set(struct mac_context *mac_ctx,
112 				     struct supported_rates *rates,
113 				     uint8_t *supported_mcs_set,
114 				     uint8_t basic_only,
115 				     struct pe_session *session_entry,
116 				     struct sDot11fIEVHTCaps *vht_caps,
117 				     struct sDot11fIEhe_cap *he_caps,
118 				     struct sDot11fIEeht_cap *eht_caps);
119 
120 QDF_STATUS lim_populate_matching_rate_set(struct mac_context *mac_ctx,
121 					  tpDphHashNode sta_ds,
122 					  tSirMacRateSet *oper_rate_set,
123 					  tSirMacRateSet *ext_rate_set,
124 					  uint8_t *supported_mcs_set,
125 					  struct pe_session *session_entry,
126 					  tDot11fIEVHTCaps *vht_caps,
127 					  tDot11fIEhe_cap *he_caps,
128 					  tDot11fIEeht_cap *eht_caps);
129 
130 QDF_STATUS lim_add_sta(struct mac_context *, tpDphHashNode, uint8_t, struct pe_session *);
131 QDF_STATUS lim_del_bss(struct mac_context *, tpDphHashNode, uint16_t, struct pe_session *);
132 QDF_STATUS lim_del_sta(struct mac_context *, tpDphHashNode, bool, struct pe_session *);
133 QDF_STATUS lim_add_sta_self(struct mac_context *, uint8_t, struct pe_session *);
134 
135 /**
136  *lim_del_peer_info() - remove all peer information from host driver and fw
137  * @mac:    Pointer to Global MAC structure
138  * @pe_session: Pointer to PE Session entry
139  *
140  * @Return: QDF_STATUS
141  */
142 QDF_STATUS lim_del_peer_info(struct mac_context *mac,
143 			     struct pe_session *pe_session);
144 
145 /**
146  * lim_del_sta_all() - Cleanup all peers associated with VDEV
147  * @mac:    Pointer to Global MAC structure
148  * @pe_session: Pointer to PE Session entry
149  *
150  * @Return: QDF Status of operation.
151  */
152 QDF_STATUS lim_del_sta_all(struct mac_context *mac,
153 			   struct pe_session *pe_session);
154 
155 #ifdef WLAN_FEATURE_HOST_ROAM
156 void lim_restore_pre_reassoc_state(struct mac_context *,
157 				   tSirResultCodes, uint16_t, struct pe_session *);
158 void lim_post_reassoc_failure(struct mac_context *,
159 			      tSirResultCodes, uint16_t, struct pe_session *);
160 bool lim_is_reassoc_in_progress(struct mac_context *, struct pe_session *);
161 
162 void lim_handle_add_bss_in_re_assoc_context(struct mac_context *mac,
163 		tpDphHashNode sta, struct pe_session *pe_session);
164 void lim_handle_del_bss_in_re_assoc_context(struct mac_context *mac,
165 		   tpDphHashNode sta, struct pe_session *pe_session);
166 void lim_send_retry_reassoc_req_frame(struct mac_context *mac,
167 	      tLimMlmReassocReq *pMlmReassocReq, struct pe_session *pe_session);
168 QDF_STATUS lim_add_ft_sta_self(struct mac_context *mac, uint16_t assocId,
169 				  struct pe_session *pe_session);
170 #else
lim_restore_pre_reassoc_state(struct mac_context * mac_ctx,tSirResultCodes res_code,uint16_t prot_status,struct pe_session * pe_session)171 static inline void lim_restore_pre_reassoc_state(struct mac_context *mac_ctx,
172 			tSirResultCodes res_code, uint16_t prot_status,
173 			struct pe_session *pe_session)
174 {}
lim_post_reassoc_failure(struct mac_context * mac_ctx,tSirResultCodes res_code,uint16_t prot_status,struct pe_session * pe_session)175 static inline void lim_post_reassoc_failure(struct mac_context *mac_ctx,
176 			      tSirResultCodes res_code, uint16_t prot_status,
177 			      struct pe_session *pe_session)
178 {}
lim_handle_add_bss_in_re_assoc_context(struct mac_context * mac,tpDphHashNode sta,struct pe_session * pe_session)179 static inline void lim_handle_add_bss_in_re_assoc_context(struct mac_context *mac,
180 		tpDphHashNode sta, struct pe_session *pe_session)
181 {}
lim_handle_del_bss_in_re_assoc_context(struct mac_context * mac,tpDphHashNode sta,struct pe_session * pe_session)182 static inline void lim_handle_del_bss_in_re_assoc_context(struct mac_context *mac,
183 		   tpDphHashNode sta, struct pe_session *pe_session)
184 {}
lim_send_retry_reassoc_req_frame(struct mac_context * mac,tLimMlmReassocReq * pMlmReassocReq,struct pe_session * pe_session)185 static inline void lim_send_retry_reassoc_req_frame(struct mac_context *mac,
186 	      tLimMlmReassocReq *pMlmReassocReq, struct pe_session *pe_session)
187 {}
lim_is_reassoc_in_progress(struct mac_context * mac_ctx,struct pe_session * pe_session)188 static inline bool lim_is_reassoc_in_progress(struct mac_context *mac_ctx,
189 		struct pe_session *pe_session)
190 {
191 	return false;
192 }
lim_add_ft_sta_self(struct mac_context * mac,uint16_t assocId,struct pe_session * pe_session)193 static inline QDF_STATUS lim_add_ft_sta_self(struct mac_context *mac,
194 		uint16_t assocId, struct pe_session *pe_session)
195 {
196 	return QDF_STATUS_SUCCESS;
197 }
198 #endif
199 
200 #ifdef WLAN_FEATURE_11BE
201 static inline bool
lim_is_add_sta_params_eht_capable(tpAddStaParams add_sta_params)202 lim_is_add_sta_params_eht_capable(tpAddStaParams add_sta_params)
203 {
204 	return add_sta_params->eht_capable;
205 }
206 #else
207 static inline bool
lim_is_add_sta_params_eht_capable(tpAddStaParams add_sta_params)208 lim_is_add_sta_params_eht_capable(tpAddStaParams add_sta_params)
209 {
210 	return false;
211 }
212 #endif
213 
214 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
lim_is_roam_synch_in_progress(struct wlan_objmgr_psoc * psoc,struct pe_session * pe_session)215 static inline bool lim_is_roam_synch_in_progress(struct wlan_objmgr_psoc *psoc,
216 						 struct pe_session *pe_session)
217 {
218 	return wlan_cm_is_vdev_roam_sync_inprogress(pe_session->vdev);
219 }
220 #else
lim_is_roam_synch_in_progress(struct wlan_objmgr_psoc * psoc,struct pe_session * pe_session)221 static inline bool lim_is_roam_synch_in_progress(struct wlan_objmgr_psoc *psoc,
222 						 struct pe_session *pe_session)
223 {
224 	return false;
225 }
226 #endif
227 
228 void
229 lim_send_del_sta_cnf(struct mac_context *mac, struct qdf_mac_addr sta_dsaddr,
230 		     uint16_t staDsAssocId,
231 		     struct lim_sta_context mlmStaContext,
232 		     tSirResultCodes status_code,
233 		     struct pe_session *pe_session);
234 
235 void lim_handle_cnf_wait_timeout(struct mac_context *mac, uint16_t staId);
236 void lim_delete_dph_hash_entry(struct mac_context *, tSirMacAddr, uint16_t, struct pe_session *);
237 void lim_check_and_announce_join_success(struct mac_context *,
238 					 tSirProbeRespBeacon *,
239 					 tpSirMacMgmtHdr, struct pe_session *);
240 void lim_update_re_assoc_globals(struct mac_context *mac,
241 				 tpSirAssocRsp pAssocRsp,
242 				 struct pe_session *pe_session);
243 
244 void lim_update_assoc_sta_datas(struct mac_context *mac,
245 				tpDphHashNode sta, tpSirAssocRsp pAssocRsp,
246 				struct pe_session *pe_session,
247 				tSchBeaconStruct *beacon);
248 
249 /**
250  * lim_sta_add_bss_update_ht_parameter() - function to update ht related
251  *                                         parameters when add bss request
252  * @bss_chan_freq: operating frequency of bss
253  * @ht_cap: ht capability extract from beacon/assoc response
254  * @ht_inf: ht information extract from beacon/assoc response
255  * @chan_width_support: local wide bandwidth support capability
256  * @add_bss: add bss request struct to be updated
257  *
258  * Return: none
259  */
260 void lim_sta_add_bss_update_ht_parameter(uint32_t bss_chan_freq,
261 					 tDot11fIEHTCaps* ht_cap,
262 					 tDot11fIEHTInfo* ht_inf,
263 					 bool chan_width_support,
264 					 struct bss_params *add_bss);
265 
266 /**
267  * lim_sta_send_add_bss() - add bss and send peer assoc after receive assoc
268  * rsp in sta mode
269  *.@mac: pointer to Global MAC structure
270  * @pAssocRsp: contains the structured assoc/reassoc Response got from AP
271  * @beaconstruct: the ProbeRsp/Beacon structured details
272  * @bssDescription: bss description passed to PE from the SME
273  * @updateEntry: bool flag of whether update bss and sta
274  * @pe_session: pointer to pe session
275  *
276  * Return: none
277  */
278 QDF_STATUS lim_sta_send_add_bss(struct mac_context *mac,
279 				tpSirAssocRsp pAssocRsp,
280 				tpSchBeaconStruct pBeaconStruct,
281 				struct bss_description *bssDescription,
282 				uint8_t updateEntry,
283 				struct pe_session *pe_session);
284 
285 /**
286  * lim_sta_send_add_bss_pre_assoc() - add bss after channel switch and before
287  * associate req in sta mode
288  *.@mac: pointer to Global MAC structure
289  * @pe_session: pointer to pe session
290  *
291  * Return: none
292  */
293 QDF_STATUS lim_sta_send_add_bss_pre_assoc(struct mac_context *mac,
294 					  struct pe_session *pe_session);
295 
296 void lim_prepare_and_send_del_all_sta_cnf(struct mac_context *mac,
297 					  tSirResultCodes status_code,
298 					  struct pe_session *pe_session);
299 
300 void lim_prepare_and_send_del_sta_cnf(struct mac_context *mac,
301 				      tpDphHashNode sta,
302 				      tSirResultCodes status_code,
303 				      struct pe_session *pe_session);
304 
305 QDF_STATUS lim_extract_ap_capabilities(struct mac_context *mac, uint8_t *pIE,
306 					  uint16_t ieLen,
307 					  tpSirProbeRespBeacon beaconStruct);
308 void lim_init_pre_auth_timer_table(struct mac_context *mac,
309 				   tpLimPreAuthTable pPreAuthTimerTable);
310 tpLimPreAuthNode lim_acquire_free_pre_auth_node(struct mac_context *mac,
311 						tpLimPreAuthTable
312 						pPreAuthTimerTable);
313 tpLimPreAuthNode lim_get_pre_auth_node_from_index(struct mac_context *mac,
314 						  tpLimPreAuthTable pAuthTable,
315 						  uint32_t authNodeIdx);
316 
317 /* Util API to check if the channels supported by STA is within range */
318 QDF_STATUS lim_is_dot11h_supported_channels_valid(struct mac_context *mac,
319 						     tSirAssocReq *assoc);
320 
321 /* Util API to check if the txpower supported by STA is within range */
322 QDF_STATUS lim_is_dot11h_power_capabilities_in_range(struct mac_context *mac,
323 							tSirAssocReq *assoc,
324 							struct pe_session *);
325 /**
326  * lim_fill_rx_highest_supported_rate() - Fill highest rx rate
327  * @mac: Global MAC context
328  * @rxHighestRate: location to store the highest rate
329  * @pSupportedMCSSet: location of the 'supported MCS set' field in HT
330  *                    capability element
331  *
332  * Fills in the Rx Highest Supported Data Rate field from
333  * the 'supported MCS set' field in HT capability element.
334  *
335  * Return: void
336  */
337 void lim_fill_rx_highest_supported_rate(struct mac_context *mac,
338 					uint16_t *rxHighestRate,
339 					uint8_t *pSupportedMCSSet);
340 void lim_send_sme_unprotected_mgmt_frame_ind(struct mac_context *mac, uint8_t frameType,
341 					     uint8_t *frame, uint32_t frameLen,
342 					     uint16_t sessionId,
343 					     struct pe_session *pe_session);
344 /**
345  * lim_send_sme_tsm_ie_ind() - Send TSM IE information to SME
346  * @mac: Global MAC context
347  * @pe_session: PE session context
348  * @tid: traffic id
349  * @state: tsm state (enabled/disabled)
350  * @measurement_interval: measurement interval
351  *
352  * Return: void
353  */
354 #ifdef FEATURE_WLAN_ESE
355 void lim_send_sme_tsm_ie_ind(struct mac_context *mac,
356 			     struct pe_session *pe_session,
357 			     uint8_t tid, uint8_t state,
358 			     uint16_t measurement_interval);
359 #else
360 static inline
lim_send_sme_tsm_ie_ind(struct mac_context * mac,struct pe_session * pe_session,uint8_t tid,uint8_t state,uint16_t measurement_interval)361 void lim_send_sme_tsm_ie_ind(struct mac_context *mac,
362 			     struct pe_session *pe_session,
363 			     uint8_t tid, uint8_t state,
364 			     uint16_t measurement_interval)
365 {}
366 #endif /* FEATURE_WLAN_ESE */
367 
368 /**
369  * lim_populate_vht_mcs_set - function to populate vht mcs rate set
370  * @mac_ctx: pointer to global mac structure
371  * @rates: pointer to supported rate set
372  * @peer_vht_caps: pointer to peer vht capabilities
373  * @session_entry: pe session entry
374  * @nss: number of spatial streams
375  * @sta_ds: pointer to peer sta data structure
376  *
377  * Populates vht mcs rate set based on peer and self capabilities
378  *
379  * Return: QDF_STATUS_SUCCESS on success else QDF_STATUS_E_FAILURE
380  */
381 QDF_STATUS lim_populate_vht_mcs_set(struct mac_context *mac_ctx,
382 				    struct supported_rates *rates,
383 				    tDot11fIEVHTCaps *peer_vht_caps,
384 				    struct pe_session *session_entry,
385 				    uint8_t nss,
386 				    struct sDphHashNode *sta_ds);
387 
388 /**
389  * lim_extract_ies_from_deauth_disassoc() - Extract IEs from deauth/disassoc
390  *
391  * @session: PE session entry
392  * @deauth_disassoc_frame: A pointer to the deauth/disconnect frame buffer
393  *			   received from WMA.
394  * @deauth_disassoc_frame_leni: Length of the deauth/disconnect frame.
395  *
396  * This function receives deauth/disassoc frame from header. It extracts
397  * the IEs(tagged params) from the frame and caches in vdev object.
398  *
399  * Return: None
400  */
401 void
402 lim_extract_ies_from_deauth_disassoc(struct pe_session *session,
403 				     uint8_t *deauth_disassoc_frame,
404 				     uint16_t deauth_disassoc_frame_len);
405 
406 /**
407  * lim_update_vhtcaps_assoc_resp : Update VHT caps in assoc response.
408  * @mac_ctx Pointer to Global MAC structure
409  * @pAddBssParams: parameters required for add bss params.
410  * @vht_caps: VHT capabilities.
411  * @pe_session : session entry.
412  *
413  * Return : void
414  */
415 void lim_update_vhtcaps_assoc_resp(struct mac_context *mac_ctx,
416 				   struct bss_params *pAddBssParams,
417 				   tDot11fIEVHTCaps *vht_caps,
418 				   struct pe_session *pe_session);
419 
420 /**
421  * lim_free_assoc_req_frm_buf() - free assoc request frame buffer
422  * @assoc_req: pointer to tpSirAssocReq
423  *
424  * Return : void
425  */
426 void lim_free_assoc_req_frm_buf(tpSirAssocReq assoc_req);
427 
428 /**
429  * lim_alloc_assoc_req_frm_buf() - allocate assoc request frame buffer
430  * @assoc_req: pointer to tpSirAssocReq
431  * @buf: pointer to assoc request frame
432  * @mac_header_len: ieee80211 header length
433  * @frame_len: payload length of assoc request frame
434  */
435 bool lim_alloc_assoc_req_frm_buf(tpSirAssocReq assoc_req,
436 				 qdf_nbuf_t buf, uint32_t mac_header_len,
437 				 uint32_t frame_len);
438 #endif /* __LIM_ASSOC_UTILS_H */
439