New: mac80211 stack from the wireless-dev tree
[openwrt/svn-archive/archive.git] / package / mac80211 / src / mac80211 / sta_info.h
1 /*
2 * Copyright 2002-2005, Devicescape Software, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9 #ifndef STA_INFO_H
10 #define STA_INFO_H
11
12 #include <linux/list.h>
13 #include <linux/types.h>
14 #include <linux/if_ether.h>
15 #include <linux/kref.h>
16 #include "ieee80211_key.h"
17
18 /* Stations flags (struct sta_info::flags) */
19 #define WLAN_STA_AUTH BIT(0)
20 #define WLAN_STA_ASSOC BIT(1)
21 #define WLAN_STA_PS BIT(2)
22 #define WLAN_STA_TIM BIT(3) /* TIM bit is on for PS stations */
23 #define WLAN_STA_PERM BIT(4) /* permanent; do not remove entry on expiration */
24 #define WLAN_STA_AUTHORIZED BIT(5) /* If 802.1X is used, this flag is
25 * controlling whether STA is authorized to
26 * send and receive non-IEEE 802.1X frames
27 */
28 #define WLAN_STA_SHORT_PREAMBLE BIT(7)
29 #define WLAN_STA_WME BIT(9)
30 #define WLAN_STA_HT BIT(10)
31 #define WLAN_STA_WDS BIT(27)
32
33
34 struct sta_info {
35 struct kref kref;
36 struct list_head list;
37 struct sta_info *hnext; /* next entry in hash table list */
38
39 struct ieee80211_local *local;
40
41 u8 addr[ETH_ALEN];
42 u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */
43 u32 flags; /* WLAN_STA_ */
44
45 struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in
46 * power saving state */
47 int pspoll; /* whether STA has send a PS Poll frame */
48 struct sk_buff_head tx_filtered; /* buffer of TX frames that were
49 * already given to low-level driver,
50 * but were filtered */
51 int clear_dst_mask;
52
53 unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */
54 unsigned long rx_bytes, tx_bytes;
55 unsigned long tx_retry_failed, tx_retry_count;
56 unsigned long tx_filtered_count;
57
58 unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */
59
60 unsigned long last_rx;
61 u32 supp_rates; /* bitmap of supported rates in local->curr_rates */
62 int txrate; /* index in local->curr_rates */
63 int last_txrate; /* last rate used to send a frame to this STA */
64 int last_nonerp_idx;
65
66 struct net_device *dev; /* which net device is this station associated
67 * to */
68
69 struct ieee80211_key *key;
70
71 u32 tx_num_consecutive_failures;
72 u32 tx_num_mpdu_ok;
73 u32 tx_num_mpdu_fail;
74
75 struct rate_control_ref *rate_ctrl;
76 void *rate_ctrl_priv;
77
78 /* last received seq/frag number from this STA (per RX queue) */
79 __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES];
80 unsigned long num_duplicates; /* number of duplicate frames received
81 * from this STA */
82 unsigned long tx_fragments; /* number of transmitted MPDUs */
83 unsigned long rx_fragments; /* number of received MPDUs */
84 unsigned long rx_dropped; /* number of dropped MPDUs from this STA */
85
86 int last_rssi; /* RSSI of last received frame from this STA */
87 int last_signal; /* signal of last received frame from this STA */
88 int last_noise; /* noise of last received frame from this STA */
89 int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
90 unsigned long last_ack;
91 int channel_use;
92 int channel_use_raw;
93
94 u8 antenna_sel_tx;
95 u8 antenna_sel_rx;
96
97
98 int key_idx_compression; /* key table index for compression and TX
99 * filtering; used only if sta->key is not
100 * set */
101
102 #ifdef CONFIG_MAC80211_DEBUGFS
103 int debugfs_registered;
104 #endif
105 unsigned int assoc_ap:1; /* whether this is an AP that we are
106 * associated with as a client */
107 unsigned int dls_sta:1; /* whether this stations is a DLS peer of us */
108
109 #define DLS_STATUS_OK 0
110 #define DLS_STATUS_NOLINK 1
111 int dls_status;
112 u32 dls_timeout;
113
114 #ifdef CONFIG_HOSTAPD_WPA_TESTING
115 u32 wpa_trigger;
116 #endif /* CONFIG_HOSTAPD_WPA_TESTING */
117
118 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
119 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
120 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
121 #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
122
123 int vlan_id;
124
125 u16 listen_interval;
126
127 #ifdef CONFIG_MAC80211_DEBUGFS
128 struct sta_info_debugfsdentries {
129 struct dentry *dir;
130 struct dentry *flags;
131 struct dentry *num_ps_buf_frames;
132 struct dentry *last_ack_rssi;
133 struct dentry *last_ack_ms;
134 struct dentry *inactive_ms;
135 struct dentry *last_seq_ctrl;
136 #ifdef CONFIG_MAC80211_DEBUG_COUNTERS
137 struct dentry *wme_rx_queue;
138 struct dentry *wme_tx_queue;
139 #endif
140 } debugfs;
141 #endif
142 };
143
144
145 /* Maximum number of concurrently registered stations */
146 #define MAX_STA_COUNT 2007
147
148 #define STA_HASH_SIZE 256
149 #define STA_HASH(sta) (sta[5])
150
151
152 /* Maximum number of frames to buffer per power saving station */
153 #define STA_MAX_TX_BUFFER 128
154
155 /* Minimum buffered frame expiry time. If STA uses listen interval that is
156 * smaller than this value, the minimum value here is used instead. */
157 #define STA_TX_BUFFER_EXPIRE (10 * HZ)
158
159 /* How often station data is cleaned up (e.g., expiration of buffered frames)
160 */
161 #define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
162
163 struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
164 int sta_info_min_txrate_get(struct ieee80211_local *local);
165 void sta_info_put(struct sta_info *sta);
166 struct sta_info * sta_info_add(struct ieee80211_local *local,
167 struct net_device *dev, u8 *addr, gfp_t gfp);
168 void sta_info_free(struct sta_info *sta, int locked);
169 void sta_info_init(struct ieee80211_local *local);
170 int sta_info_start(struct ieee80211_local *local);
171 void sta_info_stop(struct ieee80211_local *local);
172 void sta_info_remove_aid_ptr(struct sta_info *sta);
173 void sta_info_flush(struct ieee80211_local *local, struct net_device *dev);
174
175 #endif /* STA_INFO_H */