FreeBSD kernel WPI device code
if_wpivar.h
Go to the documentation of this file.
1/* $FreeBSD$ */
3/*-
4 * Copyright (c) 2006,2007
5 * Damien Bergamini <damien.bergamini@free.fr>
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 */
20 struct ieee80211_radiotap_header wr_ihdr;
21 uint64_t wr_tsft;
22 uint8_t wr_flags;
23 uint8_t wr_rate;
24 uint16_t wr_chan_freq;
25 uint16_t wr_chan_flags;
28 uint8_t wr_antenna;
30
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))
39
41 struct ieee80211_radiotap_header wt_ihdr;
42 uint8_t wt_flags;
43 uint8_t wt_rate;
44 uint16_t wt_chan_freq;
45 uint16_t wt_chan_flags;
47
48#define WPI_TX_RADIOTAP_PRESENT \
49 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
50 (1 << IEEE80211_RADIOTAP_RATE) | \
51 (1 << IEEE80211_RADIOTAP_CHANNEL))
52
54 bus_dma_tag_t tag;
55 bus_dmamap_t map;
56 bus_addr_t paddr;
57 caddr_t vaddr;
58 bus_size_t size;
59};
60
62 bus_dmamap_t map;
63 bus_addr_t cmd_paddr;
64 struct mbuf *m;
65 struct ieee80211_node *ni;
66 int hdrlen;
67};
68
73 struct wpi_tx_cmd *cmd;
75 bus_dma_tag_t data_dmat;
76 uint8_t qid;
77 uint8_t cur;
78 uint8_t pending;
79 int16_t queued;
80 int update:1;
81};
82
84 struct mbuf *m;
85 bus_dmamap_t map;
86};
87
90 uint32_t *desc;
92 bus_dma_tag_t data_dmat;
93 uint16_t cur;
94 int update;
95};
96
97struct wpi_node {
98 struct ieee80211_node ni; /* must be the first */
99 uint8_t id;
100};
101#define WPI_NODE(ni) ((struct wpi_node *)(ni))
102
104 uint8_t index;
105 int8_t power;
106};
107
109#define WPI_SAMPLES_COUNT 5
111 uint8_t chan;
112 int8_t maxpwr;
113 int16_t temp;
114};
115
116struct wpi_buf {
117 uint8_t data[56]; /* sizeof(struct wpi_cmd_beacon) */
118 struct ieee80211_node *ni;
119 struct mbuf *m;
120 size_t size;
121 uint8_t code;
122 uint16_t ac;
123};
124
125struct wpi_vap {
126 struct ieee80211vap wv_vap;
127
129 struct mtx wv_mtx;
130
131 uint8_t wv_gtk;
132#define WPI_VAP_KEY(kid) (1 << kid)
133
134 int (*wv_newstate)(struct ieee80211vap *,
135 enum ieee80211_state, int);
136 void (*wv_recv_mgmt)(struct ieee80211_node *,
137 struct mbuf *, int,
138 const struct ieee80211_rx_stats *,
139 int, int);
140};
141#define WPI_VAP(vap) ((struct wpi_vap *)(vap))
142
143#define WPI_VAP_LOCK_INIT(_wvp) \
144 mtx_init(&(_wvp)->wv_mtx, "lock for wv_bcbuf/wv_boff structures", \
145 NULL, MTX_DEF)
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)
150
152 const uint8_t *text;
153 uint32_t textsz;
154 const uint8_t *data;
155 uint32_t datasz;
156};
157
159 const uint8_t *data;
160 size_t size;
164};
165
166struct wpi_softc {
167 device_t sc_dev;
169
171
172 struct mtx sc_mtx;
173 struct ieee80211com sc_ic;
174 struct ieee80211_ratectl_tx_status sc_txs;
175
176 struct mtx tx_mtx;
177
178 /* Shared area. */
181
183 struct mtx txq_mtx;
184 struct mtx txq_state_mtx;
185
187 uint64_t rx_tstamp;
188
189 /* TX Thermal Callibration. */
190 struct callout calib_to;
191
192 struct callout scan_timeout;
193 struct callout tx_timeout;
194
195 /* Watch dog timer. */
196 struct callout watchdog_rfkill;
197
198 /* Firmware image. */
200 uint32_t errptr;
201
202 struct resource *irq;
203 struct resource *mem;
204 bus_space_tag_t sc_st;
205 bus_space_handle_t sc_sh;
206 void *sc_ih;
207 bus_size_t sc_sz;
208 int sc_cap_off; /* PCIe Capabilities. */
209
211 struct mtx rxon_mtx;
212
213 int temp;
214
215 uint32_t nodesmsk;
216 struct mtx nt_mtx;
217
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 *);
222
225
226 /* Firmware image. */
227 const struct firmware *fw_fp;
228
229 /* Firmware DMA transfer. */
231
232 /* Tasks used by the driver. */
233 struct task sc_radiooff_task;
234 struct task sc_radioon_task;
235
236 /* Eeprom info. */
237 uint8_t cap;
238 uint16_t rev;
239 uint8_t type;
240 struct wpi_eeprom_chan
243 int8_t maxpwr[IEEE80211_CHAN_MAX];
244 char domain[4]; /* Regulatory domain. */
245};
246
247/*
248 * Locking order:
249 * 1. WPI_LOCK;
250 * 2. WPI_RXON_LOCK;
251 * 3. WPI_TX_LOCK;
252 * 4. WPI_NT_LOCK / WPI_VAP_LOCK;
253 * 5. WPI_TXQ_LOCK;
254 * 6. WPI_TXQ_STATE_LOCK;
255 */
256
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)
264
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)
271
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)
277
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)
283
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)
289
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)
#define WPI_DRV_NTXQUEUES
Definition: if_wpireg.h:33
#define WPI_POWER_GROUPS_COUNT
Definition: if_wpireg.h:867
#define WPI_TX_RING_COUNT
Definition: if_wpireg.h:20
#define WPI_RX_RING_COUNT
Definition: if_wpireg.h:30
#define WPI_CHAN_BANDS_COUNT
Definition: if_wpireg.h:877
#define WPI_MAX_CHAN_PER_BAND
Definition: if_wpireg.h:878
#define WPI_SAMPLES_COUNT
Definition: if_wpivar.h:109
struct wpi_tx_radiotap_header __packed
struct wpi_rx_radiotap_header __aligned(8)
size_t size
Definition: if_wpivar.h:120
uint8_t code
Definition: if_wpivar.h:121
struct ieee80211_node * ni
Definition: if_wpivar.h:118
uint16_t ac
Definition: if_wpivar.h:122
struct mbuf * m
Definition: if_wpivar.h:119
uint8_t data[56]
Definition: if_wpivar.h:117
bus_dmamap_t map
Definition: if_wpivar.h:55
bus_size_t size
Definition: if_wpivar.h:58
bus_dma_tag_t tag
Definition: if_wpivar.h:54
caddr_t vaddr
Definition: if_wpivar.h:57
bus_addr_t paddr
Definition: if_wpivar.h:56
struct wpi_fw_part boot
Definition: if_wpivar.h:163
size_t size
Definition: if_wpivar.h:160
struct wpi_fw_part init
Definition: if_wpivar.h:161
struct wpi_fw_part main
Definition: if_wpivar.h:162
const uint8_t * data
Definition: if_wpivar.h:159
uint32_t textsz
Definition: if_wpivar.h:153
uint32_t datasz
Definition: if_wpivar.h:155
const uint8_t * data
Definition: if_wpivar.h:154
const uint8_t * text
Definition: if_wpivar.h:152
uint8_t id
Definition: if_wpivar.h:99
struct ieee80211_node ni
Definition: if_wpivar.h:98
uint8_t chan
Definition: if_wpivar.h:111
struct wpi_power_sample samples[WPI_SAMPLES_COUNT]
Definition: if_wpivar.h:110
int16_t temp
Definition: if_wpivar.h:113
bus_dmamap_t map
Definition: if_wpivar.h:85
struct mbuf * m
Definition: if_wpivar.h:84
struct ieee80211_radiotap_header wr_ihdr
Definition: if_wpivar.h:20
uint16_t wr_chan_flags
Definition: if_wpivar.h:25
uint32_t * desc
Definition: if_wpivar.h:90
struct wpi_rx_data data[WPI_RX_RING_COUNT]
Definition: if_wpivar.h:91
struct wpi_dma_info desc_dma
Definition: if_wpivar.h:89
uint16_t cur
Definition: if_wpivar.h:93
int update
Definition: if_wpivar.h:94
bus_dma_tag_t data_dmat
Definition: if_wpivar.h:92
struct task sc_radioon_task
Definition: if_wpivar.h:234
uint8_t type
Definition: if_wpivar.h:239
bus_space_tag_t sc_st
Definition: if_wpivar.h:204
struct resource * mem
Definition: if_wpivar.h:203
uint16_t rev
Definition: if_wpivar.h:238
bus_space_handle_t sc_sh
Definition: if_wpivar.h:205
struct wpi_rx_ring rxq
Definition: if_wpivar.h:186
struct resource * irq
Definition: if_wpivar.h:202
struct mtx txq_mtx
Definition: if_wpivar.h:183
struct mtx tx_mtx
Definition: if_wpivar.h:176
int8_t maxpwr[IEEE80211_CHAN_MAX]
Definition: if_wpivar.h:243
void * sc_ih
Definition: if_wpivar.h:206
struct mtx sc_mtx
Definition: if_wpivar.h:172
uint32_t nodesmsk
Definition: if_wpivar.h:215
struct wpi_fw_info fw
Definition: if_wpivar.h:199
struct callout watchdog_rfkill
Definition: if_wpivar.h:196
struct wpi_shared * shared
Definition: if_wpivar.h:180
const struct firmware * fw_fp
Definition: if_wpivar.h:227
struct ieee80211com sc_ic
Definition: if_wpivar.h:173
struct mtx txq_state_mtx
Definition: if_wpivar.h:184
device_t sc_dev
Definition: if_wpivar.h:167
struct callout tx_timeout
Definition: if_wpivar.h:193
struct wpi_tx_radiotap_header sc_txtap
Definition: if_wpivar.h:224
struct task sc_radiooff_task
Definition: if_wpivar.h:233
uint32_t errptr
Definition: if_wpivar.h:200
int temp
Definition: if_wpivar.h:213
int sc_cap_off
Definition: if_wpivar.h:208
int sc_running
Definition: if_wpivar.h:170
struct mtx rxon_mtx
Definition: if_wpivar.h:211
bus_size_t sc_sz
Definition: if_wpivar.h:207
void(* sc_update_rx_ring)(struct wpi_softc *)
Definition: if_wpivar.h:219
struct wpi_dma_info fw_dma
Definition: if_wpivar.h:230
struct callout calib_to
Definition: if_wpivar.h:190
int sc_debug
Definition: if_wpivar.h:168
void(* sc_node_free)(struct ieee80211_node *)
Definition: if_wpivar.h:218
struct wpi_power_group groups[WPI_POWER_GROUPS_COUNT]
Definition: if_wpivar.h:242
void(* sc_update_tx_ring)(struct wpi_softc *, struct wpi_tx_ring *)
Definition: if_wpivar.h:220
struct wpi_rx_radiotap_header sc_rxtap
Definition: if_wpivar.h:223
uint64_t rx_tstamp
Definition: if_wpivar.h:187
struct wpi_eeprom_chan eeprom_channels[WPI_CHAN_BANDS_COUNT][WPI_MAX_CHAN_PER_BAND]
Definition: if_wpivar.h:240
struct wpi_rxon rxon
Definition: if_wpivar.h:210
struct wpi_tx_ring txq[WPI_DRV_NTXQUEUES]
Definition: if_wpivar.h:182
struct ieee80211_ratectl_tx_status sc_txs
Definition: if_wpivar.h:174
char domain[4]
Definition: if_wpivar.h:244
struct callout scan_timeout
Definition: if_wpivar.h:192
uint8_t cap
Definition: if_wpivar.h:237
struct wpi_dma_info shared_dma
Definition: if_wpivar.h:179
struct mtx nt_mtx
Definition: if_wpivar.h:216
bus_addr_t cmd_paddr
Definition: if_wpivar.h:63
struct mbuf * m
Definition: if_wpivar.h:64
int hdrlen
Definition: if_wpivar.h:66
struct ieee80211_node * ni
Definition: if_wpivar.h:65
bus_dmamap_t map
Definition: if_wpivar.h:62
struct ieee80211_radiotap_header wt_ihdr
Definition: if_wpivar.h:41
uint16_t wt_chan_flags
Definition: if_wpivar.h:45
struct wpi_tx_cmd * cmd
Definition: if_wpivar.h:73
bus_dma_tag_t data_dmat
Definition: if_wpivar.h:75
int16_t queued
Definition: if_wpivar.h:79
struct wpi_dma_info cmd_dma
Definition: if_wpivar.h:71
int update
Definition: if_wpivar.h:80
uint8_t pending
Definition: if_wpivar.h:78
struct wpi_tx_desc * desc
Definition: if_wpivar.h:72
struct wpi_tx_data data[WPI_TX_RING_COUNT]
Definition: if_wpivar.h:74
struct wpi_dma_info desc_dma
Definition: if_wpivar.h:70
uint8_t cur
Definition: if_wpivar.h:77
uint8_t qid
Definition: if_wpivar.h:76
int(* wv_newstate)(struct ieee80211vap *, enum ieee80211_state, int)
Definition: if_wpivar.h:134
void(* wv_recv_mgmt)(struct ieee80211_node *, struct mbuf *, int, const struct ieee80211_rx_stats *, int, int)
Definition: if_wpivar.h:136
struct ieee80211vap wv_vap
Definition: if_wpivar.h:126
struct wpi_buf wv_bcbuf
Definition: if_wpivar.h:128
struct mtx wv_mtx
Definition: if_wpivar.h:129
uint8_t wv_gtk
Definition: if_wpivar.h:131