staging: rtl8712: r8712_set_auth(): Change return values
[linux-2.6-block.git] / drivers / staging / rtl8712 / rtl871x_mlme.h
CommitLineData
e24c1f86 1/* SPDX-License-Identifier: GPL-2.0 */
cf3e6881
AB
2/******************************************************************************
3 *
4 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5 *
cf3e6881
AB
6 * Modifications for inclusion into the Linux staging tree are
7 * Copyright(c) 2010 Larry Finger. All rights reserved.
8 *
9 * Contact information:
10 * WLAN FAE <wlanfae@realtek.com>
11 * Larry Finger <Larry.Finger@lwfinger.net>
12 *
13 ******************************************************************************/
2865d42c
LF
14#ifndef __RTL871X_MLME_H_
15#define __RTL871X_MLME_H_
16
17#include "osdep_service.h"
18#include "drv_types.h"
19#include "wlan_bssdef.h"
20
21#define MAX_BSS_CNT 64
22#define MAX_JOIN_TIMEOUT 6000
23
24#define SCANNING_TIMEOUT 4500
25
26#define SCANQUEUE_LIFETIME 20 /* unit:sec */
27
28#define WIFI_NULL_STATE 0x00000000
29#define WIFI_ASOC_STATE 0x00000001 /* Under Linked state...*/
30#define WIFI_REASOC_STATE 0x00000002
31#define WIFI_SLEEP_STATE 0x00000004
32#define WIFI_STATION_STATE 0x00000008
33#define WIFI_AP_STATE 0x00000010
34#define WIFI_ADHOC_STATE 0x00000020
35#define WIFI_ADHOC_MASTER_STATE 0x00000040
36#define WIFI_UNDER_LINKING 0x00000080
37#define WIFI_SITE_MONITOR 0x00000800 /* to indicate the station
bef611a9
RB
38 * is under site surveying
39 */
2865d42c
LF
40#define WIFI_MP_STATE 0x00010000
41#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in cont. tx background*/
42#define WIFI_MP_CTX_ST 0x00040000 /* in cont. tx with
bef611a9
RB
43 * single-tone
44 */
2865d42c 45#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in cont, tx
3be4fdf6
MH
46 * background due
47 * to out of skb
bef611a9 48 */
25985edc 49#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx*/
2865d42c 50#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in cont, tx with carrier
bef611a9
RB
51 * suppression
52 */
2865d42c
LF
53#define WIFI_MP_LPBK_STATE 0x00400000
54
55#define _FW_UNDER_LINKING WIFI_UNDER_LINKING
56#define _FW_LINKED WIFI_ASOC_STATE
57#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
58
59/*
875f3a6b
DR
60 * there are several "locks" in mlme_priv,
61 * since mlme_priv is a shared resource between many threads,
62 * like ISR/Call-Back functions, the OID handlers, and even timer functions.
63 * Each _queue has its own locks, already.
64 * Other items are protected by mlme_priv.lock.
65 * To avoid possible dead lock, any thread trying to modify mlme_priv
66 * SHALL not lock up more than one lock at a time!
67 */
2865d42c
LF
68
69#define traffic_threshold 10
70#define traffic_scan_period 500
71
72struct sitesurvey_ctrl {
73 u64 last_tx_pkts;
74 uint last_rx_pkts;
75 sint traffic_busy;
76 struct timer_list sitesurvey_ctrl_timer;
77};
78
79struct mlme_priv {
80
81 spinlock_t lock;
82 spinlock_t lock2;
83 sint fw_state; /*shall we protect this variable? */
84 u8 to_join; /*flag*/
85 u8 *nic_hdl;
86 struct list_head *pscanned;
87 struct __queue free_bss_pool;
88 struct __queue scanned_queue;
89 u8 *free_bss_buf;
90 unsigned long num_of_scanned;
c6dc001f 91 u8 passive_mode; /*add for Android's SCAN-ACTIVE/SCAN-PASSIVE */
2865d42c
LF
92 struct ndis_802_11_ssid assoc_ssid;
93 u8 assoc_bssid[6];
94 struct wlan_network cur_network;
95 struct sitesurvey_ctrl sitesurveyctrl;
96 struct timer_list assoc_timer;
97 uint assoc_by_bssid;
98 uint assoc_by_rssi;
99 struct timer_list scan_to_timer; /* driver handles scan_timeout.*/
100 struct timer_list dhcp_timer; /* set dhcp to if driver in ps mode.*/
101 struct qos_priv qospriv;
102 struct ht_priv htpriv;
103 struct timer_list wdg_timer; /*watchdog periodic timer*/
104};
105
106static inline u8 *get_bssid(struct mlme_priv *pmlmepriv)
107{
108 return pmlmepriv->cur_network.network.MacAddress;
109}
110
111static inline u8 check_fwstate(struct mlme_priv *pmlmepriv, sint state)
112{
113 if (pmlmepriv->fw_state & state)
114 return true;
115 return false;
116}
117
118static inline sint get_fwstate(struct mlme_priv *pmlmepriv)
119{
120 return pmlmepriv->fw_state;
121}
122
123/*
124 * No Limit on the calling context,
125 * therefore set it to be the critical section...
126 *
127 * ### NOTE:#### (!!!!)
be10ac2b 128 * TAKE CARE BEFORE CALLING THIS FUNC, LOCK pmlmepriv->lock
2865d42c
LF
129 */
130static inline void set_fwstate(struct mlme_priv *pmlmepriv, sint state)
131{
132 pmlmepriv->fw_state |= state;
133}
134
135static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, sint state)
136{
137 pmlmepriv->fw_state &= ~state;
138}
139
140/*
141 * No Limit on the calling context,
142 * therefore set it to be the critical section...
143 */
144static inline void clr_fwstate(struct mlme_priv *pmlmepriv, sint state)
145{
146 unsigned long irqL;
147
148 spin_lock_irqsave(&pmlmepriv->lock, irqL);
1ca96884 149 if (check_fwstate(pmlmepriv, state))
2865d42c
LF
150 pmlmepriv->fw_state ^= state;
151 spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
152}
153
2865d42c
LF
154static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv,
155 sint val)
156{
157 unsigned long irqL;
158
159 spin_lock_irqsave(&pmlmepriv->lock, irqL);
160 pmlmepriv->num_of_scanned = val;
161 spin_unlock_irqrestore(&pmlmepriv->lock, irqL);
162}
163
164void r8712_survey_event_callback(struct _adapter *adapter, u8 *pbuf);
165void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf);
166void r8712_joinbss_event_callback(struct _adapter *adapter, u8 *pbuf);
167void r8712_stassoc_event_callback(struct _adapter *adapter, u8 *pbuf);
168void r8712_stadel_event_callback(struct _adapter *adapter, u8 *pbuf);
169void r8712_atimdone_event_callback(struct _adapter *adapter, u8 *pbuf);
170void r8712_cpwm_event_callback(struct _adapter *adapter, u8 *pbuf);
171void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf);
172void r8712_free_network_queue(struct _adapter *adapter);
173int r8712_init_mlme_priv(struct _adapter *adapter);
174void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv);
36f484ef 175int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv);
2865d42c
LF
176sint r8712_set_key(struct _adapter *adapter,
177 struct security_priv *psecuritypriv, sint keyid);
33972d48
ND
178int r8712_set_auth(struct _adapter *adapter,
179 struct security_priv *psecuritypriv);
986fc8e7 180uint r8712_get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss);
2865d42c
LF
181void r8712_generate_random_ibss(u8 *pibss);
182u8 *r8712_get_capability_from_ie(u8 *ie);
183struct wlan_network *r8712_get_oldest_wlan_network(
184 struct __queue *scanned_queue);
185void r8712_free_assoc_resources(struct _adapter *adapter);
186void r8712_ind_disconnect(struct _adapter *adapter);
187void r8712_indicate_connect(struct _adapter *adapter);
188int r8712_restruct_sec_ie(struct _adapter *adapter, u8 *in_ie,
189 u8 *out_ie, uint in_len);
190int r8712_restruct_wmm_ie(struct _adapter *adapter, u8 *in_ie,
191 u8 *out_ie, uint in_len, uint initial_out_len);
192void r8712_init_registrypriv_dev_network(struct _adapter *adapter);
193void r8712_update_registrypriv_dev_network(struct _adapter *adapter);
194void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter);
195void _r8712_join_timeout_handler(struct _adapter *adapter);
196void r8712_scan_timeout_handler(struct _adapter *adapter);
197void _r8712_dhcp_timeout_handler(struct _adapter *adapter);
2865d42c
LF
198struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv);
199sint r8712_if_up(struct _adapter *padapter);
200void r8712_joinbss_reset(struct _adapter *padapter);
201unsigned int r8712_restructure_ht_ie(struct _adapter *padapter, u8 *in_ie,
202 u8 *out_ie, uint in_len, uint *pout_len);
203void r8712_issue_addbareq_cmd(struct _adapter *padapter, int priority);
2865d42c
LF
204int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork);
205
206#endif /*__RTL871X_MLME_H_*/