base.h 9.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*-
 * Copyright (c) 2002-2007 Sam Leffler, Errno Consulting
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer,
 *    without modification.
 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
 *    similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
 *    redistribution must be conditioned upon including a substantially
 *    similar Disclaimer requirement for further binary redistribution.
 * 3. Neither the names of the above-listed copyright holders nor the names
 *    of any contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * Alternatively, this software may be distributed under the terms of the
 * GNU General Public License ("GPL") version 2 as published by the Free
 * Software Foundation.
 *
 * NO WARRANTY
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGES.
 *
 */

/*
39
 * Definitions for the Atheros Wireless LAN controller driver.
40
41
42
43
44
45
46
47
 */
#ifndef _DEV_ATH_ATHVAR_H
#define _DEV_ATH_ATHVAR_H

#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/wireless.h>
#include <linux/if_ether.h>
48
#include <linux/leds.h>
49
#include <linux/rfkill.h>
50
#include <linux/workqueue.h>
51
52
53

#include "ath5k.h"
#include "debug.h"
54
#include "ani.h"
55
56

#include "../regd.h"
57
#include "../ath.h"
58
59
60

#define	ATH_RXBUF	40		/* number of RX buffers */
#define	ATH_TXBUF	200		/* number of TX buffers */
61
#define ATH_BCBUF	4		/* number of beacon buffers */
62
63
64
#define ATH5K_TXQ_LEN_MAX	(ATH_TXBUF / 4)		/* bufs per queue */
#define ATH5K_TXQ_LEN_LOW	(ATH5K_TXQ_LEN_MAX / 2)	/* low mark */

65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
struct ath5k_buf {
	struct list_head	list;
	struct ath5k_desc	*desc;	/* virtual addr of desc */
	dma_addr_t		daddr;	/* physical addr of desc */
	struct sk_buff		*skb;	/* skbuff for buf */
	dma_addr_t		skbaddr;/* physical addr of skb data */
};

/*
 * Data transmit queue state.  One of these exists for each
 * hardware transmit queue.  Packets sent to us from above
 * are assigned to queues based on their priority.  Not all
 * devices support a complete set of hardware transmit queues.
 * For those devices the array sc_ac2q will map multiple
 * priorities to fewer hardware queues (typically all to one
 * hardware queue).
 */
struct ath5k_txq {
	unsigned int		qnum;	/* hardware q number */
	u32			*link;	/* link ptr in last TX desc */
	struct list_head	q;	/* transmit queue */
	spinlock_t		lock;	/* lock on q and link */
	bool			setup;
88
	int			txq_len; /* number of queued buffers */
89
	int			txq_max; /* max allowed num of queued buffers */
90
	bool			txq_poll_mark;
91
	unsigned int		txq_stuck;	/* informational counter */
92
93
};

94
95
96
97
98
#define ATH5K_LED_MAX_NAME_LEN 31

/*
 * State for LED triggers
 */
99
struct ath5k_led {
100
101
102
103
104
	char name[ATH5K_LED_MAX_NAME_LEN + 1];	/* name of the LED in sysfs */
	struct ath5k_softc *sc;			/* driver state */
	struct led_classdev led_dev;		/* led classdev */
};

105
106
107
108
109
110
111
112
113
/* Rfkill */
struct ath5k_rfkill {
	/* GPIO PIN for rfkill */
	u16 gpio;
	/* polarity of rfkill GPIO PIN */
	bool polarity;
	/* RFKILL toggle tasklet */
	struct tasklet_struct toggleq;
};
114

Bruno Randolf's avatar
Bruno Randolf committed
115
/* statistics */
116
struct ath5k_statistics {
Bruno Randolf's avatar
Bruno Randolf committed
117
	/* antenna use */
118
119
	unsigned int antenna_rx[5];	/* frames count per antenna RX */
	unsigned int antenna_tx[5];	/* frames count per antenna TX */
Bruno Randolf's avatar
Bruno Randolf committed
120
121

	/* frame errors */
122
123
	unsigned int rx_all_count;	/* all RX frames, including errors */
	unsigned int tx_all_count;	/* all TX frames, including errors */
124
125
126
127
128
129
130
	unsigned int rx_bytes_count;	/* all RX bytes, including errored pks
					 * and the MAC headers for each packet
					 */
	unsigned int tx_bytes_count;	/* all TX bytes, including errored pkts
					 * and the MAC headers and padding for
					 * each packet.
					 */
131
132
	unsigned int rxerr_crc;
	unsigned int rxerr_phy;
Bruno Randolf's avatar
Bruno Randolf committed
133
	unsigned int rxerr_phy_code[32];
134
135
136
137
138
139
140
141
	unsigned int rxerr_fifo;
	unsigned int rxerr_decrypt;
	unsigned int rxerr_mic;
	unsigned int rxerr_proc;
	unsigned int rxerr_jumbo;
	unsigned int txerr_retry;
	unsigned int txerr_fifo;
	unsigned int txerr_filt;
Bruno Randolf's avatar
Bruno Randolf committed
142
143
144
145
146
147
148

	/* MIB counters */
	unsigned int ack_fail;
	unsigned int rts_fail;
	unsigned int rts_ok;
	unsigned int fcs_error;
	unsigned int beacons;
149
150

	unsigned int mib_intr;
151
	unsigned int rxorn_intr;
152
	unsigned int rxeol_intr;
153
154
};

155
156
157
#if CHAN_DEBUG
#define ATH_CHAN_MAX	(26+26+26+200+200)
#else
158
#define ATH_CHAN_MAX	(14+14+14+252+20)
159
160
#endif

161
162
163
164
165
166
167
168
struct ath5k_vif {
	bool			assoc; /* are we associated or not */
	enum nl80211_iftype	opmode;
	int			bslot;
	struct ath5k_buf	*bbuf; /* beacon buffer */
	u8			lladdr[ETH_ALEN];
};

169
170
171
/* Software Carrier, keeps track of the driver state
 * associated with an instance of a device */
struct ath5k_softc {
172
173
174
	struct pci_dev		*pdev;
	struct device		*dev;		/* for dma mapping */
	int irq;
175
	u16 devid;
176
177
178
	void __iomem		*iobase;	/* address of the device */
	struct mutex		lock;		/* dev-level lock */
	struct ieee80211_hw	*hw;		/* IEEE 802.11 common */
179
	struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
180
	struct ieee80211_channel channels[ATH_CHAN_MAX];
Bruno Randolf's avatar
Bruno Randolf committed
181
	struct ieee80211_rate	rates[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
182
	s8			rate_idx[IEEE80211_NUM_BANDS][AR5K_MAX_RATES];
183
	enum nl80211_iftype	opmode;
184
185
	struct ath5k_hw		*ah;		/* Atheros HW */

186
#ifdef CONFIG_ATH5K_DEBUG
187
	struct ath5k_dbg_info	debug;		/* debug info */
188
#endif /* CONFIG_ATH5K_DEBUG */
189
190
191
192
193
194

	struct ath5k_buf	*bufptr;	/* allocated buffer ptr */
	struct ath5k_desc	*desc;		/* TX/RX descriptors */
	dma_addr_t		desc_daddr;	/* DMA (physical) address */
	size_t			desc_len;	/* size of TX/RX descriptors */

195
	DECLARE_BITMAP(status, 6);
196
197
198
#define ATH_STAT_INVALID	0		/* disable hardware accesses */
#define ATH_STAT_MRRETRY	1		/* multi-rate retry support */
#define ATH_STAT_PROMISC	2
199
#define ATH_STAT_LEDSOFT	3		/* enable LED gpio status */
200
#define ATH_STAT_STARTED	4		/* opened & irqs enabled */
201
#define ATH_STAT_2G_DISABLED	5		/* multiband radio without 2G */
202
203
204
205

	unsigned int		filter_flags;	/* HW flags, AR5K_RX_FILTER_* */
	struct ieee80211_channel *curchan;	/* current h/w channel */

206
	u16			nvifs;
207
208
209

	enum ath5k_int		imask;		/* interrupt mask copy */

210
211
212
213
	spinlock_t		irqlock;
	bool			rx_pending;	/* rx tasklet pending */
	bool			tx_pending;	/* tx tasklet pending */

214
	u8			lladdr[ETH_ALEN];
215
216
217
	u8			bssidmask[ETH_ALEN];

	unsigned int		led_pin,	/* GPIO pin for driving LED */
218
				led_on;		/* pin setting for LED on */
219

220
	struct work_struct	reset_work;	/* deferred chip reset */
221
222
223
224
225
226

	unsigned int		rxbufsize;	/* rx size based on mtu */
	struct list_head	rxbuf;		/* receive buffer */
	spinlock_t		rxbuflock;
	u32			*rxlink;	/* link ptr in last RX desc */
	struct tasklet_struct	rxtq;		/* rx intr tasklet */
227
	struct ath5k_led	rx_led;		/* rx led */
228
229
230
231

	struct list_head	txbuf;		/* transmit buffer */
	spinlock_t		txbuflock;
	unsigned int		txbuf_len;	/* buf count in txbuf list */
232
	struct ath5k_txq	txqs[AR5K_NUM_TX_QUEUES];	/* tx queues */
233
	struct tasklet_struct	txtq;		/* tx intr tasklet */
234
	struct ath5k_led	tx_led;		/* tx led */
235

236
237
	struct ath5k_rfkill	rf_kill;

238
239
	struct tasklet_struct	calib;		/* calibration tasklet */

Jiri Slaby's avatar
Jiri Slaby committed
240
	spinlock_t		block;		/* protects beacon */
241
	struct tasklet_struct	beacontq;	/* beacon intr tasklet */
242
243
244
245
	struct list_head	bcbuf;		/* beacon buffer */
	struct ieee80211_vif	*bslot[ATH_BCBUF];
	u16			num_ap_vifs;
	u16			num_adhoc_vifs;
246
247
	unsigned int		bhalq,		/* SW q for outgoing beacons */
				bmisscount,	/* missed beacon transmits */
248
				bintval,	/* beacon interval in TU */
249
				bsent;
250
	unsigned int		nexttbtt;	/* next beacon time in TU */
251
	struct ath5k_txq	*cabq;		/* content after beacon */
252

253
	int			power_level;	/* Requested tx power in dbm */
254
	bool			assoc;		/* associate state */
255
	bool			enable_beacon;	/* true if beacons are on */
256
257

	struct ath5k_statistics	stats;
258
259
260

	struct ath5k_ani_state	ani_state;
	struct tasklet_struct	ani_tasklet;	/* ANI calibration */
261
262

	struct delayed_work	tx_complete_work;
Bruno Randolf's avatar
Bruno Randolf committed
263
264

	struct survey_info	survey;		/* collected survey info */
265
266
};

267
268
269
270
271
272
273
274
275
276
277
278
279
struct ath5k_vif_iter_data {
	const u8	*hw_macaddr;
	u8		mask[ETH_ALEN];
	u8		active_mac[ETH_ALEN]; /* first active MAC */
	bool		need_set_hw_addr;
	bool		found_active;
	bool		any_assoc;
	enum nl80211_iftype opmode;
	int n_stas;
};
void ath5k_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif);


280
281
282
283
284
285
#define ath5k_hw_hasbssidmask(_ah) \
	(ath5k_hw_get_capability(_ah, AR5K_CAP_BSSIDMASK, 0, NULL) == 0)
#define ath5k_hw_hasveol(_ah) \
	(ath5k_hw_get_capability(_ah, AR5K_CAP_VEOL, 0, NULL) == 0)

#endif