4 * Copyright (c) 2004-2006
5 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice unmodified, this list of conditions, and the following
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #define IPW_MAX_NSEG 1
35 #define IPW_SBD_TYPE_NOASSOC 0
36 #define IPW_SBD_TYPE_COMMAND 1
37 #define IPW_SBD_TYPE_HEADER 2
38 #define IPW_SBD_TYPE_DATA 3
45 SLIST_ENTRY(ipw_soft_hdr) next;
50 struct ieee80211_node *ni;
52 SLIST_ENTRY(ipw_soft_buf) next;
55 struct ipw_rx_radiotap_header {
56 struct ieee80211_radiotap_header wr_ihdr;
58 uint16_t wr_chan_freq;
59 uint16_t wr_chan_flags;
63 #define IPW_RX_RADIOTAP_PRESENT \
64 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
65 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
66 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL))
68 struct ipw_tx_radiotap_header {
69 struct ieee80211_radiotap_header wt_ihdr;
71 uint16_t wt_chan_freq;
72 uint16_t wt_chan_flags;
75 #define IPW_TX_RADIOTAP_PRESENT \
76 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
77 (1 << IEEE80211_RADIOTAP_CHANNEL))
81 struct ieee80211com sc_ic;
82 int (*sc_newstate)(struct ieee80211com *,
83 enum ieee80211_state, int);
87 struct task sc_init_task;
88 struct task sc_scan_task;
89 struct task sc_chan_task;
90 struct task sc_assoc_task;
91 struct task sc_disassoc_task;
92 struct callout sc_wdtimer; /* watchdog timer */
95 #define IPW_FLAG_FW_INITED (1 << 0)
96 #define IPW_FLAG_INIT_LOCKED (1 << 1)
97 #define IPW_FLAG_HAS_RADIO_SWITCH (1 << 2)
98 #define IPW_FLAG_HACK (1 << 3)
99 #define IPW_FLAG_SCANNING (1 << 4)
100 #define IPW_FLAG_ENABLED (1 << 5)
101 #define IPW_FLAG_BUSY (1 << 6)
102 #define IPW_FLAG_ASSOCIATED (1 << 7)
106 struct resource *irq;
107 struct resource *mem;
108 bus_space_tag_t sc_st;
109 bus_space_handle_t sc_sh;
111 const struct firmware *sc_firmware;
116 bus_dma_tag_t tbd_dmat;
117 bus_dma_tag_t rbd_dmat;
118 bus_dma_tag_t status_dmat;
119 bus_dma_tag_t cmd_dmat;
120 bus_dma_tag_t hdr_dmat;
121 bus_dma_tag_t txbuf_dmat;
122 bus_dma_tag_t rxbuf_dmat;
124 bus_dmamap_t tbd_map;
125 bus_dmamap_t rbd_map;
126 bus_dmamap_t status_map;
127 bus_dmamap_t cmd_map;
131 bus_addr_t status_phys;
133 struct ipw_bd *tbd_list;
134 struct ipw_bd *rbd_list;
135 struct ipw_status *status_list;
138 struct ipw_soft_bd stbd_list[IPW_NTBD];
139 struct ipw_soft_buf tx_sbuf_list[IPW_NDATA];
140 struct ipw_soft_hdr shdr_list[IPW_NDATA];
141 struct ipw_soft_bd srbd_list[IPW_NRBD];
142 struct ipw_soft_buf rx_sbuf_list[IPW_NRBD];
144 SLIST_HEAD(, ipw_soft_hdr) free_shdr;
145 SLIST_HEAD(, ipw_soft_buf) free_sbuf;
147 uint32_t table1_base;
148 uint32_t table2_base;
157 struct bpf_if *sc_drvbpf;
160 struct ipw_rx_radiotap_header th;
163 #define sc_rxtap sc_rxtapu.th
167 struct ipw_tx_radiotap_header th;
170 #define sc_txtap sc_txtapu.th
175 * NB.: This models the only instance of async locking in ipw_init_locked
176 * and must be kept in sync.
178 #define IPW_LOCK_DECL int __waslocked = 0
179 #define IPW_LOCK(sc) do { \
180 if (!(__waslocked = mtx_owned(&(sc)->sc_mtx))) \
181 mtx_lock(&sc->sc_mtx); \
183 #define IPW_UNLOCK(sc) do { \
185 mtx_unlock(&sc->sc_mtx); \
187 #define IPW_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)