]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/net/wireless/ar9170/ar9170.h
Make ar9170 use common ath reg code
[mirror_ubuntu-artful-kernel.git] / drivers / net / wireless / ar9170 / ar9170.h
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>
43 #include <net/wireless.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"
50
51 #include "../ath/regd.h"
52
53 #define PAYLOAD_MAX (AR9170_MAX_CMD_LEN/4 - 1)
54
55 enum ar9170_bw {
56 AR9170_BW_20,
57 AR9170_BW_40_BELOW,
58 AR9170_BW_40_ABOVE,
59
60 __AR9170_NUM_BW,
61 };
62
63 enum ar9170_rf_init_mode {
64 AR9170_RFI_NONE,
65 AR9170_RFI_WARM,
66 AR9170_RFI_COLD,
67 };
68
69 #define AR9170_MAX_RX_BUFFER_SIZE 8192
70
71 #ifdef CONFIG_AR9170_LEDS
72 struct ar9170;
73
74 struct ar9170_led {
75 struct ar9170 *ar;
76 struct led_classdev l;
77 char name[32];
78 unsigned int toggled;
79 bool registered;
80 };
81
82 #endif /* CONFIG_AR9170_LEDS */
83
84 enum ar9170_device_state {
85 AR9170_UNKNOWN_STATE,
86 AR9170_STOPPED,
87 AR9170_IDLE,
88 AR9170_STARTED,
89 AR9170_ASSOCIATED,
90 };
91
92 struct ar9170 {
93 struct ieee80211_hw *hw;
94 struct mutex mutex;
95 enum ar9170_device_state state;
96
97 int (*open)(struct ar9170 *);
98 void (*stop)(struct ar9170 *);
99 int (*tx)(struct ar9170 *, struct sk_buff *, bool, unsigned int);
100 int (*exec_cmd)(struct ar9170 *, enum ar9170_cmd, u32 ,
101 void *, u32 , void *);
102 void (*callback_cmd)(struct ar9170 *, u32 , void *);
103
104 /* interface mode settings */
105 struct ieee80211_vif *vif;
106 u8 mac_addr[ETH_ALEN];
107 u8 bssid[ETH_ALEN];
108
109 /* beaconing */
110 struct sk_buff *beacon;
111 struct work_struct beacon_work;
112
113 /* cryptographic engine */
114 u64 usedkeys;
115 bool rx_software_decryption;
116 bool disable_offload;
117
118 /* filter settings */
119 struct work_struct filter_config_work;
120 u64 cur_mc_hash, want_mc_hash;
121 u32 cur_filter, want_filter;
122 unsigned int filter_changed;
123 bool sniffer_enabled;
124
125 /* PHY */
126 struct ieee80211_channel *channel;
127 int noise[4];
128
129 /* power calibration data */
130 u8 power_5G_leg[4];
131 u8 power_2G_cck[4];
132 u8 power_2G_ofdm[4];
133 u8 power_5G_ht20[8];
134 u8 power_5G_ht40[8];
135 u8 power_2G_ht20[8];
136 u8 power_2G_ht40[8];
137
138 #ifdef CONFIG_AR9170_LEDS
139 struct delayed_work led_work;
140 struct ar9170_led leds[AR9170_NUM_LEDS];
141 #endif /* CONFIG_AR9170_LEDS */
142
143 /* qos queue settings */
144 spinlock_t tx_stats_lock;
145 struct ieee80211_tx_queue_stats tx_stats[5];
146 struct ieee80211_tx_queue_params edcf[5];
147
148 spinlock_t cmdlock;
149 __le32 cmdbuf[PAYLOAD_MAX + 1];
150
151 /* MAC statistics */
152 struct ieee80211_low_level_stats stats;
153
154 /* EEPROM */
155 struct ar9170_eeprom eeprom;
156 struct ath_regulatory regulatory;
157
158 /* global tx status for unregistered Stations. */
159 struct sk_buff_head global_tx_status;
160 struct sk_buff_head global_tx_status_waste;
161 struct delayed_work tx_status_janitor;
162 };
163
164 struct ar9170_sta_info {
165 struct sk_buff_head tx_status[__AR9170_NUM_TXQ];
166 };
167
168 #define IS_STARTED(a) (a->state >= AR9170_STARTED)
169 #define IS_ACCEPTING_CMD(a) (a->state >= AR9170_IDLE)
170
171 #define AR9170_FILTER_CHANGED_PROMISC BIT(0)
172 #define AR9170_FILTER_CHANGED_MULTICAST BIT(1)
173 #define AR9170_FILTER_CHANGED_FRAMEFILTER BIT(2)
174
175 /* exported interface */
176 void *ar9170_alloc(size_t priv_size);
177 int ar9170_register(struct ar9170 *ar, struct device *pdev);
178 void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb);
179 void ar9170_unregister(struct ar9170 *ar);
180 void ar9170_handle_tx_status(struct ar9170 *ar, struct sk_buff *skb,
181 bool update_statistics, u16 tx_status);
182
183 /* MAC */
184 int ar9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
185 int ar9170_init_mac(struct ar9170 *ar);
186 int ar9170_set_qos(struct ar9170 *ar);
187 int ar9170_update_multicast(struct ar9170 *ar);
188 int ar9170_update_frame_filter(struct ar9170 *ar);
189 int ar9170_set_operating_mode(struct ar9170 *ar);
190 int ar9170_set_beacon_timers(struct ar9170 *ar);
191 int ar9170_set_hwretry_limit(struct ar9170 *ar, u32 max_retry);
192 int ar9170_update_beacon(struct ar9170 *ar);
193 void ar9170_new_beacon(struct work_struct *work);
194 int ar9170_upload_key(struct ar9170 *ar, u8 id, const u8 *mac, u8 ktype,
195 u8 keyidx, u8 *keydata, int keylen);
196 int ar9170_disable_key(struct ar9170 *ar, u8 id);
197
198 /* LEDs */
199 #ifdef CONFIG_AR9170_LEDS
200 int ar9170_register_leds(struct ar9170 *ar);
201 void ar9170_unregister_leds(struct ar9170 *ar);
202 #endif /* CONFIG_AR9170_LEDS */
203 int ar9170_init_leds(struct ar9170 *ar);
204 int ar9170_set_leds_state(struct ar9170 *ar, u32 led_state);
205
206 /* PHY / RF */
207 int ar9170_init_phy(struct ar9170 *ar, enum ieee80211_band band);
208 int ar9170_init_rf(struct ar9170 *ar);
209 int ar9170_set_channel(struct ar9170 *ar, struct ieee80211_channel *channel,
210 enum ar9170_rf_init_mode rfi, enum ar9170_bw bw);
211
212 #endif /* __AR9170_H */