2 * Atheros AR9170 driver
4 * Driver specific definitions
6 * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
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.
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.
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/.
22 * This file incorporates work covered by the following copyright and
24 * Copyright (c) 2007-2008 Atheros Communications, Inc.
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.
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.
41 #include <linux/completion.h>
42 #include <linux/spinlock.h>
43 #include <net/cfg80211.h>
44 #include <net/mac80211.h>
45 #ifdef CONFIG_AR9170_LEDS
46 #include <linux/leds.h>
47 #endif /* CONFIG_AR9170_LEDS */
53 #define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
63 static inline enum ar9170_bw nl80211_to_ar9170(enum nl80211_channel_type type)
66 case NL80211_CHAN_NO_HT:
67 case NL80211_CHAN_HT20:
69 case NL80211_CHAN_HT40MINUS:
70 return AR9170_BW_40_BELOW;
71 case NL80211_CHAN_HT40PLUS:
72 return AR9170_BW_40_ABOVE;
78 enum ar9170_rf_init_mode {
84 #define AR9170_MAX_RX_BUFFER_SIZE 8192
86 #ifdef CONFIG_AR9170_LEDS
91 struct led_classdev l;
98 #endif /* CONFIG_AR9170_LEDS */
100 enum ar9170_device_state {
101 AR9170_UNKNOWN_STATE,
107 struct ar9170_rxstream_mpdu_merge {
108 struct ar9170_rx_head plcp;
112 #define AR9170_NUM_MAX_BA_RETRY 5
113 #define AR9170_NUM_TID 16
114 #define WME_BA_BMP_SIZE 64
115 #define AR9170_NUM_MAX_AGG_LEN (2 * WME_BA_BMP_SIZE)
122 #define TID_TO_WME_AC(_tid) \
123 ((((_tid) == 0) || ((_tid) == 3)) ? WME_AC_BE : \
124 (((_tid) == 1) || ((_tid) == 2)) ? WME_AC_BK : \
125 (((_tid) == 4) || ((_tid) == 5)) ? WME_AC_VI : \
128 #define BAW_WITHIN(_start, _bawsz, _seqno) \
129 ((((_seqno) - (_start)) & 0xfff) < (_bawsz))
131 enum ar9170_tid_state {
132 AR9170_TID_STATE_INVALID,
133 AR9170_TID_STATE_SHUTDOWN,
134 AR9170_TID_STATE_PROGRESS,
135 AR9170_TID_STATE_COMPLETE,
138 struct ar9170_sta_tid {
139 struct list_head list;
140 struct sk_buff_head queue;
144 enum ar9170_tid_state state;
149 #define AR9170_QUEUE_TIMEOUT 64
150 #define AR9170_TX_TIMEOUT 8
151 #define AR9170_BA_TIMEOUT 4
152 #define AR9170_JANITOR_DELAY 128
153 #define AR9170_TX_INVALID_RATE 0xffffffff
155 #define AR9170_NUM_TX_STATUS 128
156 #define AR9170_NUM_TX_AGG_MAX 30
159 struct ieee80211_hw *hw;
161 enum ar9170_device_state state;
162 unsigned long bad_hw_nagger;
164 int (*open)(struct ar9170 *);
165 void (*stop)(struct ar9170 *);
166 int (*tx)(struct ar9170 *, struct sk_buff *);
167 int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
168 void *, u32 , void *);
169 void (*callback_cmd)(struct ar9170 *, u32 , void *);
170 int (*flush)(struct ar9170 *);
172 /* interface mode settings */
173 struct ieee80211_vif *vif;
174 u8 mac_addr[ETH_ALEN];
178 struct sk_buff *beacon;
179 struct work_struct beacon_work;
181 /* cryptographic engine */
183 bool rx_software_decryption;
184 bool disable_offload;
186 /* filter settings */
187 struct work_struct filter_config_work;
188 u64 cur_mc_hash, want_mc_hash;
189 u32 cur_filter, want_filter;
190 unsigned long filter_changed;
191 unsigned int filter_state;
192 bool sniffer_enabled;
195 struct ieee80211_channel *channel;
198 /* power calibration data */
207 #ifdef CONFIG_AR9170_LEDS
208 struct delayed_work led_work;
209 struct ar9170_led leds[AR9170_NUM_LEDS];
210 #endif /* CONFIG_AR9170_LEDS */
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];
218 __le32 cmdbuf[PAYLOAD_MAX + 1];
221 struct ieee80211_low_level_stats stats;
224 struct ar9170_eeprom eeprom;
225 struct ath_regulatory regulatory;
227 /* tx queues - as seen by hw - */
228 struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
229 struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
230 struct delayed_work tx_janitor;
232 struct sk_buff_head tx_status_ampdu;
233 spinlock_t tx_ampdu_list_lock;
234 struct list_head tx_ampdu_list;
235 unsigned int tx_ampdu_pending;
237 /* rxstream mpdu merge */
238 struct ar9170_rxstream_mpdu_merge rx_mpdu;
239 struct sk_buff *rx_failover;
240 int rx_failover_missing;
242 /* (cached) HW A-MPDU settings */
243 u8 global_ampdu_density;
244 u8 global_ampdu_factor;
247 struct ar9170_sta_info {
248 struct ar9170_sta_tid agg[AR9170_NUM_TID];
249 unsigned int ampdu_max_len;
252 #define AR9170_TX_FLAG_WAIT_FOR_ACK BIT(0)
253 #define AR9170_TX_FLAG_NO_ACK BIT(1)
254 #define AR9170_TX_FLAG_BLOCK_ACK BIT(2)
256 struct ar9170_tx_info {
257 unsigned long timeout;
261 #define IS_STARTED(a) (((struct ar9170 *)a)->state >= AR9170_STARTED)
262 #define IS_ACCEPTING_CMD(a) (((struct ar9170 *)a)->state >= AR9170_IDLE)
264 #define AR9170_FILTER_CHANGED_MODE BIT(0)
265 #define AR9170_FILTER_CHANGED_MULTICAST BIT(1)
266 #define AR9170_FILTER_CHANGED_FRAMEFILTER BIT(2)
268 /* exported interface */
269 void *ar9170_alloc(size_t priv_size);
270 int ar9170_register(struct ar9170 *ar, struct device *pdev);
271 void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
272 void ar9170_unregister(struct ar9170 *ar);
273 void ar9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
274 void ar9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
275 int ar9170_nag_limiter(struct ar9170 *ar);
278 int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
279 int ar9170_init_mac(struct ar9170 *ar);
280 int ar9170_set_qos(struct ar9170 *ar);
281 int ar9170_update_multicast(struct ar9170 *ar);
282 int ar9170_update_frame_filter(struct ar9170 *ar);
283 int ar9170_set_operating_mode(struct ar9170 *ar);
284 int ar9170_set_beacon_timers(struct ar9170 *ar);
285 int ar9170_set_dyn_sifs_ack(struct ar9170 *ar);
286 int ar9170_set_slot_time(struct ar9170 *ar);
287 int ar9170_set_basic_rates(struct ar9170 *ar);
288 int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
289 int ar9170_update_beacon(struct ar9170 *ar);
290 void ar9170_new_beacon(struct work_struct *work);
291 int ar9170_upload_key(struct ar9170 *ar, u8 id, const u8 *mac, u8 ktype,
292 u8 keyidx, u8 *keydata, int keylen);
293 int ar9170_disable_key(struct ar9170 *ar, u8 id);
296 #ifdef CONFIG_AR9170_LEDS
297 int ar9170_register_leds(struct ar9170 *ar);
298 void ar9170_unregister_leds(struct ar9170 *ar);
299 #endif /* CONFIG_AR9170_LEDS */
300 int ar9170_init_leds(struct ar9170 *ar);
301 int ar9170_set_leds_state(struct ar9170 *ar, u32 led_state);
304 int ar9170_init_phy(struct ar9170 *ar, enum ieee80211_band band);
305 int ar9170_init_rf(struct ar9170 *ar);
306 int ar9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
307 enum ar9170_rf_init_mode rfi, enum ar9170_bw bw);
309 #endif /* __AR9170_H */