1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 ******************************************************************************/
19 #define IBSS_START_MAC_ID 2
24 /* if mode == 0, then the sta is allowed once the addr is hit. */
25 /* if mode == 1, then the sta is rejected once the addr is non-hit. */
26 struct rtw_wlan_acl_node {
27 struct list_head list;
32 /* mode = 0, disable */
33 /* mode = 1, accept unless in deny list */
34 /* mode =2, deny unless in accept list */
35 struct wlan_acl_pool {
38 struct rtw_wlan_acl_node aclnode[NUM_ACL];
39 struct __queue acl_node_q;
42 typedef struct _RSSI_STA{
43 s32 UndecoratedSmoothedPWDB;
44 s32 UndecoratedSmoothedCCK;
45 s32 UndecoratedSmoothedOFDM;
48 }RSSI_STA, *PRSSI_STA;
50 struct stainfo_stats {
56 u64 rx_probersp_bm_pkts;
57 u64 rx_probersp_uo_pkts;
61 u64 last_rx_mgnt_pkts;
62 u64 last_rx_beacon_pkts;
63 u64 last_rx_probereq_pkts;
64 u64 last_rx_probersp_pkts;
65 u64 last_rx_probersp_bm_pkts;
66 u64 last_rx_probersp_uo_pkts;
67 u64 last_rx_ctrl_pkts;
68 u64 last_rx_data_pkts;
81 struct list_head list; /* free_sta_queue */
82 struct list_head hash_list; /* sta_hash */
83 struct adapter *padapter;
85 struct sta_xmit_priv sta_xmitpriv;
86 struct sta_recv_priv sta_recvpriv;
88 struct __queue sleep_q;
89 unsigned int sleepq_len;
97 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
98 uint dot118021XPrivacy; /* aes, tkip... */
99 union Keytype dot11tkiptxmickey;
100 union Keytype dot11tkiprxmickey;
101 union Keytype dot118021x_UncstKey;
102 union pn48 dot11txpn; /* PN48 used for Unicast xmit */
106 u8 replay_ctr[RTW_REPLAY_CTR_LEN];
107 #endif /* CONFIG_GTK_OL */
108 union pn48 dot11wtxpn; /* PN48 used for Unicast mgmt xmit. */
109 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
123 u8 wireless_mode; /* NETWORK_TYPE */
129 struct stainfo_stats sta_stats;
131 /* for A-MPDU TX, ADDBA timeout check */
132 _timer addba_retry_timer;
134 /* for A-MPDU Rx reordering buffer control */
135 struct recv_reorder_ctrl recvreorder_ctrl[16];
138 /* unsigned char ampdu_txen_bitmap; */
139 u16 BA_starting_seqctrl[16];
142 struct ht_priv htpriv;
146 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
147 /* scan_q: AP CAP/INFO */
150 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
151 /* sta_info: (AP & STA) CAP/INFO */
153 struct list_head asoc_list;
154 struct list_head auth_list;
156 unsigned int expire_to;
157 unsigned int auth_seq;
158 unsigned int authalg;
159 unsigned char chg_txt[128];
164 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
165 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
166 int wpa_group_cipher;
167 int wpa2_group_cipher;
168 int wpa_pairwise_cipher;
169 int wpa2_pairwise_cipher;
171 u8 bpairwise_key_installed;
176 u8 no_short_slot_time_set;
177 u8 no_short_preamble_set;
182 unsigned int tx_ra_bitmap;
186 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
192 unsigned int sleepq_ac_len;
194 u8 under_exist_checking;
196 u8 keep_alive_trycnt;
198 #ifdef CONFIG_AUTO_AP_MODE
199 u8 isrc; /* this device is rc */
200 u16 pid; /* pairing id */
210 /* ================ODM Relative Info ======================= */
211 /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
214 /* 2011/10/20 MH Add for ODM STA info. */
217 u8 bValid; /* record the sta status link or not? */
218 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
220 /* 1 PHY_STATUS_INFO */
221 u8 RSSI_Path[4]; /* */
226 u8 rssi_level; /* for Refresh RA mask */
228 /* 1 TX_INFO (may changed by IC) */
229 /* TX_INFO_T pTxInfo; Define in IC folder. Move lower layer. */
231 /* ================ODM Relative Info ======================= */
234 /* To store the sequence number of received management frame */
235 u16 RxMgmtFrameSeqNum;
238 #define sta_rx_pkts(sta) \
239 (sta->sta_stats.rx_mgnt_pkts \
240 + sta->sta_stats.rx_ctrl_pkts \
241 + sta->sta_stats.rx_data_pkts)
243 #define sta_last_rx_pkts(sta) \
244 (sta->sta_stats.last_rx_mgnt_pkts \
245 + sta->sta_stats.last_rx_ctrl_pkts \
246 + sta->sta_stats.last_rx_data_pkts)
248 #define sta_rx_data_pkts(sta) \
249 (sta->sta_stats.rx_data_pkts)
251 #define sta_last_rx_data_pkts(sta) \
252 (sta->sta_stats.last_rx_data_pkts)
254 #define sta_rx_mgnt_pkts(sta) \
255 (sta->sta_stats.rx_mgnt_pkts)
257 #define sta_last_rx_mgnt_pkts(sta) \
258 (sta->sta_stats.last_rx_mgnt_pkts)
260 #define sta_rx_beacon_pkts(sta) \
261 (sta->sta_stats.rx_beacon_pkts)
263 #define sta_last_rx_beacon_pkts(sta) \
264 (sta->sta_stats.last_rx_beacon_pkts)
266 #define sta_rx_probereq_pkts(sta) \
267 (sta->sta_stats.rx_probereq_pkts)
269 #define sta_last_rx_probereq_pkts(sta) \
270 (sta->sta_stats.last_rx_probereq_pkts)
272 #define sta_rx_probersp_pkts(sta) \
273 (sta->sta_stats.rx_probersp_pkts)
275 #define sta_last_rx_probersp_pkts(sta) \
276 (sta->sta_stats.last_rx_probersp_pkts)
278 #define sta_rx_probersp_bm_pkts(sta) \
279 (sta->sta_stats.rx_probersp_bm_pkts)
281 #define sta_last_rx_probersp_bm_pkts(sta) \
282 (sta->sta_stats.last_rx_probersp_bm_pkts)
284 #define sta_rx_probersp_uo_pkts(sta) \
285 (sta->sta_stats.rx_probersp_uo_pkts)
287 #define sta_last_rx_probersp_uo_pkts(sta) \
288 (sta->sta_stats.last_rx_probersp_uo_pkts)
290 #define sta_update_last_rx_pkts(sta) \
292 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
293 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
294 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
295 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
296 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
297 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
298 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
299 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
302 #define STA_RX_PKTS_ARG(sta) \
303 sta->sta_stats.rx_mgnt_pkts \
304 , sta->sta_stats.rx_ctrl_pkts \
305 , sta->sta_stats.rx_data_pkts
307 #define STA_LAST_RX_PKTS_ARG(sta) \
308 sta->sta_stats.last_rx_mgnt_pkts \
309 , sta->sta_stats.last_rx_ctrl_pkts \
310 , sta->sta_stats.last_rx_data_pkts
312 #define STA_RX_PKTS_DIFF_ARG(sta) \
313 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
314 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
315 , sta->sta_stats.rx_data_pkts -sta->sta_stats.last_rx_data_pkts
317 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
321 u8 *pallocated_stainfo_buf;
323 struct __queue free_sta_queue;
326 struct list_head sta_hash[NUM_STA];
328 struct __queue sleep_q;
329 struct __queue wakeup_q;
331 struct adapter *padapter;
333 struct list_head asoc_list;
334 struct list_head auth_list;
335 _lock asoc_list_lock;
336 _lock auth_list_lock;
340 unsigned int auth_to; /* sec, time to expire in authenticating. */
341 unsigned int assoc_to; /* sec, time to expire before associating. */
342 unsigned int expire_to; /* sec , time to expire after associated. */
344 /* pointers to STA info; based on allocated AID or NULL if AID free
345 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
348 struct sta_info *sta_aid[NUM_STA];
350 u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
351 u16 tim_bitmap;/* only support 15 stations, aid = 0~15 mapping bit0~bit15 */
355 struct wlan_acl_pool acl_list;
359 __inline static u32 wifi_mac_hash(u8 *mac)
364 x = (x << 2) ^ mac[1];
365 x = (x << 2) ^ mac[2];
366 x = (x << 2) ^ mac[3];
367 x = (x << 2) ^ mac[4];
368 x = (x << 2) ^ mac[5];
371 x = x & (NUM_STA - 1);
377 extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
378 extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
380 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
381 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
382 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
384 extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
385 extern u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta);
386 extern void rtw_free_all_stainfo(struct adapter *padapter);
387 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
388 extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter);
389 extern struct sta_info* rtw_get_bcmc_stainfo(struct adapter *padapter);
390 extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
392 #endif /* _STA_INFO_H_ */