3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
35 #define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node"
36 #define NDIS_NODENAME_LEN 32
38 /* For setting/getting OIDs from userspace. */
40 struct ndis_oid_data {
48 struct ndis_pci_type {
55 struct ndis_pccard_type {
61 struct ndis_usb_type {
69 bus_dma_tag_t ndis_stag;
70 bus_dmamap_t ndis_smap;
72 ndis_physaddr ndis_paddr;
77 struct sysctl_oid *ndis_oid;
78 TAILQ_ENTRY(ndis_cfglist) link;
82 * Helper struct to make parsing information
90 TAILQ_HEAD(nch, ndis_cfglist);
92 #define NDIS_INITIALIZED(sc) (sc->ndis_block->nmb_devicectx != NULL)
94 #define NDIS_TXPKTS 64
96 (x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
100 #define NDIS_EVTINC(x) (x) = ((x) + 1) % NDIS_EVENTS
109 struct ieee80211vap vap;
111 int (*newstate)(struct ieee80211vap *,
112 enum ieee80211_state, int);
114 #define NDIS_VAP(vap) ((struct ndis_vap *)(vap))
116 #define NDISUSB_CONFIG_NO 0
117 #define NDISUSB_IFACE_INDEX 0
118 /* XXX at USB2 there's no USBD_NO_TIMEOUT macro anymore */
119 #define NDISUSB_NO_TIMEOUT 0
120 #define NDISUSB_INTR_TIMEOUT 1000
121 #define NDISUSB_TX_TIMEOUT 10000
124 struct usb_xfer *ne_xfer[1];
125 list_entry ne_active;
126 list_entry ne_pending;
130 struct ndisusb_xfer {
131 struct ndisusb_ep *nx_ep;
134 uint32_t nx_urbactlen;
136 uint8_t nx_shortxfer;
139 struct ndisusb_xferdone {
140 struct ndisusb_xfer *nd_xfer;
141 usb_error_t nd_status;
142 list_entry nd_donelist;
145 struct ndisusb_task {
147 #define NDISUSB_TASK_TSTART 0
148 #define NDISUSB_TASK_IRPCANCEL 1
149 #define NDISUSB_TASK_VENDOR 2
151 list_entry nt_tasklist;
156 struct ifmedia ifmedia; /* media info */
157 u_long ndis_hwassist;
160 bus_space_handle_t ndis_bhandle;
161 bus_space_tag_t ndis_btag;
163 struct resource *ndis_irq;
164 struct resource *ndis_res;
165 struct resource *ndis_res_io;
167 struct resource *ndis_res_mem;
169 struct resource *ndis_res_altmem;
171 struct resource *ndis_res_am; /* attribute mem (pccard) */
173 struct resource *ndis_res_cm; /* common mem (pccard) */
174 struct resource_list ndis_rl;
180 ndis_miniport_block *ndis_block;
181 ndis_miniport_characteristics *ndis_chars;
182 interface_type ndis_type;
183 struct callout ndis_scan_callout;
184 struct callout ndis_stat_callout;
190 ndis_packet **ndis_txarray;
191 ndis_handle ndis_txpool;
193 ndis_cfg *ndis_regvals;
194 struct nch ndis_cfglist_head;
198 uint32_t ndis_filter;
203 interface_type ndis_iftype;
204 driver_object *ndis_dobj;
205 io_workitem *ndis_tickitem;
206 io_workitem *ndis_startitem;
207 io_workitem *ndis_resetitem;
208 io_workitem *ndis_inputitem;
210 bus_dma_tag_t ndis_parent_tag;
211 list_entry ndis_shlist;
212 bus_dma_tag_t ndis_mtag;
213 bus_dma_tag_t ndis_ttag;
214 bus_dmamap_t *ndis_mmaps;
215 bus_dmamap_t *ndis_tmaps;
217 struct ndis_evt ndis_evt[NDIS_EVENTS];
220 struct ifqueue ndis_rxqueue;
221 kspin_lock ndis_rxlock;
223 int (*ndis_newstate)(struct ieee80211com *,
224 enum ieee80211_state, int);
228 struct usb_device *ndisusb_dev;
229 struct mtx ndisusb_mtx;
230 struct ndisusb_ep ndisusb_dread_ep;
231 struct ndisusb_ep ndisusb_dwrite_ep;
232 #define NDISUSB_GET_ENDPT(addr) \
233 ((UE_GET_DIR(addr) >> 7) | (UE_GET_ADDR(addr) << 1))
234 #define NDISUSB_ENDPT_MAX ((UE_ADDR + 1) * 2)
235 struct ndisusb_ep ndisusb_ep[NDISUSB_ENDPT_MAX];
236 io_workitem *ndisusb_xferdoneitem;
237 list_entry ndisusb_xferdonelist;
238 kspin_lock ndisusb_xferdonelock;
239 io_workitem *ndisusb_taskitem;
240 list_entry ndisusb_tasklist;
241 kspin_lock ndisusb_tasklock;
243 #define NDISUSB_STATUS_DETACH 0x1
244 #define NDISUSB_STATUS_SETUP_EP 0x2
247 #define NDIS_LOCK(_sc) mtx_lock(&(_sc)->ndis_mtx)
248 #define NDIS_UNLOCK(_sc) mtx_unlock(&(_sc)->ndis_mtx)
249 #define NDIS_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->ndis_mtx, t)
250 #define NDISUSB_LOCK(_sc) mtx_lock(&(_sc)->ndisusb_mtx)
251 #define NDISUSB_UNLOCK(_sc) mtx_unlock(&(_sc)->ndisusb_mtx)
252 #define NDISUSB_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->ndisusb_mtx, t)