• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* if mode ==0, then the sta is allowed once the addr is hit.
25  * if mode ==1, then the sta is rejected once the addr is non-hit.
26  */
27 struct wlan_acl_node {
28 	struct list_head list;
29 	u8       addr[ETH_ALEN];
30 	u8       mode;
31 };
32 
33 struct wlan_acl_pool {
34 	struct wlan_acl_node aclnode[NUM_ACL];
35 };
36 
37 struct	stainfo_stats {
38 	uint	rx_pkts;
39 	uint	rx_bytes;
40 	u64	tx_pkts;
41 	uint	tx_bytes;
42 };
43 
44 struct sta_info {
45 	spinlock_t lock;
46 	struct list_head list; /*free_sta_queue*/
47 	struct list_head hash_list; /*sta_hash*/
48 	struct sta_xmit_priv sta_xmitpriv;
49 	struct sta_recv_priv sta_recvpriv;
50 	uint state;
51 	uint aid;
52 	uint	mac_id;
53 	uint	qos_option;
54 	u8	hwaddr[ETH_ALEN];
55 	uint	ieee8021x_blocked;	/*0: allowed, 1:blocked */
56 	uint	XPrivacy; /*aes, tkip...*/
57 	union Keytype	tkiptxmickey;
58 	union Keytype	tkiprxmickey;
59 	union Keytype	x_UncstKey;
60 	union pn48		txpn;	/* PN48 used for Unicast xmit.*/
61 	union pn48		rxpn;	/* PN48 used for Unicast recv.*/
62 	u8	bssrateset[16];
63 	uint	bssratelen;
64 	s32  rssi;
65 	s32	signal_quality;
66 	struct stainfo_stats sta_stats;
67 	/*for A-MPDU Rx reordering buffer control */
68 	struct recv_reorder_ctrl recvreorder_ctrl[16];
69 	struct ht_priv	htpriv;
70 	/* Notes:
71 	 * STA_Mode:
72 	 * curr_network(mlme_priv/security_priv/qos/ht)
73 	 *   + sta_info: (STA & AP) CAP/INFO
74 	 * scan_q: AP CAP/INFO
75 	 * AP_Mode:
76 	 * curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
77 	 * sta_info: (AP & STA) CAP/INFO
78 	 */
79 	struct list_head asoc_list;
80 	struct list_head auth_list;
81 	unsigned int expire_to;
82 	unsigned int auth_seq;
83 	unsigned int authalg;
84 	unsigned char chg_txt[128];
85 	unsigned int tx_ra_bitmap;
86 };
87 
88 struct	sta_priv {
89 	u8 *pallocated_stainfo_buf;
90 	u8 *pstainfo_buf;
91 	struct  __queue	free_sta_queue;
92 	spinlock_t sta_hash_lock;
93 	struct list_head sta_hash[NUM_STA];
94 	int asoc_sta_count;
95 	struct  __queue sleep_q;
96 	struct  __queue wakeup_q;
97 	struct _adapter *padapter;
98 	struct list_head asoc_list;
99 	struct list_head auth_list;
100 	unsigned int auth_to;  /* sec, time to expire in authenticating. */
101 	unsigned int assoc_to; /* sec, time to expire before associating. */
102 	unsigned int expire_to; /* sec , time to expire after associated. */
103 };
104 
wifi_mac_hash(u8 * mac)105 static inline u32 wifi_mac_hash(u8 *mac)
106 {
107 	u32 x;
108 
109 	x = mac[0];
110 	x = (x << 2) ^ mac[1];
111 	x = (x << 2) ^ mac[2];
112 	x = (x << 2) ^ mac[3];
113 	x = (x << 2) ^ mac[4];
114 	x = (x << 2) ^ mac[5];
115 	x ^= x >> 8;
116 	x  = x & (NUM_STA - 1);
117 	return x;
118 }
119 
120 int _r8712_init_sta_priv(struct sta_priv *pstapriv);
121 void _r8712_free_sta_priv(struct sta_priv *pstapriv);
122 struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv,
123 				     u8 *hwaddr);
124 void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta);
125 void r8712_free_all_stainfo(struct _adapter *padapter);
126 struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
127 void r8712_init_bcmc_stainfo(struct _adapter *padapter);
128 struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter);
129 u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr);
130 
131 #endif /* _STA_INFO_H_ */
132 
133