1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#ifndef __RTL871X_MLME_H_
27#define __RTL871X_MLME_H_
28
29#include "osdep_service.h"
30#include "drv_types.h"
31#include "wlan_bssdef.h"
32
33#define MAX_BSS_CNT 64
34#define MAX_JOIN_TIMEOUT 6000
35
36#define SCANNING_TIMEOUT 4500
37
38#define SCANQUEUE_LIFETIME 20
39
40#define WIFI_NULL_STATE 0x00000000
41#define WIFI_ASOC_STATE 0x00000001
42#define WIFI_REASOC_STATE 0x00000002
43#define WIFI_SLEEP_STATE 0x00000004
44#define WIFI_STATION_STATE 0x00000008
45#define WIFI_AP_STATE 0x00000010
46#define WIFI_ADHOC_STATE 0x00000020
47#define WIFI_ADHOC_MASTER_STATE 0x00000040
48#define WIFI_UNDER_LINKING 0x00000080
49#define WIFI_SITE_MONITOR 0x00000800
50
51
52#define WIFI_MP_STATE 0x00010000
53#define WIFI_MP_CTX_BACKGROUND 0x00020000
54#define WIFI_MP_CTX_ST 0x00040000
55
56
57#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000
58
59
60#define WIFI_MP_CTX_CCK_HW 0x00100000
61#define WIFI_MP_CTX_CCK_CS 0x00200000
62
63
64#define WIFI_MP_LPBK_STATE 0x00400000
65
66#define _FW_UNDER_LINKING WIFI_UNDER_LINKING
67#define _FW_LINKED WIFI_ASOC_STATE
68#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
69
70
71
72
73
74
75
76
77
78
79
80#define traffic_threshold 10
81#define traffic_scan_period 500
82
83struct sitesurvey_ctrl {
84 u64 last_tx_pkts;
85 uint last_rx_pkts;
86 sint traffic_busy;
87 struct timer_list sitesurvey_ctrl_timer;
88};
89
90struct mlme_priv {
91
92 spinlock_t lock;
93 spinlock_t lock2;
94 sint fw_state;
95 u8 to_join;
96 u8 *nic_hdl;
97 struct list_head *pscanned;
98 struct __queue free_bss_pool;
99 struct __queue scanned_queue;
100 u8 *free_bss_buf;
101 unsigned long num_of_scanned;
102 u8 passive_mode;
103 struct ndis_802_11_ssid assoc_ssid;
104 u8 assoc_bssid[6];
105 struct wlan_network cur_network;
106 struct sitesurvey_ctrl sitesurveyctrl;
107 struct timer_list assoc_timer;
108 uint assoc_by_bssid;
109 uint assoc_by_rssi;
110 struct timer_list scan_to_timer;
111 struct timer_list dhcp_timer;
112 struct qos_priv qospriv;
113 struct ht_priv htpriv;
114 struct timer_list wdg_timer;
115};
116
117static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
118{
119 return pmlmepriv->cur_network.network.MacAddress;
120}
121
122static inline u8 check_fwstate(struct mlme_priv *pmlmepriv, sint state)
123{
124 if (pmlmepriv->fw_state & state)
125 return true;
126 return false;
127}
128
129static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
130{
131 return pmlmepriv->fw_state;
132}
133
134
135
136
137
138
139
140
141static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
142{
143 pmlmepriv->fw_state |= state;
144}
145
146static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
147{
148 pmlmepriv->fw_state &= ~state;
149}
150
151
152
153
154
155static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
156{
157 unsigned long irqL;
158
159 spin_lock_irqsave(&pmlmepriv->lock, irqL);
160 if (check_fwstate(pmlmepriv, state))
161 pmlmepriv->fw_state ^= state;
162 spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
163}
164
165static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
166{
167 unsigned long irqL;
168
169 spin_lock_irqsave(&pmlmepriv->lock, irqL);
170 pmlmepriv->num_of_scanned++;
171 spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
172}
173
174static inline void down_scanned_network(struct mlme_priv *pmlmepriv)
175{
176 unsigned long irqL;
177
178 spin_lock_irqsave(&pmlmepriv->lock, irqL);
179 pmlmepriv->num_of_scanned--;
180 spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
181}
182
183static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
184 sint val)
185{
186 unsigned long irqL;
187
188 spin_lock_irqsave(&pmlmepriv->lock, irqL);
189 pmlmepriv->num_of_scanned = val;
190 spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
191}
192
193void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf);
194void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf);
195void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf);
196void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf);
197void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf);
198void r8712_atimdone_event_callback(struct _adapter *adapter, u8 *pbuf);
199void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf);
200void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf);
201void r8712_free_network_queue(struct _adapter *adapter);
202int r8712_init_mlme_priv(struct _adapter *adapter);
203void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
204sint r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
205sint r8712_set_key(struct _adapter *adapter,
206 struct security_priv *psecuritypriv, sint keyid);
207sint r8712_set_auth(struct _adapter *adapter,
208 struct security_priv *psecuritypriv);
209uint r8712_get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss);
210void r8712_generate_random_ibss(u8 *pibss);
211u8 *r8712_get_capability_from_ie(u8 *ie);
212struct wlan_network *r8712_get_oldest_wlan_network(
213 struct __queue *scanned_queue);
214void r8712_free_assoc_resources(struct _adapter *adapter);
215void r8712_ind_disconnect(struct _adapter *adapter);
216void r8712_indicate_connect(struct _adapter *adapter);
217int r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
218 u8 *out_ie, uint in_len);
219int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie,
220 u8 *out_ie, uint in_len, uint initial_out_len);
221void r8712_init_registrypriv_dev_network(struct _adapter *adapter);
222void r8712_update_registrypriv_dev_network(struct _adapter *adapter);
223void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter);
224void _r8712_join_timeout_handler(struct _adapter *adapter);
225void r8712_scan_timeout_handler(struct _adapter *adapter);
226void _r8712_dhcp_timeout_handler(struct _adapter *adapter);
227void _r8712_wdg_timeout_handler(struct _adapter *adapter);
228struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv);
229sint r8712_if_up(struct _adapter *padapter);
230void r8712_joinbss_reset(struct _adapter *padapter);
231unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
232 u8 *out_ie, uint in_len, uint *pout_len);
233void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority);
234int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork);
235
236#endif
237