]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/wireless/ath/ar9170/ar9170.h
ar9170: remove redundant frame flags
[net-next-2.6.git] / drivers / net / wireless / ath / ar9170 / ar9170.h
CommitLineData
e9348cdd
CL
1/*
2 * Atheros AR9170 driver
3 *
4 * Driver specific definitions
5 *
6 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; see the file COPYING. If not, see
20 * http://www.gnu.org/licenses/.
21 *
22 * This file incorporates work covered by the following copyright and
23 * permission notice:
24 * Copyright (c) 2007-2008 Atheros Communications, Inc.
25 *
26 * Permission to use, copy, modify, and/or distribute this software for any
27 * purpose with or without fee is hereby granted, provided that the above
28 * copyright notice and this permission notice appear in all copies.
29 *
30 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
31 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
32 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
33 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
34 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
35 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
36 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
37 */
38#ifndef __AR9170_H
39#define __AR9170_H
40
41#include <linux/completion.h>
42#include <linux/spinlock.h>
d3236553 43#include <net/cfg80211.h>
e9348cdd
CL
44#include <net/mac80211.h>
45#ifdef CONFIG_AR9170_LEDS
46#include <linux/leds.h>
47#endif /* CONFIG_AR9170_LEDS */
48#include "eeprom.h"
49#include "hw.h"
50
203c4805 51#include "../regd.h"
1878f77e 52
e9348cdd
CL
53#define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
54
55enum ar9170_bw {
56 AR9170_BW_20,
57 AR9170_BW_40_BELOW,
58 AR9170_BW_40_ABOVE,
59
60 __AR9170_NUM_BW,
61};
62
9e52b062
JB
63static inline enum ar9170_bw nl80211_to_ar9170(enum nl80211_channel_type type)
64{
65 switch (type) {
66 case NL80211_CHAN_NO_HT:
67 case NL80211_CHAN_HT20:
68 return AR9170_BW_20;
69 case NL80211_CHAN_HT40MINUS:
70 return AR9170_BW_40_BELOW;
71 case NL80211_CHAN_HT40PLUS:
72 return AR9170_BW_40_ABOVE;
73 default:
74 BUG();
75 }
76}
77
e9348cdd
CL
78enum ar9170_rf_init_mode {
79 AR9170_RFI_NONE,
80 AR9170_RFI_WARM,
81 AR9170_RFI_COLD,
82};
83
84#define AR9170_MAX_RX_BUFFER_SIZE 8192
85
86#ifdef CONFIG_AR9170_LEDS
87struct ar9170;
88
89struct ar9170_led {
90 struct ar9170 *ar;
91 struct led_classdev l;
92 char name[32];
93 unsigned int toggled;
2431fe9a 94 bool last_state;
e9348cdd
CL
95 bool registered;
96};
97
98#endif /* CONFIG_AR9170_LEDS */
99
100enum ar9170_device_state {
101 AR9170_UNKNOWN_STATE,
102 AR9170_STOPPED,
103 AR9170_IDLE,
104 AR9170_STARTED,
e9348cdd
CL
105};
106
cca84799
CL
107struct ar9170_rxstream_mpdu_merge {
108 struct ar9170_rx_head plcp;
109 bool has_plcp;
110};
111
acbadf01
CL
112#define AR9170_NUM_TID 16
113#define WME_BA_BMP_SIZE 64
114#define AR9170_NUM_MAX_AGG_LEN (2 * WME_BA_BMP_SIZE)
115
116#define WME_AC_BE 2
117#define WME_AC_BK 3
118#define WME_AC_VI 1
119#define WME_AC_VO 0
120
121#define TID_TO_WME_AC(_tid) \
122 ((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
123 (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
124 (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
125 WME_AC_VO)
126
127#define BAW_WITHIN(_start, _bawsz, _seqno) \
128 ((((_seqno) - (_start)) & 0xfff) < (_bawsz))
129
130enum ar9170_tid_state {
131 AR9170_TID_STATE_INVALID,
132 AR9170_TID_STATE_SHUTDOWN,
133 AR9170_TID_STATE_PROGRESS,
134 AR9170_TID_STATE_COMPLETE,
135};
136
137struct ar9170_sta_tid {
138 struct list_head list;
139 struct sk_buff_head queue;
140 u8 addr[ETH_ALEN];
141 u16 ssn;
142 u16 tid;
143 enum ar9170_tid_state state;
144 bool active;
acbadf01
CL
145};
146
9b9c5aae
CL
147#define AR9170_QUEUE_TIMEOUT 64
148#define AR9170_TX_TIMEOUT 8
acbadf01 149#define AR9170_BA_TIMEOUT 4
9b9c5aae
CL
150#define AR9170_JANITOR_DELAY 128
151#define AR9170_TX_INVALID_RATE 0xffffffff
152
acbadf01
CL
153#define AR9170_NUM_TX_STATUS 128
154#define AR9170_NUM_TX_AGG_MAX 30
53a76b58
CL
155#define AR9170_NUM_TX_LIMIT_HARD AR9170_TXQ_DEPTH
156#define AR9170_NUM_TX_LIMIT_SOFT (AR9170_TXQ_DEPTH - 10)
acbadf01 157
e9348cdd
CL
158struct ar9170 {
159 struct ieee80211_hw *hw;
608b88cb 160 struct ath_common common;
e9348cdd
CL
161 struct mutex mutex;
162 enum ar9170_device_state state;
cca84799 163 unsigned long bad_hw_nagger;
e9348cdd
CL
164
165 int (*open)(struct ar9170 *);
166 void (*stop)(struct ar9170 *);
9b9c5aae 167 int (*tx)(struct ar9170 *, struct sk_buff *);
e9348cdd
CL
168 int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
169 void *, u32 , void *);
170 void (*callback_cmd)(struct ar9170 *, u32 , void *);
9b9c5aae 171 int (*flush)(struct ar9170 *);
e9348cdd
CL
172
173 /* interface mode settings */
174 struct ieee80211_vif *vif;
e9348cdd
CL
175
176 /* beaconing */
177 struct sk_buff *beacon;
178 struct work_struct beacon_work;
ea39d1a4 179 bool enable_beacon;
e9348cdd
CL
180
181 /* cryptographic engine */
182 u64 usedkeys;
183 bool rx_software_decryption;
184 bool disable_offload;
185
186 /* filter settings */
eeef4185
CL
187 u64 cur_mc_hash;
188 u32 cur_filter;
cca84799 189 unsigned int filter_state;
e9348cdd
CL
190 bool sniffer_enabled;
191
192 /* PHY */
193 struct ieee80211_channel *channel;
194 int noise[4];
195
196 /* power calibration data */
197 u8 power_5G_leg[4];
198 u8 power_2G_cck[4];
199 u8 power_2G_ofdm[4];
200 u8 power_5G_ht20[8];
201 u8 power_5G_ht40[8];
202 u8 power_2G_ht20[8];
203 u8 power_2G_ht40[8];
204
7c52c07d
JA
205 u8 phy_heavy_clip;
206
e9348cdd
CL
207#ifdef CONFIG_AR9170_LEDS
208 struct delayed_work led_work;
209 struct ar9170_led leds[AR9170_NUM_LEDS];
210#endif /* CONFIG_AR9170_LEDS */
211
212 /* qos queue settings */
213 spinlock_t tx_stats_lock;
214 struct ieee80211_tx_queue_stats tx_stats[5];
215 struct ieee80211_tx_queue_params edcf[5];
216
217 spinlock_t cmdlock;
218 __le32 cmdbuf[PAYLOAD_MAX + 1];
219
220 /* MAC statistics */
221 struct ieee80211_low_level_stats stats;
222
223 /* EEPROM */
224 struct ar9170_eeprom eeprom;
225
9b9c5aae
CL
226 /* tx queues - as seen by hw - */
227 struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
228 struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
229 struct delayed_work tx_janitor;
acbadf01
CL
230 /* tx ampdu */
231 struct sk_buff_head tx_status_ampdu;
232 spinlock_t tx_ampdu_list_lock;
233 struct list_head tx_ampdu_list;
02bdf5b4 234 atomic_t tx_ampdu_pending;
cca84799
CL
235
236 /* rxstream mpdu merge */
237 struct ar9170_rxstream_mpdu_merge rx_mpdu;
238 struct sk_buff *rx_failover;
239 int rx_failover_missing;
acbadf01
CL
240
241 /* (cached) HW A-MPDU settings */
242 u8 global_ampdu_density;
243 u8 global_ampdu_factor;
e9348cdd
CL
244};
245
246struct ar9170_sta_info {
acbadf01
CL
247 struct ar9170_sta_tid agg[AR9170_NUM_TID];
248 unsigned int ampdu_max_len;
e9348cdd
CL
249};
250
9b9c5aae
CL
251struct ar9170_tx_info {
252 unsigned long timeout;
9b9c5aae
CL
253};
254
255#define IS_STARTED(a) (((struct ar9170 *)a)->state >= AR9170_STARTED)
256#define IS_ACCEPTING_CMD(a) (((struct ar9170 *)a)->state >= AR9170_IDLE)
e9348cdd 257
e9348cdd
CL
258/* exported interface */
259void *ar9170_alloc(size_t priv_size);
260int ar9170_register(struct ar9170 *ar, struct device *pdev);
261void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
262void ar9170_unregister(struct ar9170 *ar);
9b9c5aae 263void ar9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
66d00813 264void ar9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
9b9c5aae 265int ar9170_nag_limiter(struct ar9170 *ar);
e9348cdd
CL
266
267/* MAC */
268int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
269int ar9170_init_mac(struct ar9170 *ar);
270int ar9170_set_qos(struct ar9170 *ar);
eeef4185
CL
271int ar9170_update_multicast(struct ar9170 *ar, const u64 mc_hast);
272int ar9170_update_frame_filter(struct ar9170 *ar, const u32 filter);
e9348cdd
CL
273int ar9170_set_operating_mode(struct ar9170 *ar);
274int ar9170_set_beacon_timers(struct ar9170 *ar);
29ceff5d
CL
275int ar9170_set_dyn_sifs_ack(struct ar9170 *ar);
276int ar9170_set_slot_time(struct ar9170 *ar);
277int ar9170_set_basic_rates(struct ar9170 *ar);
e9348cdd
CL
278int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
279int ar9170_update_beacon(struct ar9170 *ar);
280void ar9170_new_beacon(struct work_struct *work);
281int ar9170_upload_key(struct ar9170 *ar, u8 id, const u8 *mac, u8 ktype,
282 u8 keyidx, u8 *keydata, int keylen);
283int ar9170_disable_key(struct ar9170 *ar, u8 id);
284
285/* LEDs */
286#ifdef CONFIG_AR9170_LEDS
287int ar9170_register_leds(struct ar9170 *ar);
288void ar9170_unregister_leds(struct ar9170 *ar);
289#endif /* CONFIG_AR9170_LEDS */
290int ar9170_init_leds(struct ar9170 *ar);
291int ar9170_set_leds_state(struct ar9170 *ar, u32 led_state);
292
293/* PHY / RF */
294int ar9170_init_phy(struct ar9170 *ar, enum ieee80211_band band);
295int ar9170_init_rf(struct ar9170 *ar);
296int ar9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
297 enum ar9170_rf_init_mode rfi, enum ar9170_bw bw);
298
299#endif /* __AR9170_H */