]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/net/wireless/realtek/rtl8192cu/include/sta_info.h
net: Fix rtl8192cu build errors on other platforms
[mirror_ubuntu-artful-kernel.git] / drivers / net / wireless / realtek / rtl8192cu / include / sta_info.h
CommitLineData
abb3b3dc 1/******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 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 *
19 ******************************************************************************/
20#ifndef __STA_INFO_H_
21#define __STA_INFO_H_
22
23#include <drv_conf.h>
24#include <osdep_service.h>
25#include <drv_types.h>
26#include <wifi.h>
27
28#define IBSS_START_MAC_ID 2
29#define NUM_STA 32
30#define NUM_ACL 16
31
32
33//if mode ==0, then the sta is allowed once the addr is hit.
34//if mode ==1, then the sta is rejected once the addr is non-hit.
35struct rtw_wlan_acl_node {
36 _list list;
37 u8 addr[ETH_ALEN];
38 u8 valid;
39};
40
41//mode=0, disable
42//mode=1, accept unless in deny list
43//mode=2, deny unless in accept list
44struct wlan_acl_pool {
45 int mode;
46 int num;
47 struct rtw_wlan_acl_node aclnode[NUM_ACL];
48 _queue acl_node_q;
49};
50
51typedef struct _RSSI_STA{
52 s32 UndecoratedSmoothedPWDB;
53 s32 UndecoratedSmoothedCCK;
54 s32 UndecoratedSmoothedOFDM;
55 u64 PacketMap;
56 u8 ValidBit;
57}RSSI_STA, *PRSSI_STA;
58
59struct stainfo_stats {
60
61 u64 rx_mgnt_pkts;
62 u64 rx_beacon_pkts;
63 u64 rx_probereq_pkts;
64 u64 rx_probersp_pkts;
65 u64 rx_probersp_bm_pkts;
66 u64 rx_probersp_uo_pkts;
67 u64 rx_ctrl_pkts;
68 u64 rx_data_pkts;
69
70 u64 last_rx_mgnt_pkts;
71 u64 last_rx_beacon_pkts;
72 u64 last_rx_probereq_pkts;
73 u64 last_rx_probersp_pkts;
74 u64 last_rx_probersp_bm_pkts;
75 u64 last_rx_probersp_uo_pkts;
76 u64 last_rx_ctrl_pkts;
77 u64 last_rx_data_pkts;
78
79 u64 rx_bytes;
80 u64 rx_drops;
81
82 u64 tx_pkts;
83 u64 tx_bytes;
84 u64 tx_drops;
85
86};
87
88#ifdef CONFIG_TDLS
89struct TDLS_PeerKey {
90 u8 kck[16]; /* TPK-KCK */
91 u8 tk[16]; /* TPK-TK; only CCMP will be used */
92} ;
93#endif //CONFIG_TDLS
94
95struct sta_info {
96
97 _lock lock;
98 _list list; //free_sta_queue
99 _list hash_list; //sta_hash
100 //_list asoc_list; //20061114
101 //_list sleep_list;//sleep_q
102 //_list wakeup_list;//wakeup_q
103
104 struct sta_xmit_priv sta_xmitpriv;
105 struct sta_recv_priv sta_recvpriv;
106
107 _queue sleep_q;
108 unsigned int sleepq_len;
109
110 uint state;
111 uint aid;
112 uint mac_id;
113 uint qos_option;
114 u8 hwaddr[ETH_ALEN];
115
116 uint ieee8021x_blocked; //0: allowed, 1:blocked
117 uint dot118021XPrivacy; //aes, tkip...
118 union Keytype dot11tkiptxmickey;
119 union Keytype dot11tkiprxmickey;
120 union Keytype dot118021x_UncstKey;
121 union pn48 dot11txpn; // PN48 used for Unicast xmit.
122#ifdef CONFIG_IEEE80211W
123 union pn48 dot11wtxpn; // PN48 used for Unicast mgmt xmit.
124#endif //CONFIG_IEEE80211W
125 union pn48 dot11rxpn; // PN48 used for Unicast recv.
126
127
128 u8 bssrateset[16];
129 u32 bssratelen;
130 s32 rssi;
131 s32 signal_quality;
132
133 u8 cts2self;
134 u8 rtsen;
135
136 u8 raid;
137 u8 init_rate;
138 u32 ra_mask;
139 struct stainfo_stats sta_stats;
140
141#ifdef CONFIG_TDLS
142 u32 tdls_sta_state;
143 u8 dialog;
144 u8 SNonce[32];
145 u8 ANonce[32];
146 u32 TDLS_PeerKey_Lifetime;
147 u16 TPK_count;
148 _timer TPK_timer;
149 struct TDLS_PeerKey tpk;
150 _adapter *padapter;
151 u16 stat_code;
152 u8 off_ch;
153 u16 ch_switch_time;
154 u16 ch_switch_timeout;
155 u8 option;
156 _timer option_timer;
157 _timer base_ch_timer;
158 _timer off_ch_timer;
159
160 _timer handshake_timer;
161 _timer alive_timer1;
162 _timer alive_timer2;
163 u8 timer_flag;
164 u8 alive_count;
165#endif //CONFIG_TDLS
166
167 //for A-MPDU TX, ADDBA timeout check
168 _timer addba_retry_timer;
169
170 //for A-MPDU Rx reordering buffer control
171 struct recv_reorder_ctrl recvreorder_ctrl[16];
172
173 //for A-MPDU Tx
174 //unsigned char ampdu_txen_bitmap;
175 u16 BA_starting_seqctrl[16];
176
177
178#ifdef CONFIG_80211N_HT
179 struct ht_priv htpriv;
180#endif
181
182 //Notes:
183 //STA_Mode:
184 //curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO
185 //scan_q: AP CAP/INFO
186
187 //AP_Mode:
188 //curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
189 //sta_info: (AP & STA) CAP/INFO
190
191#ifdef CONFIG_AP_MODE
192
193 _list asoc_list;
194 _list auth_list;
195
196 unsigned int expire_to;
197 unsigned int auth_seq;
198 unsigned int authalg;
199 unsigned char chg_txt[128];
200
201 u16 capability;
202 int flags;
203
204 int dot8021xalg;//0:disable, 1:psk, 2:802.1x
205 int wpa_psk;//0:disable, bit(0): WPA, bit(1):WPA2
206 int wpa_group_cipher;
207 int wpa2_group_cipher;
208 int wpa_pairwise_cipher;
209 int wpa2_pairwise_cipher;
210
211 u8 bpairwise_key_installed;
212
213#ifdef CONFIG_NATIVEAP_MLME
214 u8 wpa_ie[32];
215
216 u8 nonerp_set;
217 u8 no_short_slot_time_set;
218 u8 no_short_preamble_set;
219 u8 no_ht_gf_set;
220 u8 no_ht_set;
221 u8 ht_20mhz_set;
222#endif // CONFIG_NATIVEAP_MLME
223
224 unsigned int tx_ra_bitmap;
225 u8 qos_info;
226
227 u8 max_sp_len;
228 u8 uapsd_bk;//BIT(0): Delivery enabled, BIT(1): Trigger enabled
229 u8 uapsd_be;
230 u8 uapsd_vi;
231 u8 uapsd_vo;
232
233 u8 has_legacy_ac;
234 unsigned int sleepq_ac_len;
235
236#ifdef CONFIG_P2P
237 //p2p priv data
238 u8 is_p2p_device;
239 u8 p2p_status_code;
240
241 //p2p client info
242 u8 dev_addr[ETH_ALEN];
243 //u8 iface_addr[ETH_ALEN];//= hwaddr[ETH_ALEN]
244 u8 dev_cap;
245 u16 config_methods;
246 u8 primary_dev_type[8];
247 u8 num_of_secdev_type;
248 u8 secdev_types_list[32];// 32/8 == 4;
249 u16 dev_name_len;
250 u8 dev_name[32];
251#endif //CONFIG_P2P
252
253#ifdef CONFIG_TX_MCAST2UNI
254 u8 under_exist_checking;
255#endif // CONFIG_TX_MCAST2UNI
256
257 u8 keep_alive_trycnt;
258
259#endif // CONFIG_AP_MODE
260
261#ifdef CONFIG_IOCTL_CFG80211
262 u8 *passoc_req;
263 u32 assoc_req_len;
264#endif
265
266 //for DM
267 RSSI_STA rssi_stat;
268
269 /* To store the sequence number of received management frame */
270 u16 RxMgmtFrameSeqNum;
271};
272
273#define sta_rx_pkts(sta) \
274 (sta->sta_stats.rx_mgnt_pkts \
275 + sta->sta_stats.rx_ctrl_pkts \
276 + sta->sta_stats.rx_data_pkts)
277
278#define sta_last_rx_pkts(sta) \
279 (sta->sta_stats.last_rx_mgnt_pkts \
280 + sta->sta_stats.last_rx_ctrl_pkts \
281 + sta->sta_stats.last_rx_data_pkts)
282
283#define sta_rx_data_pkts(sta) \
284 (sta->sta_stats.rx_data_pkts)
285
286#define sta_last_rx_data_pkts(sta) \
287 (sta->sta_stats.last_rx_data_pkts)
288
289#define sta_rx_mgnt_pkts(sta) \
290 (sta->sta_stats.rx_mgnt_pkts)
291
292#define sta_last_rx_mgnt_pkts(sta) \
293 (sta->sta_stats.last_rx_mgnt_pkts)
294
295#define sta_rx_beacon_pkts(sta) \
296 (sta->sta_stats.rx_beacon_pkts)
297
298#define sta_last_rx_beacon_pkts(sta) \
299 (sta->sta_stats.last_rx_beacon_pkts)
300
301#define sta_rx_probereq_pkts(sta) \
302 (sta->sta_stats.rx_probereq_pkts)
303
304#define sta_last_rx_probereq_pkts(sta) \
305 (sta->sta_stats.last_rx_probereq_pkts)
306
307#define sta_rx_probersp_pkts(sta) \
308 (sta->sta_stats.rx_probersp_pkts)
309
310#define sta_last_rx_probersp_pkts(sta) \
311 (sta->sta_stats.last_rx_probersp_pkts)
312
313#define sta_rx_probersp_bm_pkts(sta) \
314 (sta->sta_stats.rx_probersp_bm_pkts)
315
316#define sta_last_rx_probersp_bm_pkts(sta) \
317 (sta->sta_stats.last_rx_probersp_bm_pkts)
318
319#define sta_rx_probersp_uo_pkts(sta) \
320 (sta->sta_stats.rx_probersp_uo_pkts)
321
322#define sta_last_rx_probersp_uo_pkts(sta) \
323 (sta->sta_stats.last_rx_probersp_uo_pkts)
324
325#define sta_update_last_rx_pkts(sta) \
326 do { \
327 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
328 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
329 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
330 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
331 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
332 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
333 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
334 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
335 } while(0)
336
337#define STA_RX_PKTS_ARG(sta) \
338 sta->sta_stats.rx_mgnt_pkts \
339 , sta->sta_stats.rx_ctrl_pkts \
340 , sta->sta_stats.rx_data_pkts
341
342#define STA_LAST_RX_PKTS_ARG(sta) \
343 sta->sta_stats.last_rx_mgnt_pkts \
344 , sta->sta_stats.last_rx_ctrl_pkts \
345 , sta->sta_stats.last_rx_data_pkts
346
347#define STA_RX_PKTS_DIFF_ARG(sta) \
348 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
349 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
350 , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
351
352#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
353
354struct sta_priv {
355
356 u8 *pallocated_stainfo_buf;
357 u8 *pstainfo_buf;
358 _queue free_sta_queue;
359
360 _lock sta_hash_lock;
361 _list sta_hash[NUM_STA];
362 int asoc_sta_count;
363 _queue sleep_q;
364 _queue wakeup_q;
365
366 _adapter *padapter;
367
368
369#ifdef CONFIG_AP_MODE
370 _list asoc_list;
371 _list auth_list;
372 _lock asoc_list_lock;
373 _lock auth_list_lock;
374 u8 asoc_list_cnt;
375 u8 auth_list_cnt;
376
377 unsigned int auth_to; //sec, time to expire in authenticating.
378 unsigned int assoc_to; //sec, time to expire before associating.
379 unsigned int expire_to; //sec , time to expire after associated.
380
381 /* pointers to STA info; based on allocated AID or NULL if AID free
382 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
383 * and so on
384 */
385 struct sta_info *sta_aid[NUM_STA];
386
387 u16 sta_dz_bitmap;//only support 15 stations, staion aid bitmap for sleeping sta.
388 u16 tim_bitmap;//only support 15 stations, aid=0~15 mapping bit0~bit15
389
390 u16 max_num_sta;
391
392 struct wlan_acl_pool acl_list;
393#endif
394
395};
396
397
1130c632 398__inline static u32 wifi_mac_hash(const u8 *mac)
abb3b3dc 399{
400 u32 x;
401
402 x = mac[0];
403 x = (x << 2) ^ mac[1];
404 x = (x << 2) ^ mac[2];
405 x = (x << 2) ^ mac[3];
406 x = (x << 2) ^ mac[4];
407 x = (x << 2) ^ mac[5];
408
409 x ^= x >> 8;
410 x = x & (NUM_STA - 1);
411
412 return x;
413}
414
415
416extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
417extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
418
419#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
420int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
421struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
422
423extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
424extern u32 rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
425extern void rtw_free_all_stainfo(_adapter *padapter);
1130c632 426extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, const u8 *hwaddr);
abb3b3dc 427extern u32 rtw_init_bcmc_stainfo(_adapter* padapter);
428extern struct sta_info* rtw_get_bcmc_stainfo(_adapter* padapter);
429extern u8 rtw_access_ctrl(_adapter *padapter, u8 *mac_addr);
430
431#endif //_STA_INFO_H_