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