Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt
[linux-2.6-microblaze.git] / drivers / staging / rtl8712 / sta_info.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
3  *
4  * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
5  *
6  * Modifications for inclusion into the Linux staging tree are
7  * Copyright(c) 2010 Larry Finger. All rights reserved.
8  *
9  * Contact information:
10  * WLAN FAE <wlanfae@realtek.com>
11  * Larry Finger <Larry.Finger@lwfinger.net>
12  *
13  ******************************************************************************/
14 #ifndef __STA_INFO_H_
15 #define __STA_INFO_H_
16
17 #include "osdep_service.h"
18 #include "drv_types.h"
19 #include "wifi.h"
20
21 #define NUM_STA 32
22 #define NUM_ACL 64
23
24
25 /* if mode ==0, then the sta is allowed once the addr is hit.
26  * if mode ==1, then the sta is rejected once the addr is non-hit.
27  */
28 struct wlan_acl_node {
29         struct list_head list;
30         u8       addr[ETH_ALEN];
31         u8       mode;
32 };
33
34 struct wlan_acl_pool {
35         struct wlan_acl_node aclnode[NUM_ACL];
36 };
37
38 struct  stainfo_stats {
39         uint    rx_pkts;
40         uint    rx_bytes;
41         u64     tx_pkts;
42         uint    tx_bytes;
43 };
44
45 struct sta_info {
46         spinlock_t lock;
47         struct list_head list; /*free_sta_queue*/
48         struct list_head hash_list; /*sta_hash*/
49         struct sta_xmit_priv sta_xmitpriv;
50         struct sta_recv_priv sta_recvpriv;
51         uint state;
52         uint aid;
53         uint    mac_id;
54         uint    qos_option;
55         u8      hwaddr[ETH_ALEN];
56         uint    ieee8021x_blocked;      /*0: allowed, 1:blocked */
57         uint    XPrivacy; /*aes, tkip...*/
58         union Keytype   tkiptxmickey;
59         union Keytype   tkiprxmickey;
60         union Keytype   x_UncstKey;
61         union pn48              txpn;   /* PN48 used for Unicast xmit.*/
62         union pn48              rxpn;   /* PN48 used for Unicast recv.*/
63         u8      bssrateset[16];
64         uint    bssratelen;
65         s32  rssi;
66         s32     signal_quality;
67         struct stainfo_stats sta_stats;
68         /*for A-MPDU Rx reordering buffer control */
69         struct recv_reorder_ctrl recvreorder_ctrl[16];
70         struct ht_priv  htpriv;
71         /* Notes:
72          * STA_Mode:
73          * curr_network(mlme_priv/security_priv/qos/ht)
74          *   + sta_info: (STA & AP) CAP/INFO
75          * scan_q: AP CAP/INFO
76          * AP_Mode:
77          * curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
78          * sta_info: (AP & STA) CAP/INFO
79          */
80         struct list_head asoc_list;
81         struct list_head auth_list;
82         unsigned int expire_to;
83         unsigned int auth_seq;
84         unsigned int authalg;
85         unsigned char chg_txt[128];
86         unsigned int tx_ra_bitmap;
87 };
88
89 struct  sta_priv {
90         u8 *pallocated_stainfo_buf;
91         u8 *pstainfo_buf;
92         struct  __queue free_sta_queue;
93         spinlock_t sta_hash_lock;
94         struct list_head sta_hash[NUM_STA];
95         int asoc_sta_count;
96         struct  __queue sleep_q;
97         struct  __queue wakeup_q;
98         struct _adapter *padapter;
99         struct list_head asoc_list;
100         struct list_head auth_list;
101         unsigned int auth_to;  /* sec, time to expire in authenticating. */
102         unsigned int assoc_to; /* sec, time to expire before associating. */
103         unsigned int expire_to; /* sec , time to expire after associated. */
104 };
105
106 static inline u32 wifi_mac_hash(u8 *mac)
107 {
108         u32 x;
109
110         x = mac[0];
111         x = (x << 2) ^ mac[1];
112         x = (x << 2) ^ mac[2];
113         x = (x << 2) ^ mac[3];
114         x = (x << 2) ^ mac[4];
115         x = (x << 2) ^ mac[5];
116         x ^= x >> 8;
117         x  = x & (NUM_STA - 1);
118         return x;
119 }
120
121 int _r8712_init_sta_priv(struct sta_priv *pstapriv);
122 void _r8712_free_sta_priv(struct sta_priv *pstapriv);
123 struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv,
124                                      u8 *hwaddr);
125 void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta);
126 void r8712_free_all_stainfo(struct _adapter *padapter);
127 struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
128 void r8712_init_bcmc_stainfo(struct _adapter *padapter);
129 struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter);
130 u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr);
131
132 #endif /* _STA_INFO_H_ */
133