if_ndisvar.h revision 186507
1139749Simp/*- 2123474Swpaul * Copyright (c) 2003 3123474Swpaul * Bill Paul <wpaul@windriver.com>. All rights reserved. 4123474Swpaul * 5123474Swpaul * Redistribution and use in source and binary forms, with or without 6123474Swpaul * modification, are permitted provided that the following conditions 7123474Swpaul * are met: 8123474Swpaul * 1. Redistributions of source code must retain the above copyright 9123474Swpaul * notice, this list of conditions and the following disclaimer. 10123474Swpaul * 2. Redistributions in binary form must reproduce the above copyright 11123474Swpaul * notice, this list of conditions and the following disclaimer in the 12123474Swpaul * documentation and/or other materials provided with the distribution. 13123474Swpaul * 3. All advertising materials mentioning features or use of this software 14123474Swpaul * must display the following acknowledgement: 15123474Swpaul * This product includes software developed by Bill Paul. 16123474Swpaul * 4. Neither the name of the author nor the names of any co-contributors 17123474Swpaul * may be used to endorse or promote products derived from this software 18123474Swpaul * without specific prior written permission. 19123474Swpaul * 20123474Swpaul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21123474Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22123474Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23123474Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24123474Swpaul * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25123474Swpaul * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26123474Swpaul * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27123474Swpaul * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28123474Swpaul * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29123474Swpaul * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30123474Swpaul * THE POSSIBILITY OF SUCH DAMAGE. 31123474Swpaul * 32123474Swpaul * $FreeBSD: head/sys/dev/if_ndis/if_ndisvar.h 186507 2008-12-27 08:03:32Z weongyo $ 33123474Swpaul */ 34123474Swpaul 35128229Swpaul#define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node" 36128229Swpaul#define NDIS_NODENAME_LEN 32 37128229Swpaul 38151207Swpaul/* For setting/getting OIDs from userspace. */ 39151207Swpaul 40151207Swpaulstruct ndis_oid_data { 41151207Swpaul uint32_t oid; 42151207Swpaul uint32_t len; 43151207Swpaul#ifdef notdef 44151207Swpaul uint8_t data[1]; 45151207Swpaul#endif 46151207Swpaul}; 47151207Swpaul 48126706Swpaulstruct ndis_pci_type { 49123474Swpaul uint16_t ndis_vid; 50123474Swpaul uint16_t ndis_did; 51123620Swpaul uint32_t ndis_subsys; 52123474Swpaul char *ndis_name; 53123474Swpaul}; 54123474Swpaul 55126706Swpaulstruct ndis_pccard_type { 56126706Swpaul const char *ndis_vid; 57126706Swpaul const char *ndis_did; 58126706Swpaul char *ndis_name; 59126706Swpaul}; 60126706Swpaul 61186507Sweongyostruct ndis_usb_type { 62186507Sweongyo uint16_t ndis_vid; 63186507Sweongyo uint16_t ndis_did; 64186507Sweongyo char *ndis_name; 65186507Sweongyo}; 66186507Sweongyo 67123474Swpaulstruct ndis_shmem { 68151207Swpaul list_entry ndis_list; 69123474Swpaul bus_dma_tag_t ndis_stag; 70123474Swpaul bus_dmamap_t ndis_smap; 71123474Swpaul void *ndis_saddr; 72145895Swpaul ndis_physaddr ndis_paddr; 73123474Swpaul}; 74123474Swpaul 75123474Swpaulstruct ndis_cfglist { 76123474Swpaul ndis_cfg ndis_cfg; 77151207Swpaul struct sysctl_oid *ndis_oid; 78123474Swpaul TAILQ_ENTRY(ndis_cfglist) link; 79123474Swpaul}; 80123474Swpaul 81151207Swpaul/* 82151207Swpaul * Helper struct to make parsing information 83151207Swpaul * elements easier. 84151207Swpaul */ 85151207Swpaulstruct ndis_ie { 86151207Swpaul uint8_t ni_oui[3]; 87151207Swpaul uint8_t ni_val; 88151207Swpaul}; 89151207Swpaul 90123474SwpaulTAILQ_HEAD(nch, ndis_cfglist); 91123474Swpaul 92151207Swpaul#define NDIS_INITIALIZED(sc) (sc->ndis_block->nmb_devicectx != NULL) 93131750Swpaul 94151451Swpaul#define NDIS_TXPKTS 64 95123474Swpaul#define NDIS_INC(x) \ 96183587Sweongyo (x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts 97123474Swpaul 98151207Swpaul 99151207Swpaul#define NDIS_EVENTS 4 100151207Swpaul#define NDIS_EVTINC(x) (x) = ((x) + 1) % NDIS_EVENTS 101151207Swpaul 102151207Swpaulstruct ndis_evt { 103151207Swpaul uint32_t ne_sts; 104151207Swpaul uint32_t ne_len; 105151207Swpaul char *ne_buf; 106151207Swpaul}; 107151207Swpaul 108178354Ssamstruct ndis_vap { 109178354Ssam struct ieee80211vap vap; 110178354Ssam 111178354Ssam int (*newstate)(struct ieee80211vap *, 112178354Ssam enum ieee80211_state, int); 113178354Ssam}; 114178354Ssam#define NDIS_VAP(vap) ((struct ndis_vap *)(vap)) 115178354Ssam 116186507Sweongyo#define NDISUSB_CONFIG_NO 1 117186507Sweongyo#define NDISUSB_IFACE_INDEX 0 118186507Sweongyo#define NDISUSB_INTR_TIMEOUT 1000 119186507Sweongyo#define NDISUSB_TX_TIMEOUT 10000 120186507Sweongyostruct ndisusb_xfer { 121186507Sweongyo usbd_xfer_handle nx_xfer; 122186507Sweongyo usbd_private_handle nx_priv; 123186507Sweongyo usbd_status nx_status; 124186507Sweongyo list_entry nx_xferlist; 125186507Sweongyo}; 126186507Sweongyo 127123474Swpaulstruct ndis_softc { 128147256Sbrooks struct ifnet *ifp; 129123474Swpaul struct ifmedia ifmedia; /* media info */ 130124821Swpaul u_long ndis_hwassist; 131124821Swpaul uint32_t ndis_v4tx; 132124821Swpaul uint32_t ndis_v4rx; 133123474Swpaul bus_space_handle_t ndis_bhandle; 134123474Swpaul bus_space_tag_t ndis_btag; 135123474Swpaul void *ndis_intrhand; 136123474Swpaul struct resource *ndis_irq; 137123474Swpaul struct resource *ndis_res; 138123474Swpaul struct resource *ndis_res_io; 139123474Swpaul int ndis_io_rid; 140123474Swpaul struct resource *ndis_res_mem; 141123474Swpaul int ndis_mem_rid; 142123474Swpaul struct resource *ndis_res_altmem; 143123474Swpaul int ndis_altmem_rid; 144123474Swpaul struct resource *ndis_res_am; /* attribute mem (pccard) */ 145131953Swpaul int ndis_am_rid; 146123474Swpaul struct resource *ndis_res_cm; /* common mem (pccard) */ 147131953Swpaul struct resource_list ndis_rl; 148123474Swpaul int ndis_rescnt; 149179723Scokane struct mtx ndis_mtx; 150151207Swpaul uint8_t ndis_irql; 151123474Swpaul device_t ndis_dev; 152123474Swpaul int ndis_unit; 153141524Swpaul ndis_miniport_block *ndis_block; 154141524Swpaul ndis_miniport_characteristics *ndis_chars; 155123474Swpaul interface_type ndis_type; 156178286Scokane struct callout ndis_stat_callout; 157123474Swpaul int ndis_maxpkts; 158123474Swpaul ndis_oid *ndis_oids; 159123474Swpaul int ndis_oidcnt; 160123474Swpaul int ndis_txidx; 161123474Swpaul int ndis_txpending; 162123474Swpaul ndis_packet **ndis_txarray; 163141963Swpaul ndis_handle ndis_txpool; 164123474Swpaul int ndis_sc; 165123474Swpaul ndis_cfg *ndis_regvals; 166123474Swpaul struct nch ndis_cfglist_head; 167123695Swpaul int ndis_80211; 168123695Swpaul int ndis_link; 169151207Swpaul uint32_t ndis_sts; 170123695Swpaul uint32_t ndis_filter; 171123695Swpaul int ndis_if_flags; 172125076Swpaul int ndis_skip; 173123474Swpaul 174123620Swpaul int ndis_devidx; 175123474Swpaul interface_type ndis_iftype; 176145485Swpaul driver_object *ndis_dobj; 177151207Swpaul io_workitem *ndis_tickitem; 178151207Swpaul io_workitem *ndis_startitem; 179151207Swpaul io_workitem *ndis_resetitem; 180151451Swpaul io_workitem *ndis_inputitem; 181146230Swpaul kdpc ndis_rxdpc; 182123474Swpaul bus_dma_tag_t ndis_parent_tag; 183151207Swpaul list_entry ndis_shlist; 184123474Swpaul bus_dma_tag_t ndis_mtag; 185123474Swpaul bus_dma_tag_t ndis_ttag; 186123474Swpaul bus_dmamap_t *ndis_mmaps; 187123474Swpaul bus_dmamap_t *ndis_tmaps; 188123474Swpaul int ndis_mmapcnt; 189151207Swpaul struct ndis_evt ndis_evt[NDIS_EVENTS]; 190151207Swpaul int ndis_evtpidx; 191151207Swpaul int ndis_evtcidx; 192151451Swpaul struct ifqueue ndis_rxqueue; 193151451Swpaul kspin_lock ndis_rxlock; 194171390Sthompsa 195171390Sthompsa struct taskqueue *ndis_tq; /* private task queue */ 196171390Sthompsa struct task ndis_scantask; 197178930Sthompsa struct task ndis_authtask; 198178930Sthompsa struct task ndis_assoctask; 199171390Sthompsa int (*ndis_newstate)(struct ieee80211com *, 200171390Sthompsa enum ieee80211_state, int); 201179498Scokane int ndis_tx_timer; 202179498Scokane int ndis_hang_timer; 203186507Sweongyo 204186507Sweongyo io_workitem *ndisusb_xferitem; 205186507Sweongyo list_entry ndisusb_xferlist; 206186507Sweongyo kspin_lock ndisusb_xferlock; 207186507Sweongyo#define NDISUSB_ENDPT_BOUT 0 208186507Sweongyo#define NDISUSB_ENDPT_BIN 1 209186507Sweongyo#define NDISUSB_ENDPT_IIN 2 210186507Sweongyo#define NDISUSB_ENDPT_IOUT 3 211186507Sweongyo#define NDISUSB_ENDPT_MAX 4 212186507Sweongyo usbd_pipe_handle ndisusb_ep[NDISUSB_ENDPT_MAX]; 213186507Sweongyo char *ndisusb_iin_buf; 214186507Sweongyo int ndisusb_status; 215186507Sweongyo#define NDISUSB_STATUS_DETACH 0x1 216123474Swpaul}; 217123474Swpaul 218186507Sweongyo#define NDISMTX_LOCK(_sc) mtx_lock(&(_sc)->ndis_mtx) 219186507Sweongyo#define NDISMTX_UNLOCK(_sc) mtx_unlock(&(_sc)->ndis_mtx) 220186507Sweongyo#define NDISUSB_LOCK(_sc) mtx_lock(&Giant) 221186507Sweongyo#define NDISUSB_UNLOCK(_sc) mtx_unlock(&Giant) 222186507Sweongyo#define NDIS_LOCK(_sc) do { \ 223186507Sweongyo if ((_sc)->ndis_iftype == PNPBus) \ 224186507Sweongyo NDISUSB_LOCK(_sc); \ 225186507Sweongyo NDISMTX_LOCK(_sc); \ 226186507Sweongyo} while (0) 227186507Sweongyo#define NDIS_UNLOCK(_sc) do { \ 228186507Sweongyo if ((_sc)->ndis_iftype == PNPBus) \ 229186507Sweongyo NDISUSB_UNLOCK(_sc); \ 230186507Sweongyo NDISMTX_UNLOCK(_sc); \ 231186507Sweongyo} while (0) 232