]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/compat/ndis/ndis_var.h
Add libbearssl
[FreeBSD/FreeBSD.git] / sys / compat / ndis / ndis_var.h
1 /*-
2  * SPDX-License-Identifier: BSD-4-Clause
3  *
4  * Copyright (c) 2003
5  *      Bill Paul <wpaul@windriver.com>.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Bill Paul.
18  * 4. Neither the name of the author nor the names of any co-contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $FreeBSD$
35  */
36
37 #ifndef _NDIS_VAR_H_
38 #define _NDIS_VAR_H_
39
40 /* Forward declarations */
41 struct ndis_miniport_block;
42 struct ndis_mdriver_block;
43 typedef struct ndis_miniport_block ndis_miniport_block;
44 typedef struct ndis_mdriver_block ndis_mdriver_block;
45
46 /* Base types */
47 typedef uint32_t ndis_status;
48 typedef void *ndis_handle;
49 typedef uint32_t ndis_oid;
50 typedef uint32_t ndis_error_code;
51 typedef register_t ndis_kspin_lock;
52 typedef uint8_t ndis_kirql;
53
54 /*
55  * NDIS status codes (there are lots of them). The ones that
56  * don't seem to fit the pattern are actually mapped to generic
57  * NT status codes.
58  */
59
60 #define NDIS_STATUS_SUCCESS             0
61 #define NDIS_STATUS_PENDING             0x00000103
62 #define NDIS_STATUS_NOT_RECOGNIZED      0x00010001
63 #define NDIS_STATUS_NOT_COPIED          0x00010002
64 #define NDIS_STATUS_NOT_ACCEPTED        0x00010003
65 #define NDIS_STATUS_CALL_ACTIVE         0x00010007
66 #define NDIS_STATUS_ONLINE              0x40010003
67 #define NDIS_STATUS_RESET_START         0x40010004
68 #define NDIS_STATUS_RESET_END           0x40010005
69 #define NDIS_STATUS_RING_STATUS         0x40010006
70 #define NDIS_STATUS_CLOSED              0x40010007
71 #define NDIS_STATUS_WAN_LINE_UP         0x40010008
72 #define NDIS_STATUS_WAN_LINE_DOWN       0x40010009
73 #define NDIS_STATUS_WAN_FRAGMENT        0x4001000A
74 #define NDIS_STATUS_MEDIA_CONNECT       0x4001000B
75 #define NDIS_STATUS_MEDIA_DISCONNECT    0x4001000C
76 #define NDIS_STATUS_HARDWARE_LINE_UP    0x4001000D
77 #define NDIS_STATUS_HARDWARE_LINE_DOWN  0x4001000E
78 #define NDIS_STATUS_INTERFACE_UP        0x4001000F
79 #define NDIS_STATUS_INTERFACE_DOWN      0x40010010
80 #define NDIS_STATUS_MEDIA_BUSY          0x40010011
81 #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION   0x40010012
82 #define NDIS_STATUS_WW_INDICATION NDIS_STATUS_MEDIA_SPECIFIC_INDICATION
83 #define NDIS_STATUS_LINK_SPEED_CHANGE   0x40010013
84 #define NDIS_STATUS_WAN_GET_STATS       0x40010014
85 #define NDIS_STATUS_WAN_CO_FRAGMENT     0x40010015
86 #define NDIS_STATUS_WAN_CO_LINKPARAMS   0x40010016
87 #define NDIS_STATUS_NOT_RESETTABLE      0x80010001
88 #define NDIS_STATUS_SOFT_ERRORS         0x80010003
89 #define NDIS_STATUS_HARD_ERRORS         0x80010004
90 #define NDIS_STATUS_BUFFER_OVERFLOW     0x80000005
91 #define NDIS_STATUS_FAILURE             0xC0000001
92 #define NDIS_STATUS_RESOURCES           0xC000009A
93 #define NDIS_STATUS_CLOSING             0xC0010002
94 #define NDIS_STATUS_BAD_VERSION         0xC0010004
95 #define NDIS_STATUS_BAD_CHARACTERISTICS 0xC0010005
96 #define NDIS_STATUS_ADAPTER_NOT_FOUND   0xC0010006
97 #define NDIS_STATUS_OPEN_FAILED         0xC0010007
98 #define NDIS_STATUS_DEVICE_FAILED       0xC0010008
99 #define NDIS_STATUS_MULTICAST_FULL      0xC0010009
100 #define NDIS_STATUS_MULTICAST_EXISTS    0xC001000A
101 #define NDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B
102 #define NDIS_STATUS_REQUEST_ABORTED     0xC001000C
103 #define NDIS_STATUS_RESET_IN_PROGRESS   0xC001000D
104 #define NDIS_STATUS_CLOSING_INDICATING  0xC001000E
105 #define NDIS_STATUS_NOT_SUPPORTED       0xC00000BB
106 #define NDIS_STATUS_INVALID_PACKET      0xC001000F
107 #define NDIS_STATUS_OPEN_LIST_FULL      0xC0010010
108 #define NDIS_STATUS_ADAPTER_NOT_READY   0xC0010011
109 #define NDIS_STATUS_ADAPTER_NOT_OPEN    0xC0010012
110 #define NDIS_STATUS_NOT_INDICATING      0xC0010013
111 #define NDIS_STATUS_INVALID_LENGTH      0xC0010014
112 #define NDIS_STATUS_INVALID_DATA        0xC0010015
113 #define NDIS_STATUS_BUFFER_TOO_SHORT    0xC0010016
114 #define NDIS_STATUS_INVALID_OID         0xC0010017
115 #define NDIS_STATUS_ADAPTER_REMOVED     0xC0010018
116 #define NDIS_STATUS_UNSUPPORTED_MEDIA   0xC0010019
117 #define NDIS_STATUS_GROUP_ADDRESS_IN_USE        0xC001001A
118 #define NDIS_STATUS_FILE_NOT_FOUND      0xC001001B
119 #define NDIS_STATUS_ERROR_READING_FILE  0xC001001C
120 #define NDIS_STATUS_ALREADY_MAPPED      0xC001001D
121 #define NDIS_STATUS_RESOURCE_CONFLICT   0xC001001E
122 #define NDIS_STATUS_NO_CABLE            0xC001001F
123 #define NDIS_STATUS_INVALID_SAP         0xC0010020
124 #define NDIS_STATUS_SAP_IN_USE          0xC0010021
125 #define NDIS_STATUS_INVALID_ADDRESS     0xC0010022
126 #define NDIS_STATUS_VC_NOT_ACTIVATED    0xC0010023
127 #define NDIS_STATUS_DEST_OUT_OF_ORDER   0xC0010024
128 #define NDIS_STATUS_VC_NOT_AVAILABLE    0xC0010025
129 #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE      0xC0010026
130 #define NDIS_STATUS_INCOMPATABLE_QOS    0xC0010027
131 #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED      0xC0010028
132 #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION     0xC0010029
133 #define NDIS_STATUS_TOKEN_RING_OPEN_ERROR       0xC0011000
134 #define NDIS_STATUS_INVALID_DEVICE_REQUEST      0xC0000010
135 #define NDIS_STATUS_NETWORK_UNREACHABLE         0xC000023C
136
137 /*
138  * NDIS event codes. They are usually reported to NdisWriteErrorLogEntry().
139  */
140
141 #define EVENT_NDIS_RESOURCE_CONFLICT    0xC0001388
142 #define EVENT_NDIS_OUT_OF_RESOURCE      0xC0001389
143 #define EVENT_NDIS_HARDWARE_FAILURE     0xC000138A
144 #define EVENT_NDIS_ADAPTER_NOT_FOUND    0xC000138B
145 #define EVENT_NDIS_INTERRUPT_CONNECT    0xC000138C
146 #define EVENT_NDIS_DRIVER_FAILURE       0xC000138D
147 #define EVENT_NDIS_BAD_VERSION          0xC000138E
148 #define EVENT_NDIS_TIMEOUT              0x8000138F
149 #define EVENT_NDIS_NETWORK_ADDRESS      0xC0001390
150 #define EVENT_NDIS_UNSUPPORTED_CONFIGURATION    0xC0001391
151 #define EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER   0xC0001392
152 #define EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER      0xC0001393
153 #define EVENT_NDIS_BAD_IO_BASE_ADDRESS  0xC0001394
154 #define EVENT_NDIS_RECEIVE_SPACE_SMALL  0x40001395
155 #define EVENT_NDIS_ADAPTER_DISABLED     0x80001396
156 #define EVENT_NDIS_IO_PORT_CONFLICT     0x80001397
157 #define EVENT_NDIS_PORT_OR_DMA_CONFLICT 0x80001398
158 #define EVENT_NDIS_MEMORY_CONFLICT      0x80001399
159 #define EVENT_NDIS_INTERRUPT_CONFLICT   0x8000139A
160 #define EVENT_NDIS_DMA_CONFLICT         0x8000139B
161 #define EVENT_NDIS_INVALID_DOWNLOAD_FILE_ERROR  0xC000139C
162 #define EVENT_NDIS_MAXRECEIVES_ERROR    0x8000139D
163 #define EVENT_NDIS_MAXTRANSMITS_ERROR   0x8000139E
164 #define EVENT_NDIS_MAXFRAMESIZE_ERROR   0x8000139F
165 #define EVENT_NDIS_MAXINTERNALBUFS_ERROR        0x800013A0
166 #define EVENT_NDIS_MAXMULTICAST_ERROR   0x800013A1
167 #define EVENT_NDIS_PRODUCTID_ERROR      0x800013A2
168 #define EVENT_NDIS_LOBE_FAILUE_ERROR    0x800013A3
169 #define EVENT_NDIS_SIGNAL_LOSS_ERROR    0x800013A4
170 #define EVENT_NDIS_REMOVE_RECEIVED_ERROR        0x800013A5
171 #define EVENT_NDIS_TOKEN_RING_CORRECTION        0x400013A6
172 #define EVENT_NDIS_ADAPTER_CHECK_ERROR  0xC00013A7
173 #define EVENT_NDIS_RESET_FAILURE_ERROR  0x800013A8
174 #define EVENT_NDIS_CABLE_DISCONNECTED_ERROR     0x800013A9
175 #define EVENT_NDIS_RESET_FAILURE_CORRECTION     0x800013AA
176
177 /*
178  * NDIS OIDs used by the queryinfo/setinfo routines.
179  * Some are required by all NDIS drivers, some are specific to
180  * a particular type of device, and some are purely optional.
181  * Unfortunately, one of the purely optional OIDs is the one
182  * that lets us set the MAC address of the device.
183  */
184
185 /* Required OIDs */
186 #define OID_GEN_SUPPORTED_LIST                  0x00010101
187 #define OID_GEN_HARDWARE_STATUS                 0x00010102
188 #define OID_GEN_MEDIA_SUPPORTED                 0x00010103
189 #define OID_GEN_MEDIA_IN_USE                    0x00010104
190 #define OID_GEN_MAXIMUM_LOOKAHEAD               0x00010105
191 #define OID_GEN_MAXIMUM_FRAME_SIZE              0x00010106
192 #define OID_GEN_LINK_SPEED                      0x00010107
193 #define OID_GEN_TRANSMIT_BUFFER_SPACE           0x00010108
194 #define OID_GEN_RECEIVE_BUFFER_SPACE            0x00010109
195 #define OID_GEN_TRANSMIT_BLOCK_SIZE             0x0001010A
196 #define OID_GEN_RECEIVE_BLOCK_SIZE              0x0001010B
197 #define OID_GEN_VENDOR_ID                       0x0001010C
198 #define OID_GEN_VENDOR_DESCRIPTION              0x0001010D
199 #define OID_GEN_CURRENT_PACKET_FILTER           0x0001010E
200 #define OID_GEN_CURRENT_LOOKAHEAD               0x0001010F
201 #define OID_GEN_DRIVER_VERSION                  0x00010110
202 #define OID_GEN_MAXIMUM_TOTAL_SIZE              0x00010111
203 #define OID_GEN_PROTOCOL_OPTIONS                0x00010112
204 #define OID_GEN_MAC_OPTIONS                     0x00010113
205 #define OID_GEN_MEDIA_CONNECT_STATUS            0x00010114
206 #define OID_GEN_MAXIMUM_SEND_PACKETS            0x00010115
207 #define OID_GEN_VENDOR_DRIVER_VERSION           0x00010116
208 #define OID_GEN_SUPPORTED_GUIDS                 0x00010117
209 #define OID_GEN_NETWORK_LAYER_ADDRESSES         0x00010118      /* Set only */
210 #define OID_GEN_TRANSPORT_HEADER_OFFSET         0x00010119      /* Set only */
211 #define OID_GEN_MACHINE_NAME                    0x0001021A
212 #define OID_GEN_RNDIS_CONFIG_PARAMETER          0x0001021B      /* Set only */
213 #define OID_GEN_VLAN_ID                         0x0001021C
214
215 /* Optional OIDs. */
216 #define OID_GEN_MEDIA_CAPABILITIES              0x00010201
217 #define OID_GEN_PHYSICAL_MEDIUM                 0x00010202
218
219 /* Required statistics OIDs. */
220 #define OID_GEN_XMIT_OK                         0x00020101
221 #define OID_GEN_RCV_OK                          0x00020102
222 #define OID_GEN_XMIT_ERROR                      0x00020103
223 #define OID_GEN_RCV_ERROR                       0x00020104
224 #define OID_GEN_RCV_NO_BUFFER                   0x00020105
225
226 /* Optional OID statistics */
227 #define OID_GEN_DIRECTED_BYTES_XMIT             0x00020201
228 #define OID_GEN_DIRECTED_FRAMES_XMIT            0x00020202
229 #define OID_GEN_MULTICAST_BYTES_XMIT            0x00020203
230 #define OID_GEN_MULTICAST_FRAMES_XMIT           0x00020204
231 #define OID_GEN_BROADCAST_BYTES_XMIT            0x00020205
232 #define OID_GEN_BROADCAST_FRAMES_XMIT           0x00020206
233 #define OID_GEN_DIRECTED_BYTES_RCV              0x00020207
234 #define OID_GEN_DIRECTED_FRAMES_RCV             0x00020208
235 #define OID_GEN_MULTICAST_BYTES_RCV             0x00020209
236 #define OID_GEN_MULTICAST_FRAMES_RCV            0x0002020A
237 #define OID_GEN_BROADCAST_BYTES_RCV             0x0002020B
238 #define OID_GEN_BROADCAST_FRAMES_RCV            0x0002020C
239 #define OID_GEN_RCV_CRC_ERROR                   0x0002020D
240 #define OID_GEN_TRANSMIT_QUEUE_LENGTH           0x0002020E
241 #define OID_GEN_GET_TIME_CAPS                   0x0002020F
242 #define OID_GEN_GET_NETCARD_TIME                0x00020210
243 #define OID_GEN_NETCARD_LOAD                    0x00020211
244 #define OID_GEN_DEVICE_PROFILE                  0x00020212
245
246 /* 802.3 (ethernet) OIDs */
247 #define OID_802_3_PERMANENT_ADDRESS             0x01010101
248 #define OID_802_3_CURRENT_ADDRESS               0x01010102
249 #define OID_802_3_MULTICAST_LIST                0x01010103
250 #define OID_802_3_MAXIMUM_LIST_SIZE             0x01010104
251 #define OID_802_3_MAC_OPTIONS                   0x01010105
252 #define NDIS_802_3_MAC_OPTION_PRIORITY          0x00000001
253 #define OID_802_3_RCV_ERROR_ALIGNMENT           0x01020101
254 #define OID_802_3_XMIT_ONE_COLLISION            0x01020102
255 #define OID_802_3_XMIT_MORE_COLLISIONS          0x01020103
256 #define OID_802_3_XMIT_DEFERRED                 0x01020201
257 #define OID_802_3_XMIT_MAX_COLLISIONS           0x01020202
258 #define OID_802_3_RCV_OVERRUN                   0x01020203
259 #define OID_802_3_XMIT_UNDERRUN                 0x01020204
260 #define OID_802_3_XMIT_HEARTBEAT_FAILURE        0x01020205
261 #define OID_802_3_XMIT_TIMES_CRS_LOST           0x01020206
262 #define OID_802_3_XMIT_LATE_COLLISIONS          0x01020207
263
264 /* PnP and power management OIDs */
265 #define OID_PNP_CAPABILITIES                    0xFD010100
266 #define OID_PNP_SET_POWER                       0xFD010101
267 #define OID_PNP_QUERY_POWER                     0xFD010102
268 #define OID_PNP_ADD_WAKE_UP_PATTERN             0xFD010103
269 #define OID_PNP_REMOVE_WAKE_UP_PATTERN          0xFD010104
270 #define OID_PNP_WAKE_UP_PATTERN_LIST            0xFD010105
271 #define OID_PNP_ENABLE_WAKE_UP                  0xFD010106
272
273 /*
274  * These are the possible power states for
275  * OID_PNP_SET_POWER and OID_PNP_QUERY_POWER.
276  */
277 #define NDIS_POWERSTATE_UNSPEC                  0
278 #define NDIS_POWERSTATE_D0                      1
279 #define NDIS_POWERSTATE_D1                      2
280 #define NDIS_POWERSTATE_D2                      3
281 #define NDIS_POWERSTATE_D3                      4
282
283 /*
284  * These are used with the MiniportPnpEventNotify() method.
285  */
286
287 #define NDIS_POWERPROFILE_BATTERY               0
288 #define NDIS_POWERPROFILE_ACONLINE              1
289
290 #define NDIS_PNP_EVENT_QUERY_REMOVED            0
291 #define NDIS_PNP_EVENT_REMOVED                  1
292 #define NDIS_PNP_EVENT_SURPRISE_REMOVED         2
293 #define NDIS_PNP_EVENT_QUERY_STOPPED            3
294 #define NDIS_PNP_EVENT_STOPPED                  4
295 #define NDIS_PNP_EVENT_PROFILECHANGED           5
296
297
298 /* PnP/PM Statistics (Optional). */
299 #define OID_PNP_WAKE_UP_OK                      0xFD020200
300 #define OID_PNP_WAKE_UP_ERROR                   0xFD020201
301
302 /* The following bits are defined for OID_PNP_ENABLE_WAKE_UP */
303 #define NDIS_PNP_WAKE_UP_MAGIC_PACKET           0x00000001
304 #define NDIS_PNP_WAKE_UP_PATTERN_MATCH          0x00000002
305 #define NDIS_PNP_WAKE_UP_LINK_CHANGE            0x00000004
306
307 /* 802.11 OIDs */
308 #define OID_802_11_BSSID                        0x0D010101
309 #define OID_802_11_SSID                         0x0D010102
310 #define OID_802_11_NETWORK_TYPES_SUPPORTED      0x0D010203
311 #define OID_802_11_NETWORK_TYPE_IN_USE          0x0D010204
312 #define OID_802_11_TX_POWER_LEVEL               0x0D010205
313 #define OID_802_11_RSSI                         0x0D010206
314 #define OID_802_11_RSSI_TRIGGER                 0x0D010207
315 #define OID_802_11_INFRASTRUCTURE_MODE          0x0D010108
316 #define OID_802_11_FRAGMENTATION_THRESHOLD      0x0D010209
317 #define OID_802_11_RTS_THRESHOLD                0x0D01020A
318 #define OID_802_11_NUMBER_OF_ANTENNAS           0x0D01020B
319 #define OID_802_11_RX_ANTENNA_SELECTED          0x0D01020C
320 #define OID_802_11_TX_ANTENNA_SELECTED          0x0D01020D
321 #define OID_802_11_SUPPORTED_RATES              0x0D01020E
322 #define OID_802_11_DESIRED_RATES                0x0D010210
323 #define OID_802_11_CONFIGURATION                0x0D010211
324 #define OID_802_11_STATISTICS                   0x0D020212
325 #define OID_802_11_ADD_WEP                      0x0D010113
326 #define OID_802_11_REMOVE_WEP                   0x0D010114
327 #define OID_802_11_DISASSOCIATE                 0x0D010115
328 #define OID_802_11_POWER_MODE                   0x0D010216
329 #define OID_802_11_BSSID_LIST                   0x0D010217
330 #define OID_802_11_AUTHENTICATION_MODE          0x0D010118
331 #define OID_802_11_PRIVACY_FILTER               0x0D010119
332 #define OID_802_11_BSSID_LIST_SCAN              0x0D01011A
333 #define OID_802_11_WEP_STATUS                   0x0D01011B
334 #define OID_802_11_ENCRYPTION_STATUS            OID_802_11_WEP_STATUS
335 #define OID_802_11_RELOAD_DEFAULTS              0x0D01011C
336 #define OID_802_11_ADD_KEY                      0x0D01011D
337 #define OID_802_11_REMOVE_KEY                   0x0D01011E
338 #define OID_802_11_ASSOCIATION_INFORMATION      0x0D01011F
339 #define OID_802_11_TEST                         0x0D010120
340 #define OID_802_11_CAPABILITY                   0x0D010122
341 #define OID_802_11_PMKID                        0x0D010123
342
343 /* structures/definitions for 802.11 */
344 #define NDIS_80211_NETTYPE_11FH         0x00000000
345 #define NDIS_80211_NETTYPE_11DS         0x00000001
346 #define NDIS_80211_NETTYPE_11OFDM5      0x00000002
347 #define NDIS_80211_NETTYPE_11OFDM24     0x00000003
348 #define NDIS_80211_NETTYPE_AUTO         0x00000004
349
350 struct ndis_80211_nettype_list {
351         uint32_t                ntl_items;
352         uint32_t                ntl_type[1];
353 };
354
355 #define NDIS_80211_POWERMODE_CAM        0x00000000
356 #define NDIS_80211_POWERMODE_MAX_PSP    0x00000001
357 #define NDIS_80211_POWERMODE_FAST_PSP   0x00000002
358
359 typedef uint32_t ndis_80211_power;      /* Power in milliwatts */
360 typedef uint32_t ndis_80211_rssi;       /* Signal strength in dBm */
361
362 struct ndis_80211_config_fh {
363         uint32_t                ncf_length;
364         uint32_t                ncf_hoppatterh;
365         uint32_t                ncf_hopset;
366         uint32_t                ncf_dwelltime;
367 };
368
369 typedef struct ndis_80211_config_fh ndis_80211_config_fh;
370
371 struct ndis_80211_config {
372         uint32_t                nc_length;
373         uint32_t                nc_beaconperiod;
374         uint32_t                nc_atimwin;
375         uint32_t                nc_dsconfig;
376         ndis_80211_config_fh    nc_fhconfig;
377 };
378
379 typedef struct ndis_80211_config ndis_80211_config;
380
381 struct ndis_80211_stats {
382         uint32_t                ns_length;
383         uint64_t                ns_txfragcnt;
384         uint64_t                ns_txmcastcnt;
385         uint64_t                ns_failedcnt;
386         uint64_t                ns_retrycnt;
387         uint64_t                ns_multiretrycnt;
388         uint64_t                ns_rtssuccesscnt;
389         uint64_t                ns_rtsfailcnt;
390         uint64_t                ns_ackfailcnt;
391         uint64_t                ns_dupeframecnt;
392         uint64_t                ns_rxfragcnt;
393         uint64_t                ns_rxmcastcnt;
394         uint64_t                ns_fcserrcnt;
395 };
396
397 typedef struct ndis_80211_stats ndis_80211_stats;
398
399 typedef uint32_t ndis_80211_key_idx;
400
401 struct ndis_80211_wep {
402         uint32_t                nw_length;
403         uint32_t                nw_keyidx;
404         uint32_t                nw_keylen;
405         uint8_t                 nw_keydata[256];
406 };
407
408 typedef struct ndis_80211_wep ndis_80211_wep;
409
410 #define NDIS_80211_WEPKEY_TX            0x80000000
411 #define NDIS_80211_WEPKEY_PERCLIENT     0x40000000
412
413 #define NDIS_80211_NET_INFRA_IBSS       0x00000000
414 #define NDIS_80211_NET_INFRA_BSS        0x00000001
415 #define NDIS_80211_NET_INFRA_AUTO       0x00000002
416
417 #define NDIS_80211_AUTHMODE_OPEN        0x00000000
418 #define NDIS_80211_AUTHMODE_SHARED      0x00000001
419 #define NDIS_80211_AUTHMODE_AUTO        0x00000002
420 #define NDIS_80211_AUTHMODE_WPA         0x00000003
421 #define NDIS_80211_AUTHMODE_WPAPSK      0x00000004
422 #define NDIS_80211_AUTHMODE_WPANONE     0x00000005
423 #define NDIS_80211_AUTHMODE_WPA2        0x00000006
424 #define NDIS_80211_AUTHMODE_WPA2PSK     0x00000007
425
426 typedef uint8_t ndis_80211_rates[8];
427 typedef uint8_t ndis_80211_rates_ex[16];
428 typedef uint8_t ndis_80211_macaddr[6];
429
430 struct ndis_80211_ssid {
431         uint32_t                ns_ssidlen;
432         uint8_t                 ns_ssid[32];
433 };
434
435 typedef struct ndis_80211_ssid ndis_80211_ssid;
436
437 struct ndis_wlan_bssid {
438         uint32_t                nwb_length;
439         ndis_80211_macaddr      nwb_macaddr;
440         uint8_t                 nwb_rsvd[2];
441         ndis_80211_ssid         nwb_ssid;
442         uint32_t                nwb_privacy;
443         ndis_80211_rssi         nwb_rssi;
444         uint32_t                nwb_nettype;
445         ndis_80211_config       nwb_config;
446         uint32_t                nwb_netinfra;
447         ndis_80211_rates        nwb_supportedrates;
448 };
449
450 typedef struct ndis_wlan_bssid ndis_wlan_bssid;
451
452 struct ndis_80211_bssid_list {
453         uint32_t                nbl_items;
454         ndis_wlan_bssid         nbl_bssid[1];
455 };
456
457 typedef struct ndis_80211_bssid_list ndis_80211_bssid_list;
458
459 struct ndis_wlan_bssid_ex {
460         uint32_t                nwbx_len;
461         ndis_80211_macaddr      nwbx_macaddr;
462         uint8_t                 nwbx_rsvd[2];
463         ndis_80211_ssid         nwbx_ssid;
464         uint32_t                nwbx_privacy;
465         ndis_80211_rssi         nwbx_rssi;
466         uint32_t                nwbx_nettype;
467         ndis_80211_config       nwbx_config;
468         uint32_t                nwbx_netinfra;
469         ndis_80211_rates_ex     nwbx_supportedrates;
470         uint32_t                nwbx_ielen;
471         uint8_t                 nwbx_ies[1];
472 };
473
474 typedef struct ndis_wlan_bssid_ex ndis_wlan_bssid_ex;
475
476 struct ndis_80211_bssid_list_ex {
477         uint32_t                nblx_items;
478         ndis_wlan_bssid_ex      nblx_bssid[1];
479 };
480
481 typedef struct ndis_80211_bssid_list_ex ndis_80211_bssid_list_ex;
482
483 struct ndis_80211_fixed_ies {
484         uint8_t                 nfi_tstamp[8];
485         uint16_t                nfi_beaconint;
486         uint16_t                nfi_caps;
487 };
488
489 struct ndis_80211_variable_ies {
490         uint8_t                 nvi_elemid;
491         uint8_t                 nvi_len;
492         uint8_t                 nvi_data[1];
493 };
494
495 typedef uint32_t ndis_80211_fragthresh;
496 typedef uint32_t ndis_80211_rtsthresh;
497 typedef uint32_t ndis_80211_antenna;
498
499 #define NDIS_80211_PRIVFILT_ACCEPTALL   0x00000000
500 #define NDIS_80211_PRIVFILT_8021XWEP    0x00000001
501
502 #define NDIS_80211_WEPSTAT_ENABLED      0x00000000
503 #define NDIS_80211_WEPSTAT_ENC1ENABLED  NDIS_80211_WEPSTAT_ENABLED
504 #define NDIS_80211_WEPSTAT_DISABLED     0x00000001
505 #define NDIS_80211_WEPSTAT_ENCDISABLED  NDIS_80211_WEPSTAT_DISABLED
506 #define NDIS_80211_WEPSTAT_KEYABSENT    0x00000002
507 #define NDIS_80211_WEPSTAT_ENC1KEYABSENT        NDIS_80211_WEPSTAT_KEYABSENT
508 #define NDIS_80211_WEPSTAT_NOTSUPPORTED 0x00000003
509 #define NDIS_80211_WEPSTAT_ENCNOTSUPPORTED      NDIS_80211_WEPSTAT_NOTSUPPORTED
510 #define NDIS_80211_WEPSTAT_ENC2ENABLED  0x00000004
511 #define NDIS_80211_WEPSTAT_ENC2KEYABSENT        0x00000005
512 #define NDIS_80211_WEPSTAT_ENC3ENABLED  0x00000006
513 #define NDIS_80211_WEPSTAT_ENC3KEYABSENT        0x00000007
514
515 #define NDIS_80211_RELOADDEFAULT_WEP    0x00000000
516
517 #define NDIS_80211_STATUSTYPE_AUTH      0x00000000
518 #define NDIS_80211_STATUSTYPE_PMKIDLIST 0x00000001
519
520 struct ndis_80211_status_indication {
521         uint32_t                nsi_type;
522 };
523
524 typedef struct ndis_80211_status_indication ndis_80211_status_indication;
525
526 #define NDIS_802_11_AUTH_REQUEST_REAUTH         0x01
527 #define NDIS_802_11_AUTH_REQUEST_KEYUPDATE      0x02
528 #define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06
529 #define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR    0x0E
530
531 struct ndis_80211_auth_request {
532         uint32_t                nar_len;
533         ndis_80211_macaddr      nar_bssid;
534         uint32_t                nar_flags;
535 };
536
537 typedef struct ndis_80211_auth_request ndis_80211_auth_request;
538
539 struct ndis_80211_key {
540         uint32_t                nk_len;
541         uint32_t                nk_keyidx;
542         uint32_t                nk_keylen;
543         ndis_80211_macaddr      nk_bssid;
544         uint8_t                 nk_pad[6];
545         uint64_t                nk_keyrsc;
546         uint8_t                 nk_keydata[32];
547 };
548
549 typedef struct ndis_80211_key ndis_80211_key;
550
551 struct ndis_80211_remove_key {
552         uint32_t                nk_len;
553         uint32_t                nk_keyidx;
554         ndis_80211_macaddr      nk_bssid;
555 };
556
557 typedef struct ndis_80211_remove_key ndis_80211_remove_key;
558
559 #define NDIS_80211_AI_REQFI_CAPABILITIES        0x00000001
560 #define NDIS_80211_AI_REQFI_LISTENINTERVAL      0x00000002
561 #define NDIS_80211_AI_REQFI_CURRENTAPADDRESS    0x00000004
562
563 #define NDIS_80211_AI_RESFI_CAPABILITIES        0x00000001
564 #define NDIS_80211_AI_RESFI_STATUSCODE          0x00000002
565 #define NDIS_80211_AI_RESFI_ASSOCIATIONID       0x00000004
566
567 struct ndis_80211_ai_reqfi {
568         uint16_t                naq_caps;
569         uint16_t                naq_listentint;
570         ndis_80211_macaddr      naq_currentapaddr;
571 };
572
573 typedef struct ndis_80211_ai_reqfi ndis_80211_ai_reqfi;
574
575 struct ndis_80211_ai_resfi {
576         uint16_t                nas_caps;
577         uint16_t                nas_statuscode;
578         uint16_t                nas_associd;
579 };
580
581 typedef struct ndis_80211_ai_resfi ndis_80211_ai_resfi;
582
583 struct ndis_80211_assoc_info {
584         uint32_t                nai_len;
585         uint16_t                nai_avail_req_fixed_ies;
586         ndis_80211_ai_reqfi     nai_req_fixed_ies;
587         uint32_t                nai_req_ielen;
588         uint32_t                nai_offset_req_ies;
589         uint16_t                nai_avail_resp_fixed_ies;
590         ndis_80211_ai_resfi     nai_resp_fixed_iex;
591         uint32_t                nai_resp_ielen;
592         uint32_t                nai_offset_resp_ies;
593 };
594
595 typedef struct ndis_80211_assoc_info ndis_80211_assoc_info;
596
597 struct ndis_80211_auth_event {
598         ndis_80211_status_indication    nae_status;
599         ndis_80211_auth_request         nae_request[1];
600 };
601
602 typedef struct ndis_80211_auth_event ndis_80211_auth_event;
603
604 struct ndis_80211_test {
605         uint32_t                nt_len;
606         uint32_t                nt_type;
607         union {
608                 ndis_80211_auth_event   nt_authevent;
609                 uint32_t                nt_rssitrigger;
610         } u;
611 };
612
613 typedef struct ndis_80211_test ndis_80211_test;
614
615 struct ndis_80211_auth_encrypt {
616         uint32_t                ne_authmode;
617         uint32_t                ne_cryptstat;
618 };
619
620 typedef struct ndis_80211_auth_encrypt ndis_80211_auth_encrypt;
621
622 struct ndis_80211_caps {
623         uint32_t                nc_len;
624         uint32_t                nc_ver;
625         uint32_t                nc_numpmkids;
626         ndis_80211_auth_encrypt nc_authencs[1];
627 };
628
629 typedef struct ndis_80211_caps ndis_80211_caps;
630
631 struct ndis_80211_bssidinfo {
632         ndis_80211_macaddr      nb_bssid;
633         uint8_t                 nb_pmkid[16];
634 };
635
636 typedef struct ndis_80211_bssidinfo ndis_80211_bssidinfo;
637
638 struct ndis_80211_pmkid {
639         uint32_t                np_len;
640         uint32_t                np_bssidcnt;
641         ndis_80211_bssidinfo    np_bssidinfo[1];
642 };
643
644 typedef struct ndis_80211_pmkid ndis_80211_pmkid;
645
646 struct ndis_80211_pmkid_cand {
647         ndis_80211_macaddr      npc_bssid;
648         uint32_t                npc_flags;
649 };
650
651 typedef struct ndis_80211_pmkid_cand ndis_80211_pmkid_cand;
652
653 #define NDIS_802_11_PMKID_CANDIDATE_PREAUTH_ENABLED (0x01)
654
655 struct ndis_80211_pmkid_candidate_list {
656         uint32_t                npcl_version;
657         uint32_t                npcl_numcandidates;
658         ndis_80211_pmkid_cand   npcl_candidatelist[1];
659 };
660
661 typedef struct ndis_80211_pmkid_candidate_list ndis_80211_pmkid_candidate_list;
662
663 struct ndis_80211_enc_indication {
664         uint32_t                nei_statustype;
665         ndis_80211_pmkid_candidate_list nei_pmkidlist;
666 };
667
668 typedef struct ndis_80211_enc_indication ndis_80211_enc_indication;
669
670 /* TCP OIDs. */
671
672 #define OID_TCP_TASK_OFFLOAD                    0xFC010201
673 #define OID_TCP_TASK_IPSEC_ADD_SA               0xFC010202
674 #define OID_TCP_TASK_IPSEC_DELETE_SA            0xFC010203
675 #define OID_TCP_SAN_SUPPORT                     0xFC010204
676
677
678 #define NDIS_TASK_OFFLOAD_VERSION 1
679
680 #define NDIS_TASK_TCPIP_CSUM                    0x00000000
681 #define NDIS_TASK_IPSEC                         0x00000001
682 #define NDIS_TASK_TCP_LARGESEND                 0x00000002
683
684 #define NDIS_ENCAP_UNSPEC                       0x00000000
685 #define NDIS_ENCAP_NULL                         0x00000001
686 #define NDIS_ENCAP_IEEE802_3                    0x00000002
687 #define NDIS_ENCAP_IEEE802_5                    0x00000003
688 #define NDIS_ENCAP_SNAP_ROUTED                  0x00000004
689 #define NDIS_ENCAP_SNAP_BRIDGED                 0x00000005
690
691 #define NDIS_ENCAPFLAG_FIXEDHDRLEN              0x00000001
692
693 struct ndis_encap_fmt {
694         uint32_t                nef_encap;
695         uint32_t                nef_flags;
696         uint32_t                nef_encaphdrlen;
697 };
698
699 typedef struct ndis_encap_fmt ndis_encap_fmt;
700
701 struct ndis_task_offload_hdr {
702         uint32_t                ntoh_vers;
703         uint32_t                ntoh_len;
704         uint32_t                ntoh_rsvd;
705         uint32_t                ntoh_offset_firsttask;
706         ndis_encap_fmt          ntoh_encapfmt;
707 };
708
709 typedef struct ndis_task_offload_hdr ndis_task_offload_hdr;
710
711 struct ndis_task_offload {
712         uint32_t                nto_vers;
713         uint32_t                nto_len;
714         uint32_t                nto_task;
715         uint32_t                nto_offset_nexttask;
716         uint32_t                nto_taskbuflen;
717         uint8_t                 nto_taskbuf[1];
718 };
719
720 typedef struct ndis_task_offload ndis_task_offload;
721
722 #define NDIS_TCPSUM_FLAGS_IP_OPTS       0x00000001
723 #define NDIS_TCPSUM_FLAGS_TCP_OPTS      0x00000002
724 #define NDIS_TCPSUM_FLAGS_TCP_CSUM      0x00000004
725 #define NDIS_TCPSUM_FLAGS_UDP_CSUM      0x00000008
726 #define NDIS_TCPSUM_FLAGS_IP_CSUM       0x00000010
727
728 struct ndis_task_tcpip_csum {
729         uint32_t                nttc_v4tx;
730         uint32_t                nttc_v4rx;
731         uint32_t                nttc_v6tx;
732         uint32_t                nttc_v6rx;
733 };
734
735 typedef struct ndis_task_tcpip_csum ndis_task_tcpip_csum;
736
737 struct ndis_task_tcp_largesend {
738         uint32_t                nttl_vers;
739         uint32_t                nttl_maxofflen;
740         uint32_t                nttl_minsegcnt;
741         uint8_t                 nttl_tcpopt;
742         uint8_t                 nttl_ipopt;
743 };
744
745 typedef struct ndis_task_tcp_largesend ndis_task_tcp_largesend;
746
747 #define NDIS_IPSEC_AH_MD5               0x00000001
748 #define NDIS_IPSEC_AH_SHA1              0x00000002
749 #define NDIS_IPSEC_AH_TRANSPORT         0x00000004
750 #define NDIS_IPSEC_AH_TUNNEL            0x00000008
751 #define NDIS_IPSEC_AH_SEND              0x00000010
752 #define NDIS_IPSEC_AH_RECEIVE           0x00000020
753
754 #define NDIS_IPSEC_ESP_DES              0x00000001
755 #define NDIS_IPSEC_ESP_RSVD             0x00000002
756 #define NDIS_IPSEC_ESP_3DES             0x00000004
757 #define NDIS_IPSEC_ESP_NULL             0x00000008
758 #define NDIS_IPSEC_ESP_TRANSPORT        0x00000010
759 #define NDIS_IPSEC_ESP_TUNNEL           0x00000020
760 #define NDIS_IPSEC_ESP_SEND             0x00000040
761 #define NDIS_IPSEC_ESP_RECEIVE          0x00000080
762
763 struct ndis_task_ipsec {
764         uint32_t                nti_ah_esp_combined;
765         uint32_t                nti_ah_transport_tunnel_combined;
766         uint32_t                nti_v4_options;
767         uint32_t                nti_rsvd;
768         uint32_t                nti_v4ah;
769         uint32_t                nti_v4esp;
770 };
771
772 typedef struct ndis_task_ipsec ndis_task_ipsec;
773
774 /*
775  * Attribures of NDIS drivers. Not all drivers support
776  * all attributes.
777  */
778
779 #define NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT            0x00000001
780 #define NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT           0x00000002
781 #define NDIS_ATTRIBUTE_IGNORE_TOKEN_RING_ERRORS         0x00000004
782 #define NDIS_ATTRIBUTE_BUS_MASTER                       0x00000008
783 #define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER              0x00000010
784 #define NDIS_ATTRIBUTE_DESERIALIZE                      0x00000020
785 #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND               0x00000040
786 #define NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK               0x00000080
787 #define NDIS_ATTRIBUTE_NOT_CO_NDIS                      0x00000100
788 #define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS            0x00000200
789
790 #define NDIS_SERIALIZED(block)          \
791         (((block)->nmb_flags & NDIS_ATTRIBUTE_DESERIALIZE) == 0)
792
793 enum ndis_media_state {
794         nmc_connected,
795         nmc_disconnected
796 };
797
798 typedef enum ndis_media_state ndis_media_state;
799
800 /* Ndis Packet Filter Bits (OID_GEN_CURRENT_PACKET_FILTER). */
801
802 #define NDIS_PACKET_TYPE_DIRECTED               0x00000001
803 #define NDIS_PACKET_TYPE_MULTICAST              0x00000002
804 #define NDIS_PACKET_TYPE_ALL_MULTICAST          0x00000004
805 #define NDIS_PACKET_TYPE_BROADCAST              0x00000008
806 #define NDIS_PACKET_TYPE_SOURCE_ROUTING         0x00000010
807 #define NDIS_PACKET_TYPE_PROMISCUOUS            0x00000020
808 #define NDIS_PACKET_TYPE_SMT                    0x00000040
809 #define NDIS_PACKET_TYPE_ALL_LOCAL              0x00000080
810 #define NDIS_PACKET_TYPE_GROUP                  0x00001000
811 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL         0x00002000
812 #define NDIS_PACKET_TYPE_FUNCTIONAL             0x00004000
813 #define NDIS_PACKET_TYPE_MAC_FRAME              0x00008000
814
815
816 /* Ndis MAC option bits (OID_GEN_MAC_OPTIONS). */
817
818 #define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA             0x00000001
819 #define NDIS_MAC_OPTION_RECEIVE_SERIALIZED              0x00000002
820 #define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND              0x00000004
821 #define NDIS_MAC_OPTION_NO_LOOPBACK                     0x00000008
822 #define NDIS_MAC_OPTION_FULL_DUPLEX                     0x00000010
823 #define NDIS_MAC_OPTION_EOTX_INDICATION                 0x00000020
824 #define NDIS_MAC_OPTION_8021P_PRIORITY                  0x00000040
825 #define NDIS_MAC_OPTION_SUPPORTS_MAC_ADDRESS_OVERWRITE  0x00000080
826 #define NDIS_MAC_OPTION_RECEIVE_AT_DPC                  0x00000100
827 #define NDIS_MAC_OPTION_8021Q_VLAN                      0x00000200
828 #define NDIS_MAC_OPTION_RESERVED                        0x80000000
829
830 #define NDIS_DMA_24BITS         0x00
831 #define NDIS_DMA_32BITS         0x01
832 #define NDIS_DMA_64BITS         0x02
833
834 /*
835 struct ndis_physaddr {
836 #ifdef __i386__
837         uint64_t                np_quad;
838 #endif
839 #ifdef __amd64__
840         uint32_t                np_low;
841         uint32_t                np_high;
842 #define np_quad np_low
843 #endif
844 #ifdef notdef
845         uint32_t                np_low;
846         uint32_t                np_high;
847 #endif
848 };
849 */
850
851 typedef struct physaddr ndis_physaddr;
852
853 struct ndis_ansi_string {
854         uint16_t                nas_len;
855         uint16_t                nas_maxlen;
856         char                    *nas_buf;
857 };
858
859 typedef struct ndis_ansi_string ndis_ansi_string;
860
861 #ifdef notdef
862 /*
863  * nus_buf is really a wchar_t *, but it's inconvenient to include
864  * all the necessary header goop needed to define it, and it's a
865  * pointer anyway, so for now, just make it a uint16_t *.
866  */
867 struct ndis_unicode_string {
868         uint16_t                nus_len;
869         uint16_t                nus_maxlen;
870         uint16_t                *nus_buf;
871 };
872 typedef struct ndis_unicode_string ndis_unicode_string;
873 #endif
874
875 typedef unicode_string ndis_unicode_string;
876
877 enum ndis_parm_type {
878         ndis_parm_int,
879         ndis_parm_hexint,
880         ndis_parm_string,
881         ndis_parm_multistring,
882         ndis_parm_binary
883 };
884
885 typedef enum ndis_parm_type ndis_parm_type;
886
887 struct ndis_binary_data {
888         uint16_t                nbd_len;
889         void                    *nbd_buf;
890 };
891
892 typedef struct ndis_binary_data ndis_binary_data;
893
894 struct ndis_config_parm {
895         ndis_parm_type          ncp_type;
896         union {
897                 uint32_t                ncp_intdata;
898                 ndis_unicode_string     ncp_stringdata;
899                 ndis_binary_data        ncp_binarydata;
900         } ncp_parmdata;
901 };
902
903 /*
904  * Not part of Windows NDIS spec; we uses this to keep a
905  * list of ndis_config_parm structures that we've allocated.
906  */
907
908 typedef struct ndis_config_parm ndis_config_parm;
909
910 struct ndis_parmlist_entry {
911         list_entry              np_list;
912         ndis_config_parm        np_parm;
913 };
914
915 typedef struct ndis_parmlist_entry ndis_parmlist_entry;
916
917 #ifdef notdef
918 struct ndis_list_entry {
919         struct ndis_list_entry *nle_flink;
920         struct ndis_list_entry *nle_blink;
921 };
922
923 typedef struct ndis_list_entry ndis_list_entry;
924 #endif
925
926 struct ndis_bind_paths {
927         uint32_t                nbp_number;
928         ndis_unicode_string     nbp_paths[1];
929 };
930
931 typedef struct ndis_bind_paths ndis_bind_paths;
932
933 #ifdef notdef
934 struct dispatch_header {
935         uint8_t                 dh_type;
936         uint8_t                 dh_abs;
937         uint8_t                 dh_size;
938         uint8_t                 dh_inserted;
939         uint32_t                dh_sigstate;
940         list_entry              dh_waitlisthead;
941 };
942 #endif
943
944 #define dispatch_header nt_dispatch_header
945
946 struct ndis_ktimer {
947         struct dispatch_header  nk_header;
948         uint64_t                nk_duetime;
949         list_entry              nk_timerlistentry;
950         void                    *nk_dpc;
951         uint32_t                nk_period;
952 };
953
954 struct ndis_kevent {
955         struct dispatch_header  nk_header;
956 };
957
958 struct ndis_event {
959         struct nt_kevent        ne_event;
960 };
961
962 typedef struct ndis_event ndis_event;
963
964 /* Kernel defered procedure call (i.e. timer callback) */
965
966 struct ndis_kdpc;
967 typedef void (*ndis_kdpc_func)(struct ndis_kdpc *, void *, void *, void *);
968
969 struct ndis_kdpc {
970         uint16_t                nk_type;
971         uint8_t                 nk_num;
972         uint8_t                 nk_importance;
973         list_entry              nk_dpclistentry;
974         ndis_kdpc_func          nk_deferedfunc;
975         void                    *nk_deferredctx;
976         void                    *nk_sysarg1;
977         void                    *nk_sysarg2;
978         uint32_t                *nk_lock;
979 };
980
981 struct ndis_timer {
982         struct ktimer           nt_ktimer;
983         struct kdpc             nt_kdpc;
984 };
985
986 typedef struct ndis_timer ndis_timer;
987
988 typedef void (*ndis_timer_function)(void *, void *, void *, void *);
989
990 struct ndis_miniport_timer {
991         struct ktimer           nmt_ktimer;
992         struct kdpc             nmt_kdpc;
993         ndis_timer_function     nmt_timerfunc;
994         void                    *nmt_timerctx;
995         ndis_miniport_block     *nmt_block;
996         struct ndis_miniport_timer      *nmt_nexttimer;
997 };
998
999 typedef struct ndis_miniport_timer ndis_miniport_timer;
1000
1001 struct ndis_spin_lock {
1002         ndis_kspin_lock         nsl_spinlock;
1003         ndis_kirql              nsl_kirql;
1004 };
1005
1006 typedef struct ndis_spin_lock ndis_spin_lock;
1007
1008 struct ndis_rw_lock {
1009         union {
1010                 kspin_lock              nrl_spinlock;
1011                 void                    *nrl_ctx;
1012         } u;
1013         uint8_t                         nrl_rsvd[16];
1014 };
1015
1016 #define nrl_spinlock            u.nrl_spinlock
1017 #define nrl_ctx                 u.nrl_ctx;
1018
1019 typedef struct ndis_rw_lock ndis_rw_lock;
1020
1021 struct ndis_lock_state {
1022         uint16_t                        nls_lockstate;
1023         ndis_kirql                      nls_oldirql;
1024 };
1025
1026 typedef struct ndis_lock_state ndis_lock_state;
1027
1028 struct ndis_request {
1029         uint8_t                 nr_macreserved[4*sizeof(void *)];
1030         uint32_t                nr_requesttype;
1031         union _ndis_data {
1032                 struct _ndis_query_information {
1033                         ndis_oid        nr_oid;
1034                         void            *nr_infobuf;
1035                         uint32_t        nr_infobuflen;
1036                         uint32_t        nr_byteswritten;
1037                         uint32_t        nr_bytesneeded;
1038                 } ndis_query_information;
1039                 struct _ndis_set_information {
1040                         ndis_oid        nr_oid;
1041                         void            *nr_infobuf;
1042                         uint32_t        nr_infobuflen;
1043                         uint32_t        nr_byteswritten;
1044                         uint32_t        nr_bytesneeded;
1045                 } ndis_set_information;
1046         } ndis_data;
1047         /* NDIS 5.0 extensions */
1048         uint8_t                 nr_ndis_rsvd[9 * sizeof(void *)];
1049         union {
1050                 uint8_t         nr_callmgr_rsvd[2 * sizeof(void *)];
1051                 uint8_t         nr_protocol_rsvd[2 * sizeof(void *)];
1052         } u;
1053         uint8_t                 nr_miniport_rsvd[2 * sizeof(void *)];
1054 };
1055
1056 typedef struct ndis_request ndis_request;
1057
1058 /*
1059  * Filler, not used.
1060  */
1061 struct ndis_miniport_interrupt {
1062         kinterrupt              *ni_introbj;
1063         ndis_kspin_lock         ni_dpccountlock;
1064         void                    *ni_rsvd;
1065         void                    *ni_isrfunc;
1066         void                    *ni_dpcfunc;
1067         kdpc                    ni_dpc;
1068         ndis_miniport_block     *ni_block;
1069         uint8_t                 ni_dpccnt;
1070         uint8_t                 ni_filler1;
1071         struct nt_kevent        ni_dpcevt;
1072         uint8_t                 ni_shared;
1073         uint8_t                 ni_isrreq;
1074 };
1075
1076 typedef struct ndis_miniport_interrupt ndis_miniport_interrupt;
1077
1078 enum ndis_interrupt_mode {
1079         nim_level,
1080         nim_latched
1081 };
1082
1083 typedef enum ndis_interrupt_mode ndis_interrupt_mode;
1084
1085 #define NUMBER_OF_SINGLE_WORK_ITEMS 6
1086
1087 struct ndis_work_item;
1088
1089 typedef void (*ndis_proc)(struct ndis_work_item *, void *);
1090
1091 struct ndis_work_item {
1092         void                    *nwi_ctx;
1093         ndis_proc               nwi_func;
1094         uint8_t                 nwi_wraprsvd[sizeof(void *) * 8];
1095 };
1096
1097 typedef struct ndis_work_item ndis_work_item;
1098
1099 #define NdisInitializeWorkItem(w, f, c) \
1100         do {                            \
1101                 (w)->nwi_ctx = c;       \
1102                 (w)->nwi_func = f;      \
1103         } while (0)
1104
1105 #ifdef notdef
1106 struct ndis_buffer {
1107         struct ndis_buffer      *nb_next;
1108         uint16_t                nb_size;
1109         uint16_t                nb_flags;
1110         void                    *nb_process;
1111         void                    *nb_mappedsystemva;
1112         void                    *nb_startva;
1113         uint32_t                nb_bytecount;
1114         uint32_t                nb_byteoffset;
1115 };
1116
1117 typedef struct ndis_buffer ndis_buffer;
1118 #endif
1119
1120 struct ndis_sc_element {
1121         ndis_physaddr           nse_addr;
1122         uint32_t                nse_len;
1123         uint32_t                *nse_rsvd;
1124 };
1125
1126 typedef struct ndis_sc_element ndis_sc_element;
1127
1128 #define NDIS_MAXSEG             32
1129 #define NDIS_BUS_SPACE_SHARED_MAXADDR   0x3E7FFFFF
1130
1131 struct ndis_sc_list {
1132         uint32_t                nsl_frags;
1133         uint32_t                *nsl_rsvd;
1134         ndis_sc_element         nsl_elements[NDIS_MAXSEG];
1135 };
1136
1137 typedef struct ndis_sc_list ndis_sc_list;
1138
1139 struct ndis_tcpip_csum {
1140         union {
1141                 uint32_t                ntc_txflags;
1142                 uint32_t                ntc_rxflags;
1143                 uint32_t                ntc_val;
1144         } u;
1145 };
1146
1147 typedef struct ndis_tcpip_csum ndis_tcpip_csum;
1148
1149 #define NDIS_TXCSUM_DO_IPV4             0x00000001
1150 #define NDIS_TXCSUM_DO_IPV6             0x00000002
1151 #define NDIS_TXCSUM_DO_TCP              0x00000004
1152 #define NDIS_TXCSUM_DO_UDP              0x00000008
1153 #define NDIS_TXCSUM_DO_IP               0x00000010
1154
1155 #define NDIS_RXCSUM_TCP_FAILED          0x00000001
1156 #define NDIS_RXCSUM_UDP_FAILED          0x00000002
1157 #define NDIS_RXCSUM_IP_FAILED           0x00000004
1158 #define NDIS_RXCSUM_TCP_PASSED          0x00000008
1159 #define NDIS_RXCSUM_UDP_PASSED          0x00000010
1160 #define NDIS_RXCSUM_IP_PASSED           0x00000020
1161 #define NDIS_RXCSUM_LOOPBACK            0x00000040
1162
1163 struct ndis_vlan {
1164         union {
1165                 struct {
1166                         uint32_t                        nvt_userprio:3;
1167                         uint32_t                        nvt_canformatid:1;
1168                         uint32_t                        nvt_vlanid:12;
1169                         uint32_t                        nvt_rsvd:16;
1170                 } nv_taghdr;
1171         } u;
1172 };
1173
1174 typedef struct ndis_vlan ndis_vlan;
1175
1176 enum ndis_perpkt_info {
1177         ndis_tcpipcsum_info,
1178         ndis_ipsec_info,
1179         ndis_largesend_info,
1180         ndis_classhandle_info,
1181         ndis_rsvd,
1182         ndis_sclist_info,
1183         ndis_ieee8021q_info,
1184         ndis_originalpkt_info,
1185         ndis_packetcancelid,
1186         ndis_maxpkt_info
1187 };
1188
1189 typedef enum ndis_perpkt_info ndis_perpkt_info;
1190
1191 struct ndis_packet_extension {
1192         void                    *npe_info[ndis_maxpkt_info];
1193 };
1194
1195 typedef struct ndis_packet_extension ndis_packet_extension;
1196
1197 struct ndis_packet_private {
1198         uint32_t                npp_physcnt;
1199         uint32_t                npp_totlen;
1200         ndis_buffer             *npp_head;
1201         ndis_buffer             *npp_tail;
1202
1203         void                    *npp_pool;
1204         uint32_t                npp_count;
1205         uint32_t                npp_flags;
1206         uint8_t                 npp_validcounts;
1207         uint8_t                 npp_ndispktflags;
1208         uint16_t                npp_packetooboffset;
1209 };
1210
1211 #define NDIS_FLAGS_PROTOCOL_ID_MASK             0x0000000F
1212 #define NDIS_FLAGS_MULTICAST_PACKET             0x00000010
1213 #define NDIS_FLAGS_RESERVED2                    0x00000020
1214 #define NDIS_FLAGS_RESERVED3                    0x00000040
1215 #define NDIS_FLAGS_DONT_LOOPBACK                0x00000080
1216 #define NDIS_FLAGS_IS_LOOPBACK_PACKET           0x00000100
1217 #define NDIS_FLAGS_LOOPBACK_ONLY                0x00000200
1218 #define NDIS_FLAGS_RESERVED4                    0x00000400
1219 #define NDIS_FLAGS_DOUBLE_BUFFERED              0x00000800
1220 #define NDIS_FLAGS_SENT_AT_DPC                  0x00001000
1221 #define NDIS_FLAGS_USES_SG_BUFFER_LIST          0x00002000
1222
1223 #define NDIS_PACKET_WRAPPER_RESERVED                    0x3F
1224 #define NDIS_PACKET_CONTAINS_MEDIA_SPECIFIC_INFO        0x40
1225 #define NDIS_PACKET_ALLOCATED_BY_NDIS                   0x80
1226
1227 #define NDIS_PROTOCOL_ID_DEFAULT        0x00
1228 #define NDIS_PROTOCOL_ID_TCP_IP         0x02
1229 #define NDIS_PROTOCOL_ID_IPX            0x06
1230 #define NDIS_PROTOCOL_ID_NBF            0x07
1231 #define NDIS_PROTOCOL_ID_MAX            0x0F
1232 #define NDIS_PROTOCOL_ID_MASK           0x0F
1233
1234 typedef struct ndis_packet_private ndis_packet_private;
1235
1236 enum ndis_classid {
1237         ndis_class_802_3prio,
1238         ndis_class_wirelesswan_mbx,
1239         ndis_class_irda_packetinfo,
1240         ndis_class_atm_aainfo
1241 };
1242
1243 typedef enum ndis_classid ndis_classid;
1244
1245 struct ndis_mediaspecific_info {
1246         uint32_t                nmi_nextentoffset;
1247         ndis_classid            nmi_classid;
1248         uint32_t                nmi_size;
1249         uint8_t                 nmi_classinfo[1];
1250 };
1251
1252 typedef struct ndis_mediaspecific_info ndis_mediaspecific_info;
1253
1254 struct ndis_packet_oob {
1255         union {
1256                 uint64_t                npo_timetotx;
1257                 uint64_t                npo_timetxed;
1258         } u;
1259         uint64_t                        npo_timerxed;
1260         uint32_t                        npo_hdrlen;
1261         uint32_t                        npo_mediaspecific_len;
1262         void                            *npo_mediaspecific;
1263         ndis_status                     npo_status;
1264 };
1265
1266 typedef struct ndis_packet_oob ndis_packet_oob;
1267
1268 /*
1269  * Our protocol private region for handling ethernet.
1270  * We need this to stash some of the things returned
1271  * by NdisMEthIndicateReceive().
1272  */
1273
1274 struct ndis_ethpriv {
1275         void                    *nep_ctx;       /* packet context */
1276         long                    nep_offset;     /* residual data to transfer */
1277         void                    *nep_pad[2];
1278 };
1279
1280 typedef struct ndis_ethpriv ndis_ethpriv;
1281
1282 #define PROTOCOL_RESERVED_SIZE_IN_PACKET        (4 * sizeof(void *))
1283
1284 struct ndis_packet {
1285         ndis_packet_private     np_private;
1286         union {
1287                 /* For connectionless miniports. */
1288                 struct {
1289                         uint8_t         np_miniport_rsvd[2 * sizeof(void *)];
1290                         uint8_t         np_wrapper_rsvd[2 * sizeof(void *)];
1291                 } np_clrsvd;
1292                 /* For de-serialized miniports */
1293                 struct {
1294                         uint8_t         np_miniport_rsvdex[3 * sizeof(void *)];
1295                         uint8_t         np_wrapper_rsvdex[sizeof(void *)];
1296                 } np_dsrsvd;
1297                 struct {
1298                         uint8_t         np_mac_rsvd[4 * sizeof(void *)];
1299                 } np_macrsvd;
1300         } u;
1301         uint32_t                *np_rsvd[2];
1302         uint8_t                 np_protocolreserved[PROTOCOL_RESERVED_SIZE_IN_PACKET];
1303
1304         /*
1305          * This next part is probably wrong, but we need some place
1306          * to put the out of band data structure...
1307          */
1308         ndis_packet_oob         np_oob;
1309         ndis_packet_extension   np_ext;
1310         ndis_sc_list            np_sclist;
1311
1312         /* BSD-specific stuff which should be invisible to drivers. */
1313
1314         uint32_t                np_refcnt;
1315         void                    *np_softc;
1316         void                    *np_m0;
1317         int                     np_txidx;
1318         list_entry              np_list;
1319 };
1320
1321 typedef struct ndis_packet ndis_packet;
1322
1323 struct ndis_packet_pool {
1324         slist_header            np_head;
1325         int                     np_dead;
1326         nt_kevent               np_event;
1327         kspin_lock              np_lock;
1328         int                     np_cnt;
1329         int                     np_len;
1330         int                     np_protrsvd;
1331         void                    *np_pktmem;
1332 };
1333
1334 typedef struct ndis_packet_pool ndis_packet_pool;
1335
1336 /* mbuf ext type for NDIS */
1337 #define EXT_NDIS                EXT_NET_DRV
1338
1339 /* mtx type for NDIS */
1340 #define MTX_NDIS_LOCK "NDIS lock"
1341
1342 struct ndis_filterdbs {
1343         union {
1344                 void                    *nf_ethdb;
1345                 void                    *nf_nulldb;
1346         } u;
1347         void                    *nf_trdb;
1348         void                    *nf_fddidb;
1349         void                    *nf_arcdb;
1350 };
1351
1352 typedef struct ndis_filterdbs ndis_filterdbs;
1353
1354 #define nf_ethdb u.nf_ethdb
1355
1356 enum ndis_medium {
1357     NdisMedium802_3,
1358     NdisMedium802_5,
1359     NdisMediumFddi,
1360     NdisMediumWan,
1361     NdisMediumLocalTalk,
1362     NdisMediumDix,              /* defined for convenience, not a real medium */
1363     NdisMediumArcnetRaw,
1364     NdisMediumArcnet878_2,
1365     NdisMediumAtm,
1366     NdisMediumWirelessWan,
1367     NdisMediumIrda,
1368     NdisMediumBpc,
1369     NdisMediumCoWan,
1370     NdisMedium1394,
1371     NdisMediumMax
1372 };
1373
1374 typedef enum ndis_medium ndis_medium;
1375 /*
1376 enum interface_type {
1377         InterfaceTypeUndefined = -1,
1378         Internal,
1379         Isa,
1380         Eisa,
1381         MicroChannel,
1382         TurboChannel,
1383         PCIBus,
1384         VMEBus,
1385         NuBus,
1386         PCMCIABus,
1387         CBus,
1388         MPIBus,
1389         MPSABus,
1390         ProcessorInternal,
1391         InternalPowerBus,
1392         PNPISABus,
1393         PNPBus,
1394         MaximumInterfaceType
1395 };
1396 */
1397 enum ndis_interface_type {
1398         NdisInterfaceInternal = Internal,
1399         NdisInterfaceIsa = Isa,
1400         NdisInterfaceEisa = Eisa,
1401         NdisInterfaceMca = MicroChannel,
1402         NdisInterfaceTurboChannel = TurboChannel,
1403         NdisInterfacePci = PCIBus,
1404         NdisInterfacePcMcia = PCMCIABus
1405 };
1406
1407 typedef enum ndis_interface_type ndis_interface_type;
1408
1409 struct ndis_paddr_unit {
1410         ndis_physaddr           npu_physaddr;
1411         uint32_t                npu_len;
1412 };
1413
1414 typedef struct ndis_paddr_unit ndis_paddr_unit;
1415
1416 struct ndis_map_arg {
1417         ndis_paddr_unit         *nma_fraglist;
1418         int                     nma_cnt;
1419         int                     nma_max;
1420 };
1421
1422 /*
1423  * Miniport characteristics were originally defined in the NDIS 3.0
1424  * spec and then extended twice, in NDIS 4.0 and 5.0.
1425  */
1426
1427 struct ndis_miniport_characteristics {
1428
1429         /* NDIS 3.0 */
1430
1431         uint8_t                 nmc_version_major;
1432         uint8_t                 nmc_version_minor;
1433         uint16_t                nmc_pad;
1434         uint32_t                nmc_rsvd;
1435         void *                  nmc_checkhang_func;
1436         void *                  nmc_disable_interrupts_func;
1437         void *                  nmc_enable_interrupts_func;
1438         void *                  nmc_halt_func;
1439         void *                  nmc_interrupt_func;
1440         void *                  nmc_init_func;
1441         void *                  nmc_isr_func;
1442         void *                  nmc_queryinfo_func;
1443         void *                  nmc_reconfig_func;
1444         void *                  nmc_reset_func;
1445         void *                  nmc_sendsingle_func;
1446         void *                  nmc_setinfo_func;
1447         void *                  nmc_transferdata_func;
1448
1449         /* NDIS 4.0 extensions */
1450
1451         void *                  nmc_return_packet_func;
1452         void *                  nmc_sendmulti_func;
1453         void *                  nmc_allocate_complete_func;
1454
1455         /* NDIS 5.0 extensions */
1456
1457         void *                  nmc_cocreatevc_func;
1458         void *                  nmc_codeletevc_func;
1459         void *                  nmc_coactivatevc_func;
1460         void *                  nmc_codeactivatevc_func;
1461         void *                  nmc_comultisend_func;
1462         void *                  nmc_corequest_func;
1463
1464         /* NDIS 5.1 extensions */
1465
1466         void *                  nmc_canceltxpkts_handler;
1467         void *                  nmc_pnpevent_handler;
1468         void *                  nmc_shutdown_handler;
1469         void *                  nmc_rsvd0;
1470         void *                  nmc_rsvd1;
1471         void *                  nmc_rsvd2;
1472         void *                  nmc_rsvd3;
1473 };
1474
1475 typedef struct ndis_miniport_characteristics ndis_miniport_characteristics;
1476
1477 struct ndis_driver_object {
1478         char                    *ndo_ifname;
1479         void                    *ndo_softc;
1480         ndis_miniport_characteristics ndo_chars;
1481 };
1482
1483 typedef struct ndis_driver_object ndis_driver_object;
1484
1485 struct ndis_reference {
1486         ndis_kspin_lock         nr_spinlock;
1487         uint16_t                nr_refcnt;
1488         uint8_t                 nr_closing;
1489 };
1490
1491 typedef struct ndis_reference ndis_reference;
1492
1493 struct ndis_timer_entry {
1494         struct callout          nte_ch;
1495         ndis_miniport_timer     *nte_timer;
1496         TAILQ_ENTRY(ndis_timer_entry)   link;
1497 };
1498
1499 TAILQ_HEAD(nte_head, ndis_timer_entry);
1500
1501 #define NDIS_FH_TYPE_VFS        0
1502 #define NDIS_FH_TYPE_MODULE     1
1503
1504 struct ndis_fh {
1505         int                     nf_type;
1506         char                    *nf_name;
1507         void                    *nf_vp;
1508         void                    *nf_map;
1509         uint32_t                nf_maplen;
1510 };
1511
1512 typedef struct ndis_fh ndis_fh;
1513
1514 /*
1515  * The miniport block is basically the internal NDIS handle. We need
1516  * to define this because, unfortunately, it is not entirely opaque
1517  * to NDIS drivers. For one thing, it contains the function pointer
1518  * to the NDIS packet receive handler, which is invoked out of the
1519  * NDIS block via a macro rather than a function pointer. (The
1520  * NdisMIndicateReceivePacket() routine is a macro rather than
1521  * a function.) For another, the driver maintains a pointer to the
1522  * miniport block and passes it as a handle to various NDIS functions.
1523  * (The driver never really knows this because it's hidden behind
1524  * an ndis_handle though.)
1525  *
1526  * The miniport block has two parts: the first part contains fields
1527  * that must never change, since they are referenced by driver
1528  * binaries through macros. The second part is ignored by the driver,
1529  * but contains various things used internaly by NDIS.SYS. In our
1530  * case, we define the first 'immutable' part exactly as it appears
1531  * in Windows, but don't bother duplicating the Windows definitions
1532  * for the second part. Instead, we replace them with a few BSD-specific
1533  * things.
1534  */
1535
1536 struct ndis_miniport_block {
1537         /*
1538          * Windows-specific portion -- DO NOT MODIFY OR NDIS
1539          * DRIVERS WILL NOT WORK.
1540          */
1541         void                    *nmb_signature; /* magic number */
1542         ndis_miniport_block     *nmb_nextminiport;
1543         ndis_mdriver_block      *nmb_driverhandle;
1544         ndis_handle             nmb_miniportadapterctx;
1545         ndis_unicode_string     nmb_name;
1546         ndis_bind_paths         *nmb_bindpaths;
1547         ndis_handle             nmb_openqueue;
1548         ndis_reference          nmb_ref;
1549         ndis_handle             nmb_devicectx;
1550         uint8_t                 nmb_padding;
1551         uint8_t                 nmb_lockacquired;
1552         uint8_t                 nmb_pmodeopens;
1553         uint8_t                 nmb_assignedcpu;
1554         ndis_kspin_lock         nmb_lock;
1555         ndis_request            *nmb_mediarequest;
1556         ndis_miniport_interrupt *nmb_interrupt;
1557         uint32_t                nmb_flags;
1558         uint32_t                nmb_pnpflags;
1559         list_entry              nmb_packetlist;
1560         ndis_packet             *nmb_firstpendingtxpacket;
1561         ndis_packet             *nmb_returnpacketqueue;
1562         uint32_t                nmb_requestbuffer;
1563         void                    *nmb_setmcastbuf;
1564         ndis_miniport_block     *nmb_primaryminiport;
1565         void                    *nmb_wrapperctx;
1566         void                    *nmb_busdatactx;
1567         uint32_t                nmb_pnpcaps;
1568         cm_resource_list        *nmb_resources;
1569         ndis_timer              nmb_wkupdpctimer;
1570         ndis_unicode_string     nmb_basename;
1571         ndis_unicode_string     nmb_symlinkname;
1572         uint32_t                nmb_checkforhangsecs;
1573         uint16_t                nmb_cfhticks;
1574         uint16_t                nmb_cfhcurrticks;
1575         ndis_status             nmb_resetstatus;
1576         ndis_handle             nmb_resetopen;
1577         ndis_filterdbs          nmb_filterdbs;
1578         void                    *nmb_pktind_func;
1579         void                    *nmb_senddone_func;
1580         void                    *nmb_sendrsrc_func;
1581         void                    *nmb_resetdone_func;
1582         ndis_medium             nmb_medium;
1583         uint32_t                nmb_busnum;
1584         uint32_t                nmb_bustype;
1585         uint32_t                nmb_adaptertype;
1586         device_object           *nmb_deviceobj; /* Functional device */
1587         device_object           *nmb_physdeviceobj; /* Physical device */
1588         device_object           *nmb_nextdeviceobj; /* Next dev in stack */
1589         void                    *nmb_mapreg;
1590         void                    *nmb_callmgraflist;
1591         void                    *nmb_miniportthread;
1592         void                    *nmb_setinfobuf;
1593         uint16_t                nmb_setinfobuflen;
1594         uint16_t                nmb_maxsendpkts;
1595         ndis_status             nmb_fakestatus;
1596         void                    *nmb_lockhandler;
1597         ndis_unicode_string     *nmb_adapterinstancename;
1598         void                    *nmb_timerqueue;
1599         uint32_t                nmb_mactoptions;
1600         ndis_request            *nmb_pendingreq;
1601         uint32_t                nmb_maxlongaddrs;
1602         uint32_t                nmb_maxshortaddrs;
1603         uint32_t                nmb_currlookahead;
1604         uint32_t                nmb_maxlookahead;
1605         void                    *nmb_interrupt_func;
1606         void                    *nmb_disableintr_func;
1607         void                    *nmb_enableintr_func;
1608         void                    *nmb_sendpkts_func;
1609         void                    *nmb_deferredsend_func;
1610         void                    *nmb_ethrxindicate_func;
1611         void                    *nmb_txrxindicate_func;
1612         void                    *nmb_fddirxindicate_func;
1613         void                    *nmb_ethrxdone_func;
1614         void                    *nmb_txrxdone_func;
1615         void                    *nmb_fddirxcond_func;
1616         void                    *nmb_status_func;
1617         void                    *nmb_statusdone_func;
1618         void                    *nmb_tdcond_func;
1619         void                    *nmb_querydone_func;
1620         void                    *nmb_setdone_func;
1621         void                    *nmb_wantxdone_func;
1622         void                    *nmb_wanrx_func;
1623         void                    *nmb_wanrxdone_func;
1624         /*
1625          * End of windows-specific portion of miniport block. Everything
1626          * below is BSD-specific.
1627          */
1628         list_entry              nmb_parmlist;
1629         ndis_resource_list      *nmb_rlist;
1630         ndis_status             nmb_getstat;
1631         nt_kevent               nmb_getevent;
1632         ndis_status             nmb_setstat;
1633         nt_kevent               nmb_setevent;
1634         nt_kevent               nmb_resetevent;
1635         io_workitem             *nmb_returnitem;
1636         ndis_miniport_timer     *nmb_timerlist;
1637         ndis_handle             nmb_rxpool;
1638         list_entry              nmb_returnlist;
1639         kspin_lock              nmb_returnlock;
1640         TAILQ_ENTRY(ndis_miniport_block)        link;
1641 };
1642
1643 TAILQ_HEAD(nd_head, ndis_miniport_block);
1644
1645 typedef ndis_status (*ndis_init_handler)(ndis_status *, uint32_t *,
1646                 ndis_medium *, uint32_t, ndis_handle, ndis_handle);
1647 typedef ndis_status (*ndis_queryinfo_handler)(ndis_handle, ndis_oid,
1648                 void *, uint32_t, uint32_t *, uint32_t *);
1649 typedef ndis_status (*ndis_setinfo_handler)(ndis_handle, ndis_oid,
1650                 void *, uint32_t, uint32_t *, uint32_t *);
1651 typedef ndis_status (*ndis_sendsingle_handler)(ndis_handle,
1652                 ndis_packet *, uint32_t);
1653 typedef ndis_status (*ndis_sendmulti_handler)(ndis_handle,
1654                 ndis_packet **, uint32_t);
1655 typedef void (*ndis_isr_handler)(uint8_t *, uint8_t *, ndis_handle);
1656 typedef void (*ndis_interrupt_handler)(ndis_handle);
1657 typedef int (*ndis_reset_handler)(uint8_t *, ndis_handle);
1658 typedef void (*ndis_halt_handler)(ndis_handle);
1659 typedef void (*ndis_return_handler)(ndis_handle, ndis_packet *);
1660 typedef void (*ndis_enable_interrupts_handler)(ndis_handle);
1661 typedef void (*ndis_disable_interrupts_handler)(ndis_handle);
1662 typedef void (*ndis_shutdown_handler)(void *);
1663 typedef void (*ndis_pnpevent_handler)(void *, int, void *, uint32_t);
1664 typedef void (*ndis_allocdone_handler)(ndis_handle, void *,
1665                 ndis_physaddr *, uint32_t, void *);
1666 typedef uint8_t (*ndis_checkforhang_handler)(ndis_handle);
1667
1668 typedef ndis_status (*driver_entry)(void *, unicode_string *);
1669
1670 extern image_patch_table ndis_functbl[];
1671
1672 #define NDIS_TASKQUEUE  1
1673 #define NDIS_SWI        2
1674
1675 #define NDIS_PSTATE_RUNNING     1
1676 #define NDIS_PSTATE_SLEEPING    2
1677
1678 #define NdisQueryPacket(p, pbufcnt, bufcnt, firstbuf, plen)             \
1679         do {                                                            \
1680                 if ((firstbuf) != NULL) {                               \
1681                         ndis_buffer             **_first;               \
1682                         _first = firstbuf;                              \
1683                         *(_first) = (p)->np_private.npp_head;           \
1684                 }                                                       \
1685                 if ((plen) || (bufcnt) || (pbufcnt)) {                  \
1686                         if ((p)->np_private.npp_validcounts == FALSE) { \
1687                                 ndis_buffer             *tmp;           \
1688                                 unsigned int            tlen = 0, pcnt = 0; \
1689                                 unsigned int            add = 0;        \
1690                                 unsigned int            pktlen, off;    \
1691                                                                         \
1692                                 tmp = (p)->np_private.npp_head;         \
1693                                 while (tmp != NULL) {                   \
1694                                         off = MmGetMdlByteOffset(tmp);  \
1695                                         pktlen = MmGetMdlByteCount(tmp);\
1696                                         tlen += pktlen;                 \
1697                                         pcnt +=                         \
1698                                             NDIS_BUFFER_TO_SPAN_PAGES(tmp); \
1699                                         add++;                          \
1700                                         tmp = tmp->mdl_next;            \
1701                                 }                                       \
1702                                 (p)->np_private.npp_count = add;        \
1703                                 (p)->np_private.npp_totlen = tlen;      \
1704                                 (p)->np_private.npp_physcnt = pcnt;     \
1705                                 (p)->np_private.npp_validcounts = TRUE; \
1706                         }                                               \
1707                         if (pbufcnt) {                                  \
1708                                 unsigned int            *_pbufcnt;      \
1709                                 _pbufcnt = (pbufcnt);                   \
1710                                 *(_pbufcnt) = (p)->np_private.npp_physcnt; \
1711                         }                                               \
1712                         if (bufcnt) {                                   \
1713                                 unsigned int            *_bufcnt;       \
1714                                 _bufcnt = (bufcnt);                     \
1715                                 *(_bufcnt) = (p)->np_private.npp_count; \
1716                         }                                               \
1717                         if (plen) {                                     \
1718                                 unsigned int            *_plen;         \
1719                                 _plen = (plen);                         \
1720                                 *(_plen) = (p)->np_private.npp_totlen;  \
1721                         }                                               \
1722                 }                                                       \
1723         } while (0)
1724
1725 __BEGIN_DECLS
1726 extern int ndis_libinit(void);
1727 extern int ndis_libfini(void);
1728 extern int ndis_load_driver(vm_offset_t, void *);
1729 extern int ndis_unload_driver(void *);
1730 extern int ndis_mtop(struct mbuf *, ndis_packet **);
1731 extern int ndis_ptom(struct mbuf **, ndis_packet *);
1732 extern int ndis_get_info(void *, ndis_oid, void *, int *);
1733 extern int ndis_set_info(void *, ndis_oid, void *, int *);
1734 extern void *ndis_get_routine_address(struct image_patch_table *, char *);
1735 extern int ndis_get_supported_oids(void *, ndis_oid **, int *);
1736 extern int ndis_send_packets(void *, ndis_packet **, int);
1737 extern int ndis_send_packet(void *, ndis_packet *);
1738 extern int ndis_convert_res(void *);
1739 extern void ndis_free_packet(ndis_packet *);
1740 extern void ndis_free_bufs(ndis_buffer *);
1741 extern int ndis_reset_nic(void *);
1742 extern int ndis_halt_nic(void *);
1743 extern int ndis_shutdown_nic(void *);
1744 extern int ndis_pnpevent_nic(void *, int);
1745 extern int ndis_init_nic(void *);
1746 extern void ndis_return_packet(ndis_packet *);
1747 extern int ndis_init_dma(void *);
1748 extern int ndis_destroy_dma(void *);
1749 extern int ndis_create_sysctls(void *);
1750 extern int ndis_add_sysctl(void *, char *, char *, char *, int);
1751 extern int ndis_flush_sysctls(void *);
1752
1753 extern uint32_t NdisAddDevice(driver_object *, device_object *);
1754 extern void NdisAllocatePacketPool(ndis_status *,
1755     ndis_handle *, uint32_t, uint32_t);
1756 extern void NdisAllocatePacketPoolEx(ndis_status *,
1757     ndis_handle *, uint32_t, uint32_t, uint32_t);
1758 extern uint32_t NdisPacketPoolUsage(ndis_handle);
1759 extern void NdisFreePacketPool(ndis_handle);
1760 extern void NdisAllocatePacket(ndis_status *,
1761         ndis_packet **, ndis_handle);
1762 extern void NdisFreePacket(ndis_packet *);
1763 extern ndis_status NdisScheduleWorkItem(ndis_work_item *);
1764 extern void NdisMSleep(uint32_t);
1765 __END_DECLS
1766
1767 #endif /* _NDIS_VAR_H_ */