4 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 * Copyright (c) 2004-2006
7 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice unmodified, this list of conditions, and the following
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #define IPW_MAX_NSEG 1
37 #define IPW_SBD_TYPE_NOASSOC 0
38 #define IPW_SBD_TYPE_COMMAND 1
39 #define IPW_SBD_TYPE_HEADER 2
40 #define IPW_SBD_TYPE_DATA 3
47 SLIST_ENTRY(ipw_soft_hdr) next;
52 struct ieee80211_node *ni;
54 SLIST_ENTRY(ipw_soft_buf) next;
57 struct ipw_rx_radiotap_header {
58 struct ieee80211_radiotap_header wr_ihdr;
61 uint16_t wr_chan_freq;
62 uint16_t wr_chan_flags;
65 } __packed __aligned(8);
67 #define IPW_RX_RADIOTAP_PRESENT \
68 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
69 (1 << IEEE80211_RADIOTAP_CHANNEL) | \
70 (1 << IEEE80211_RADIOTAP_DB_ANTSIGNAL) | \
71 (1 << IEEE80211_RADIOTAP_DB_ANTNOISE))
73 struct ipw_tx_radiotap_header {
74 struct ieee80211_radiotap_header wt_ihdr;
77 uint16_t wt_chan_freq;
78 uint16_t wt_chan_flags;
81 #define IPW_TX_RADIOTAP_PRESENT \
82 ((1 << IEEE80211_RADIOTAP_FLAGS) | \
83 (1 << IEEE80211_RADIOTAP_CHANNEL))
86 struct ieee80211vap vap;
88 int (*newstate)(struct ieee80211vap *,
89 enum ieee80211_state, int);
91 #define IPW_VAP(vap) ((struct ipw_vap *)(vap))
94 struct ieee80211com sc_ic;
99 struct task sc_init_task;
100 struct callout sc_wdtimer; /* watchdog timer */
103 #define IPW_FLAG_FW_INITED 0x0001
104 #define IPW_FLAG_INIT_LOCKED 0x0002
105 #define IPW_FLAG_HAS_RADIO_SWITCH 0x0004
106 #define IPW_FLAG_HACK 0x0008
107 #define IPW_FLAG_SCANNING 0x0010
108 #define IPW_FLAG_ENABLED 0x0020
109 #define IPW_FLAG_BUSY 0x0040
110 #define IPW_FLAG_ASSOCIATING 0x0080
111 #define IPW_FLAG_ASSOCIATED 0x0100
112 #define IPW_FLAG_RUNNING 0x0200
114 struct resource *irq;
115 struct resource *mem;
116 bus_space_tag_t sc_st;
117 bus_space_handle_t sc_sh;
119 const struct firmware *sc_firmware;
124 bus_dma_tag_t parent_dmat;
125 bus_dma_tag_t tbd_dmat;
126 bus_dma_tag_t rbd_dmat;
127 bus_dma_tag_t status_dmat;
128 bus_dma_tag_t cmd_dmat;
129 bus_dma_tag_t hdr_dmat;
130 bus_dma_tag_t txbuf_dmat;
131 bus_dma_tag_t rxbuf_dmat;
133 bus_dmamap_t tbd_map;
134 bus_dmamap_t rbd_map;
135 bus_dmamap_t status_map;
136 bus_dmamap_t cmd_map;
140 bus_addr_t status_phys;
142 struct ipw_bd *tbd_list;
143 struct ipw_bd *rbd_list;
144 struct ipw_status *status_list;
147 struct ipw_soft_bd stbd_list[IPW_NTBD];
148 struct ipw_soft_buf tx_sbuf_list[IPW_NDATA];
149 struct ipw_soft_hdr shdr_list[IPW_NDATA];
150 struct ipw_soft_bd srbd_list[IPW_NRBD];
151 struct ipw_soft_buf rx_sbuf_list[IPW_NRBD];
153 SLIST_HEAD(, ipw_soft_hdr) free_shdr;
154 SLIST_HEAD(, ipw_soft_buf) free_sbuf;
156 uint32_t table1_base;
157 uint32_t table2_base;
166 struct ipw_rx_radiotap_header sc_rxtap;
167 struct ipw_tx_radiotap_header sc_txtap;
171 * NB.: This models the only instance of async locking in ipw_init_locked
172 * and must be kept in sync.
174 #define IPW_LOCK(sc) mtx_lock(&sc->sc_mtx);
175 #define IPW_UNLOCK(sc) mtx_unlock(&sc->sc_mtx);
176 #define IPW_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)