Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 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 | |
Johannes Berg | 238814f | 2008-01-28 17:19:37 +0100 | [diff] [blame] | 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 |
Johannes Berg | 238814f | 2008-01-28 17:19:37 +0100 | [diff] [blame] | 26 | * @WLAN_STA_AUTHORIZED: Station is authorized to send/receive traffic. |
| 27 | * This bit is always checked so needs to be enabled for all stations |
| 28 | * when virtual port control is not in use. |
| 29 | * @WLAN_STA_SHORT_PREAMBLE: Station is capable of receiving short-preamble |
| 30 | * frames. |
| 31 | * @WLAN_STA_ASSOC_AP: We're associated to that station, it is an AP. |
| 32 | * @WLAN_STA_WME: Station is a QoS-STA. |
| 33 | * @WLAN_STA_WDS: Station is one of our WDS peers. |
Johannes Berg | 4a9a66e | 2008-02-19 11:31:14 +0100 | [diff] [blame] | 34 | * @WLAN_STA_PSPOLL: Station has just PS-polled us. |
Johannes Berg | d46e144 | 2008-02-20 23:59:33 +0100 | [diff] [blame] | 35 | * @WLAN_STA_CLEAR_PS_FILT: Clear PS filter in hardware (using the |
| 36 | * IEEE80211_TXCTL_CLEAR_PS_FILT control flag) when the next |
| 37 | * frame to this station is transmitted. |
Johannes Berg | 238814f | 2008-01-28 17:19:37 +0100 | [diff] [blame] | 38 | */ |
| 39 | enum ieee80211_sta_info_flags { |
| 40 | WLAN_STA_AUTH = 1<<0, |
| 41 | WLAN_STA_ASSOC = 1<<1, |
| 42 | WLAN_STA_PS = 1<<2, |
Johannes Berg | 836341a | 2008-02-20 02:07:21 +0100 | [diff] [blame] | 43 | WLAN_STA_AUTHORIZED = 1<<3, |
| 44 | WLAN_STA_SHORT_PREAMBLE = 1<<4, |
| 45 | WLAN_STA_ASSOC_AP = 1<<5, |
| 46 | WLAN_STA_WME = 1<<6, |
| 47 | WLAN_STA_WDS = 1<<7, |
| 48 | WLAN_STA_PSPOLL = 1<<8, |
Johannes Berg | d46e144 | 2008-02-20 23:59:33 +0100 | [diff] [blame] | 49 | WLAN_STA_CLEAR_PS_FILT = 1<<9, |
Johannes Berg | 238814f | 2008-01-28 17:19:37 +0100 | [diff] [blame] | 50 | }; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 51 | |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 52 | #define STA_TID_NUM 16 |
| 53 | #define ADDBA_RESP_INTERVAL HZ |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 54 | #define HT_AGG_MAX_RETRIES (0x3) |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 55 | |
| 56 | #define HT_AGG_STATE_INITIATOR_SHIFT (4) |
| 57 | |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 58 | #define HT_ADDBA_REQUESTED_MSK BIT(0) |
| 59 | #define HT_ADDBA_DRV_READY_MSK BIT(1) |
| 60 | #define HT_ADDBA_RECEIVED_MSK BIT(2) |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 61 | #define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3) |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 62 | #define HT_AGG_STATE_INITIATOR_MSK BIT(HT_AGG_STATE_INITIATOR_SHIFT) |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 63 | #define HT_AGG_STATE_IDLE (0x0) |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 64 | #define HT_AGG_STATE_OPERATIONAL (HT_ADDBA_REQUESTED_MSK | \ |
| 65 | HT_ADDBA_DRV_READY_MSK | \ |
| 66 | HT_ADDBA_RECEIVED_MSK) |
| 67 | |
| 68 | /** |
| 69 | * struct tid_ampdu_tx - TID aggregation information (Tx). |
| 70 | * |
| 71 | * @state: TID's state in session state machine. |
| 72 | * @dialog_token: dialog token for aggregation session |
| 73 | * @ssn: Starting Sequence Number expected to be aggregated. |
| 74 | * @addba_resp_timer: timer for peer's response to addba request |
| 75 | * @addba_req_num: number of times addBA request has been sent. |
| 76 | */ |
| 77 | struct tid_ampdu_tx { |
| 78 | u8 state; |
| 79 | u8 dialog_token; |
| 80 | u16 ssn; |
| 81 | struct timer_list addba_resp_timer; |
| 82 | u8 addba_req_num; |
| 83 | }; |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 84 | |
| 85 | /** |
| 86 | * struct tid_ampdu_rx - TID aggregation information (Rx). |
| 87 | * |
| 88 | * @state: TID's state in session state machine. |
| 89 | * @dialog_token: dialog token for aggregation session |
| 90 | * @ssn: Starting Sequence Number expected to be aggregated. |
| 91 | * @buf_size: buffer size for incoming A-MPDUs |
| 92 | * @timeout: reset timer value. |
| 93 | * @head_seq_num: head sequence number in reordering buffer. |
| 94 | * @stored_mpdu_num: number of MPDUs in reordering buffer |
| 95 | * @reorder_buf: buffer to reorder incoming aggregated MPDUs |
| 96 | * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value) |
| 97 | */ |
| 98 | struct tid_ampdu_rx { |
| 99 | u8 state; |
| 100 | u8 dialog_token; |
| 101 | u16 ssn; |
| 102 | u16 buf_size; |
| 103 | u16 timeout; |
| 104 | u16 head_seq_num; |
| 105 | u16 stored_mpdu_num; |
| 106 | struct sk_buff **reorder_buf; |
| 107 | struct timer_list session_timer; |
| 108 | }; |
| 109 | |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 110 | enum plink_state { |
| 111 | LISTEN, |
| 112 | OPN_SNT, |
| 113 | OPN_RCVD, |
| 114 | CNF_RCVD, |
| 115 | ESTAB, |
| 116 | HOLDING, |
| 117 | BLOCKED |
| 118 | }; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 119 | |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 120 | /** |
| 121 | * struct sta_ampdu_mlme - STA aggregation information. |
| 122 | * |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 123 | * @tid_rx: aggregation info for Rx per TID |
| 124 | * @tid_tx: aggregation info for Tx per TID |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 125 | * @ampdu_rx: for locking sections in aggregation Rx flow |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 126 | * @ampdu_tx: for locking sectionsi in aggregation Tx flow |
| 127 | * @dialog_token_allocator: dialog token enumerator for each new session; |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 128 | */ |
| 129 | struct sta_ampdu_mlme { |
| 130 | struct tid_ampdu_rx tid_rx[STA_TID_NUM]; |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 131 | struct tid_ampdu_tx tid_tx[STA_TID_NUM]; |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 132 | spinlock_t ampdu_rx; |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 133 | spinlock_t ampdu_tx; |
| 134 | u8 dialog_token_allocator; |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 135 | }; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 136 | |
| 137 | struct sta_info { |
| 138 | struct kref kref; |
| 139 | struct list_head list; |
| 140 | struct sta_info *hnext; /* next entry in hash table list */ |
| 141 | |
| 142 | struct ieee80211_local *local; |
| 143 | |
| 144 | u8 addr[ETH_ALEN]; |
| 145 | u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */ |
| 146 | u32 flags; /* WLAN_STA_ */ |
| 147 | |
| 148 | struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in |
| 149 | * power saving state */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 150 | struct sk_buff_head tx_filtered; /* buffer of TX frames that were |
| 151 | * already given to low-level driver, |
| 152 | * but were filtered */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 153 | unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */ |
| 154 | unsigned long rx_bytes, tx_bytes; |
| 155 | unsigned long tx_retry_failed, tx_retry_count; |
| 156 | unsigned long tx_filtered_count; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 157 | /* moving percentage of failed MSDUs */ |
| 158 | unsigned int fail_avg; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 159 | |
| 160 | unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */ |
| 161 | |
| 162 | unsigned long last_rx; |
Johannes Berg | 8318d78 | 2008-01-24 19:38:38 +0100 | [diff] [blame] | 163 | /* bitmap of supported rates per band */ |
| 164 | u64 supp_rates[IEEE80211_NUM_BANDS]; |
| 165 | int txrate_idx; |
| 166 | /* last rates used to send a frame to this STA */ |
| 167 | int last_txrate_idx, last_nonerp_txrate_idx; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 168 | |
| 169 | struct net_device *dev; /* which net device is this station associated |
| 170 | * to */ |
| 171 | |
| 172 | struct ieee80211_key *key; |
| 173 | |
| 174 | u32 tx_num_consecutive_failures; |
| 175 | u32 tx_num_mpdu_ok; |
| 176 | u32 tx_num_mpdu_fail; |
| 177 | |
| 178 | struct rate_control_ref *rate_ctrl; |
| 179 | void *rate_ctrl_priv; |
| 180 | |
| 181 | /* last received seq/frag number from this STA (per RX queue) */ |
| 182 | __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES]; |
| 183 | unsigned long num_duplicates; /* number of duplicate frames received |
| 184 | * from this STA */ |
| 185 | unsigned long tx_fragments; /* number of transmitted MPDUs */ |
| 186 | unsigned long rx_fragments; /* number of received MPDUs */ |
| 187 | unsigned long rx_dropped; /* number of dropped MPDUs from this STA */ |
| 188 | |
| 189 | int last_rssi; /* RSSI of last received frame from this STA */ |
| 190 | int last_signal; /* signal of last received frame from this STA */ |
| 191 | int last_noise; /* noise of last received frame from this STA */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 192 | int channel_use; |
| 193 | int channel_use_raw; |
| 194 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 195 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
| 196 | unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES]; |
| 197 | unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES]; |
| 198 | #endif /* CONFIG_MAC80211_DEBUG_COUNTERS */ |
| 199 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 200 | u16 listen_interval; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 201 | |
Ron Rindjunsky | 10816d4 | 2007-11-26 16:14:30 +0200 | [diff] [blame] | 202 | struct ieee80211_ht_info ht_info; /* 802.11n HT capabilities |
| 203 | of this STA */ |
Ron Rindjunsky | 5aae288 | 2007-12-25 17:00:32 +0200 | [diff] [blame] | 204 | struct sta_ampdu_mlme ampdu_mlme; |
| 205 | u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */ |
Ron Rindjunsky | 80656c2 | 2008-01-28 14:07:16 +0200 | [diff] [blame] | 206 | u8 tid_to_tx_q[STA_TID_NUM]; /* map tid to tx queue */ |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 207 | #ifdef CONFIG_MAC80211_MESH |
| 208 | /* mesh peer link attributes */ |
| 209 | __le16 llid; /* Local link ID */ |
| 210 | __le16 plid; /* Peer link ID */ |
| 211 | __le16 reason; /* Buffer for cancel reason on HOLDING state */ |
Johannes Berg | 7495883 | 2008-02-25 22:17:30 +0100 | [diff] [blame^] | 212 | u8 plink_retries; /* Retries in establishment */ |
| 213 | bool ignore_plink_timer; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 214 | enum plink_state plink_state; |
| 215 | u32 plink_timeout; |
| 216 | struct timer_list plink_timer; |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 217 | spinlock_t plink_lock; /* For peer_state reads / updates and other |
| 218 | updates in the structure. Ensures robust |
| 219 | transitions for the peerlink FSM */ |
| 220 | #endif |
Ron Rindjunsky | 10816d4 | 2007-11-26 16:14:30 +0200 | [diff] [blame] | 221 | |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 222 | #ifdef CONFIG_MAC80211_DEBUGFS |
| 223 | struct sta_info_debugfsdentries { |
| 224 | struct dentry *dir; |
| 225 | struct dentry *flags; |
| 226 | struct dentry *num_ps_buf_frames; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 227 | struct dentry *inactive_ms; |
| 228 | struct dentry *last_seq_ctrl; |
| 229 | #ifdef CONFIG_MAC80211_DEBUG_COUNTERS |
| 230 | struct dentry *wme_rx_queue; |
| 231 | struct dentry *wme_tx_queue; |
| 232 | #endif |
Ron Rindjunsky | eb2ba62 | 2008-01-28 14:07:20 +0200 | [diff] [blame] | 233 | struct dentry *agg_status; |
Jiri Benc | e9f207f | 2007-05-05 11:46:38 -0700 | [diff] [blame] | 234 | } debugfs; |
| 235 | #endif |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 236 | }; |
| 237 | |
Johannes Berg | d6d1a5a | 2008-02-25 16:24:38 +0100 | [diff] [blame] | 238 | static inline enum plink_state sta_plink_state(struct sta_info *sta) |
| 239 | { |
| 240 | #ifdef CONFIG_MAC80211_MESH |
| 241 | return sta->plink_state; |
| 242 | #endif |
| 243 | return LISTEN; |
| 244 | } |
| 245 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 246 | |
| 247 | /* Maximum number of concurrently registered stations */ |
| 248 | #define MAX_STA_COUNT 2007 |
| 249 | |
| 250 | #define STA_HASH_SIZE 256 |
| 251 | #define STA_HASH(sta) (sta[5]) |
| 252 | |
| 253 | |
| 254 | /* Maximum number of frames to buffer per power saving station */ |
| 255 | #define STA_MAX_TX_BUFFER 128 |
| 256 | |
| 257 | /* Minimum buffered frame expiry time. If STA uses listen interval that is |
| 258 | * smaller than this value, the minimum value here is used instead. */ |
| 259 | #define STA_TX_BUFFER_EXPIRE (10 * HZ) |
| 260 | |
| 261 | /* How often station data is cleaned up (e.g., expiration of buffered frames) |
| 262 | */ |
| 263 | #define STA_INFO_CLEANUP_INTERVAL (10 * HZ) |
| 264 | |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 265 | static inline void __sta_info_get(struct sta_info *sta) |
| 266 | { |
| 267 | kref_get(&sta->kref); |
| 268 | } |
| 269 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 270 | struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr); |
Luis Carlos Cobo | ee38585 | 2008-02-23 15:17:11 +0100 | [diff] [blame] | 271 | struct sta_info *sta_info_get_by_idx(struct ieee80211_local *local, int idx, |
| 272 | struct net_device *dev); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 273 | void sta_info_put(struct sta_info *sta); |
Johannes Berg | 43ba7e9 | 2008-02-21 14:09:30 +0100 | [diff] [blame] | 274 | struct sta_info *sta_info_add(struct ieee80211_local *local, |
| 275 | struct net_device *dev, u8 *addr, gfp_t gfp); |
Michael Wu | be8755e | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 276 | void sta_info_remove(struct sta_info *sta); |
| 277 | void sta_info_free(struct sta_info *sta); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 278 | void sta_info_init(struct ieee80211_local *local); |
| 279 | int sta_info_start(struct ieee80211_local *local); |
| 280 | void sta_info_stop(struct ieee80211_local *local); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 281 | void sta_info_flush(struct ieee80211_local *local, struct net_device *dev); |
| 282 | |
Johannes Berg | 004c872 | 2008-02-20 11:21:35 +0100 | [diff] [blame] | 283 | void sta_info_set_tim_bit(struct sta_info *sta); |
| 284 | void sta_info_clear_tim_bit(struct sta_info *sta); |
| 285 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 286 | #endif /* STA_INFO_H */ |