proc: use seq_puts()/seq_putc() where possible
[linux-2.6/next.git] / drivers / net / wireless / ath / ar9170 / ar9170.h
blob4f845f80c0984ea054481979d9e928dc5ce0f290
1 /*
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
23 * permission notice:
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.
38 #ifndef __AR9170_H
39 #define __AR9170_H
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 */
48 #include "eeprom.h"
49 #include "hw.h"
51 #include "../regd.h"
53 #define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
55 enum ar9170_bw {
56 AR9170_BW_20,
57 AR9170_BW_40_BELOW,
58 AR9170_BW_40_ABOVE,
60 __AR9170_NUM_BW,
63 static inline enum ar9170_bw nl80211_to_ar9170(enum nl80211_channel_type type)
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();
78 enum ar9170_rf_init_mode {
79 AR9170_RFI_NONE,
80 AR9170_RFI_WARM,
81 AR9170_RFI_COLD,
84 #define AR9170_MAX_RX_BUFFER_SIZE 8192
86 #ifdef CONFIG_AR9170_LEDS
87 struct ar9170;
89 struct ar9170_led {
90 struct ar9170 *ar;
91 struct led_classdev l;
92 char name[32];
93 unsigned int toggled;
94 bool last_state;
95 bool registered;
98 #endif /* CONFIG_AR9170_LEDS */
100 enum ar9170_device_state {
101 AR9170_UNKNOWN_STATE,
102 AR9170_STOPPED,
103 AR9170_IDLE,
104 AR9170_STARTED,
107 struct ar9170_rxstream_mpdu_merge {
108 struct ar9170_rx_head plcp;
109 bool has_plcp;
112 struct ar9170_tx_queue_stats {
113 unsigned int len;
114 unsigned int limit;
115 unsigned int count;
118 #define AR9170_QUEUE_TIMEOUT 64
119 #define AR9170_TX_TIMEOUT 8
120 #define AR9170_JANITOR_DELAY 128
121 #define AR9170_TX_INVALID_RATE 0xffffffff
123 #define AR9170_NUM_TX_LIMIT_HARD AR9170_TXQ_DEPTH
124 #define AR9170_NUM_TX_LIMIT_SOFT (AR9170_TXQ_DEPTH - 10)
126 struct ar9170 {
127 struct ieee80211_hw *hw;
128 struct ath_common common;
129 struct mutex mutex;
130 enum ar9170_device_state state;
131 bool registered;
132 unsigned long bad_hw_nagger;
134 int (*open)(struct ar9170 *);
135 void (*stop)(struct ar9170 *);
136 int (*tx)(struct ar9170 *, struct sk_buff *);
137 int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
138 void *, u32 , void *);
139 void (*callback_cmd)(struct ar9170 *, u32 , void *);
140 int (*flush)(struct ar9170 *);
142 /* interface mode settings */
143 struct ieee80211_vif *vif;
145 /* beaconing */
146 struct sk_buff *beacon;
147 struct work_struct beacon_work;
148 bool enable_beacon;
150 /* cryptographic engine */
151 u64 usedkeys;
152 bool rx_software_decryption;
153 bool disable_offload;
155 /* filter settings */
156 u64 cur_mc_hash;
157 u32 cur_filter;
158 unsigned int filter_state;
159 bool sniffer_enabled;
161 /* PHY */
162 struct ieee80211_channel *channel;
163 int noise[4];
165 /* power calibration data */
166 u8 power_5G_leg[4];
167 u8 power_2G_cck[4];
168 u8 power_2G_ofdm[4];
169 u8 power_5G_ht20[8];
170 u8 power_5G_ht40[8];
171 u8 power_2G_ht20[8];
172 u8 power_2G_ht40[8];
174 u8 phy_heavy_clip;
176 #ifdef CONFIG_AR9170_LEDS
177 struct delayed_work led_work;
178 struct ar9170_led leds[AR9170_NUM_LEDS];
179 #endif /* CONFIG_AR9170_LEDS */
181 /* qos queue settings */
182 spinlock_t tx_stats_lock;
183 struct ar9170_tx_queue_stats tx_stats[5];
184 struct ieee80211_tx_queue_params edcf[5];
186 spinlock_t cmdlock;
187 __le32 cmdbuf[PAYLOAD_MAX + 1];
189 /* MAC statistics */
190 struct ieee80211_low_level_stats stats;
192 /* EEPROM */
193 struct ar9170_eeprom eeprom;
195 /* tx queues - as seen by hw - */
196 struct sk_buff_head tx_pending[__AR9170_NUM_TXQ];
197 struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
198 struct delayed_work tx_janitor;
200 /* rxstream mpdu merge */
201 struct ar9170_rxstream_mpdu_merge rx_mpdu;
202 struct sk_buff *rx_failover;
203 int rx_failover_missing;
205 /* (cached) HW A-MPDU settings */
206 u8 global_ampdu_density;
207 u8 global_ampdu_factor;
210 struct ar9170_tx_info {
211 unsigned long timeout;
214 #define IS_STARTED(a) (((struct ar9170 *)a)->state >= AR9170_STARTED)
215 #define IS_ACCEPTING_CMD(a) (((struct ar9170 *)a)->state >= AR9170_IDLE)
217 /* exported interface */
218 void *ar9170_alloc(size_t priv_size);
219 int ar9170_register(struct ar9170 *ar, struct device *pdev);
220 void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
221 void ar9170_unregister(struct ar9170 *ar);
222 void ar9170_tx_callback(struct ar9170 *ar, struct sk_buff *skb);
223 void ar9170_handle_command_response(struct ar9170 *ar, void *buf, u32 len);
224 int ar9170_nag_limiter(struct ar9170 *ar);
226 /* MAC */
227 int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
228 int ar9170_init_mac(struct ar9170 *ar);
229 int ar9170_set_qos(struct ar9170 *ar);
230 int ar9170_update_multicast(struct ar9170 *ar, const u64 mc_hast);
231 int ar9170_update_frame_filter(struct ar9170 *ar, const u32 filter);
232 int ar9170_set_operating_mode(struct ar9170 *ar);
233 int ar9170_set_beacon_timers(struct ar9170 *ar);
234 int ar9170_set_dyn_sifs_ack(struct ar9170 *ar);
235 int ar9170_set_slot_time(struct ar9170 *ar);
236 int ar9170_set_basic_rates(struct ar9170 *ar);
237 int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
238 int ar9170_update_beacon(struct ar9170 *ar);
239 void ar9170_new_beacon(struct work_struct *work);
240 int ar9170_upload_key(struct ar9170 *ar, u8 id, const u8 *mac, u8 ktype,
241 u8 keyidx, u8 *keydata, int keylen);
242 int ar9170_disable_key(struct ar9170 *ar, u8 id);
244 /* LEDs */
245 #ifdef CONFIG_AR9170_LEDS
246 int ar9170_register_leds(struct ar9170 *ar);
247 void ar9170_unregister_leds(struct ar9170 *ar);
248 #endif /* CONFIG_AR9170_LEDS */
249 int ar9170_init_leds(struct ar9170 *ar);
250 int ar9170_set_leds_state(struct ar9170 *ar, u32 led_state);
252 /* PHY / RF */
253 int ar9170_init_phy(struct ar9170 *ar, enum ieee80211_band band);
254 int ar9170_init_rf(struct ar9170 *ar);
255 int ar9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
256 enum ar9170_rf_init_mode rfi, enum ar9170_bw bw);
258 #endif /* __AR9170_H */