1 /** @file mlan_sta_event.c
2 *
3 * @brief This file provides Function for STA event handling
4 *
5 * Copyright 2008-2024 NXP
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 *
9 */
10
11 /********************************************************
12 Change log:
13 10/13/2008: initial version
14 ********************************************************/
15
16 #include <mlan_api.h>
17
18 /* Additional WMSDK header files */
19 #include <wmerrno.h>
20 #include <osa.h>
21
22 /* Always keep this include at the end of all include files */
23 #include <mlan_remap_mem_operations.h>
24
25 /**
26 * @brief This function handles disconnect event, reports disconnect
27 * to upper layer, cleans tx/rx packets,
28 * resets link state etc.
29 *
30 * @param priv A pointer to mlan_private structure
31 * @param drv_disconnect Flag indicating the driver should disconnect
32 * and flush pending packets.
33 *
34 * @return N/A
35 */
wlan_reset_connect_state(pmlan_private priv,t_u8 drv_disconnect)36 t_void wlan_reset_connect_state(pmlan_private priv, t_u8 drv_disconnect)
37 {
38 ENTER();
39
40 PRINTM(MINFO, "Handles disconnect event.\n");
41
42 if (drv_disconnect == MTRUE)
43 {
44 priv->media_connected = MFALSE;
45 }
46
47 if (priv->port_ctrl_mode == MTRUE)
48 {
49 /* Close the port on Disconnect */
50 PRINTM(MINFO, "DISC: port_status = CLOSED\n");
51 priv->port_open = MFALSE;
52 }
53 priv->scan_block = MFALSE;
54
55 /* Reset SNR/NF/RSSI values */
56 priv->data_rssi_last = 0;
57 priv->data_nf_last = 0;
58 priv->data_rssi_avg = 0;
59 priv->data_nf_avg = 0;
60 priv->bcn_rssi_last = 0;
61 priv->bcn_nf_last = 0;
62 priv->bcn_rssi_avg = 0;
63 priv->bcn_nf_avg = 0;
64 priv->rxpd_rate = 0;
65 #ifdef SD8801
66 priv->rxpd_htinfo = 0;
67 #else
68 priv->rxpd_rate_info = 0;
69 #endif
70 priv->max_amsdu = 0;
71
72 priv->tx_pause = 0;
73 #if (CONFIG_WPS2) || (CONFIG_WPA_SUPP_WPS)
74 priv->wps.session_enable = MFALSE;
75 priv->wps.wps_mgmt_bitmap_index = -1;
76 (void)__memset(priv->adapter, (t_u8 *)&priv->wps.wps_ie, 0x00, sizeof(priv->wps.wps_ie));
77 #endif /* CONFIG_WPS2 */
78
79 /* Enable auto data rate */
80 priv->is_data_rate_auto = MTRUE;
81 priv->data_rate = 0;
82 #if CONFIG_11K
83 priv->neighbor_rep_token = (t_u8)1U;
84 #endif
85 #if CONFIG_11V
86 priv->bss_trans_query_token = (t_u8)1U;
87 #endif
88 if (priv->bss_mode == MLAN_BSS_MODE_IBSS)
89 {
90 priv->adhoc_state = (t_u8)ADHOC_IDLE;
91 priv->adhoc_is_link_sensed = MFALSE;
92 priv->intf_state_11h.adhoc_auto_sel_chan = MTRUE;
93 }
94
95 #if CONFIG_WMM_UAPSD
96 /* Need to put uapsd_sem before getting ra_list.plock in wlan_ralist_del_all_enh */
97 if (priv->adapter->pps_uapsd_mode)
98 {
99 OSA_SemaphorePost((osa_semaphore_handle_t)uapsd_sem);
100 }
101 priv->adapter->tx_lock_flag = MFALSE;
102 priv->adapter->pps_uapsd_mode = MFALSE;
103 #endif
104
105 #if CONFIG_GTK_REKEY_OFFLOAD
106 (void)__memset(pmadapter, &priv->gtk_rekey, 0, sizeof(priv->gtk_rekey));
107 #endif
108
109 if (drv_disconnect == MTRUE)
110 {
111 /* Free Tx and Rx packets, report disconnect to upper layer */
112 wlan_clean_txrx(priv);
113
114 /* Need to erase the current SSID and BSSID info */
115 (void)__memset(priv->adapter, &priv->curr_bss_params, 0x00, sizeof(priv->curr_bss_params));
116 }
117
118 LEAVE();
119 }
120
121 /**
122 * @brief This function handles link lost, deauth and
123 * disassoc events.
124 *
125 * @param priv A pointer to mlan_private structure
126 * @return N/A
127 */
wlan_handle_disconnect_event(pmlan_private pmpriv)128 t_void wlan_handle_disconnect_event(pmlan_private pmpriv)
129 {
130 ENTER();
131
132 wlan_reset_connect_state(pmpriv, MTRUE);
133
134 LEAVE();
135 }
136