]>
Commit | Line | Data |
---|---|---|
f0706e82 JB |
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) | |
c9ee23df JB |
29 | /* whether this is an AP that we are associated with as a client */ |
30 | #define WLAN_STA_ASSOC_AP BIT(8) | |
f0706e82 JB |
31 | #define WLAN_STA_WME BIT(9) |
32 | #define WLAN_STA_WDS BIT(27) | |
33 | ||
5aae2880 RR |
34 | #define STA_TID_NUM 16 |
35 | #define ADDBA_RESP_INTERVAL HZ | |
80656c20 | 36 | #define HT_AGG_MAX_RETRIES (0x3) |
5aae2880 RR |
37 | |
38 | #define HT_AGG_STATE_INITIATOR_SHIFT (4) | |
39 | ||
80656c20 RR |
40 | #define HT_ADDBA_REQUESTED_MSK BIT(0) |
41 | #define HT_ADDBA_DRV_READY_MSK BIT(1) | |
42 | #define HT_ADDBA_RECEIVED_MSK BIT(2) | |
5aae2880 | 43 | #define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3) |
80656c20 | 44 | #define HT_AGG_STATE_INITIATOR_MSK BIT(HT_AGG_STATE_INITIATOR_SHIFT) |
5aae2880 | 45 | #define HT_AGG_STATE_IDLE (0x0) |
80656c20 RR |
46 | #define HT_AGG_STATE_OPERATIONAL (HT_ADDBA_REQUESTED_MSK | \ |
47 | HT_ADDBA_DRV_READY_MSK | \ | |
48 | HT_ADDBA_RECEIVED_MSK) | |
49 | ||
50 | /** | |
51 | * struct tid_ampdu_tx - TID aggregation information (Tx). | |
52 | * | |
53 | * @state: TID's state in session state machine. | |
54 | * @dialog_token: dialog token for aggregation session | |
55 | * @ssn: Starting Sequence Number expected to be aggregated. | |
56 | * @addba_resp_timer: timer for peer's response to addba request | |
57 | * @addba_req_num: number of times addBA request has been sent. | |
58 | */ | |
59 | struct tid_ampdu_tx { | |
60 | u8 state; | |
61 | u8 dialog_token; | |
62 | u16 ssn; | |
63 | struct timer_list addba_resp_timer; | |
64 | u8 addba_req_num; | |
65 | }; | |
5aae2880 RR |
66 | |
67 | /** | |
68 | * struct tid_ampdu_rx - TID aggregation information (Rx). | |
69 | * | |
70 | * @state: TID's state in session state machine. | |
71 | * @dialog_token: dialog token for aggregation session | |
72 | * @ssn: Starting Sequence Number expected to be aggregated. | |
73 | * @buf_size: buffer size for incoming A-MPDUs | |
74 | * @timeout: reset timer value. | |
75 | * @head_seq_num: head sequence number in reordering buffer. | |
76 | * @stored_mpdu_num: number of MPDUs in reordering buffer | |
77 | * @reorder_buf: buffer to reorder incoming aggregated MPDUs | |
78 | * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value) | |
79 | */ | |
80 | struct tid_ampdu_rx { | |
81 | u8 state; | |
82 | u8 dialog_token; | |
83 | u16 ssn; | |
84 | u16 buf_size; | |
85 | u16 timeout; | |
86 | u16 head_seq_num; | |
87 | u16 stored_mpdu_num; | |
88 | struct sk_buff **reorder_buf; | |
89 | struct timer_list session_timer; | |
90 | }; | |
91 | ||
92 | /** | |
93 | * struct sta_ampdu_mlme - STA aggregation information. | |
94 | * | |
80656c20 RR |
95 | * @tid_rx: aggregation info for Rx per TID |
96 | * @tid_tx: aggregation info for Tx per TID | |
5aae2880 | 97 | * @ampdu_rx: for locking sections in aggregation Rx flow |
80656c20 RR |
98 | * @ampdu_tx: for locking sectionsi in aggregation Tx flow |
99 | * @dialog_token_allocator: dialog token enumerator for each new session; | |
5aae2880 RR |
100 | */ |
101 | struct sta_ampdu_mlme { | |
102 | struct tid_ampdu_rx tid_rx[STA_TID_NUM]; | |
80656c20 | 103 | struct tid_ampdu_tx tid_tx[STA_TID_NUM]; |
5aae2880 | 104 | spinlock_t ampdu_rx; |
80656c20 RR |
105 | spinlock_t ampdu_tx; |
106 | u8 dialog_token_allocator; | |
5aae2880 | 107 | }; |
f0706e82 JB |
108 | |
109 | struct sta_info { | |
110 | struct kref kref; | |
111 | struct list_head list; | |
112 | struct sta_info *hnext; /* next entry in hash table list */ | |
113 | ||
114 | struct ieee80211_local *local; | |
115 | ||
116 | u8 addr[ETH_ALEN]; | |
117 | u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */ | |
118 | u32 flags; /* WLAN_STA_ */ | |
119 | ||
120 | struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in | |
121 | * power saving state */ | |
122 | int pspoll; /* whether STA has send a PS Poll frame */ | |
123 | struct sk_buff_head tx_filtered; /* buffer of TX frames that were | |
124 | * already given to low-level driver, | |
125 | * but were filtered */ | |
126 | int clear_dst_mask; | |
127 | ||
128 | unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */ | |
129 | unsigned long rx_bytes, tx_bytes; | |
130 | unsigned long tx_retry_failed, tx_retry_count; | |
131 | unsigned long tx_filtered_count; | |
132 | ||
133 | unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */ | |
134 | ||
135 | unsigned long last_rx; | |
8318d78a JB |
136 | /* bitmap of supported rates per band */ |
137 | u64 supp_rates[IEEE80211_NUM_BANDS]; | |
138 | int txrate_idx; | |
139 | /* last rates used to send a frame to this STA */ | |
140 | int last_txrate_idx, last_nonerp_txrate_idx; | |
f0706e82 JB |
141 | |
142 | struct net_device *dev; /* which net device is this station associated | |
143 | * to */ | |
144 | ||
145 | struct ieee80211_key *key; | |
146 | ||
147 | u32 tx_num_consecutive_failures; | |
148 | u32 tx_num_mpdu_ok; | |
149 | u32 tx_num_mpdu_fail; | |
150 | ||
151 | struct rate_control_ref *rate_ctrl; | |
152 | void *rate_ctrl_priv; | |
153 | ||
154 | /* last received seq/frag number from this STA (per RX queue) */ | |
155 | __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES]; | |
156 | unsigned long num_duplicates; /* number of duplicate frames received | |
157 | * from this STA */ | |
158 | unsigned long tx_fragments; /* number of transmitted MPDUs */ | |
159 | unsigned long rx_fragments; /* number of received MPDUs */ | |
160 | unsigned long rx_dropped; /* number of dropped MPDUs from this STA */ | |
161 | ||
162 | int last_rssi; /* RSSI of last received frame from this STA */ | |
163 | int last_signal; /* signal of last received frame from this STA */ | |
164 | int last_noise; /* noise of last received frame from this STA */ | |
165 | int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */ | |
166 | unsigned long last_ack; | |
167 | int channel_use; | |
168 | int channel_use_raw; | |
169 | ||
f0706e82 JB |
170 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
171 | unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES]; | |
172 | unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES]; | |
173 | #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */ | |
174 | ||
f0706e82 | 175 | u16 listen_interval; |
e9f207f0 | 176 | |
10816d40 RR |
177 | struct ieee80211_ht_info ht_info; /* 802.11n HT capabilities |
178 | of this STA */ | |
5aae2880 RR |
179 | struct sta_ampdu_mlme ampdu_mlme; |
180 | u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */ | |
80656c20 | 181 | u8 tid_to_tx_q[STA_TID_NUM]; /* map tid to tx queue */ |
10816d40 | 182 | |
e9f207f0 JB |
183 | #ifdef CONFIG_MAC80211_DEBUGFS |
184 | struct sta_info_debugfsdentries { | |
185 | struct dentry *dir; | |
186 | struct dentry *flags; | |
187 | struct dentry *num_ps_buf_frames; | |
188 | struct dentry *last_ack_rssi; | |
189 | struct dentry *last_ack_ms; | |
190 | struct dentry *inactive_ms; | |
191 | struct dentry *last_seq_ctrl; | |
192 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS | |
193 | struct dentry *wme_rx_queue; | |
194 | struct dentry *wme_tx_queue; | |
195 | #endif | |
eb2ba62e | 196 | struct dentry *agg_status; |
e9f207f0 JB |
197 | } debugfs; |
198 | #endif | |
f0706e82 JB |
199 | }; |
200 | ||
201 | ||
202 | /* Maximum number of concurrently registered stations */ | |
203 | #define MAX_STA_COUNT 2007 | |
204 | ||
205 | #define STA_HASH_SIZE 256 | |
206 | #define STA_HASH(sta) (sta[5]) | |
207 | ||
208 | ||
209 | /* Maximum number of frames to buffer per power saving station */ | |
210 | #define STA_MAX_TX_BUFFER 128 | |
211 | ||
212 | /* Minimum buffered frame expiry time. If STA uses listen interval that is | |
213 | * smaller than this value, the minimum value here is used instead. */ | |
214 | #define STA_TX_BUFFER_EXPIRE (10 * HZ) | |
215 | ||
216 | /* How often station data is cleaned up (e.g., expiration of buffered frames) | |
217 | */ | |
218 | #define STA_INFO_CLEANUP_INTERVAL (10 * HZ) | |
219 | ||
be8755e1 MW |
220 | static inline void __sta_info_get(struct sta_info *sta) |
221 | { | |
222 | kref_get(&sta->kref); | |
223 | } | |
224 | ||
f0706e82 | 225 | struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr); |
f0706e82 JB |
226 | void sta_info_put(struct sta_info *sta); |
227 | struct sta_info * sta_info_add(struct ieee80211_local *local, | |
228 | struct net_device *dev, u8 *addr, gfp_t gfp); | |
be8755e1 MW |
229 | void sta_info_remove(struct sta_info *sta); |
230 | void sta_info_free(struct sta_info *sta); | |
f0706e82 JB |
231 | void sta_info_init(struct ieee80211_local *local); |
232 | int sta_info_start(struct ieee80211_local *local); | |
233 | void sta_info_stop(struct ieee80211_local *local); | |
234 | void sta_info_remove_aid_ptr(struct sta_info *sta); | |
235 | void sta_info_flush(struct ieee80211_local *local, struct net_device *dev); | |
236 | ||
237 | #endif /* STA_INFO_H */ |