4 * Damien Bergamini <damien.bergamini@free.fr>
5 * Copyright (c) 2008 Sam Leffler, Errno Consulting
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.
20 struct iwn_rx_radiotap_header {
21 struct ieee80211_radiotap_header wr_ihdr;
25 uint16_t wr_chan_freq;
26 uint16_t wr_chan_flags;
27 int8_t wr_dbm_antsignal;
28 int8_t wr_dbm_antnoise;
31 #define IWN_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))
39 struct iwn_tx_radiotap_header {
40 struct ieee80211_radiotap_header wt_ihdr;
43 uint16_t wt_chan_freq;
44 uint16_t wt_chan_flags;
47 #define IWN_TX_RADIOTAP_PRESENT \
48 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
49 (1 << IEEE80211_RADIOTAP_RATE) | \
50 (1 << IEEE80211_RADIOTAP_CHANNEL))
55 bus_dma_segment_t seg;
64 struct ieee80211_node *ni;
68 struct iwn_dma_info desc_dma;
69 struct iwn_dma_info cmd_dma;
70 struct iwn_tx_desc *desc;
71 struct iwn_tx_cmd *cmd;
72 struct iwn_tx_data data[IWN_TX_RING_COUNT];
73 bus_dma_tag_t data_dmat;
85 struct iwn_dma_info desc_dma;
87 struct iwn_rx_data data[IWN_RX_RING_COUNT];
88 bus_dma_tag_t data_dmat;
93 struct ieee80211_node ni; /* must be the first */
94 struct ieee80211_amrr_node amn;
96 #define IWN_NODE(_ni) ((struct iwn_node *)(_ni))
98 struct iwn_calib_state {
100 #define IWN_CALIB_STATE_INIT 0
101 #define IWN_CALIB_STATE_ASSOC 1
102 #define IWN_CALIB_STATE_RUN 2
106 uint32_t corr_ofdm_x1;
107 uint32_t corr_ofdm_mrc_x1;
108 uint32_t corr_ofdm_x4;
109 uint32_t corr_ofdm_mrc_x4;
110 uint32_t corr_cck_x4;
111 uint32_t corr_cck_mrc_x4;
112 uint32_t bad_plcp_ofdm;
114 uint32_t bad_plcp_cck;
118 #define IWN_CCK_STATE_INIT 0
119 #define IWN_CCK_STATE_LOFA 1
120 #define IWN_CCK_STATE_HIFA 2
121 uint8_t noise_samples[20];
122 u_int cur_noise_sample;
124 uint32_t energy_samples[10];
125 u_int cur_energy_sample;
130 struct ieee80211vap iv_vap;
131 struct ieee80211_amrr iv_amrr;
132 struct callout iv_amrr_to;
134 int (*iv_newstate)(struct ieee80211vap *,
135 enum ieee80211_state, int);
137 #define IWN_VAP(_vap) ((struct iwn_vap *)(_vap))
140 struct ifnet *sc_ifp;
142 struct callout sc_timer_to; /* calib+watchdog timer */
143 int sc_tx_timer; /* tx watchdog timer/counter */
144 const struct ieee80211_channel *sc_curchan;
146 struct iwn_rx_radiotap_header sc_rxtap;
147 struct iwn_tx_radiotap_header sc_txtap;
156 struct resource *mem;
157 struct resource *irq;
160 struct iwn_dma_info shared_dma;
161 struct iwn_shared *shared;
163 /* "keep warm" page */
164 struct iwn_dma_info kw_dma;
167 const struct firmware *fw_fp;
169 /* firmware DMA transfer */
170 struct iwn_dma_info fw_dma;
173 struct iwn_tx_ring txq[IWN_NTXQUEUES];
174 struct iwn_rx_ring rxq;
176 bus_space_tag_t sc_st;
177 bus_space_handle_t sc_sh;
181 /* Tasks used by the driver */
182 struct task sc_reinit_task;
183 struct task sc_radioon_task;
184 struct task sc_radiooff_task;
186 /* Thermal calibration */
188 struct iwn_calib_state calib;
190 struct iwn_rx_stat last_rx_stat;
192 struct iwn_ucode_info ucode_info;
193 struct iwn_config config;
199 struct iwn_eeprom_band bands[IWN_NBANDS];
200 int16_t eeprom_voltage;
205 #define IWN_LOCK_INIT(_sc) \
206 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
207 MTX_NETWORK_LOCK, MTX_DEF)
208 #define IWN_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
209 #define IWN_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
210 #define IWN_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
211 #define IWN_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)