aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/rtl8712/sta_info.h
blob: c4e0ef2f52c68d6abc200ac03df99f368e944bf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/******************************************************************************
 *
 * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
 *
 * Modifications for inclusion into the Linux staging tree are
 * Copyright(c) 2010 Larry Finger. All rights reserved.
 *
 * Contact information:
 * WLAN FAE <wlanfae@realtek.com>
 * Larry Finger <Larry.Finger@lwfinger.net>
 *
 ******************************************************************************/
#ifndef __STA_INFO_H_
#define __STA_INFO_H_

#include "osdep_service.h"
#include "drv_types.h"
#include "wifi.h"

#define NUM_STA 32
#define NUM_ACL 64


/* if mode ==0, then the sta is allowed once the addr is hit.
 * if mode ==1, then the sta is rejected once the addr is non-hit.
 */
struct wlan_acl_node {
	struct list_head list;
	u8       addr[ETH_ALEN];
	u8       mode;
};

struct wlan_acl_pool {
	struct wlan_acl_node aclnode[NUM_ACL];
};

struct	stainfo_stats {

	uint	rx_pkts;
	uint	rx_bytes;
	u64	tx_pkts;
	uint	tx_bytes;
};

struct sta_info {
	spinlock_t lock;
	struct list_head list; /*free_sta_queue*/
	struct list_head hash_list; /*sta_hash*/
	struct sta_xmit_priv sta_xmitpriv;
	struct sta_recv_priv sta_recvpriv;
	uint state;
	uint aid;
	uint	mac_id;
	uint	qos_option;
	u8	hwaddr[ETH_ALEN];
	uint	ieee8021x_blocked;	/*0: allowed, 1:blocked */
	uint	XPrivacy; /*aes, tkip...*/
	union Keytype	tkiptxmickey;
	union Keytype	tkiprxmickey;
	union Keytype	x_UncstKey;
	union pn48		txpn;	/* PN48 used for Unicast xmit.*/
	union pn48		rxpn;	/* PN48 used for Unicast recv.*/
	u8	bssrateset[16];
	uint	bssratelen;
	s32  rssi;
	s32	signal_quality;
	struct stainfo_stats sta_stats;
	/*for A-MPDU Rx reordering buffer control */
	struct recv_reorder_ctrl recvreorder_ctrl[16];
	struct ht_priv	htpriv;
	/* Notes:
	 * STA_Mode:
	 * curr_network(mlme_priv/security_priv/qos/ht)
	 *   + sta_info: (STA & AP) CAP/INFO
	 * scan_q: AP CAP/INFO
	 * AP_Mode:
	 * curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO
	 * sta_info: (AP & STA) CAP/INFO
	 */
	struct list_head asoc_list;
	struct list_head auth_list;
	unsigned int expire_to;
	unsigned int auth_seq;
	unsigned int authalg;
	unsigned char chg_txt[128];
	unsigned int tx_ra_bitmap;
};

struct	sta_priv {
	u8 *pallocated_stainfo_buf;
	u8 *pstainfo_buf;
	struct  __queue	free_sta_queue;
	spinlock_t sta_hash_lock;
	struct list_head sta_hash[NUM_STA];
	int asoc_sta_count;
	struct  __queue sleep_q;
	struct  __queue wakeup_q;
	struct _adapter *padapter;
	struct list_head asoc_list;
	struct list_head auth_list;
	unsigned int auth_to;  /* sec, time to expire in authenticating. */
	unsigned int assoc_to; /* sec, time to expire before associating. */
	unsigned int expire_to; /* sec , time to expire after associated. */
};

static inline u32 wifi_mac_hash(u8 *mac)
{
	u32 x;

	x = mac[0];
	x = (x << 2) ^ mac[1];
	x = (x << 2) ^ mac[2];
	x = (x << 2) ^ mac[3];
	x = (x << 2) ^ mac[4];
	x = (x << 2) ^ mac[5];
	x ^= x >> 8;
	x  = x & (NUM_STA - 1);
	return x;
}

u32 _r8712_init_sta_priv(struct sta_priv *pstapriv);
u32 _r8712_free_sta_priv(struct sta_priv *pstapriv);
struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv,
				     u8 *hwaddr);
void r8712_free_stainfo(struct _adapter *padapter , struct sta_info *psta);
void r8712_free_all_stainfo(struct _adapter *padapter);
struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr);
void r8712_init_bcmc_stainfo(struct _adapter *padapter);
struct sta_info *r8712_get_bcmc_stainfo(struct _adapter *padapter);
u8 r8712_access_ctrl(struct wlan_acl_pool *pacl_list, u8 *mac_addr);

#endif /* _STA_INFO_H_ */