blob: 4099ece143efeffc535868dae888cdc499a6462a [file] [log] [blame]
Jiri Bencf0706e82007-05-05 11:45:53 -07001/*
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 Berg238814f2008-01-28 17:19:37 +010018/**
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 Berg238814f2008-01-28 17:19:37 +010026 * @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 Berg4a9a66e2008-02-19 11:31:14 +010034 * @WLAN_STA_PSPOLL: Station has just PS-polled us.
Johannes Berg238814f2008-01-28 17:19:37 +010035 */
36enum ieee80211_sta_info_flags {
37 WLAN_STA_AUTH = 1<<0,
38 WLAN_STA_ASSOC = 1<<1,
39 WLAN_STA_PS = 1<<2,
Johannes Berg836341a2008-02-20 02:07:21 +010040 WLAN_STA_AUTHORIZED = 1<<3,
41 WLAN_STA_SHORT_PREAMBLE = 1<<4,
42 WLAN_STA_ASSOC_AP = 1<<5,
43 WLAN_STA_WME = 1<<6,
44 WLAN_STA_WDS = 1<<7,
45 WLAN_STA_PSPOLL = 1<<8,
Johannes Berg238814f2008-01-28 17:19:37 +010046};
Jiri Bencf0706e82007-05-05 11:45:53 -070047
Ron Rindjunsky5aae2882007-12-25 17:00:32 +020048#define STA_TID_NUM 16
49#define ADDBA_RESP_INTERVAL HZ
Ron Rindjunsky80656c22008-01-28 14:07:16 +020050#define HT_AGG_MAX_RETRIES (0x3)
Ron Rindjunsky5aae2882007-12-25 17:00:32 +020051
52#define HT_AGG_STATE_INITIATOR_SHIFT (4)
53
Ron Rindjunsky80656c22008-01-28 14:07:16 +020054#define HT_ADDBA_REQUESTED_MSK BIT(0)
55#define HT_ADDBA_DRV_READY_MSK BIT(1)
56#define HT_ADDBA_RECEIVED_MSK BIT(2)
Ron Rindjunsky5aae2882007-12-25 17:00:32 +020057#define HT_AGG_STATE_REQ_STOP_BA_MSK BIT(3)
Ron Rindjunsky80656c22008-01-28 14:07:16 +020058#define HT_AGG_STATE_INITIATOR_MSK BIT(HT_AGG_STATE_INITIATOR_SHIFT)
Ron Rindjunsky5aae2882007-12-25 17:00:32 +020059#define HT_AGG_STATE_IDLE (0x0)
Ron Rindjunsky80656c22008-01-28 14:07:16 +020060#define HT_AGG_STATE_OPERATIONAL (HT_ADDBA_REQUESTED_MSK | \
61 HT_ADDBA_DRV_READY_MSK | \
62 HT_ADDBA_RECEIVED_MSK)
63
64/**
65 * struct tid_ampdu_tx - TID aggregation information (Tx).
66 *
67 * @state: TID's state in session state machine.
68 * @dialog_token: dialog token for aggregation session
69 * @ssn: Starting Sequence Number expected to be aggregated.
70 * @addba_resp_timer: timer for peer's response to addba request
71 * @addba_req_num: number of times addBA request has been sent.
72 */
73struct tid_ampdu_tx {
74 u8 state;
75 u8 dialog_token;
76 u16 ssn;
77 struct timer_list addba_resp_timer;
78 u8 addba_req_num;
79};
Ron Rindjunsky5aae2882007-12-25 17:00:32 +020080
81/**
82 * struct tid_ampdu_rx - TID aggregation information (Rx).
83 *
84 * @state: TID's state in session state machine.
85 * @dialog_token: dialog token for aggregation session
86 * @ssn: Starting Sequence Number expected to be aggregated.
87 * @buf_size: buffer size for incoming A-MPDUs
88 * @timeout: reset timer value.
89 * @head_seq_num: head sequence number in reordering buffer.
90 * @stored_mpdu_num: number of MPDUs in reordering buffer
91 * @reorder_buf: buffer to reorder incoming aggregated MPDUs
92 * @session_timer: check if peer keeps Tx-ing on the TID (by timeout value)
93 */
94struct tid_ampdu_rx {
95 u8 state;
96 u8 dialog_token;
97 u16 ssn;
98 u16 buf_size;
99 u16 timeout;
100 u16 head_seq_num;
101 u16 stored_mpdu_num;
102 struct sk_buff **reorder_buf;
103 struct timer_list session_timer;
104};
105
106/**
107 * struct sta_ampdu_mlme - STA aggregation information.
108 *
Ron Rindjunsky80656c22008-01-28 14:07:16 +0200109 * @tid_rx: aggregation info for Rx per TID
110 * @tid_tx: aggregation info for Tx per TID
Ron Rindjunsky5aae2882007-12-25 17:00:32 +0200111 * @ampdu_rx: for locking sections in aggregation Rx flow
Ron Rindjunsky80656c22008-01-28 14:07:16 +0200112 * @ampdu_tx: for locking sectionsi in aggregation Tx flow
113 * @dialog_token_allocator: dialog token enumerator for each new session;
Ron Rindjunsky5aae2882007-12-25 17:00:32 +0200114 */
115struct sta_ampdu_mlme {
116 struct tid_ampdu_rx tid_rx[STA_TID_NUM];
Ron Rindjunsky80656c22008-01-28 14:07:16 +0200117 struct tid_ampdu_tx tid_tx[STA_TID_NUM];
Ron Rindjunsky5aae2882007-12-25 17:00:32 +0200118 spinlock_t ampdu_rx;
Ron Rindjunsky80656c22008-01-28 14:07:16 +0200119 spinlock_t ampdu_tx;
120 u8 dialog_token_allocator;
Ron Rindjunsky5aae2882007-12-25 17:00:32 +0200121};
Jiri Bencf0706e82007-05-05 11:45:53 -0700122
123struct sta_info {
124 struct kref kref;
125 struct list_head list;
126 struct sta_info *hnext; /* next entry in hash table list */
127
128 struct ieee80211_local *local;
129
130 u8 addr[ETH_ALEN];
131 u16 aid; /* STA's unique AID (1..2007), 0 = not yet assigned */
132 u32 flags; /* WLAN_STA_ */
133
134 struct sk_buff_head ps_tx_buf; /* buffer of TX frames for station in
135 * power saving state */
Jiri Bencf0706e82007-05-05 11:45:53 -0700136 struct sk_buff_head tx_filtered; /* buffer of TX frames that were
137 * already given to low-level driver,
138 * but were filtered */
139 int clear_dst_mask;
140
141 unsigned long rx_packets, tx_packets; /* number of RX/TX MSDUs */
142 unsigned long rx_bytes, tx_bytes;
143 unsigned long tx_retry_failed, tx_retry_count;
144 unsigned long tx_filtered_count;
145
146 unsigned int wep_weak_iv_count; /* number of RX frames with weak IV */
147
148 unsigned long last_rx;
Johannes Berg8318d782008-01-24 19:38:38 +0100149 /* bitmap of supported rates per band */
150 u64 supp_rates[IEEE80211_NUM_BANDS];
151 int txrate_idx;
152 /* last rates used to send a frame to this STA */
153 int last_txrate_idx, last_nonerp_txrate_idx;
Jiri Bencf0706e82007-05-05 11:45:53 -0700154
155 struct net_device *dev; /* which net device is this station associated
156 * to */
157
158 struct ieee80211_key *key;
159
160 u32 tx_num_consecutive_failures;
161 u32 tx_num_mpdu_ok;
162 u32 tx_num_mpdu_fail;
163
164 struct rate_control_ref *rate_ctrl;
165 void *rate_ctrl_priv;
166
167 /* last received seq/frag number from this STA (per RX queue) */
168 __le16 last_seq_ctrl[NUM_RX_DATA_QUEUES];
169 unsigned long num_duplicates; /* number of duplicate frames received
170 * from this STA */
171 unsigned long tx_fragments; /* number of transmitted MPDUs */
172 unsigned long rx_fragments; /* number of received MPDUs */
173 unsigned long rx_dropped; /* number of dropped MPDUs from this STA */
174
175 int last_rssi; /* RSSI of last received frame from this STA */
176 int last_signal; /* signal of last received frame from this STA */
177 int last_noise; /* noise of last received frame from this STA */
178 int last_ack_rssi[3]; /* RSSI of last received ACKs from this STA */
179 unsigned long last_ack;
180 int channel_use;
181 int channel_use_raw;
182
Jiri Bencf0706e82007-05-05 11:45:53 -0700183#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
184 unsigned int wme_rx_queue[NUM_RX_DATA_QUEUES];
185 unsigned int wme_tx_queue[NUM_RX_DATA_QUEUES];
186#endif /* CONFIG_MAC80211_DEBUG_COUNTERS */
187
Jiri Bencf0706e82007-05-05 11:45:53 -0700188 u16 listen_interval;
Jiri Bence9f207f2007-05-05 11:46:38 -0700189
Ron Rindjunsky10816d42007-11-26 16:14:30 +0200190 struct ieee80211_ht_info ht_info; /* 802.11n HT capabilities
191 of this STA */
Ron Rindjunsky5aae2882007-12-25 17:00:32 +0200192 struct sta_ampdu_mlme ampdu_mlme;
193 u8 timer_to_tid[STA_TID_NUM]; /* convert timer id to tid */
Ron Rindjunsky80656c22008-01-28 14:07:16 +0200194 u8 tid_to_tx_q[STA_TID_NUM]; /* map tid to tx queue */
Ron Rindjunsky10816d42007-11-26 16:14:30 +0200195
Jiri Bence9f207f2007-05-05 11:46:38 -0700196#ifdef CONFIG_MAC80211_DEBUGFS
197 struct sta_info_debugfsdentries {
198 struct dentry *dir;
199 struct dentry *flags;
200 struct dentry *num_ps_buf_frames;
201 struct dentry *last_ack_rssi;
202 struct dentry *last_ack_ms;
203 struct dentry *inactive_ms;
204 struct dentry *last_seq_ctrl;
205#ifdef CONFIG_MAC80211_DEBUG_COUNTERS
206 struct dentry *wme_rx_queue;
207 struct dentry *wme_tx_queue;
208#endif
Ron Rindjunskyeb2ba622008-01-28 14:07:20 +0200209 struct dentry *agg_status;
Jiri Bence9f207f2007-05-05 11:46:38 -0700210 } debugfs;
211#endif
Jiri Bencf0706e82007-05-05 11:45:53 -0700212};
213
214
215/* Maximum number of concurrently registered stations */
216#define MAX_STA_COUNT 2007
217
218#define STA_HASH_SIZE 256
219#define STA_HASH(sta) (sta[5])
220
221
222/* Maximum number of frames to buffer per power saving station */
223#define STA_MAX_TX_BUFFER 128
224
225/* Minimum buffered frame expiry time. If STA uses listen interval that is
226 * smaller than this value, the minimum value here is used instead. */
227#define STA_TX_BUFFER_EXPIRE (10 * HZ)
228
229/* How often station data is cleaned up (e.g., expiration of buffered frames)
230 */
231#define STA_INFO_CLEANUP_INTERVAL (10 * HZ)
232
Michael Wube8755e2007-07-27 15:43:23 +0200233static inline void __sta_info_get(struct sta_info *sta)
234{
235 kref_get(&sta->kref);
236}
237
Jiri Bencf0706e82007-05-05 11:45:53 -0700238struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
Jiri Bencf0706e82007-05-05 11:45:53 -0700239void sta_info_put(struct sta_info *sta);
240struct sta_info * sta_info_add(struct ieee80211_local *local,
241 struct net_device *dev, u8 *addr, gfp_t gfp);
Michael Wube8755e2007-07-27 15:43:23 +0200242void sta_info_remove(struct sta_info *sta);
243void sta_info_free(struct sta_info *sta);
Jiri Bencf0706e82007-05-05 11:45:53 -0700244void sta_info_init(struct ieee80211_local *local);
245int sta_info_start(struct ieee80211_local *local);
246void sta_info_stop(struct ieee80211_local *local);
Jiri Bencf0706e82007-05-05 11:45:53 -0700247void sta_info_flush(struct ieee80211_local *local, struct net_device *dev);
248
Johannes Berg004c8722008-02-20 11:21:35 +0100249void sta_info_set_tim_bit(struct sta_info *sta);
250void sta_info_clear_tim_bit(struct sta_info *sta);
251
Jiri Bencf0706e82007-05-05 11:45:53 -0700252#endif /* STA_INFO_H */