]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - sys/dev/if_ndis/if_ndisvar.h
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / sys / dev / if_ndis / if_ndisvar.h
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$
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
40 struct ndis_oid_data {
41         uint32_t                oid;
42         uint32_t                len;
43 #ifdef notdef
44         uint8_t                 data[1];
45 #endif
46 };
47
48 struct ndis_pci_type {
49         uint16_t                ndis_vid;
50         uint16_t                ndis_did;
51         uint32_t                ndis_subsys;
52         char                    *ndis_name;
53 };
54
55 struct ndis_pccard_type {
56         const char              *ndis_vid;
57         const char              *ndis_did;
58         char                    *ndis_name;
59 };
60
61 struct 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
69 struct 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  */
79 struct ndis_ie {
80         uint8_t         ni_oui[3];
81         uint8_t         ni_val;
82 };
83
84 TAILQ_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) % (x)->ndis_maxpkts
91
92 #if __FreeBSD_version < 600007
93 #define arpcom ic.ic_ac
94 #endif
95
96 #define NDIS_EVENTS 4
97 #define NDIS_EVTINC(x)  (x) = ((x) + 1) % NDIS_EVENTS
98
99 struct ndis_evt {
100         uint32_t                ne_sts;
101         uint32_t                ne_len;
102         char                    *ne_buf;
103 };
104
105 struct ndis_softc {
106         struct ieee80211com     ic;             /* interface info */
107         struct ifnet            *ifp;
108         struct ifmedia          ifmedia;        /* media info */
109         u_long                  ndis_hwassist;
110         uint32_t                ndis_v4tx;
111         uint32_t                ndis_v4rx;
112         bus_space_handle_t      ndis_bhandle;
113         bus_space_tag_t         ndis_btag;
114         void                    *ndis_intrhand;
115         struct resource         *ndis_irq;
116         struct resource         *ndis_res;
117         struct resource         *ndis_res_io;
118         int                     ndis_io_rid;
119         struct resource         *ndis_res_mem;
120         int                     ndis_mem_rid;
121         struct resource         *ndis_res_altmem;
122         int                     ndis_altmem_rid;
123         struct resource         *ndis_res_am;   /* attribute mem (pccard) */
124         int                     ndis_am_rid;
125         struct resource         *ndis_res_cm;   /* common mem (pccard) */
126         struct resource_list    ndis_rl;
127         int                     ndis_rescnt;
128         kspin_lock              ndis_spinlock;
129         uint8_t                 ndis_irql;
130         device_t                ndis_dev;
131         int                     ndis_unit;
132         ndis_miniport_block     *ndis_block;
133         ndis_miniport_characteristics   *ndis_chars;
134         interface_type          ndis_type;
135         struct callout_handle   ndis_stat_ch;
136         int                     ndis_maxpkts;
137         ndis_oid                *ndis_oids;
138         int                     ndis_oidcnt;
139         int                     ndis_txidx;
140         int                     ndis_txpending;
141         ndis_packet             **ndis_txarray;
142         ndis_handle             ndis_txpool;
143         int                     ndis_sc;
144         ndis_cfg                *ndis_regvals;
145         struct nch              ndis_cfglist_head;
146         int                     ndis_80211;
147         int                     ndis_link;
148         uint32_t                ndis_sts;
149         uint32_t                ndis_filter;
150         int                     ndis_if_flags;
151         int                     ndis_skip;
152
153 #if __FreeBSD_version < 502113
154         struct sysctl_ctx_list  ndis_ctx;
155         struct sysctl_oid       *ndis_tree;
156 #endif
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 #if __FreeBSD_version < 700000
180         struct proc             *ndis_tqproc;
181 #endif
182         struct task             ndis_scantask;
183         int                     (*ndis_newstate)(struct ieee80211com *,
184                                     enum ieee80211_state, int);
185 };
186
187 #define NDIS_LOCK(_sc)          KeAcquireSpinLock(&(_sc)->ndis_spinlock, \
188                                     &(_sc)->ndis_irql);
189 #define NDIS_UNLOCK(_sc)        KeReleaseSpinLock(&(_sc)->ndis_spinlock, \
190                                     (_sc)->ndis_irql);
191
192 /*
193  * Backwards compatibility defines.
194  */
195
196 #ifndef IF_ADDR_LOCK
197 #define IF_ADDR_LOCK(x)
198 #define IF_ADDR_UNLOCK(x)
199 #endif
200
201 #ifndef IFF_DRV_OACTIVE
202 #define IFF_DRV_OACTIVE IFF_OACTIVE
203 #define IFF_DRV_RUNNING IFF_RUNNING
204 #define if_drv_flags if_flags
205 #endif
206
207 #ifndef ic_def_txkey
208 #define ic_def_txkey ic_wep_txkey
209 #define wk_keylen wk_len
210 #endif
211
212 #ifndef SIOCGDRVSPEC
213 #define SIOCSDRVSPEC    _IOW('i', 123, struct ifreq)    /* set driver-specific
214                                                                 parameters */
215 #define SIOCGDRVSPEC    _IOWR('i', 123, struct ifreq)   /* get driver-specific
216                                                                 parameters */
217 #endif