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 ******************************************************************************/
18 #include <osdep_service.h>
19 #include <drv_types.h>
22 #define IBSS_START_MAC_ID 2
26 /* if mode ==0, then the sta is allowed once the addr is hit. */
27 /* if mode ==1, then the sta is rejected once the addr is non-hit. */
28 struct rtw_wlan_acl_node {
29 struct list_head list;
35 /* mode=1, accept unless in deny list */
36 /* mode=2, deny unless in accept list */
37 struct wlan_acl_pool {
40 struct rtw_wlan_acl_node aclnode[NUM_ACL];
41 struct __queue acl_node_q;
45 s32 UndecoratedSmoothedPWDB;
46 s32 UndecoratedSmoothedCCK;
47 s32 UndecoratedSmoothedOFDM;
52 struct stainfo_stats {
57 u64 rx_probersp_bm_pkts;
58 u64 rx_probersp_uo_pkts;
62 u64 last_rx_mgnt_pkts;
63 u64 last_rx_beacon_pkts;
64 u64 last_rx_probereq_pkts;
65 u64 last_rx_probersp_pkts;
66 u64 last_rx_probersp_bm_pkts;
67 u64 last_rx_probersp_uo_pkts;
68 u64 last_rx_ctrl_pkts;
69 u64 last_rx_data_pkts;
79 struct list_head list; /* free_sta_queue */
80 struct list_head hash_list; /* sta_hash */
82 struct sta_xmit_priv sta_xmitpriv;
83 struct sta_recv_priv sta_recvpriv;
85 struct __queue sleep_q;
86 unsigned int sleepq_len;
94 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
95 uint dot118021XPrivacy; /* aes, tkip... */
96 union Keytype dot11tkiptxmickey;
97 union Keytype dot11tkiprxmickey;
98 union Keytype dot118021x_UncstKey;
99 union pn48 dot11txpn; /* PN48 used for Unicast xmit. */
100 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
111 u8 wireless_mode; /* NETWORK_TYPE */
112 struct stainfo_stats sta_stats;
114 /* for A-MPDU TX, ADDBA timeout check */
115 struct timer_list addba_retry_timer;
117 /* for A-MPDU Rx reordering buffer control */
118 struct recv_reorder_ctrl recvreorder_ctrl[16];
121 /* unsigned char ampdu_txen_bitmap; */
122 u16 BA_starting_seqctrl[16];
124 struct ht_priv htpriv;
128 /* curr_network(mlme_priv/security_priv/qos/ht) +
129 * sta_info: (STA & AP) CAP/INFO */
130 /* scan_q: AP CAP/INFO */
133 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
134 /* sta_info: (AP & STA) CAP/INFO */
136 struct list_head asoc_list;
137 #ifdef CONFIG_88EU_AP_MODE
138 struct list_head auth_list;
140 unsigned int expire_to;
141 unsigned int auth_seq;
142 unsigned int authalg;
143 unsigned char chg_txt[128];
148 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
149 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
150 int wpa_group_cipher;
151 int wpa2_group_cipher;
152 int wpa_pairwise_cipher;
153 int wpa2_pairwise_cipher;
155 u8 bpairwise_key_installed;
160 u8 no_short_slot_time_set;
161 u8 no_short_preamble_set;
166 unsigned int tx_ra_bitmap;
170 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
176 unsigned int sleepq_ac_len;
177 #endif /* CONFIG_88EU_AP_MODE */
179 u8 under_exist_checking;
180 u8 keep_alive_trycnt;
183 struct rssi_sta rssi_stat;
185 /* ================ODM Relative Info======================= */
186 /* Please be careful, don't declare too much structure here.
187 * It will cost memory * STA support num. */
188 /* 2011/10/20 MH Add for ODM STA info. */
190 u8 bValid; /* record the sta status link or not? */
191 u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */
192 u8 rssi_level; /* for Refresh RA mask */
194 /* 1 PHY_STATUS_INFO */
195 u8 RSSI_Path[4]; /* */
200 /* ================ODM Relative Info======================= */
203 /* To store the sequence number of received management frame */
204 u16 RxMgmtFrameSeqNum;
207 #define sta_rx_pkts(sta) \
208 (sta->sta_stats.rx_mgnt_pkts \
209 + sta->sta_stats.rx_ctrl_pkts \
210 + sta->sta_stats.rx_data_pkts)
212 #define sta_last_rx_pkts(sta) \
213 (sta->sta_stats.last_rx_mgnt_pkts \
214 + sta->sta_stats.last_rx_ctrl_pkts \
215 + sta->sta_stats.last_rx_data_pkts)
217 #define sta_rx_data_pkts(sta) \
218 (sta->sta_stats.rx_data_pkts)
220 #define sta_last_rx_data_pkts(sta) \
221 (sta->sta_stats.last_rx_data_pkts)
223 #define sta_rx_mgnt_pkts(sta) \
224 (sta->sta_stats.rx_mgnt_pkts)
226 #define sta_last_rx_mgnt_pkts(sta) \
227 (sta->sta_stats.last_rx_mgnt_pkts)
229 #define sta_rx_beacon_pkts(sta) \
230 (sta->sta_stats.rx_beacon_pkts)
232 #define sta_last_rx_beacon_pkts(sta) \
233 (sta->sta_stats.last_rx_beacon_pkts)
235 #define sta_rx_probereq_pkts(sta) \
236 (sta->sta_stats.rx_probereq_pkts)
238 #define sta_last_rx_probereq_pkts(sta) \
239 (sta->sta_stats.last_rx_probereq_pkts)
241 #define sta_rx_probersp_pkts(sta) \
242 (sta->sta_stats.rx_probersp_pkts)
244 #define sta_last_rx_probersp_pkts(sta) \
245 (sta->sta_stats.last_rx_probersp_pkts)
247 #define sta_rx_probersp_bm_pkts(sta) \
248 (sta->sta_stats.rx_probersp_bm_pkts)
250 #define sta_last_rx_probersp_bm_pkts(sta) \
251 (sta->sta_stats.last_rx_probersp_bm_pkts)
253 #define sta_rx_probersp_uo_pkts(sta) \
254 (sta->sta_stats.rx_probersp_uo_pkts)
256 #define sta_last_rx_probersp_uo_pkts(sta) \
257 (sta->sta_stats.last_rx_probersp_uo_pkts)
259 #define sta_update_last_rx_pkts(sta) \
261 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
262 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
263 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
264 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
265 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
266 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
267 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
268 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
271 #define STA_RX_PKTS_ARG(sta) \
272 sta->sta_stats.rx_mgnt_pkts \
273 , sta->sta_stats.rx_ctrl_pkts \
274 , sta->sta_stats.rx_data_pkts
276 #define STA_LAST_RX_PKTS_ARG(sta) \
277 sta->sta_stats.last_rx_mgnt_pkts \
278 , sta->sta_stats.last_rx_ctrl_pkts \
279 , sta->sta_stats.last_rx_data_pkts
281 #define STA_RX_PKTS_DIFF_ARG(sta) \
282 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
283 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
284 , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
286 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
289 u8 *pallocated_stainfo_buf;
291 struct __queue free_sta_queue;
293 spinlock_t sta_hash_lock;
294 struct list_head sta_hash[NUM_STA];
296 struct __queue sleep_q;
297 struct __queue wakeup_q;
299 struct adapter *padapter;
301 spinlock_t asoc_list_lock;
302 struct list_head asoc_list;
304 #ifdef CONFIG_88EU_AP_MODE
305 struct list_head auth_list;
306 spinlock_t auth_list_lock;
310 unsigned int auth_to; /* sec, time to expire in authenticating. */
311 unsigned int assoc_to; /* sec, time to expire before associating. */
312 unsigned int expire_to; /* sec , time to expire after associated. */
314 /* pointers to STA info; based on allocated AID or NULL if AID free
315 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
318 struct sta_info *sta_aid[NUM_STA];
320 u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
321 * for sleeping sta. */
322 u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping
327 struct wlan_acl_pool acl_list;
332 static inline u32 wifi_mac_hash(u8 *mac)
337 x = (x << 2) ^ mac[1];
338 x = (x << 2) ^ mac[2];
339 x = (x << 2) ^ mac[3];
340 x = (x << 2) ^ mac[4];
341 x = (x << 2) ^ mac[5];
344 x = x & (NUM_STA - 1);
348 u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
349 u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
351 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
352 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
353 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off);
355 struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
356 u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta);
357 void rtw_free_all_stainfo(struct adapter *adapt);
358 struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
359 u32 rtw_init_bcmc_stainfo(struct adapter *adapt);
360 struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
361 u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
363 #endif /* _STA_INFO_H_ */