1 /*
2 * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3 * Copyright (c) 2022-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 * DOC: csr_inside_api.h
22 *
23 * Define interface only used by CSR.
24 */
25 #ifndef CSR_INSIDE_API_H__
26 #define CSR_INSIDE_API_H__
27
28 #include "csr_support.h"
29 #include "sme_inside.h"
30 #include "cds_reg_service.h"
31 #include "wlan_objmgr_vdev_obj.h"
32
33 bool csr_is_supported_channel(struct mac_context *mac, uint32_t chan_freq);
34
35 enum csr_sap_response_type {
36 CSR_SAP_START_BSS_SUCCESS,
37 CSR_SAP_START_BSS_FAILURE,
38 CSR_SAP_STOP_BSS_SUCCESS,
39 CSR_SAP_STOP_BSS_FAILURE,
40 };
41
42 struct tag_csrscan_result {
43 tListElem Link;
44 /* Preferred Encryption type that matched with profile. */
45 eCsrEncryptionType ucEncryptionType;
46 eCsrEncryptionType mcEncryptionType;
47 /* Preferred auth type that matched with the profile. */
48 enum csr_akm_type authType;
49
50 tCsrScanResultInfo Result;
51 /*
52 * WARNING - Do not add any element here
53 * This member Result must be the last in the structure because the end
54 * of struct bss_description (inside) is an array with nonknown size at
55 * this time.
56 */
57 };
58
59 struct scan_result_list {
60 tDblLinkList List;
61 tListElem *pCurEntry;
62 };
63
64 #define CSR_IS_WAIT_FOR_KEY(mac, sessionId) \
65 (CSR_IS_ROAM_JOINED(mac, sessionId) && \
66 CSR_IS_ROAM_SUBSTATE_WAITFORKEY(mac, sessionId))
67
68 enum csr_roam_state csr_roam_state_change(struct mac_context *mac,
69 enum csr_roam_state NewRoamState,
70 uint8_t sessionId);
71 void csr_roaming_state_msg_processor(struct mac_context *mac, void *msg_buf);
72 void csr_roam_joined_state_msg_processor(struct mac_context *mac,
73 void *msg_buf);
74
75 void csr_release_command_roam(struct mac_context *mac, tSmeCmd *pCommand);
76 void csr_release_command_wm_status_change(struct mac_context *mac,
77 tSmeCmd *pCommand);
78 QDF_STATUS csr_scan_open(struct mac_context *mac);
79 QDF_STATUS csr_scan_close(struct mac_context *mac);
80
81 void csr_free_scan_result_entry(struct mac_context *mac, struct tag_csrscan_result
82 *pResult);
83
84 QDF_STATUS csr_roam_call_callback(struct mac_context *mac, uint32_t sessionId,
85 struct csr_roam_info *roam_info,
86 eRoamCmdStatus u1, eCsrRoamResult u2);
87 void csr_roam_complete(struct mac_context *mac, uint8_t session_id);
88
89 /**
90 * csr_issue_set_context_req_helper - Function to fill unicast/broadcast keys
91 * request to set the keys to fw
92 * @mac_ctx: Pointer to mac context
93 * @vdev_id: vdev id
94 * @bssid: Connected BSSID
95 * @addkey: Is add key request to crypto
96 * @unicast: Unicast(1) or broadcast key(0)
97 * @key_id: Key index
98 *
99 * Return: QDF_STATUS
100 */
101 QDF_STATUS
102 csr_issue_set_context_req_helper(struct mac_context *mac_ctx,
103 uint32_t vdev_id, tSirMacAddr *bssid,
104 bool addkey, bool unicast, uint8_t key_id);
105
106 void csr_roam_check_for_link_status_change(struct mac_context *mac,
107 tSirSmeRsp *pSirMsg);
108 QDF_STATUS csr_send_mb_disassoc_req_msg(struct mac_context *mac, uint32_t sessionId,
109 tSirMacAddr bssId, uint16_t reasonCode);
110 QDF_STATUS csr_send_mb_deauth_req_msg(struct mac_context *mac, uint32_t sessionId,
111 tSirMacAddr bssId, uint16_t reasonCode);
112 QDF_STATUS csr_send_mb_disassoc_cnf_msg(struct mac_context *mac,
113 struct disassoc_ind *pDisassocInd);
114 QDF_STATUS csr_send_mb_deauth_cnf_msg(struct mac_context *mac,
115 struct deauth_ind *pDeauthInd);
116 QDF_STATUS csr_send_assoc_cnf_msg(struct mac_context *mac,
117 struct assoc_ind *pAssocInd,
118 QDF_STATUS status,
119 enum wlan_status_code mac_status_code);
120 /**
121 * csr_get_cfg_valid_channels() - Get valid channel frequency list
122 * @mac: mac context
123 * @ch_freq_list: valid channel frequencies
124 * @num_ch_freq: valid channel number
125 *
126 * This function returns the valid channel frequencies.
127 *
128 * Return: QDF_STATUS_SUCCESS for success.
129 */
130 QDF_STATUS csr_get_cfg_valid_channels(struct mac_context *mac,
131 uint32_t *ch_freq_list,
132 uint32_t *num_ch_freq);
133
134 enum csr_cfgdot11mode
135 csr_get_cfg_dot11_mode_from_csr_phy_mode(bool is_ap, eCsrPhyMode phyMode);
136
137 uint32_t csr_translate_to_wni_cfg_dot11_mode(struct mac_context *mac,
138 enum csr_cfgdot11mode csrDot11Mode);
139 void csr_save_channel_power_for_band(struct mac_context *mac, bool fPopulate5GBand);
140 void csr_apply_channel_power_info_to_fw(struct mac_context *mac,
141 struct csr_channel *pChannelList);
142 void csr_apply_power2_current(struct mac_context *mac);
143 void csr_apply_channel_power_info_wrapper(struct mac_context *mac);
144 QDF_STATUS csr_save_to_channel_power2_g_5_g(struct mac_context *mac,
145 uint32_t tableSize,
146 struct pwr_channel_info *channelTable);
147
148 /*
149 * csr_prepare_vdev_delete() - CSR api to delete vdev
150 * @mac_ctx: pointer to mac context
151 * @vdev: vdev object to be prepared for deletion.
152 *
153 * Return QDF_STATUS
154 */
155 QDF_STATUS csr_prepare_vdev_delete(struct mac_context *mac_ctx,
156 struct wlan_objmgr_vdev *vdev);
157
158 /*
159 * csr_cleanup_vdev_session() - CSR api to cleanup vdev
160 * @mac_ctx: pointer to mac context
161 * @vdev_id: vdev id to be deleted.
162 *
163 * This API is used to clean up vdev information gathered during
164 * vdev was enabled.
165 *
166 * Return QDF_STATUS
167 */
168 void csr_cleanup_vdev_session(struct mac_context *mac, uint8_t vdev_id);
169
170 QDF_STATUS csr_roam_get_session_id_from_bssid(struct mac_context *mac,
171 struct qdf_mac_addr *bssid,
172 uint32_t *pSessionId);
173
174 /*
175 * csr_scan_get_result() - Return scan results based on filter
176 * @mac: Pointer to Global MAC structure
177 * @filter: If pFilter is NULL, all cached results are returned
178 * @phResult: an object for the result.
179 *
180 * Return QDF_STATUS
181 */
182 QDF_STATUS csr_scan_get_result(struct mac_context *mac,
183 struct scan_filter *filter,
184 tScanResultHandle *phResult);
185
186 /**
187 * csr_scan_get_result_for_bssid - gets the scan result from scan cache for the
188 * bssid specified
189 * @mac_ctx: mac context
190 * @bssid: bssid to get the scan result for
191 * @ret_list: pointer to scan results
192 *
193 * Return: QDF_STATUS
194 */
195 QDF_STATUS csr_scan_get_result_for_bssid(struct mac_context *mac_ctx,
196 struct qdf_mac_addr *bssid,
197 qdf_list_t **ret_list);
198
199 /**
200 * csr_scan_filter_results: filter scan result based
201 * on valid channel list number.
202 * @mac_ctx: mac context
203 *
204 * Get scan result from scan list and Check Scan result channel number
205 * with 11d channel list if channel number is found in 11d channel list
206 * then do not remove scan result entry from scan list
207 *
208 * return: QDF Status
209 */
210 QDF_STATUS csr_scan_filter_results(struct mac_context *mac);
211
212 /*
213 * csr_scan_result_get_first
214 * Returns the first element of scan result.
215 *
216 * hScanResult - returned from csr_scan_get_result
217 * tCsrScanResultInfo * - NULL if no result
218 */
219 tCsrScanResultInfo *csr_scan_result_get_first(struct mac_context *mac,
220 tScanResultHandle hScanResult);
221 /*
222 * csr_scan_result_get_next
223 * Returns the next element of scan result. It can be called without calling
224 * csr_scan_result_get_first first
225 *
226 * hScanResult - returned from csr_scan_get_result
227 * Return Null if no result or reach the end
228 */
229 tCsrScanResultInfo *csr_scan_result_get_next(struct mac_context *mac,
230 tScanResultHandle hScanResult);
231
232 /* some support functions */
233 bool csr_is11h_supported(struct mac_context *mac);
234 bool csr_is_wmm_supported(struct mac_context *mac);
235
236 /* Return SUCCESS is the command is queued, failed */
237 QDF_STATUS csr_queue_sme_command(struct mac_context *mac, tSmeCmd *pCommand,
238 bool fHighPriority);
239 tSmeCmd *csr_get_command_buffer(struct mac_context *mac);
240 void csr_release_command(struct mac_context *mac, tSmeCmd *pCommand);
241 void csr_release_command_buffer(struct mac_context *mac, tSmeCmd *pCommand);
242
243 /**
244 * csr_get_vdev_type_nss() - gets the nss value based on vdev type
245 * @dev_mode: current device operating mode.
246 * @nss2g: Pointer to the 2G Nss parameter.
247 * @nss5g: Pointer to the 5G Nss parameter.
248 *
249 * Fills the 2G and 5G Nss values based on device mode.
250 *
251 * Return: None
252 */
253 void csr_get_vdev_type_nss(enum QDF_OPMODE dev_mode, uint8_t *nss_2g,
254 uint8_t *nss_5g);
255
256 /**
257 * csr_send_set_ie - Send Set IE request to lim
258 * @type: Vdev type
259 * @sub_type: Vdev sub type
260 * @vdev_id: Vdev id
261 *
262 * Return: None
263 */
264 void csr_send_set_ie(uint8_t type, uint8_t sub_type, uint8_t vdev_id);
265 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
266
267 /* Security */
268 #define WLAN_SECURITY_EVENT_MIC_ERROR 9
269 #define WLAN_SECURITY_EVENT_SET_UNICAST_RSP 11
270 #define WLAN_SECURITY_EVENT_SET_BCAST_RSP 13
271
272 #define WLAN_SECURITY_STATUS_SUCCESS 0
273 #define WLAN_SECURITY_STATUS_FAILURE 1
274
275 /* 11d */
276 #define WLAN_80211D_EVENT_RESET 1
277 #endif /* #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR */
278 /*
279 * csr_scan_result_purge() -
280 * Remove all items(tCsrScanResult) in the list and free memory for each item
281 * hScanResult - returned from csr_scan_get_result. hScanResult is considered
282 * gone by calling this function and even before this function returns.
283 * Return QDF_STATUS
284 */
285 QDF_STATUS csr_scan_result_purge(struct mac_context *mac,
286 tScanResultHandle hScanResult);
287
288 /* /////////////////////////////////////////Common Scan ends */
289 /**
290 * csr_bss_start() - CSR API to post the start bss request to serialization
291 * module.
292 * @mac: mac context
293 * @vdev_id: vdev id
294 * @bss_config: start bss config
295 *
296 * Return: QDF_STATUS
297 */
298 QDF_STATUS csr_bss_start(struct mac_context *mac, uint32_t vdev_id,
299 struct start_bss_config *bss_config);
300
301 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
302 /*
303 * csr_get_pmk_info(): store PMK in pmk_cache
304 * @mac_ctx: pointer to global structure for MAC
305 * @session_id: Sme session id
306 * @pmk_cache: pointer to a structure of Pmk
307 *
308 * This API gets the PMK from the session and
309 * stores it in the pmk_cache
310 *
311 * Return: none
312 */
313 void csr_get_pmk_info(struct mac_context *mac_ctx, uint8_t session_id,
314 struct wlan_crypto_pmksa *pmk_cache);
315
316 /*
317 * csr_roam_set_psk_pmk() - store PSK/PMK in CSR session
318 * @mac - pointer to global structure for MAC
319 * @pmksa: PMKSA entry
320 * @vdev_id - vdev id
321 * @update_to_fw - Send RSO update config command to firmware to update
322 * PMK
323 *
324 * Return QDF_STATUS - usually it succeed unless sessionId is not found
325 */
326 QDF_STATUS csr_roam_set_psk_pmk(struct mac_context *mac,
327 struct wlan_crypto_pmksa *pmksa,
328 uint8_t vdev_id, bool update_to_fw);
329
330 /**
331 * csr_set_pmk_cache_ft() - store MDID in PMK cache
332 *
333 * @mac - pointer to global structure for MAC
334 * @session_id - Sme session id
335 * @pmk_cache: pointer to a structure of PMK
336 *
337 * Return QDF_STATUS - usually it succeed unless session_id is not found
338 */
339 QDF_STATUS csr_set_pmk_cache_ft(struct mac_context *mac, uint8_t vdev_id,
340 struct wlan_crypto_pmksa *pmk_cache);
341 #endif
342
343 /*
344 * csr_apply_channel_and_power_list() -
345 * HDD calls this function to set the CFG_VALID_CHANNEL_LIST base on the
346 * band/mode settings. This function must be called after CFG is downloaded
347 * and all the band/mode setting already passed into CSR.
348
349 * Return QDF_STATUS
350 */
351 QDF_STATUS csr_apply_channel_and_power_list(struct mac_context *mac);
352
353 /*
354 * csr_roam_ndi_stop() - stop ndi
355 * @mac: pointer to mac context
356 * @vdev_id: vdev ID
357 *
358 * Return QDF_STATUS
359 */
360 QDF_STATUS csr_roam_ndi_stop(struct mac_context *mac, uint8_t vdev_id);
361
362 /**
363 * csr_roam_issue_stop_bss_cmd() - This API posts the stop bss command
364 * to the serialization module.
365 *
366 * @mac: Global mac context
367 * @vdev_id: Vdev id
368 * @bss_type: BSS type
369 *
370 * Return : QDF_STATUS
371 */
372 QDF_STATUS csr_roam_issue_stop_bss_cmd(struct mac_context *mac, uint8_t vdev_id,
373 eCsrRoamBssType bss_type);
374
375 /**
376 * csr_roam_issue_disassociate_sta_cmd() - disassociate a associated station
377 * @mac: Pointer to global structure for MAC
378 * @vdev_id: vdev Id for Soft AP
379 * @del_sta_params: Pointer to parameters of the station to disassoc
380 *
381 * CSR function that HDD calls to issue a deauthenticate station command
382 *
383 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_* on error
384 */
385 QDF_STATUS
386 csr_roam_issue_disassociate_sta_cmd(struct mac_context *mac,
387 uint8_t vdev_id,
388 struct csr_del_sta_params *del_sta_params);
389 /**
390 * csr_roam_issue_deauth_sta_cmd() - issue deauthenticate station command
391 * @mac: Pointer to global structure for MAC
392 * @vdev_id: vdev Id for Soft AP
393 * @del_sta_params: Pointer to parameters of the station to deauthenticate
394 *
395 * CSR function that HDD calls to issue a deauthenticate station command
396 *
397 * Return: QDF_STATUS_SUCCESS on success or another QDF_STATUS_** on error
398 */
399 QDF_STATUS
400 csr_roam_issue_deauth_sta_cmd(struct mac_context *mac,
401 uint8_t vdev_id,
402 struct csr_del_sta_params *del_sta_params);
403
404 /*
405 * csr_send_chng_mcc_beacon_interval() -
406 * csr function that HDD calls to send Update beacon interval
407 *
408 * sessionId - session Id for Soft AP
409 * Return QDF_STATUS
410 */
411 QDF_STATUS
412 csr_send_chng_mcc_beacon_interval(struct mac_context *mac, uint32_t sessionId);
413
414 #ifdef FEATURE_WLAN_ESE
415 void csr_update_prev_ap_info(struct csr_roam_session *session,
416 struct wlan_objmgr_vdev *vdev);
417
418 #else
csr_update_prev_ap_info(struct csr_roam_session * session,struct wlan_objmgr_vdev * vdev)419 static inline void csr_update_prev_ap_info(struct csr_roam_session *session,
420 struct wlan_objmgr_vdev *vdev) {}
421 #endif
422
423 QDF_STATUS csr_update_channel_list(struct mac_context *mac);
424
425 #if defined(WLAN_SAE_SINGLE_PMK) && defined(WLAN_FEATURE_ROAM_OFFLOAD)
426 /**
427 * csr_clear_sae_single_pmk - API to clear single_pmk_info cache
428 * @psoc: psoc common object
429 * @vdev_id: session id
430 * @pmksa: pmk info
431 *
432 * Return : None
433 */
434 void csr_clear_sae_single_pmk(struct wlan_objmgr_psoc *psoc,
435 uint8_t vdev_id, struct wlan_crypto_pmksa *pmksa);
436 #else
437 static inline void
csr_clear_sae_single_pmk(struct wlan_objmgr_psoc * psoc,uint8_t vdev_id,struct wlan_crypto_pmksa * pmksa)438 csr_clear_sae_single_pmk(struct wlan_objmgr_psoc *psoc, uint8_t vdev_id,
439 struct wlan_crypto_pmksa *pmksa)
440 {
441 }
442 #endif
443
444 QDF_STATUS csr_send_ext_change_freq(struct mac_context *mac_ctx,
445 qdf_freq_t ch_freq, uint8_t session_id);
446
447 /**
448 * csr_csa_start() - request CSA IE transmission from PE
449 * @mac_ctx: handle returned by mac_open
450 * @session_id: SAP session id
451 *
452 * Return: QDF_STATUS
453 */
454 QDF_STATUS csr_csa_restart(struct mac_context *mac_ctx, uint8_t session_id);
455
456 /**
457 * csr_sta_continue_csa() - Continue for CSA for STA after HW mode change
458 * @mac_ctx: handle returned by mac_open
459 * @vdev_id: STA VDEV ID
460 *
461 * Return: QDF_STATUS
462 */
463 QDF_STATUS csr_sta_continue_csa(struct mac_context *mac_ctx,
464 uint8_t vdev_id);
465
466 #ifdef QCA_HT_2040_COEX
467 QDF_STATUS csr_set_ht2040_mode(struct mac_context *mac, uint32_t sessionId,
468 ePhyChanBondState cbMode, bool obssEnabled);
469 #endif
470
471 void csr_prune_channel_list_for_mode(struct mac_context *mac,
472 struct csr_channel *pChannelList);
473
474 /**
475 * csr_is_pmkid_found_for_peer() - check if pmkid sent by peer is present
476 in PMK cache. Used in SAP mode.
477 * @mac: pointer to mac
478 * @session: sme session pointer
479 * @peer_mac_addr: mac address of the connecting peer
480 * @pmkid: pointer to pmkid(s) send by peer
481 * @pmkid_count: number of pmkids sent by peer
482 *
483 * Return: true if pmkid is found else false
484 */
485 bool csr_is_pmkid_found_for_peer(struct mac_context *mac,
486 struct csr_roam_session *session,
487 tSirMacAddr peer_mac_addr,
488 uint8_t *pmkid, uint16_t pmkid_count);
489 #ifdef WLAN_FEATURE_11BE
490
491 /**
492 * csr_update_session_eht_cap() - update sme session eht capabilities
493 * @mac_ctx: pointer to mac
494 * @session: sme session pointer
495 *
496 * Return: None
497 */
498 void csr_update_session_eht_cap(struct mac_context *mac_ctx,
499 struct csr_roam_session *session);
500 #else
csr_update_session_eht_cap(struct mac_context * mac_ctx,struct csr_roam_session * session)501 static inline void csr_update_session_eht_cap(struct mac_context *mac_ctx,
502 struct csr_roam_session *session)
503 {
504 }
505 #endif
506
507 #ifdef WLAN_FEATURE_11AX
508 void csr_update_session_he_cap(struct mac_context *mac_ctx,
509 struct csr_roam_session *session);
510 #else
csr_update_session_he_cap(struct mac_context * mac_ctx,struct csr_roam_session * session)511 static inline void csr_update_session_he_cap(struct mac_context *mac_ctx,
512 struct csr_roam_session *session)
513 {
514 }
515 #endif
516
517 /**
518 * csr_setup_vdev_session() - API to setup vdev mac session
519 * @vdev_mlme: vdev mlme private object
520 *
521 * This API setsup the vdev session for the mac layer
522 *
523 * Returns: QDF_STATUS
524 */
525 QDF_STATUS csr_setup_vdev_session(struct vdev_mlme_obj *vdev_mlme);
526
527
528 #ifdef WLAN_UNIT_TEST
529 #ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
530 /**
531 * csr_cm_get_sta_cxn_info() - This function populates all the connection
532 * information which is formed by DUT-STA to AP
533 * @mac_ctx: pointer to mac context
534 * @vdev_id: vdev id
535 * @buf: pointer to char buffer to write all the connection information.
536 * @buf_size: maximum size of the provided buffer
537 *
538 * Returns: None (information gets populated in buffer)
539 */
540 void csr_cm_get_sta_cxn_info(struct mac_context *mac_ctx, uint8_t vdev_id,
541 char *buf, uint32_t buf_sz);
542
543 #endif
544 #endif
545
546 /**
547 * csr_process_sap_response() - Wrapper API to process the SAP
548 * response from LIM
549 * @mac_ctx: mac context
550 * @result: Response status of LIM processing
551 * @context: Response from LIM
552 * @session_id: vdev id
553 *
554 * Return: void
555 */
556 void csr_process_sap_response(struct mac_context *mac,
557 enum csr_sap_response_type result,
558 void *context, uint8_t session_id);
559
560 /**
561 * csr_roam_roaming_state_start_bss_rsp_processor() - Handles start bss
562 * response from LIM
563 *
564 * @mac: mac context
565 * @msg: start bss response pointer
566 *
567 * Return: void
568 */
569 void
570 csr_roam_roaming_state_start_bss_rsp_processor(struct mac_context *mac,
571 void *msg);
572
573 /**
574 * csr_roam_roaming_state_stop_bss_rsp_processor() - Handles stop bss
575 * response from LIM
576 *
577 * @mac: mac context
578 * @msg: stop bss response pointer
579 *
580 * Return: void
581 */
582 void csr_roam_roaming_state_stop_bss_rsp_processor(struct mac_context *mac,
583 void *msg);
584
585 /**
586 * csr_roam_process_results_default() - Process the result for start bss
587 * @mac_ctx: Global MAC Context
588 * @cmd: Command to be processed
589 *
590 * Return: None
591 */
592 void
593 csr_roam_process_results_default(struct mac_context *mac_ctx, tSmeCmd *cmd);
594
595 #endif /* CSR_INSIDE_API_H__ */
596