if_ndisvar.h revision 178930
1/*-
2 * Copyright (c) 2003
3 *	Bill Paul <wpaul@windriver.com>.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
19 *
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.
31 *
32 * $FreeBSD: head/sys/dev/if_ndis/if_ndisvar.h 178930 2008-05-10 20:12:43Z thompsa $
33 */
34
35#define NDIS_DEFAULT_NODENAME	"FreeBSD NDIS node"
36#define NDIS_NODENAME_LEN	32
37
38/* For setting/getting OIDs from userspace. */
39
40struct ndis_oid_data {
41	uint32_t		oid;
42	uint32_t		len;
43#ifdef notdef
44	uint8_t			data[1];
45#endif
46};
47
48struct ndis_pci_type {
49	uint16_t		ndis_vid;
50	uint16_t		ndis_did;
51	uint32_t		ndis_subsys;
52	char			*ndis_name;
53};
54
55struct ndis_pccard_type {
56	const char		*ndis_vid;
57	const char		*ndis_did;
58	char			*ndis_name;
59};
60
61struct ndis_shmem {
62	list_entry		ndis_list;
63	bus_dma_tag_t		ndis_stag;
64	bus_dmamap_t		ndis_smap;
65	void			*ndis_saddr;
66	ndis_physaddr		ndis_paddr;
67};
68
69struct ndis_cfglist {
70	ndis_cfg		ndis_cfg;
71	struct sysctl_oid	*ndis_oid;
72        TAILQ_ENTRY(ndis_cfglist)	link;
73};
74
75/*
76 * Helper struct to make parsing information
77 * elements easier.
78 */
79struct ndis_ie {
80	uint8_t		ni_oui[3];
81	uint8_t		ni_val;
82};
83
84TAILQ_HEAD(nch, ndis_cfglist);
85
86#define NDIS_INITIALIZED(sc)	(sc->ndis_block->nmb_devicectx != NULL)
87
88#define NDIS_TXPKTS 64
89#define NDIS_INC(x)		\
90	(x)->ndis_txidx = ((x)->ndis_txidx + 1) % NDIS_TXPKTS
91
92
93#define NDIS_EVENTS 4
94#define NDIS_EVTINC(x)	(x) = ((x) + 1) % NDIS_EVENTS
95
96struct ndis_evt {
97	uint32_t		ne_sts;
98	uint32_t		ne_len;
99	char			*ne_buf;
100};
101
102struct ndis_vap {
103	struct ieee80211vap	vap;
104
105	int			(*newstate)(struct ieee80211vap *,
106				    enum ieee80211_state, int);
107};
108#define	NDIS_VAP(vap)	((struct ndis_vap *)(vap))
109
110struct ndis_softc {
111	struct ifnet		*ifp;
112	struct ifmedia		ifmedia;	/* media info */
113	u_long			ndis_hwassist;
114	uint32_t		ndis_v4tx;
115	uint32_t		ndis_v4rx;
116	bus_space_handle_t	ndis_bhandle;
117	bus_space_tag_t		ndis_btag;
118	void			*ndis_intrhand;
119	struct resource		*ndis_irq;
120	struct resource		*ndis_res;
121	struct resource		*ndis_res_io;
122	int			ndis_io_rid;
123	struct resource		*ndis_res_mem;
124	int			ndis_mem_rid;
125	struct resource		*ndis_res_altmem;
126	int			ndis_altmem_rid;
127	struct resource		*ndis_res_am;	/* attribute mem (pccard) */
128	int			ndis_am_rid;
129	struct resource		*ndis_res_cm;	/* common mem (pccard) */
130	struct resource_list	ndis_rl;
131	int			ndis_rescnt;
132	kspin_lock		ndis_spinlock;
133	uint8_t			ndis_irql;
134	device_t		ndis_dev;
135	int			ndis_unit;
136	ndis_miniport_block	*ndis_block;
137	ndis_miniport_characteristics	*ndis_chars;
138	interface_type		ndis_type;
139	struct callout		ndis_stat_callout;
140	int			ndis_maxpkts;
141	ndis_oid		*ndis_oids;
142	int			ndis_oidcnt;
143	int			ndis_txidx;
144	int			ndis_txpending;
145	ndis_packet		**ndis_txarray;
146	ndis_handle		ndis_txpool;
147	int			ndis_sc;
148	ndis_cfg		*ndis_regvals;
149	struct nch		ndis_cfglist_head;
150	int			ndis_80211;
151	int			ndis_link;
152	uint32_t		ndis_sts;
153	uint32_t		ndis_filter;
154	int			ndis_if_flags;
155	int			ndis_skip;
156
157	int			ndis_devidx;
158	interface_type		ndis_iftype;
159	driver_object		*ndis_dobj;
160	io_workitem		*ndis_tickitem;
161	io_workitem		*ndis_startitem;
162	io_workitem		*ndis_resetitem;
163	io_workitem		*ndis_inputitem;
164	kdpc			ndis_rxdpc;
165	bus_dma_tag_t		ndis_parent_tag;
166	list_entry		ndis_shlist;
167	bus_dma_tag_t		ndis_mtag;
168	bus_dma_tag_t		ndis_ttag;
169	bus_dmamap_t		*ndis_mmaps;
170	bus_dmamap_t		*ndis_tmaps;
171	int			ndis_mmapcnt;
172	struct ndis_evt		ndis_evt[NDIS_EVENTS];
173	int			ndis_evtpidx;
174	int			ndis_evtcidx;
175	struct ifqueue		ndis_rxqueue;
176	kspin_lock		ndis_rxlock;
177
178	struct taskqueue	*ndis_tq;		/* private task queue */
179	struct task		ndis_scantask;
180	struct task		ndis_authtask;
181	struct task		ndis_assoctask;
182	int			(*ndis_newstate)(struct ieee80211com *,
183				    enum ieee80211_state, int);
184};
185
186#define NDIS_LOCK(_sc)		KeAcquireSpinLock(&(_sc)->ndis_spinlock, \
187				    &(_sc)->ndis_irql);
188#define NDIS_UNLOCK(_sc)	KeReleaseSpinLock(&(_sc)->ndis_spinlock, \
189				    (_sc)->ndis_irql);
190