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.
32 * $FreeBSD: src/sys/dev/if_ndis/if_ndisvar.h,v 1.39 2009/05/02 15:14:18 thompsa Exp $
35 #include "use_usb4bsd.h"
37 #define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node"
38 #define NDIS_NODENAME_LEN 32
40 /* For setting/getting OIDs from userspace. */
42 struct ndis_oid_data {
50 struct ndis_pci_type {
57 struct ndis_pccard_type {
63 struct ndis_usb_type {
71 bus_dma_tag_t ndis_stag;
72 bus_dmamap_t ndis_smap;
74 ndis_physaddr ndis_paddr;
79 struct sysctl_oid *ndis_oid;
80 TAILQ_ENTRY(ndis_cfglist) link;
84 * Helper struct to make parsing information
92 TAILQ_HEAD(nch, ndis_cfglist);
94 #define NDIS_INITIALIZED(sc) (sc->ndis_block->nmb_devicectx != NULL)
96 #define NDIS_TXPKTS 64
98 (x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
101 #define NDIS_EVENTS 4
102 #define NDIS_EVTINC(x) (x) = ((x) + 1) % NDIS_EVENTS
111 struct ieee80211vap vap;
113 int (*newstate)(struct ieee80211vap *,
114 enum ieee80211_state, int);
116 #define NDIS_VAP(vap) ((struct ndis_vap *)(vap))
119 #define NDISUSB_CONFIG_NO 0
120 #define NDISUSB_IFACE_INDEX 0
121 /* XXX at USB2 there's no USBD_NO_TIMEOUT macro anymore */
122 #define NDISUSB_NO_TIMEOUT 0
123 #define NDISUSB_INTR_TIMEOUT 1000
124 #define NDISUSB_TX_TIMEOUT 10000
127 struct usb_xfer *ne_xfer[1];
128 list_entry ne_active;
129 list_entry ne_pending;
133 struct ndisusb_xfer {
134 struct ndisusb_ep *nx_ep;
137 uint32_t nx_urbactlen;
139 uint8_t nx_shortxfer;
142 struct ndisusb_xferdone {
143 struct ndisusb_xfer *nd_xfer;
144 usb_error_t nd_status;
145 list_entry nd_donelist;
148 struct ndisusb_task {
150 #define NDISUSB_TASK_TSTART 0
151 #define NDISUSB_TASK_IRPCANCEL 1
152 #define NDISUSB_TASK_VENDOR 2
154 list_entry nt_tasklist;
156 #else /* !NUSB4BSD > 0 */
157 #define NDISUSB_CONFIG_NO 1
158 #define NDISUSB_IFACE_INDEX 0
159 #define NDISUSB_INTR_TIMEOUT 1000
160 #define NDISUSB_TX_TIMEOUT 10000
161 struct ndisusb_xfer {
162 usbd_xfer_handle nx_xfer;
163 usbd_private_handle nx_priv;
164 usbd_status nx_status;
165 list_entry nx_xferlist;
171 struct ifmedia ifmedia; /* media info */
172 u_long ndis_hwassist;
175 bus_space_handle_t ndis_bhandle;
176 bus_space_tag_t ndis_btag;
178 struct resource *ndis_irq;
179 struct resource *ndis_res;
180 struct resource *ndis_res_io;
182 struct resource *ndis_res_mem;
184 struct resource *ndis_res_altmem;
186 struct resource *ndis_res_am; /* attribute mem (pccard) */
188 struct resource *ndis_res_cm; /* common mem (pccard) */
189 struct resource_list ndis_rl;
191 struct lock ndis_lock;
195 ndis_miniport_block *ndis_block;
196 ndis_miniport_characteristics *ndis_chars;
197 interface_type ndis_type;
198 struct callout ndis_scan_callout;
199 struct callout ndis_stat_callout;
205 ndis_packet **ndis_txarray;
206 ndis_handle ndis_txpool;
208 ndis_cfg *ndis_regvals;
209 struct nch ndis_cfglist_head;
213 uint32_t ndis_filter;
217 struct sysctl_ctx_list ndis_ctx;
218 struct sysctl_oid *ndis_tree;
220 interface_type ndis_iftype;
221 driver_object *ndis_dobj;
222 io_workitem *ndis_tickitem;
223 io_workitem *ndis_startitem;
224 io_workitem *ndis_resetitem;
225 io_workitem *ndis_inputitem;
227 bus_dma_tag_t ndis_parent_tag;
228 list_entry ndis_shlist;
229 bus_dma_tag_t ndis_mtag;
230 bus_dma_tag_t ndis_ttag;
231 bus_dmamap_t *ndis_mmaps;
232 bus_dmamap_t *ndis_tmaps;
234 struct ndis_evt ndis_evt[NDIS_EVENTS];
237 struct ifqueue ndis_rxqueue;
238 kspin_lock ndis_rxlock;
240 int (*ndis_newstate)(struct ieee80211com *,
241 enum ieee80211_state, int);
246 struct usb_device *ndisusb_dev;
247 struct lock ndisusb_lock;
248 struct ndisusb_ep ndisusb_dread_ep;
249 struct ndisusb_ep ndisusb_dwrite_ep;
250 #define NDISUSB_GET_ENDPT(addr) \
251 ((UE_GET_DIR(addr) >> 7) | (UE_GET_ADDR(addr) << 1))
252 #define NDISUSB_ENDPT_MAX ((UE_ADDR + 1) * 2)
253 struct ndisusb_ep ndisusb_ep[NDISUSB_ENDPT_MAX];
254 io_workitem *ndisusb_xferdoneitem;
255 list_entry ndisusb_xferdonelist;
256 kspin_lock ndisusb_xferdonelock;
257 io_workitem *ndisusb_taskitem;
258 list_entry ndisusb_tasklist;
259 kspin_lock ndisusb_tasklock;
261 #define NDISUSB_STATUS_DETACH 0x1
262 #define NDISUSB_STATUS_SETUP_EP 0x2
265 #define NDIS_LOCK(_sc) lockmgr(&(_sc)->ndis_lock, LK_EXCLUSIVE)
266 #define NDIS_UNLOCK(_sc) lockmgr(&(_sc)->ndis_lock, LK_RELEASE)
267 #define NDISMTX_LOCK NDIS_LOCK
268 #define NDISMTX_UNLOCK NDIS_UNLOCK
269 #define NDIS_LOCK_ASSERT(_sc, t) KKASSERT(lockstatus(&(_sc)->ndis_lock, curthread) != 0)
270 #define NDISUSB_LOCK(_sc) lockmgr(&(_sc)->ndisusb_lock, LK_EXCLUSIVE)
271 #define NDISUSB_UNLOCK(_sc) lockmgr(&(_sc)->ndisusb_lock, LK_RELEASE)
272 #define NDISUSB_LOCK_ASSERT(_sc, t) KKASSERT(lockstatus(&(_sc)->ndisusb_lock, curthread) != 0)
273 #else /* !NUSB4BSD > 0 */
274 io_workitem *ndisusb_xferitem;
275 list_entry ndisusb_xferlist;
276 kspin_lock ndisusb_xferlock;
277 #define NDISUSB_ENDPT_BOUT 0
278 #define NDISUSB_ENDPT_BIN 1
279 #define NDISUSB_ENDPT_IIN 2
280 #define NDISUSB_ENDPT_IOUT 3
281 #define NDISUSB_ENDPT_MAX 4
282 usbd_pipe_handle ndisusb_ep[NDISUSB_ENDPT_MAX];
283 char *ndisusb_iin_buf;
285 #define NDISUSB_STATUS_DETACH 0x1
288 #define NDISMTX_LOCK(_sc) lockmgr(&(_sc)->ndis_lock, LK_EXCLUSIVE)
289 #define NDISMTX_UNLOCK(_sc) lockmgr(&(_sc)->ndis_lock, LK_RELEASE)
290 #define NDISUSB_LOCK(_sc) get_mplock()
291 #define NDISUSB_UNLOCK(_sc) rel_mplock()
292 #define NDIS_LOCK(_sc) do { \
293 if ((_sc)->ndis_iftype == PNPBus) \
297 #define NDIS_UNLOCK(_sc) do { \
298 if ((_sc)->ndis_iftype == PNPBus) \
299 NDISUSB_UNLOCK(_sc); \
300 NDISMTX_UNLOCK(_sc); \