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;
109 struct wpi_power_sample {
114 struct wpi_power_group {
115 #define WPI_SAMPLES_COUNT 5
116 struct wpi_power_sample samples[WPI_SAMPLES_COUNT];
123 struct ieee80211vap vap;
125 int (*newstate)(struct ieee80211vap *,
126 enum ieee80211_state, int);
128 #define WPI_VAP(vap) ((struct wpi_vap *)(vap))
132 struct ifnet *sc_ifp;
135 /* Flags indicating the current state the driver
136 * expects the hardware to be in
139 #define WPI_FLAG_HW_RADIO_OFF (1 << 0)
140 #define WPI_FLAG_BUSY (1 << 1)
141 #define WPI_FLAG_AUTH (1 << 2)
144 struct wpi_dma_info shared_dma;
145 struct wpi_shared *shared;
147 struct wpi_tx_ring txq[WME_NUM_AC];
148 struct wpi_tx_ring cmdq;
149 struct wpi_rx_ring rxq;
151 /* TX Thermal Callibration */
152 struct callout calib_to;
155 /* Watch dog timer */
156 struct callout watchdog_to;
157 /* Hardware switch polling timer */
158 struct callout hwswitch_to;
160 struct resource *irq;
161 struct resource *mem;
162 bus_space_tag_t sc_st;
163 bus_space_handle_t sc_sh;
168 struct wpi_config config;
175 struct bpf_if *sc_drvbpf;
177 struct wpi_rx_radiotap_header sc_rxtap;
178 struct wpi_tx_radiotap_header sc_txtap;
181 const struct firmware *fw_fp;
183 /* firmware DMA transfer */
184 struct wpi_dma_info fw_dma;
186 /* Tasks used by the driver */
187 struct task sc_restarttask; /* reset firmware task */
188 struct task sc_radiotask; /* reset rf task */
194 struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT];
195 int8_t maxpwr[IEEE80211_CHAN_MAX];
196 char domain[4]; /*reglatory domain XXX */
198 #define WPI_LOCK_INIT(_sc) \
199 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
200 MTX_NETWORK_LOCK, MTX_DEF)
201 #define WPI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
202 #define WPI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
203 #define WPI_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
204 #define WPI_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)