1
2
3
4#ifndef __STA_INFO_H_
5#define __STA_INFO_H_
6
7#include "osdep_service.h"
8#include "drv_types.h"
9#include "wifi.h"
10
11#define IBSS_START_MAC_ID 2
12#define NUM_STA 32
13#define NUM_ACL 16
14
15
16
17struct rtw_wlan_acl_node {
18 struct list_head list;
19 u8 addr[ETH_ALEN];
20 u8 valid;
21};
22
23
24
25
26struct wlan_acl_pool {
27 int mode;
28 int num;
29 struct rtw_wlan_acl_node aclnode[NUM_ACL];
30 struct __queue acl_node_q;
31};
32
33struct rssi_sta {
34 s32 UndecoratedSmoothedPWDB;
35 s32 UndecoratedSmoothedCCK;
36 s32 UndecoratedSmoothedOFDM;
37 u64 PacketMap;
38 u8 ValidBit;
39};
40
41struct stainfo_stats {
42 u64 rx_mgnt_pkts;
43 u64 rx_beacon_pkts;
44 u64 rx_probereq_pkts;
45 u64 rx_probersp_pkts;
46 u64 rx_probersp_bm_pkts;
47 u64 rx_probersp_uo_pkts;
48 u64 rx_ctrl_pkts;
49 u64 rx_data_pkts;
50
51 u64 last_rx_mgnt_pkts;
52 u64 last_rx_beacon_pkts;
53 u64 last_rx_probereq_pkts;
54 u64 last_rx_probersp_pkts;
55 u64 last_rx_probersp_bm_pkts;
56 u64 last_rx_probersp_uo_pkts;
57 u64 last_rx_ctrl_pkts;
58 u64 last_rx_data_pkts;
59 u64 rx_bytes;
60 u64 rx_drops;
61 u64 tx_pkts;
62 u64 tx_bytes;
63 u64 tx_drops;
64};
65
66struct sta_info {
67 spinlock_t lock;
68 struct list_head list;
69 struct list_head hash_list;
70
71 struct sta_xmit_priv sta_xmitpriv;
72 struct sta_recv_priv sta_recvpriv;
73
74 struct __queue sleep_q;
75 unsigned int sleepq_len;
76
77 uint state;
78 uint aid;
79 uint mac_id;
80 uint qos_option;
81 u8 hwaddr[ETH_ALEN];
82
83 uint ieee8021x_blocked;
84 uint dot118021XPrivacy;
85 union Keytype dot11tkiptxmickey;
86 union Keytype dot11tkiprxmickey;
87 union Keytype dot118021x_UncstKey;
88 union pn48 dot11txpn;
89 union pn48 dot11rxpn;
90 u8 bssrateset[16];
91 u32 bssratelen;
92 s32 rssi;
93 s32 signal_quality;
94
95 u8 cts2self;
96 u8 rtsen;
97
98 u8 raid;
99 u8 init_rate;
100 u32 ra_mask;
101 u8 wireless_mode;
102 struct stainfo_stats sta_stats;
103
104
105 struct timer_list addba_retry_timer;
106
107
108 struct recv_reorder_ctrl recvreorder_ctrl[16];
109
110
111
112 u16 BA_starting_seqctrl[16];
113
114 struct ht_priv htpriv;
115
116
117
118
119
120
121
122
123
124
125
126 struct list_head asoc_list;
127#ifdef CONFIG_88EU_AP_MODE
128 struct list_head auth_list;
129
130 unsigned int expire_to;
131 unsigned int auth_seq;
132 unsigned int authalg;
133 unsigned char chg_txt[128];
134
135 u16 capability;
136 int flags;
137
138 int dot8021xalg;
139 int wpa_psk;
140 int wpa_group_cipher;
141 int wpa2_group_cipher;
142 int wpa_pairwise_cipher;
143 int wpa2_pairwise_cipher;
144
145 u8 bpairwise_key_installed;
146
147 u8 wpa_ie[32];
148
149 u8 nonerp_set;
150 u8 no_short_slot_time_set;
151 u8 no_short_preamble_set;
152 u8 no_ht_gf_set;
153 u8 no_ht_set;
154 u8 ht_20mhz_set;
155
156 unsigned int tx_ra_bitmap;
157 u8 qos_info;
158
159 u8 max_sp_len;
160 u8 uapsd_bk;
161 u8 uapsd_be;
162 u8 uapsd_vi;
163 u8 uapsd_vo;
164
165 u8 has_legacy_ac;
166 unsigned int sleepq_ac_len;
167#endif
168
169#ifdef CONFIG_88EU_P2P
170
171 u8 is_p2p_device;
172 u8 p2p_status_code;
173
174
175 u8 dev_addr[ETH_ALEN];
176 u8 dev_cap;
177 u16 config_methods;
178 u8 primary_dev_type[8];
179 u8 num_of_secdev_type;
180 u8 secdev_types_list[32];
181 u16 dev_name_len;
182 u8 dev_name[32];
183#endif
184 u8 under_exist_checking;
185 u8 keep_alive_trycnt;
186
187
188 struct rssi_sta rssi_stat;
189
190
191
192
193
194
195 u8 bValid;
196 u8 IOTPeer;
197 u8 rssi_level;
198
199
200 u8 RSSI_Path[4];
201 u8 RSSI_Ave;
202 u8 RXEVM[4];
203 u8 RXSNR[4];
204
205
206
207
208
209 u16 RxMgmtFrameSeqNum;
210};
211
212#define sta_rx_pkts(sta) \
213 (sta->sta_stats.rx_mgnt_pkts \
214 + sta->sta_stats.rx_ctrl_pkts \
215 + sta->sta_stats.rx_data_pkts)
216
217#define sta_last_rx_pkts(sta) \
218 (sta->sta_stats.last_rx_mgnt_pkts \
219 + sta->sta_stats.last_rx_ctrl_pkts \
220 + sta->sta_stats.last_rx_data_pkts)
221
222#define sta_rx_data_pkts(sta) \
223 (sta->sta_stats.rx_data_pkts)
224
225#define sta_last_rx_data_pkts(sta) \
226 (sta->sta_stats.last_rx_data_pkts)
227
228#define sta_rx_mgnt_pkts(sta) \
229 (sta->sta_stats.rx_mgnt_pkts)
230
231#define sta_last_rx_mgnt_pkts(sta) \
232 (sta->sta_stats.last_rx_mgnt_pkts)
233
234#define sta_rx_beacon_pkts(sta) \
235 (sta->sta_stats.rx_beacon_pkts)
236
237#define sta_last_rx_beacon_pkts(sta) \
238 (sta->sta_stats.last_rx_beacon_pkts)
239
240#define sta_rx_probereq_pkts(sta) \
241 (sta->sta_stats.rx_probereq_pkts)
242
243#define sta_last_rx_probereq_pkts(sta) \
244 (sta->sta_stats.last_rx_probereq_pkts)
245
246#define sta_rx_probersp_pkts(sta) \
247 (sta->sta_stats.rx_probersp_pkts)
248
249#define sta_last_rx_probersp_pkts(sta) \
250 (sta->sta_stats.last_rx_probersp_pkts)
251
252#define sta_rx_probersp_bm_pkts(sta) \
253 (sta->sta_stats.rx_probersp_bm_pkts)
254
255#define sta_last_rx_probersp_bm_pkts(sta) \
256 (sta->sta_stats.last_rx_probersp_bm_pkts)
257
258#define sta_rx_probersp_uo_pkts(sta) \
259 (sta->sta_stats.rx_probersp_uo_pkts)
260
261#define sta_last_rx_probersp_uo_pkts(sta) \
262 (sta->sta_stats.last_rx_probersp_uo_pkts)
263
264#define sta_update_last_rx_pkts(sta) \
265do { \
266 sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
267 sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
268 sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
269 sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
270 sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
271 sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
272 sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
273 sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
274} while (0)
275
276#define STA_RX_PKTS_ARG(sta) \
277 sta->sta_stats.rx_mgnt_pkts \
278 , sta->sta_stats.rx_ctrl_pkts \
279 , sta->sta_stats.rx_data_pkts
280
281#define STA_LAST_RX_PKTS_ARG(sta) \
282 sta->sta_stats.last_rx_mgnt_pkts \
283 , sta->sta_stats.last_rx_ctrl_pkts \
284 , sta->sta_stats.last_rx_data_pkts
285
286#define STA_RX_PKTS_DIFF_ARG(sta) \
287 sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
288 , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
289 , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
290
291#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
292
293struct sta_priv {
294 u8 *pallocated_stainfo_buf;
295 u8 *pstainfo_buf;
296 struct __queue free_sta_queue;
297
298 spinlock_t sta_hash_lock;
299 struct list_head sta_hash[NUM_STA];
300 int asoc_sta_count;
301 struct __queue sleep_q;
302 struct __queue wakeup_q;
303
304 struct adapter *padapter;
305
306 spinlock_t asoc_list_lock;
307 struct list_head asoc_list;
308
309#ifdef CONFIG_88EU_AP_MODE
310 struct list_head auth_list;
311 spinlock_t auth_list_lock;
312 u8 asoc_list_cnt;
313 u8 auth_list_cnt;
314
315 unsigned int auth_to;
316 unsigned int assoc_to;
317 unsigned int expire_to;
318
319
320
321
322
323 struct sta_info *sta_aid[NUM_STA];
324
325 u16 sta_dz_bitmap;
326
327 u16 tim_bitmap;
328
329
330 u16 max_num_sta;
331
332 struct wlan_acl_pool acl_list;
333#endif
334
335};
336
337static inline u32 wifi_mac_hash(u8 *mac)
338{
339 u32 x;
340
341 x = mac[0];
342 x = (x << 2) ^ mac[1];
343 x = (x << 2) ^ mac[2];
344 x = (x << 2) ^ mac[3];
345 x = (x << 2) ^ mac[4];
346 x = (x << 2) ^ mac[5];
347
348 x ^= x >> 8;
349 x = x & (NUM_STA - 1);
350 return x;
351}
352
353extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv);
354extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv);
355
356#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
357int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
358struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off);
359
360extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
361extern u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta);
362extern void rtw_free_all_stainfo(struct adapter *adapt);
363extern struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr);
364extern u32 rtw_init_bcmc_stainfo(struct adapter *adapt);
365extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter);
366extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr);
367
368#endif
369