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
27 /* if mode ==0, then the sta is allowed once the addr is hit. */
28 /* if mode ==1, then the sta is rejected once the addr is non-hit. */
29 struct rtw_wlan_acl_node {
30 struct list_head list;
36 /* mode=1, accept unless in deny list */
37 /* mode=2, deny unless in accept list */
38 struct wlan_acl_pool {
41 struct rtw_wlan_acl_node aclnode[NUM_ACL];
42 struct rtw_queue acl_node_q;
46 s32 UndecoratedSmoothedPWDB;
47 s32 UndecoratedSmoothedCCK;
48 s32 UndecoratedSmoothedOFDM;
53 struct stainfo_stats {
58 u64 rx_probersp_bm_pkts;
59 u64 rx_probersp_uo_pkts;
63 u64 last_rx_mgnt_pkts;
64 u64 last_rx_beacon_pkts;
65 u64 last_rx_probereq_pkts;
66 u64 last_rx_probersp_pkts;
67 u64 last_rx_probersp_bm_pkts;
68 u64 last_rx_probersp_uo_pkts;
69 u64 last_rx_ctrl_pkts;
70 u64 last_rx_data_pkts;
83 struct list_head list; /* free_sta_queue */
84 struct list_head hash_list; /* sta_hash */
85 struct rtw_adapter *padapter;
87 struct sta_xmit_priv sta_xmitpriv;
88 struct sta_recv_priv sta_recvpriv;
90 struct rtw_queue sleep_q;
91 unsigned int sleepq_len;
99 uint ieee8021x_blocked; /* 0: allowed, 1:blocked */
100 u32 dot118021XPrivacy; /* aes, tkip... */
101 union Keytype dot11tkiptxmickey;
102 union Keytype dot11tkiprxmickey;
103 union Keytype dot118021x_UncstKey;
104 union pn48 dot11txpn; /* PN48 used for Unicast xmit. */
105 union pn48 dot11rxpn; /* PN48 used for Unicast recv. */
119 u8 wireless_mode; /* NETWORK_TYPE */
120 struct stainfo_stats sta_stats;
122 /* for A-MPDU TX, ADDBA timeout check */
123 struct timer_list addba_retry_timer;
125 /* for A-MPDU Rx reordering buffer control */
126 struct recv_reorder_ctrl recvreorder_ctrl[16];
129 /* unsigned char ampdu_txen_bitmap; */
130 u16 BA_starting_seqctrl[16];
132 struct ht_priv htpriv;
136 /* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO */
137 /* scan_q: AP CAP/INFO */
140 /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
141 /* sta_info: (AP & STA) CAP/INFO */
143 struct list_head asoc_list;
144 struct list_head auth_list;
146 unsigned int expire_to;
147 unsigned int auth_seq;
148 unsigned int authalg;
149 unsigned char chg_txt[128];
154 int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
155 int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
156 int wpa_group_cipher;
157 int wpa2_group_cipher;
158 int wpa_pairwise_cipher;
159 int wpa2_pairwise_cipher;
161 u8 bpairwise_key_installed;
166 u8 no_short_slot_time_set;
167 u8 no_short_preamble_set;
172 unsigned int tx_ra_bitmap;
176 u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
182 unsigned int sleepq_ac_len;
188 u8 keep_alive_trycnt;
190 /* p2p client info */
191 u8 dev_addr[ETH_ALEN];
194 u8 primary_dev_type[8];
195 u8 num_of_secdev_type;
196 u8 secdev_types_list[32];/* 32/8 == 4; */
203 struct rssi_sta rssi_stat;
206 /* ================ODM Relative Info======================= */
207 /* Please be care, dont declare too much structure here. It will cost memory * STA support num. */
210 /* 2011/10/20 MH Add for ODM STA info. */
213 u8 bValid; /* record the sta status link or not? */
214 u8 rssi_level; /* for Refresh RA mask */
216 /* 1 PHY_STATUS_INFO */
217 u8 RSSI_Path[4]; /* */
223 /* 1 TX_INFO (may changed by IC) */
224 /* ================ODM Relative Info======================= */
227 /* To store the sequence number of received management frame */
228 u16 RxMgmtFrameSeqNum;
231 #define sta_rx_pkts(sta) \
232 (sta->sta_stats.rx_mgnt_pkts \
233 + sta->sta_stats.rx_ctrl_pkts \
234 + sta->sta_stats.rx_data_pkts)
236 #define sta_last_rx_pkts(sta) \
237 (sta->sta_stats.last_rx_mgnt_pkts \
238 + sta->sta_stats.last_rx_ctrl_pkts \
239 + sta->sta_stats.last_rx_data_pkts)
241 #define sta_rx_data_pkts(sta) \
242 (sta->sta_stats.rx_data_pkts)
244 #define sta_last_rx_data_pkts(sta) \
245 (sta->sta_stats.last_rx_data_pkts)
247 #define sta_rx_mgnt_pkts(sta) \
248 (sta->sta_stats.rx_mgnt_pkts)
250 #define sta_last_rx_mgnt_pkts(sta) \
251 (sta->sta_stats.last_rx_mgnt_pkts)
253 #define sta_rx_beacon_pkts(sta) \
254 (sta->sta_stats.rx_beacon_pkts)
256 #define sta_last_rx_beacon_pkts(sta) \
257 (sta->sta_stats.last_rx_beacon_pkts)
259 #define sta_rx_probereq_pkts(sta) \
260 (sta->sta_stats.rx_probereq_pkts)
262 #define sta_last_rx_probereq_pkts(sta) \
263 (sta->sta_stats.last_rx_probereq_pkts)
265 #define sta_rx_probersp_pkts(sta) \
266 (sta->sta_stats.rx_probersp_pkts)
268 #define sta_last_rx_probersp_pkts(sta) \
269 (sta->sta_stats.last_rx_probersp_pkts)
271 #define sta_rx_probersp_bm_pkts(sta) \
272 (sta->sta_stats.rx_probersp_bm_pkts)
274 #define sta_last_rx_probersp_bm_pkts(sta) \
275 (sta->sta_stats.last_rx_probersp_bm_pkts)
277 #define sta_rx_probersp_uo_pkts(sta) \
278 (sta->sta_stats.rx_probersp_uo_pkts)
280 #define sta_last_rx_probersp_uo_pkts(sta) \
281 (sta->sta_stats.last_rx_probersp_uo_pkts)
283 #define sta_update_last_rx_pkts(sta) \
285 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
286 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
287 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
288 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
289 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
290 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
291 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
292 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
295 #define STA_RX_PKTS_ARG(sta) \
296 sta->sta_stats.rx_mgnt_pkts \
297 , sta->sta_stats.rx_ctrl_pkts \
298 , sta->sta_stats.rx_data_pkts
300 #define STA_LAST_RX_PKTS_ARG(sta) \
301 sta->sta_stats.last_rx_mgnt_pkts, \
302 sta->sta_stats.last_rx_ctrl_pkts, \
303 sta->sta_stats.last_rx_data_pkts
305 #define STA_RX_PKTS_DIFF_ARG(sta) \
306 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts, \
307 sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts, \
308 sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
310 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
313 spinlock_t sta_hash_lock;
314 struct list_head sta_hash[NUM_STA];
317 struct rtw_adapter *padapter;
318 struct list_head asoc_list;
319 struct list_head auth_list;
320 spinlock_t asoc_list_lock;
321 spinlock_t auth_list_lock;
325 unsigned int auth_to; /* sec, time to expire in authenticating. */
326 unsigned int assoc_to; /* sec, time to expire before associating. */
327 unsigned int expire_to; /* sec , time to expire after associated. */
329 /* pointers to STA info; based on allocated AID or NULL if AID free
330 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
333 struct sta_info *sta_aid[NUM_STA];
335 u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
336 * for sleeping sta. */
337 u16 tim_bitmap;/* only support 15 stations,
338 * aid=0~15 mapping bit0~bit15 */
342 struct wlan_acl_pool acl_list;
345 static inline u32 wifi_mac_hash(const u8 *mac)
350 x = (x << 2) ^ mac[1];
351 x = (x << 2) ^ mac[2];
352 x = (x << 2) ^ mac[3];
353 x = (x << 2) ^ mac[4];
354 x = (x << 2) ^ mac[5];
357 x = x & (NUM_STA - 1);
362 int _rtw_init_sta_priv23a(struct sta_priv *pstapriv);
363 int _rtw_free_sta_priv23a(struct sta_priv *pstapriv);
365 struct sta_info *rtw_alloc_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr, gfp_t gfp);
366 int rtw_free_stainfo23a(struct rtw_adapter *padapter, struct sta_info *psta);
367 void rtw_free_all_stainfo23a(struct rtw_adapter *padapter);
368 struct sta_info *rtw_get_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr);
369 int rtw_init_bcmc_stainfo23a(struct rtw_adapter *padapter);
370 struct sta_info *rtw_get_bcmc_stainfo23a(struct rtw_adapter *padapter);
371 bool rtw_access_ctrl23a(struct rtw_adapter *padapter, u8 *mac_addr);
373 #endif /* _STA_INFO_H_ */