xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rtl8723bs/include/sta_info.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2017 Realtek Corporation.
4  *
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.
8  *
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
12  * more details.
13  *
14  *****************************************************************************/
15 #ifndef __STA_INFO_H_
16 #define __STA_INFO_H_
17 
18 #include <cmn_info/rtw_sta_info.h>
19 
20 #define IBSS_START_MAC_ID	2
21 #define NUM_STA MACID_NUM_SW_LIMIT
22 
23 #ifndef CONFIG_RTW_MACADDR_ACL
24 	#define CONFIG_RTW_MACADDR_ACL 1
25 #endif
26 
27 #ifndef CONFIG_RTW_PRE_LINK_STA
28 	#define CONFIG_RTW_PRE_LINK_STA 0
29 #endif
30 
31 #define NUM_ACL 16
32 #define RTW_ACL_MODE_DISABLED				0
33 #define RTW_ACL_MODE_ACCEPT_UNLESS_LISTED	1
34 #define RTW_ACL_MODE_DENY_UNLESS_LISTED		2
35 #define RTW_ACL_MODE_MAX					3
36 
37 #if CONFIG_RTW_MACADDR_ACL
38 extern const char *const _acl_mode_str[];
39 #define acl_mode_str(mode) (((mode) >= RTW_ACL_MODE_MAX) ? _acl_mode_str[RTW_ACL_MODE_DISABLED] : _acl_mode_str[(mode)])
40 #endif
41 
42 #ifndef RTW_PRE_LINK_STA_NUM
43 	#define RTW_PRE_LINK_STA_NUM 8
44 #endif
45 
46 struct pre_link_sta_node_t {
47 	u8 valid;
48 	u8 addr[ETH_ALEN];
49 };
50 
51 struct pre_link_sta_ctl_t {
52 	_lock lock;
53 	u8 num;
54 	struct pre_link_sta_node_t node[RTW_PRE_LINK_STA_NUM];
55 };
56 
57 #ifdef CONFIG_TDLS
58 #define MAX_ALLOWED_TDLS_STA_NUM	4
59 #endif
60 
61 enum sta_info_update_type {
62 	STA_INFO_UPDATE_NONE = 0,
63 	STA_INFO_UPDATE_BW = BIT(0),
64 	STA_INFO_UPDATE_RATE = BIT(1),
65 	STA_INFO_UPDATE_PROTECTION_MODE = BIT(2),
66 	STA_INFO_UPDATE_CAP = BIT(3),
67 	STA_INFO_UPDATE_HT_CAP = BIT(4),
68 	STA_INFO_UPDATE_VHT_CAP = BIT(5),
69 	STA_INFO_UPDATE_ALL = STA_INFO_UPDATE_BW
70 			      | STA_INFO_UPDATE_RATE
71 			      | STA_INFO_UPDATE_PROTECTION_MODE
72 			      | STA_INFO_UPDATE_CAP
73 			      | STA_INFO_UPDATE_HT_CAP
74 			      | STA_INFO_UPDATE_VHT_CAP,
75 	STA_INFO_UPDATE_MAX
76 };
77 
78 struct rtw_wlan_acl_node {
79 	_list		        list;
80 	u8       addr[ETH_ALEN];
81 	u8       valid;
82 };
83 
84 struct wlan_acl_pool {
85 	int mode;
86 	int num;
87 	struct rtw_wlan_acl_node aclnode[NUM_ACL];
88 	_queue	acl_node_q;
89 };
90 
91 struct	stainfo_stats	{
92 
93 	u64 rx_mgnt_pkts;
94 		u64 rx_beacon_pkts;
95 		u64 rx_probereq_pkts;
96 		u64 rx_probersp_pkts;
97 		u64 rx_probersp_bm_pkts;
98 		u64 rx_probersp_uo_pkts;
99 	u64 rx_ctrl_pkts;
100 	u64 rx_data_pkts;
101 	u64 rx_data_last_pkts;		/* For Read & Clear requirement in proc_get_rx_stat() */
102 	u64 rx_data_qos_pkts[TID_NUM];
103 	u64	last_rx_mgnt_pkts;
104 		u64 last_rx_beacon_pkts;
105 		u64 last_rx_probereq_pkts;
106 		u64 last_rx_probersp_pkts;
107 		u64 last_rx_probersp_bm_pkts;
108 		u64 last_rx_probersp_uo_pkts;
109 	u64	last_rx_ctrl_pkts;
110 	u64	last_rx_data_pkts;
111 	u64 last_rx_data_qos_pkts[TID_NUM];
112 #ifdef CONFIG_TDLS
113 	u64 rx_tdls_disc_rsp_pkts;
114 	u64 last_rx_tdls_disc_rsp_pkts;
115 #endif
116 	u64	rx_bytes;
117 	u64	last_rx_bytes;
118 	u64	rx_drops;
119 	u16 rx_tp_mbytes;
120 
121 	u64	tx_pkts;
122 	u64	last_tx_pkts;
123 	u64	last_tx_bytes;
124 	u64	tx_bytes;
125 	u64  tx_drops;
126 
127 	u32 duplicate_cnt;	/* Read & Clear, in proc_get_rx_stat() */
128 	u32 rxratecnt[128];	/* Read & Clear, in proc_get_rx_stat() */
129 	u32 tx_ok_cnt;		/* Read & Clear, in proc_get_tx_stat() */
130 	u32 tx_fail_cnt;	/* Read & Clear, in proc_get_tx_stat() */
131 	u32 tx_retry_cnt;	/* Read & Clear, in proc_get_tx_stat() */
132 	u16 tx_tp_mbytes;
133 };
134 
135 #ifndef DBG_SESSION_TRACKER
136 #define DBG_SESSION_TRACKER 0
137 #endif
138 
139 /* session tracker status */
140 #define ST_STATUS_NONE		0
141 #define ST_STATUS_CHECK		BIT0
142 #define ST_STATUS_ESTABLISH	BIT1
143 #define ST_STATUS_EXPIRE	BIT2
144 
145 #define ST_EXPIRE_MS (10 * 1000)
146 
147 struct session_tracker {
148 	_list list; /* session_tracker_queue */
149 	u32 local_naddr;
150 	u16 local_port;
151 	u32 remote_naddr;
152 	u16 remote_port;
153 	systime set_time;
154 	u8 status;
155 };
156 
157 /* session tracker cmd */
158 #define ST_CMD_ADD 0
159 #define ST_CMD_DEL 1
160 #define ST_CMD_CHK 2
161 
162 struct st_cmd_parm {
163 	u8 cmd;
164 	struct sta_info *sta;
165 	u32 local_naddr; /* TODO: IPV6 */
166 	u16 local_port;
167 	u32 remote_naddr; /* TODO: IPV6 */
168 	u16 remote_port;
169 };
170 
171 typedef bool (*st_match_rule)(_adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
172 
173 struct st_register {
174 	u8 s_proto;
175 	st_match_rule rule;
176 };
177 
178 #define SESSION_TRACKER_REG_ID_WFD 0
179 #define SESSION_TRACKER_REG_ID_NUM 1
180 
181 struct st_ctl_t {
182 	struct st_register reg[SESSION_TRACKER_REG_ID_NUM];
183 	_queue tracker_q;
184 };
185 
186 void rtw_st_ctl_init(struct st_ctl_t *st_ctl);
187 void rtw_st_ctl_deinit(struct st_ctl_t *st_ctl);
188 void rtw_st_ctl_register(struct st_ctl_t *st_ctl, u8 st_reg_id, struct st_register *reg);
189 void rtw_st_ctl_unregister(struct st_ctl_t *st_ctl, u8 st_reg_id);
190 bool rtw_st_ctl_chk_reg_s_proto(struct st_ctl_t *st_ctl, u8 s_proto);
191 bool rtw_st_ctl_chk_reg_rule(struct st_ctl_t *st_ctl, _adapter *adapter, u8 *local_naddr, u8 *local_port, u8 *remote_naddr, u8 *remote_port);
192 void dump_st_ctl(void *sel, struct st_ctl_t *st_ctl);
193 
194 #ifdef CONFIG_TDLS
195 struct TDLS_PeerKey {
196 	u8 kck[16]; /* TPK-KCK */
197 	u8 tk[16]; /* TPK-TK; only CCMP will be used */
198 } ;
199 #endif /* CONFIG_TDLS */
200 
201 #ifdef DBG_RX_DFRAME_RAW_DATA
202 struct sta_recv_dframe_info {
203 
204 	u8 sta_data_rate;
205 	u8 sta_sgi;
206 	u8 sta_bw_mode;
207 	s8 sta_mimo_signal_strength[4];
208 	s8 sta_RxPwr[4];
209 	u8 sta_ofdm_snr[4];
210 };
211 #endif
212 
213 struct sta_info {
214 
215 	_lock	lock;
216 	_list	list; /* free_sta_queue */
217 	_list	hash_list; /* sta_hash */
218 	/* _list asoc_list; */ /* 20061114 */
219 	/* _list sleep_list; */ /* sleep_q */
220 	/* _list wakeup_list; */ /* wakeup_q */
221 	_adapter *padapter;
222 	struct cmn_sta_info cmn;
223 
224 	struct sta_xmit_priv sta_xmitpriv;
225 	struct sta_recv_priv sta_recvpriv;
226 
227 #ifdef DBG_RX_DFRAME_RAW_DATA
228 	struct sta_recv_dframe_info  sta_dframe_info;
229 #endif
230 	_queue sleep_q;
231 	unsigned int sleepq_len;
232 
233 	uint state;
234 	uint qos_option;
235 	u16 hwseq;
236 
237 	uint	ieee8021x_blocked;	/* 0: allowed, 1:blocked */
238 	uint	dot118021XPrivacy; /* aes, tkip... */
239 	union Keytype	dot11tkiptxmickey;
240 	union Keytype	dot11tkiprxmickey;
241 	union Keytype	dot118021x_UncstKey;
242 	union pn48		dot11txpn;			/* PN48 used for Unicast xmit */
243 #ifdef CONFIG_GTK_OL
244 	u8 kek[RTW_KEK_LEN];
245 	u8 kck[RTW_KCK_LEN];
246 	u8 replay_ctr[RTW_REPLAY_CTR_LEN];
247 #endif /* CONFIG_GTK_OL */
248 #ifdef CONFIG_IEEE80211W
249 	union pn48		dot11wtxpn;			/* PN48 used for Unicast mgmt xmit. */
250 	_timer dot11w_expire_timer;
251 #endif /* CONFIG_IEEE80211W */
252 	union pn48		dot11rxpn;			/* PN48 used for Unicast recv. */
253 
254 
255 	u8	bssrateset[16];
256 	u32	bssratelen;
257 
258 	u8	cts2self;
259 	u8	rtsen;
260 
261 	u8	init_rate;
262 	u8	wireless_mode;	/* NETWORK_TYPE */
263 
264 	struct stainfo_stats sta_stats;
265 
266 #ifdef CONFIG_TDLS
267 	u32	tdls_sta_state;
268 	u8	SNonce[32];
269 	u8	ANonce[32];
270 	u32	TDLS_PeerKey_Lifetime;
271 	u32	TPK_count;
272 	_timer	TPK_timer;
273 	struct TDLS_PeerKey	tpk;
274 #ifdef CONFIG_TDLS_CH_SW
275 	u16	ch_switch_time;
276 	u16	ch_switch_timeout;
277 	/* u8	option; */
278 	_timer	ch_sw_timer;
279 	_timer	delay_timer;
280 	_timer	stay_on_base_chnl_timer;
281 	_timer	ch_sw_monitor_timer;
282 #endif
283 	_timer handshake_timer;
284 	u8 alive_count;
285 	_timer	pti_timer;
286 	u8	TDLS_RSNIE[20];	/* Save peer's RSNIE, used for sending TDLS_SETUP_RSP */
287 #endif /* CONFIG_TDLS */
288 
289 	/* for A-MPDU TX, ADDBA timeout check	 */
290 	_timer addba_retry_timer;
291 
292 	/* for A-MPDU Rx reordering buffer control */
293 	struct recv_reorder_ctrl recvreorder_ctrl[TID_NUM];
294 	ATOMIC_T continual_no_rx_packet[TID_NUM];
295 	/* for A-MPDU Tx */
296 	/* unsigned char		ampdu_txen_bitmap; */
297 	u16	BA_starting_seqctrl[16];
298 
299 
300 #ifdef CONFIG_80211N_HT
301 	struct ht_priv	htpriv;
302 #endif
303 
304 #ifdef CONFIG_80211AC_VHT
305 	struct vht_priv	vhtpriv;
306 #endif
307 
308 	/* Notes:	 */
309 	/* STA_Mode: */
310 	/* curr_network(mlme_priv/security_priv/qos/ht) + sta_info: (STA & AP) CAP/INFO	 */
311 	/* scan_q: AP CAP/INFO */
312 
313 	/* AP_Mode: */
314 	/* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */
315 	/* sta_info: (AP & STA) CAP/INFO */
316 
317 	unsigned int expire_to;
318 
319 #ifdef CONFIG_AP_MODE
320 
321 	_list asoc_list;
322 	_list auth_list;
323 
324 	unsigned int auth_seq;
325 	unsigned int authalg;
326 	unsigned char chg_txt[128];
327 
328 	u16 capability;
329 	int flags;
330 
331 	int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */
332 	int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */
333 	int wpa_group_cipher;
334 	int wpa2_group_cipher;
335 	int wpa_pairwise_cipher;
336 	int wpa2_pairwise_cipher;
337 
338 	u8 bpairwise_key_installed;
339 #ifdef CONFIG_RTW_80211R
340 	u8 ft_pairwise_key_installed;
341 #endif
342 
343 #ifdef CONFIG_NATIVEAP_MLME
344 	u8 wpa_ie[32];
345 
346 	u8 nonerp_set;
347 	u8 no_short_slot_time_set;
348 	u8 no_short_preamble_set;
349 	u8 no_ht_gf_set;
350 	u8 no_ht_set;
351 	u8 ht_20mhz_set;
352 	u8 ht_40mhz_intolerant;
353 #endif /* CONFIG_NATIVEAP_MLME */
354 
355 #ifdef CONFIG_ATMEL_RC_PATCH
356 	u8 flag_atmel_rc;
357 #endif
358 
359 	u8 qos_info;
360 
361 	u8 max_sp_len;
362 	u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */
363 	u8 uapsd_be;
364 	u8 uapsd_vi;
365 	u8 uapsd_vo;
366 
367 	u8 has_legacy_ac;
368 	unsigned int sleepq_ac_len;
369 
370 #ifdef CONFIG_P2P
371 	/* p2p priv data */
372 	u8 is_p2p_device;
373 	u8 p2p_status_code;
374 
375 	/* p2p client info */
376 	u8 dev_addr[ETH_ALEN];
377 	/* u8 iface_addr[ETH_ALEN]; */ /* = hwaddr[ETH_ALEN] */
378 	u8 dev_cap;
379 	u16 config_methods;
380 	u8 primary_dev_type[8];
381 	u8 num_of_secdev_type;
382 	u8 secdev_types_list[32];/* 32/8 == 4; */
383 	u16 dev_name_len;
384 	u8 dev_name[32];
385 #endif /* CONFIG_P2P */
386 
387 #ifdef CONFIG_WFD
388 	u8 op_wfd_mode;
389 #endif
390 
391 #ifdef CONFIG_TX_MCAST2UNI
392 	u8 under_exist_checking;
393 #endif /* CONFIG_TX_MCAST2UNI */
394 
395 	u8 keep_alive_trycnt;
396 
397 #ifdef CONFIG_AUTO_AP_MODE
398 	u8 isrc; /* this device is rc */
399 	u16 pid; /* pairing id */
400 #endif
401 
402 #endif /* CONFIG_AP_MODE	 */
403 
404 #ifdef CONFIG_IOCTL_CFG80211
405 	u8 *passoc_req;
406 	u32 assoc_req_len;
407 #endif
408 
409 	u8		IOTPeer;			/* Enum value.	HT_IOT_PEER_E */
410 #ifdef CONFIG_LPS_PG
411 	u8		lps_pg_rssi_lv;
412 #endif
413 
414 	/* To store the sequence number of received management frame */
415 	u16 RxMgmtFrameSeqNum;
416 
417 	struct st_ctl_t st_ctl;
418 	u8 max_agg_num_minimal_record; /*keep minimal tx desc max_agg_num setting*/
419 	u8 curr_rx_rate;
420 };
421 
422 #define sta_tx_pkts(sta) \
423 	(sta->sta_stats.tx_pkts)
424 
425 #define sta_last_tx_pkts(sta) \
426 	(sta->sta_stats.last_tx_pkts)
427 
428 #define sta_rx_pkts(sta) \
429 	(sta->sta_stats.rx_mgnt_pkts \
430 	 + sta->sta_stats.rx_ctrl_pkts \
431 	 + sta->sta_stats.rx_data_pkts)
432 
433 #define sta_last_rx_pkts(sta) \
434 	(sta->sta_stats.last_rx_mgnt_pkts \
435 	 + sta->sta_stats.last_rx_ctrl_pkts \
436 	 + sta->sta_stats.last_rx_data_pkts)
437 
438 #define sta_rx_data_pkts(sta) \
439 	(sta->sta_stats.rx_data_pkts)
440 
441 #define sta_rx_data_qos_pkts(sta, i) \
442 	(sta->sta_stats.rx_data_qos_pkts[i])
443 
444 #define sta_last_rx_data_pkts(sta) \
445 	(sta->sta_stats.last_rx_data_pkts)
446 
447 #define sta_last_rx_data_qos_pkts(sta, i) \
448 	(sta->sta_stats.last_rx_data_qos_pkts[i])
449 
450 #define sta_rx_mgnt_pkts(sta) \
451 	(sta->sta_stats.rx_mgnt_pkts)
452 
453 #define sta_last_rx_mgnt_pkts(sta) \
454 	(sta->sta_stats.last_rx_mgnt_pkts)
455 
456 #define sta_rx_beacon_pkts(sta) \
457 	(sta->sta_stats.rx_beacon_pkts)
458 
459 #define sta_last_rx_beacon_pkts(sta) \
460 	(sta->sta_stats.last_rx_beacon_pkts)
461 
462 #define sta_rx_probereq_pkts(sta) \
463 	(sta->sta_stats.rx_probereq_pkts)
464 
465 #define sta_last_rx_probereq_pkts(sta) \
466 	(sta->sta_stats.last_rx_probereq_pkts)
467 
468 #define sta_rx_probersp_pkts(sta) \
469 	(sta->sta_stats.rx_probersp_pkts)
470 
471 #define sta_last_rx_probersp_pkts(sta) \
472 	(sta->sta_stats.last_rx_probersp_pkts)
473 
474 #define sta_rx_probersp_bm_pkts(sta) \
475 	(sta->sta_stats.rx_probersp_bm_pkts)
476 
477 #define sta_last_rx_probersp_bm_pkts(sta) \
478 	(sta->sta_stats.last_rx_probersp_bm_pkts)
479 
480 #define sta_rx_probersp_uo_pkts(sta) \
481 	(sta->sta_stats.rx_probersp_uo_pkts)
482 
483 #define sta_last_rx_probersp_uo_pkts(sta) \
484 	(sta->sta_stats.last_rx_probersp_uo_pkts)
485 
486 #define sta_update_last_rx_pkts(sta) \
487 	do { \
488 		sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \
489 		sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \
490 		sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \
491 		sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \
492 		sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \
493 		sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \
494 		sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \
495 		sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \
496 	} while (0)
497 
498 #define STA_RX_PKTS_ARG(sta) \
499 	sta->sta_stats.rx_mgnt_pkts \
500 	, sta->sta_stats.rx_ctrl_pkts \
501 	, sta->sta_stats.rx_data_pkts
502 
503 #define STA_LAST_RX_PKTS_ARG(sta) \
504 	sta->sta_stats.last_rx_mgnt_pkts \
505 	, sta->sta_stats.last_rx_ctrl_pkts \
506 	, sta->sta_stats.last_rx_data_pkts
507 
508 #define STA_RX_PKTS_DIFF_ARG(sta) \
509 	sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \
510 	, sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \
511 	, sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts
512 
513 #define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)"
514 
515 #ifdef CONFIG_WFD
516 #define STA_OP_WFD_MODE(sta) (sta)->op_wfd_mode
517 #define STA_SET_OP_WFD_MODE(sta, mode) (sta)->op_wfd_mode = (mode)
518 #else
519 #define STA_OP_WFD_MODE(sta) 0
520 #define STA_SET_OP_WFD_MODE(sta, mode) do {} while (0)
521 #endif
522 
523 struct	sta_priv {
524 
525 	u8 *pallocated_stainfo_buf;
526 	u8 *pstainfo_buf;
527 	_queue	free_sta_queue;
528 
529 	_lock sta_hash_lock;
530 	_list   sta_hash[NUM_STA];
531 	int asoc_sta_count;
532 	_queue sleep_q;
533 	_queue wakeup_q;
534 
535 	_adapter *padapter;
536 
537 	u32 adhoc_expire_to;
538 
539 #ifdef CONFIG_AP_MODE
540 	_list asoc_list;
541 	_list auth_list;
542 	_lock asoc_list_lock;
543 	_lock auth_list_lock;
544 	u8 asoc_list_cnt;
545 	u8 auth_list_cnt;
546 
547 	unsigned int auth_to;  /* sec, time to expire in authenticating. */
548 	unsigned int assoc_to; /* sec, time to expire before associating. */
549 	unsigned int expire_to; /* sec , time to expire after associated. */
550 
551 	/* pointers to STA info; based on allocated AID or NULL if AID free
552 	 * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1
553 	 * and so on
554 	 */
555 	struct sta_info *sta_aid[NUM_STA];
556 
557 	u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap for sleeping sta. */
558 	u16 tim_bitmap;/* only support 15 stations, aid=0~15 mapping bit0~bit15	 */
559 
560 	u16 max_num_sta;
561 
562 #if CONFIG_RTW_MACADDR_ACL
563 	struct wlan_acl_pool acl_list;
564 #endif
565 
566 	#if CONFIG_RTW_PRE_LINK_STA
567 	struct pre_link_sta_ctl_t pre_link_sta_ctl;
568 	#endif
569 
570 #endif /* CONFIG_AP_MODE */
571 
572 #ifdef CONFIG_ATMEL_RC_PATCH
573 	u8 atmel_rc_pattern[6];
574 #endif
575 	struct sta_info *c2h_sta;
576 	struct submit_ctx *gotc2h;
577 };
578 
579 
wifi_mac_hash(u8 * mac)580 __inline static u32 wifi_mac_hash(u8 *mac)
581 {
582 	u32 x;
583 
584 	x = mac[0];
585 	x = (x << 2) ^ mac[1];
586 	x = (x << 2) ^ mac[2];
587 	x = (x << 2) ^ mac[3];
588 	x = (x << 2) ^ mac[4];
589 	x = (x << 2) ^ mac[5];
590 
591 	x ^= x >> 8;
592 	x  = x & (NUM_STA - 1);
593 
594 	return x;
595 }
596 
597 
598 extern u32	_rtw_init_sta_priv(struct sta_priv *pstapriv);
599 extern u32	_rtw_free_sta_priv(struct sta_priv *pstapriv);
600 
601 #define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0)
602 int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta);
603 struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset);
604 
605 extern struct sta_info *rtw_alloc_stainfo(struct	sta_priv *pstapriv, u8 *hwaddr);
606 extern u32	rtw_free_stainfo(_adapter *padapter , struct sta_info *psta);
607 extern void rtw_free_all_stainfo(_adapter *padapter);
608 extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
609 extern u32 rtw_init_bcmc_stainfo(_adapter *padapter);
610 extern struct sta_info *rtw_get_bcmc_stainfo(_adapter *padapter);
611 
612 #if CONFIG_RTW_MACADDR_ACL
613 extern u8 rtw_access_ctrl(_adapter *adapter, u8 *mac_addr);
614 void dump_macaddr_acl(void *sel, _adapter *adapter);
615 #endif
616 
617 bool rtw_is_pre_link_sta(struct sta_priv *stapriv, u8 *addr);
618 #if CONFIG_RTW_PRE_LINK_STA
619 struct sta_info *rtw_pre_link_sta_add(struct sta_priv *stapriv, u8 *hwaddr);
620 void rtw_pre_link_sta_del(struct sta_priv *stapriv, u8 *hwaddr);
621 void rtw_pre_link_sta_ctl_reset(struct sta_priv *stapriv);
622 void rtw_pre_link_sta_ctl_init(struct sta_priv *stapriv);
623 void rtw_pre_link_sta_ctl_deinit(struct sta_priv *stapriv);
624 void dump_pre_link_sta_ctl(void *sel, struct sta_priv *stapriv);
625 #endif /* CONFIG_RTW_PRE_LINK_STA */
626 
627 #endif /* _STA_INFO_H_ */
628