Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rtl871x_mlme.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  * Modifications for inclusion into the Linux staging tree are
19  * Copyright(c) 2010 Larry Finger. All rights reserved.
20  *
21  * Contact information:
22  * WLAN FAE <[email protected]>
23  * Larry Finger <[email protected]>
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 /* unit:sec */
39 
40 #define WIFI_NULL_STATE 0x00000000
41 #define WIFI_ASOC_STATE 0x00000001 /* Under Linked state...*/
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 /* to indicate the station
50  * is under site surveying*/
51 #define WIFI_MP_STATE 0x00010000
52 #define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in cont. tx background*/
53 #define WIFI_MP_CTX_ST 0x00040000 /* in cont. tx with
54  * single-tone*/
55 #define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in cont, tx
56  * background due to out of skb*/
57 #define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx*/
58 #define WIFI_MP_CTX_CCK_CS 0x00200000 /* in cont, tx with carrier
59  * suppression*/
60 #define WIFI_MP_LPBK_STATE 0x00400000
61 
62 #define _FW_UNDER_LINKING WIFI_UNDER_LINKING
63 #define _FW_LINKED WIFI_ASOC_STATE
64 #define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
65 
66 /*
67 there are several "locks" in mlme_priv,
68 since mlme_priv is a shared resource between many threads,
69 like ISR/Call-Back functions, the OID handlers, and even timer functions.
70 Each _queue has its own locks, already.
71 Other items are protected by mlme_priv.lock.
72 To avoid possible dead lock, any thread trying to modify mlme_priv
73 SHALL not lock up more than one lock at a time!
74 */
75 
76 #define traffic_threshold 10
77 #define traffic_scan_period 500
78 
84 };
85 
86 struct mlme_priv {
87 
90  sint fw_state; /*shall we protect this variable? */
91  u8 to_join; /*flag*/
97  unsigned long num_of_scanned;
98  u8 passive_mode; /*add for Android's SCAN-ACTIVE/SCAN-PASSIVE */
106  struct timer_list scan_to_timer; /* driver handles scan_timeout.*/
107  struct timer_list dhcp_timer; /* set dhcp to if driver in ps mode.*/
108  struct qos_priv qospriv;
109  struct ht_priv htpriv;
110  struct timer_list wdg_timer; /*watchdog periodic timer*/
111 };
112 
113 static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
114 {
115  return pmlmepriv->cur_network.network.MacAddress;
116 }
117 
118 static inline u8 check_fwstate(struct mlme_priv *pmlmepriv, sint state)
119 {
120  if (pmlmepriv->fw_state & state)
121  return true;
122  return false;
123 }
124 
125 static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
126 {
127  return pmlmepriv->fw_state;
128 }
129 
130 /*
131  * No Limit on the calling context,
132  * therefore set it to be the critical section...
133  *
134  * ### NOTE:#### (!!!!)
135  * TAKE CARE BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
136  */
137 static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
138 {
139  pmlmepriv->fw_state |= state;
140 }
141 
142 static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
143 {
144  pmlmepriv->fw_state &= ~state;
145 }
146 
147 /*
148  * No Limit on the calling context,
149  * therefore set it to be the critical section...
150  */
151 static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
152 {
153  unsigned long irqL;
154 
155  spin_lock_irqsave(&pmlmepriv->lock, irqL);
156  if (check_fwstate(pmlmepriv, state) == true)
157  pmlmepriv->fw_state ^= state;
158  spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
159 }
160 
161 static inline void up_scanned_network(struct mlme_priv *pmlmepriv)
162 {
163  unsigned long irqL;
164 
165  spin_lock_irqsave(&pmlmepriv->lock, irqL);
166  pmlmepriv->num_of_scanned++;
167  spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
168 }
169 
170 static inline void down_scanned_network(struct mlme_priv *pmlmepriv)
171 {
172  unsigned long irqL;
173 
174  spin_lock_irqsave(&pmlmepriv->lock, irqL);
175  pmlmepriv->num_of_scanned--;
176  spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
177 }
178 
179 static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
180  sint val)
181 {
182  unsigned long irqL;
183 
184  spin_lock_irqsave(&pmlmepriv->lock, irqL);
185  pmlmepriv->num_of_scanned = val;
186  spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
187 }
188 
189 void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf);
191 void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf);
192 void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf);
193 void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf);
194 void r8712_atimdone_event_callback(struct _adapter *adapter, u8 *pbuf);
195 void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf);
196 void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf);
199 void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
202  struct security_priv *psecuritypriv, sint keyid);
204  struct security_priv *psecuritypriv);
206 void r8712_generate_random_ibss(u8 *pibss);
209  struct __queue *scanned_queue);
213 int r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
214  u8 *out_ie, uint in_len);
215 int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie,
216  u8 *out_ie, uint in_len, uint initial_out_len);
224 struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv);
225 sint r8712_if_up(struct _adapter *padapter);
226 void r8712_joinbss_reset(struct _adapter *padapter);
227 unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
228  u8 *out_ie, uint in_len, uint *pout_len);
229 void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority);
230 int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork);
231 
232 #endif /*__RTL871X_MLME_H_*/