4 * Copyright (c) 2006,2007
5 * Damien Bergamini <damien.bergamini@free.fr>
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <net80211/ieee80211_amrr.h>
21 struct wpi_rx_radiotap_header {
22 struct ieee80211_radiotap_header wr_ihdr;
26 uint16_t wr_chan_freq;
27 uint16_t wr_chan_flags;
28 int8_t wr_dbm_antsignal;
29 int8_t wr_dbm_antnoise;
33 #define WPI_RX_RADIOTAP_PRESENT \
34 ((1 << IEEE80211_RADIOTAP_TSFT) | \
35 (1 << IEEE80211_RADIOTAP_FLAGS) | \
36 (1 << IEEE80211_RADIOTAP_RATE) | \
37 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
38 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
39 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
40 (1 << IEEE80211_RADIOTAP_ANTENNA))
42 struct wpi_tx_radiotap_header {
43 struct ieee80211_radiotap_header wt_ihdr;
46 uint16_t wt_chan_freq;
47 uint16_t wt_chan_flags;
51 #define WPI_TX_RADIOTAP_PRESENT \
52 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
53 (1 << IEEE80211_RADIOTAP_RATE) | \
54 (1 << IEEE80211_RADIOTAP_CHANNEL))
59 bus_addr_t paddr; /* aligned p address */
60 bus_addr_t paddr_start; /* possibly unaligned p start*/
61 caddr_t vaddr; /* aligned v address */
62 caddr_t vaddr_start; /* possibly unaligned v start */
69 struct ieee80211_node *ni;
73 struct wpi_dma_info desc_dma;
74 struct wpi_dma_info cmd_dma;
75 struct wpi_tx_desc *desc;
76 struct wpi_tx_cmd *cmd;
77 struct wpi_tx_data *data;
78 bus_dma_tag_t data_dmat;
85 #define WPI_RBUF_COUNT ( WPI_RX_RING_COUNT + 16 )
93 struct wpi_dma_info desc_dma;
95 struct wpi_rx_data data[WPI_RX_RING_COUNT];
96 bus_dma_tag_t data_dmat;
101 struct ieee80211_node ni; /* must be the first */
105 int success_threshold;
110 struct ieee80211_node ni; /* must be the first */
111 struct ieee80211_amrr_node amn;
114 struct wpi_power_sample {
119 struct wpi_power_group {
120 #define WPI_SAMPLES_COUNT 5
121 struct wpi_power_sample samples[WPI_SAMPLES_COUNT];
129 struct ifnet *sc_ifp;
131 /* net80211 driver specifics */
132 struct ieee80211com sc_ic;
133 int (*sc_newstate)(struct ieee80211com *,
134 enum ieee80211_state, int);
135 unsigned long maxdwell; /* Max dwell time whilst scanning */
139 struct ieee80211_amrr amrr;
141 /* Flags indicating the current state the driver
142 * expects the hardware to be in
145 #define WPI_FLAG_HW_RADIO_OFF (1 << 0)
146 #define WPI_FLAG_SCANNING (1 << 1)
147 #define WPI_FLAG_BUSY (1 << 2)
148 #define WPI_FLAG_AUTH (1 << 3)
151 struct wpi_dma_info shared_dma;
152 struct wpi_shared *shared;
154 struct wpi_tx_ring txq[WME_NUM_AC];
155 struct wpi_tx_ring cmdq;
156 struct wpi_rx_ring rxq;
158 /* TX Thermal Callibration */
159 struct callout calib_to;
162 /* Watch dog timer */
163 struct callout watchdog_to;
164 /* Hardware switch polling timer */
165 struct callout hwswitch_to;
167 struct resource *irq;
168 struct resource *mem;
169 bus_space_tag_t sc_st;
170 bus_space_handle_t sc_sh;
175 struct wpi_config config;
182 struct bpf_if *sc_drvbpf;
184 struct wpi_rx_radiotap_header sc_rxtap;
186 struct wpi_tx_radiotap_header sc_txtap;
190 const struct firmware *fw_fp;
192 /* firmware DMA transfer */
193 struct wpi_dma_info fw_dma;
195 /* command queue related variables */
196 #define WPI_SCAN_START (1<<0)
197 #define WPI_SCAN_CURCHAN (1<<1)
198 #define WPI_SCAN_STOP (1<<2)
199 #define WPI_SET_CHAN (1<<3)
200 #define WPI_AUTH (1<<4)
201 #define WPI_RUN (1<<5)
202 #define WPI_SCAN_NEXT (1<<6)
203 #define WPI_RESTART (1<<7)
204 #define WPI_RF_RESTART (1<<8)
205 #define WPI_CMD_MAXOPS 10
206 /* command queuing request type */
207 #define WPI_QUEUE_NORMAL 0
208 #define WPI_QUEUE_CLEAR 1
209 int sc_cmd[WPI_CMD_MAXOPS];
210 int sc_cmd_arg[WPI_CMD_MAXOPS];
211 int sc_cmd_cur; /* current queued scan task */
212 int sc_cmd_next; /* last queued scan task */
213 struct mtx sc_cmdlock;
215 /* Task queues used to control the driver */
216 struct taskqueue *sc_tq; /* Main command task queue */
217 struct taskqueue *sc_tq2;/* firmware reset task queue */
219 /* Tasks used by the driver */
220 struct task sc_radioontask; /* enable rf transmitter task*/
221 struct task sc_radioofftask;/* disable rf transmitter task*/
222 struct task sc_opstask; /* operation handling task */
223 struct task sc_restarttask; /* reset firmware task */
229 struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT];
230 int8_t maxpwr[IEEE80211_CHAN_MAX];
231 char domain[4]; //reglatory domain //XXX
233 #define WPI_LOCK_INIT(_sc) \
234 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
235 MTX_NETWORK_LOCK, MTX_DEF)
236 #define WPI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
237 #define WPI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
238 #define WPI_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
239 #define WPI_LOCK_OWNED(_sc) mtx_owned(&(_sc)->sc_mtx)
240 #define WPI_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)
242 #define WPI_CMD_LOCK_INIT(_sc) \
243 mtx_init(&(_sc)->sc_cmdlock, device_get_nameunit((_sc)->sc_dev), \
245 #define WPI_CMD_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_cmdlock)
246 #define WPI_CMD_LOCK(_sc) mtx_lock(&(_sc)->sc_cmdlock)
247 #define WPI_CMD_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_cmdlock)