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 struct wpi_rx_radiotap_header {
20 struct ieee80211_radiotap_header wr_ihdr;
24 uint16_t wr_chan_freq;
25 uint16_t wr_chan_flags;
26 int8_t wr_dbm_antsignal;
27 int8_t wr_dbm_antnoise;
29 } __packed __aligned(8);
31 #define WPI_RX_RADIOTAP_PRESENT \
32 ((1 << IEEE80211_RADIOTAP_TSFT) | \
33 (1 << IEEE80211_RADIOTAP_FLAGS) | \
34 (1 << IEEE80211_RADIOTAP_RATE) | \
35 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
36 (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
37 (1 << IEEE80211_RADIOTAP_DBM_ANTNOISE) | \
38 (1 << IEEE80211_RADIOTAP_ANTENNA))
40 struct wpi_tx_radiotap_header {
41 struct ieee80211_radiotap_header wt_ihdr;
44 uint16_t wt_chan_freq;
45 uint16_t wt_chan_flags;
48 #define WPI_TX_RADIOTAP_PRESENT \
49 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
50 (1 << IEEE80211_RADIOTAP_RATE) | \
51 (1 << IEEE80211_RADIOTAP_CHANNEL))
65 struct ieee80211_node *ni;
70 struct wpi_dma_info desc_dma;
71 struct wpi_dma_info cmd_dma;
72 struct wpi_tx_desc *desc;
73 struct wpi_tx_cmd *cmd;
74 struct wpi_tx_data data[WPI_TX_RING_COUNT];
75 bus_dma_tag_t data_dmat;
89 struct wpi_dma_info desc_dma;
91 struct wpi_rx_data data[WPI_RX_RING_COUNT];
92 bus_dma_tag_t data_dmat;
98 struct ieee80211_node ni; /* must be the first */
101 #define WPI_NODE(ni) ((struct wpi_node *)(ni))
103 struct wpi_power_sample {
108 struct wpi_power_group {
109 #define WPI_SAMPLES_COUNT 5
110 struct wpi_power_sample samples[WPI_SAMPLES_COUNT];
117 uint8_t data[56]; /* sizeof(struct wpi_cmd_beacon) */
118 struct ieee80211_node *ni;
126 struct ieee80211vap wv_vap;
128 struct wpi_buf wv_bcbuf;
132 #define WPI_VAP_KEY(kid) (1 << kid)
134 int (*wv_newstate)(struct ieee80211vap *,
135 enum ieee80211_state, int);
136 void (*wv_recv_mgmt)(struct ieee80211_node *,
138 const struct ieee80211_rx_stats *,
141 #define WPI_VAP(vap) ((struct wpi_vap *)(vap))
143 #define WPI_VAP_LOCK_INIT(_wvp) \
144 mtx_init(&(_wvp)->wv_mtx, "lock for wv_bcbuf/wv_boff structures", \
146 #define WPI_VAP_LOCK(_wvp) mtx_lock(&(_wvp)->wv_mtx)
147 #define WPI_VAP_UNLOCK(_wvp) mtx_unlock(&(_wvp)->wv_mtx)
148 #define WPI_VAP_LOCK_ASSERT(_wvp) mtx_assert(&(_wvp)->wv_mtx, MA_OWNED)
149 #define WPI_VAP_LOCK_DESTROY(_wvp) mtx_destroy(&(_wvp)->wv_mtx)
161 struct wpi_fw_part init;
162 struct wpi_fw_part main;
163 struct wpi_fw_part boot;
173 struct ieee80211com sc_ic;
174 struct ieee80211_ratectl_tx_status sc_txs;
179 struct wpi_dma_info shared_dma;
180 struct wpi_shared *shared;
182 struct wpi_tx_ring txq[WPI_DRV_NTXQUEUES];
184 struct mtx txq_state_mtx;
186 struct wpi_rx_ring rxq;
189 /* TX Thermal Callibration. */
190 struct callout calib_to;
192 struct callout scan_timeout;
193 struct callout tx_timeout;
195 /* Watch dog timer. */
196 struct callout watchdog_rfkill;
198 /* Firmware image. */
199 struct wpi_fw_info fw;
202 struct resource *irq;
203 struct resource *mem;
204 bus_space_tag_t sc_st;
205 bus_space_handle_t sc_sh;
208 int sc_cap_off; /* PCIe Capabilities. */
210 struct wpi_rxon rxon;
218 void (*sc_node_free)(struct ieee80211_node *);
219 void (*sc_update_rx_ring)(struct wpi_softc *);
220 void (*sc_update_tx_ring)(struct wpi_softc *,
221 struct wpi_tx_ring *);
223 struct wpi_rx_radiotap_header sc_rxtap;
224 struct wpi_tx_radiotap_header sc_txtap;
226 /* Firmware image. */
227 const struct firmware *fw_fp;
229 /* Firmware DMA transfer. */
230 struct wpi_dma_info fw_dma;
232 /* Tasks used by the driver. */
233 struct task sc_radiooff_task;
234 struct task sc_radioon_task;
240 struct wpi_eeprom_chan
241 eeprom_channels[WPI_CHAN_BANDS_COUNT][WPI_MAX_CHAN_PER_BAND];
242 struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT];
243 int8_t maxpwr[IEEE80211_CHAN_MAX];
244 char domain[4]; /* Regulatory domain. */
252 * 4. WPI_NT_LOCK / WPI_VAP_LOCK;
254 * 6. WPI_TXQ_STATE_LOCK;
257 #define WPI_LOCK_INIT(_sc) \
258 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
259 MTX_NETWORK_LOCK, MTX_DEF)
260 #define WPI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
261 #define WPI_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
262 #define WPI_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
263 #define WPI_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)
265 #define WPI_RXON_LOCK_INIT(_sc) \
266 mtx_init(&(_sc)->rxon_mtx, "lock for wpi_rxon structure", NULL, MTX_DEF)
267 #define WPI_RXON_LOCK(_sc) mtx_lock(&(_sc)->rxon_mtx)
268 #define WPI_RXON_UNLOCK(_sc) mtx_unlock(&(_sc)->rxon_mtx)
269 #define WPI_RXON_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->rxon_mtx, MA_OWNED)
270 #define WPI_RXON_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->rxon_mtx)
272 #define WPI_TX_LOCK_INIT(_sc) \
273 mtx_init(&(_sc)->tx_mtx, "tx path lock", NULL, MTX_DEF)
274 #define WPI_TX_LOCK(_sc) mtx_lock(&(_sc)->tx_mtx)
275 #define WPI_TX_UNLOCK(_sc) mtx_unlock(&(_sc)->tx_mtx)
276 #define WPI_TX_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->tx_mtx)
278 #define WPI_NT_LOCK_INIT(_sc) \
279 mtx_init(&(_sc)->nt_mtx, "node table lock", NULL, MTX_DEF)
280 #define WPI_NT_LOCK(_sc) mtx_lock(&(_sc)->nt_mtx)
281 #define WPI_NT_UNLOCK(_sc) mtx_unlock(&(_sc)->nt_mtx)
282 #define WPI_NT_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->nt_mtx)
284 #define WPI_TXQ_LOCK_INIT(_sc) \
285 mtx_init(&(_sc)->txq_mtx, "txq/cmdq lock", NULL, MTX_DEF)
286 #define WPI_TXQ_LOCK(_sc) mtx_lock(&(_sc)->txq_mtx)
287 #define WPI_TXQ_UNLOCK(_sc) mtx_unlock(&(_sc)->txq_mtx)
288 #define WPI_TXQ_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->txq_mtx)
290 #define WPI_TXQ_STATE_LOCK_INIT(_sc) \
291 mtx_init(&(_sc)->txq_state_mtx, "txq state lock", NULL, MTX_DEF)
292 #define WPI_TXQ_STATE_LOCK(_sc) mtx_lock(&(_sc)->txq_state_mtx)
293 #define WPI_TXQ_STATE_UNLOCK(_sc) mtx_unlock(&(_sc)->txq_state_mtx)
294 #define WPI_TXQ_STATE_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->txq_state_mtx)