Deleted Added
full compact
1/* $FreeBSD: head/sys/dev/iwn/if_iwnvar.h 178676 2008-04-29 21:36:17Z sam $ */
1/* $FreeBSD: head/sys/dev/iwn/if_iwnvar.h 191746 2009-05-02 15:14:18Z thompsa $ */
2/*-
3 * Copyright (c) 2007
4 * Damien Bergamini <damien.bergamini@free.fr>
5 * Copyright (c) 2008 Sam Leffler, Errno Consulting
6 *
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.
10 *
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.
18 */
19
20struct iwn_rx_radiotap_header {
21 struct ieee80211_radiotap_header wr_ihdr;
22 uint64_t wr_tsft;
23 uint8_t wr_flags;
24 uint8_t wr_rate;
25 uint16_t wr_chan_freq;
26 uint16_t wr_chan_flags;
27 int8_t wr_dbm_antsignal;
28 int8_t wr_dbm_antnoise;
29} __packed;
30
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))
38
39struct iwn_tx_radiotap_header {
40 struct ieee80211_radiotap_header wt_ihdr;
41 uint8_t wt_flags;
42 uint8_t wt_rate;
43 uint16_t wt_chan_freq;
44 uint16_t wt_chan_flags;
45} __packed;
46
47#define IWN_TX_RADIOTAP_PRESENT \
48 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
49 (1 << IEEE80211_RADIOTAP_RATE) | \
50 (1 << IEEE80211_RADIOTAP_CHANNEL))
51
52struct iwn_dma_info {
53 bus_dma_tag_t tag;
54 bus_dmamap_t map;
55 bus_dma_segment_t seg;
56 bus_addr_t paddr;
57 caddr_t vaddr;
58 bus_size_t size;
59};
60
61struct iwn_tx_data {
62 bus_dmamap_t map;
63 struct mbuf *m;
64 struct ieee80211_node *ni;
65};
66
67struct iwn_tx_ring {
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;
74 int qid;
75 int queued;
76 int cur;
77};
78
79struct iwn_rx_data {
80 bus_dmamap_t map;
81 struct mbuf *m;
82};
83
84struct iwn_rx_ring {
85 struct iwn_dma_info desc_dma;
86 uint32_t *desc;
87 struct iwn_rx_data data[IWN_RX_RING_COUNT];
88 bus_dma_tag_t data_dmat;
89 int cur;
90};
91
92struct iwn_node {
93 struct ieee80211_node ni; /* must be the first */
94 struct ieee80211_amrr_node amn;
95};
96#define IWN_NODE(_ni) ((struct iwn_node *)(_ni))
97
98struct iwn_calib_state {
99 uint8_t state;
100#define IWN_CALIB_STATE_INIT 0
101#define IWN_CALIB_STATE_ASSOC 1
102#define IWN_CALIB_STATE_RUN 2
103 u_int nbeacons;
104 uint32_t noise[3];
105 uint32_t rssi[3];
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;
113 uint32_t fa_ofdm;
114 uint32_t bad_plcp_cck;
115 uint32_t fa_cck;
116 uint32_t low_fa;
117 uint8_t cck_state;
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;
123 uint8_t noise_ref;
124 uint32_t energy_samples[10];
125 u_int cur_energy_sample;
126 uint32_t energy_cck;
127};
128
129struct iwn_vap {
130 struct ieee80211vap iv_vap;
131 struct ieee80211_amrr iv_amrr;
132 struct callout iv_amrr_to;
133
134 int (*iv_newstate)(struct ieee80211vap *,
135 enum ieee80211_state, int);
136};
137#define IWN_VAP(_vap) ((struct iwn_vap *)(_vap))
138
139struct iwn_softc {
140 struct ifnet *sc_ifp;
141 int sc_debug;
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;
145
146 struct iwn_rx_radiotap_header sc_rxtap;
147 int sc_rxtap_len;
148 struct iwn_tx_radiotap_header sc_txtap;
149 int sc_txtap_len;
150
151 /* locks */
152 struct mtx sc_mtx;
153
154 /* bus */
155 device_t sc_dev;
156 int mem_rid;
157 int irq_rid;
158 struct resource *mem;
159 struct resource *irq;
160
161 /* shared area */
162 struct iwn_dma_info shared_dma;
163 struct iwn_shared *shared;
164
165 /* "keep warm" page */
166 struct iwn_dma_info kw_dma;
167
168 /* firmware image */
169 const struct firmware *fw_fp;
170
171 /* firmware DMA transfer */
172 struct iwn_dma_info fw_dma;
173
174 /* rings */
175 struct iwn_tx_ring txq[IWN_NTXQUEUES];
176 struct iwn_rx_ring rxq;
177
178 bus_space_tag_t sc_st;
179 bus_space_handle_t sc_sh;
180 void *sc_ih;
181 bus_size_t sc_sz;
182
183 /* command queue related variables */
184#define IWN_SCAN_START (1<<0)
185#define IWN_SCAN_CURCHAN (1<<1)
186#define IWN_SCAN_STOP (1<<2)
187#define IWN_SET_CHAN (1<<3)
188#define IWN_AUTH (1<<4)
189#define IWN_SCAN_NEXT (1<<5)
190#define IWN_RUN (1<<6)
191#define IWN_RADIO_ENABLE (1<<7)
192#define IWN_RADIO_DISABLE (1<<8)
193#define IWN_REINIT (1<<9)
194#define IWN_CMD_MAXOPS 10
195 /* command queuing request type */
196#define IWN_QUEUE_NORMAL 0
197#define IWN_QUEUE_CLEAR 1
198 int sc_cmd[IWN_CMD_MAXOPS];
199 int sc_cmd_arg[IWN_CMD_MAXOPS];
200 int sc_cmd_cur; /* current queued scan task */
201 int sc_cmd_next; /* last queued scan task */
202 struct mtx sc_cmdlock;
203
204 /* Task queues used to control the driver */
205 struct taskqueue *sc_tq; /* Main command task queue */
206
183 /* Tasks used by the driver */
208 struct task sc_ops_task; /* deferred ops */
209 struct task sc_bmiss_task; /* beacon miss */
184 struct task sc_reinit_task;
185 struct task sc_radioon_task;
186 struct task sc_radiooff_task;
187
188 /* Thermal calibration */
189 int calib_cnt;
190 struct iwn_calib_state calib;
191
192 struct iwn_rx_stat last_rx_stat;
193 int last_rx_valid;
194 struct iwn_ucode_info ucode_info;
195 struct iwn_config config;
196 uint32_t rawtemp;
197 int temp;
198 int noise;
199 uint8_t antmsk;
200
201 struct iwn_eeprom_band bands[IWN_NBANDS];
202 int16_t eeprom_voltage;
203 int8_t maxpwr2GHz;
204 int8_t maxpwr5GHz;
205};
206
207#define IWN_LOCK_INIT(_sc) \
208 mtx_init(&(_sc)->sc_mtx, device_get_nameunit((_sc)->sc_dev), \
209 MTX_NETWORK_LOCK, MTX_DEF)
210#define IWN_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
211#define IWN_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->sc_mtx, MA_OWNED)
212#define IWN_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
213#define IWN_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)
237#define IWN_CMD_LOCK_INIT(_sc) \
238 mtx_init(&(_sc)->sc_cmdlock, device_get_nameunit((_sc)->sc_dev), \
239 NULL, MTX_DEF);
240#define IWN_CMD_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_cmdlock)
241#define IWN_CMD_LOCK(_sc) mtx_lock(&(_sc)->sc_cmdlock)
242#define IWN_CMD_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_cmdlock)