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