1 /* $NetBSD: if_ndisvar.h,v 1.9 2012/10/27 17:18:23 chs Exp $ */ 2 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: src/sys/dev/if_ndis/if_ndisvar.h,v 1.15.2.2 2005/02/18 16:30:10 wpaul Exp $ 35 */ 36 37 #define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node" 38 #define NDIS_NODENAME_LEN 32 39 40 #ifdef __NetBSD__ 41 #include <dev/pci/pcivar.h> 42 #include <dev/pci/pcireg.h> 43 #include <dev/pci/pcidevs.h> 44 45 #include <dev/pcmcia/pcmciareg.h> 46 #include <dev/pcmcia/pcmciavar.h> 47 #include <dev/pcmcia/pcmciadevs.h> 48 49 #include <dev/cardbus/cardbusvar.h> 50 #include <dev/cardbus/cardbusreg.h> 51 #endif 52 53 struct ndis_pci_type { 54 const uint16_t ndis_vid; 55 const uint16_t ndis_did; 56 const uint32_t ndis_subsys; 57 const char *ndis_name; 58 }; 59 60 struct ndis_pccard_type { 61 const char *ndis_vid; 62 const char *ndis_did; 63 char *ndis_name; 64 }; 65 66 struct ndis_shmem { 67 bus_dma_tag_t ndis_stag; 68 bus_dmamap_t ndis_smap; 69 void *ndis_saddr; 70 struct ndis_shmem *ndis_next; 71 }; 72 73 struct ndis_cfglist { 74 ndis_cfg ndis_cfg; 75 TAILQ_ENTRY(ndis_cfglist) link; 76 }; 77 78 TAILQ_HEAD(nch, ndis_cfglist); 79 80 #define NDIS_INITIALIZED(sc) (sc->ndis_block->nmb_miniportadapterctx != NULL) 81 82 #define NDIS_INC(x) \ 83 (x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts 84 85 #ifdef __NetBSD__ 86 /* 87 * A linked list of resources 88 */ 89 struct resource { 90 SLIST_ENTRY(resource) link; 91 cm_partial_resource_desc win_res; 92 }; 93 SLIST_HEAD(resource_list, resource); 94 #endif /* __NetBSD__ */ 95 96 #ifdef __FreeBSD__ 97 #define arpcom ic.ic_ac 98 #endif 99 100 #ifdef __NetBSD__ 101 struct ndis_resource { 102 bus_space_handle_t res_handle; 103 bus_space_tag_t res_tag; 104 bus_addr_t res_base; 105 bus_size_t res_size; 106 }; 107 #endif 108 109 #ifdef __NetBSD__ 110 extern int ndis_in_isr; 111 #endif 112 113 struct ndis_softc { 114 #ifdef __NetBSD__ 115 struct ethercom arpcom; 116 #endif 117 struct ieee80211com ic; /* interface info */ 118 #ifdef notdef 119 struct ieee80211com arpcom; /* interface info */ 120 #endif 121 struct ifmedia ifmedia; /* media info */ 122 u_long ndis_hwassist; 123 uint32_t ndis_v4tx; 124 uint32_t ndis_v4rx; 125 bus_space_handle_t ndis_bhandle; 126 bus_space_tag_t ndis_btag; 127 void *ndis_intrhand; 128 #ifdef __FreeBSD__ 129 struct resource *ndis_irq; 130 struct resource *ndis_res; 131 struct resource *ndis_res_io; 132 int ndis_io_rid; 133 struct resource *ndis_res_mem; 134 int ndis_mem_rid; 135 struct resource *ndis_res_altmem; 136 int ndis_altmem_rid; 137 struct resource *ndis_res_am; /* attribute mem (pccard) */ 138 int ndis_am_rid; 139 struct resource *ndis_res_cm; /* common mem (pccard) */ 140 struct resource_list ndis_rl; 141 #else /* __NetBSD__ */ 142 uint8_t ndis_mac[ETHER_ADDR_LEN]; 143 int ndis_sysctl_mib; 144 struct sysctllog *sysctllog; 145 146 //ndis_resource_list ndis_rl; 147 ndis_resource_list *ndis_rl; 148 int error; 149 /* TODO: Is the ndis_irq set up right? */ 150 void *ndis_irq; 151 152 /* for both pci and cardbus ? */ 153 struct ndis_resource *ndis_res_io; 154 int ndis_io_rid; /* not actuially used, just for bus_release_resource() */ 155 struct ndis_resource *ndis_res_mem; 156 struct ndis_resource *ndis_res_altmem; 157 int ndis_mem_rid; /* not actuially used, just for bus_release_resource() */ 158 159 /* pci specific */ 160 pci_chipset_tag_t ndis_res_pc; /* pci chipset */ 161 pcitag_t ndis_res_pctag; /* pci tag */ 162 pci_intr_handle_t pci_ih; /* interrupt handle */ 163 164 /* pcmcia specific */ 165 struct pcmcia_io_handle ndis_res_pcioh; /* specific i/o for pcmcia */ 166 struct pcmcia_mem_handle ndis_res_pcmem; /* specific mem for pcmcia */ 167 int sc_io_windows; /* i/o window */ 168 struct pcmcia_function * ndis_res_pcfunc; /* pcmcia function */ 169 170 /* cardbus specific */ 171 cardbus_devfunc_t ndis_res_ct; /* cardbus devfuncs */ 172 pcitag_t ndis_res_ctag; /* carbus tag */ 173 bus_size_t ndis_res_mapsize; /* size of mapped bus space region */ 174 #endif /* end __NetBSD__ section */ 175 int ndis_rescnt; 176 #ifdef __FreeBSD__ 177 struct mtx ndis_mtx; 178 #else /* __NetBSD__ */ 179 kmutex_t ndis_mtx; 180 #endif 181 device_t ndis_dev; 182 int ndis_unit; 183 ndis_miniport_block *ndis_block; 184 ndis_miniport_characteristics *ndis_chars; 185 interface_type ndis_type; 186 #ifdef __FreeBSD__ 187 struct callout_handle ndis_stat_ch; 188 #else 189 struct callout ndis_stat_ch; 190 #endif 191 int ndis_maxpkts; 192 ndis_oid *ndis_oids; 193 int ndis_oidcnt; 194 int ndis_txidx; 195 int ndis_txpending; 196 ndis_packet **ndis_txarray; 197 ndis_handle ndis_txpool; 198 int ndis_sc; 199 ndis_cfg *ndis_regvals; 200 struct nch ndis_cfglist_head; 201 int ndis_80211; 202 int ndis_link; 203 uint32_t ndis_filter; 204 int ndis_if_flags; 205 int ndis_skip; 206 207 #ifdef __FreeBSD__ 208 struct sysctl_ctx_list ndis_ctx; 209 #endif 210 #if __FreeBSD__ && __FreeBSD_version < 502113 211 struct sysctl_oid *ndis_tree; 212 #endif 213 int ndis_devidx; 214 interface_type ndis_iftype; 215 216 bus_dma_tag_t ndis_parent_tag; 217 struct ndis_shmem *ndis_shlist; 218 bus_dma_tag_t ndis_mtag; 219 bus_dma_tag_t ndis_ttag; 220 bus_dmamap_t *ndis_mmaps; 221 bus_dmamap_t *ndis_tmaps; 222 int ndis_mmapcnt; 223 }; 224 225 #define NDIS_LOCK(_sc) mtx_lock(&(_sc)->ndis_mtx) 226 #define NDIS_UNLOCK(_sc) mtx_unlock(&(_sc)->ndis_mtx) 227 228 /*static*/ __stdcall void ndis_txeof (ndis_handle, ndis_packet *, ndis_status); 229 /*static*/ __stdcall void ndis_rxeof (ndis_handle, ndis_packet **, uint32_t); 230 /*static*/ __stdcall void ndis_linksts (ndis_handle, ndis_status, void *, uint32_t); 231 /*static*/ __stdcall void ndis_linksts_done (ndis_handle); 232