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