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