Module Name: src
Committed By: dyoung
Date: Thu Apr 2 00:39:37 UTC 2009
Modified Files:
src/sys/dev/if_ndis: if_ndis.c
Log Message:
I find myself making a lot of changes in this code to keep it compiling
and (let us hope) working in the 21st century, so I have put it through
unifdef -D__NetBSD__ -U__FreeBSD__ so that it is less of a chore to read
and to maintain.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/dev/if_ndis/if_ndis.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/if_ndis/if_ndis.c
diff -u src/sys/dev/if_ndis/if_ndis.c:1.24 src/sys/dev/if_ndis/if_ndis.c:1.25
--- src/sys/dev/if_ndis/if_ndis.c:1.24 Wed Mar 18 17:06:49 2009
+++ src/sys/dev/if_ndis/if_ndis.c Thu Apr 2 00:39:37 2009
@@ -35,12 +35,9 @@
__FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis.c,v 1.69.2.6 2005/03/31 04:24:36 wpaul Exp $");
#endif
#ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: if_ndis.c,v 1.24 2009/03/18 17:06:49 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ndis.c,v 1.25 2009/04/02 00:39:37 dyoung Exp $");
#endif
-#ifdef __FreeBSD__
-#include "opt_bdg.h"
-#endif
#include <sys/param.h>
#include <sys/systm.h>
@@ -51,30 +48,18 @@
#include <sys/socket.h>
#include <sys/queue.h>
-#ifdef __NetBSD__
#include <sys/device.h>
#include <sys/kauth.h>
-#endif
-#ifdef __FreeBSD__
-#include <sys/module.h>
-#else /* __NetBSD__ */
#include <sys/module.h>
-#endif
#include <sys/proc.h>
-#if __FreeBSD_version < 502113
#include <sys/sysctl.h>
-#endif
#include <net/if.h>
#include <net/if_arp.h>
-#ifdef __FreeBSD__
-#include <net/ethernet.h>
-#else
#include <net/if_ether.h>
-#endif
#include <net/if_dl.h>
#include <net/if_media.h>
@@ -82,33 +67,18 @@
#include <net/bpf.h>
-#ifdef __FreeBSD__
-#include <machine/bus_memio.h>
-#include <machine/bus_pio.h>
-#include <machine/resource.h>
-#endif
#include <sys/bus.h>
-#ifdef __FreeBSD__
-#include <sys/bus.h>
-#include <sys/rman.h>
-#endif
#include <net80211/ieee80211_var.h>
#include <net80211/ieee80211_ioctl.h>
-#ifdef __FreeBSD__
-#include <dev/wi/if_wavelan_ieee.h>
-#else /* __NetBSD__ */
#include <dev/ic/wi_ieee.h>
-#endif
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
-#ifdef __NetBSD__
#include <dev/pci/pcidevs.h>
-#endif
#include <compat/ndis/pe_var.h>
#include <compat/ndis/resource_var.h>
@@ -116,9 +86,7 @@
#include <compat/ndis/hal_var.h>
#include <compat/ndis/ndis_var.h>
#include <compat/ndis/cfg_var.h>
-#ifdef __NetBSD__
#include <compat/ndis/nbcompat.h>
-#endif
#include <dev/if_ndis/if_ndisvar.h>
#define NDIS_IMAGE
@@ -126,25 +94,13 @@
#include "ndis_driver_data.h"
-#ifdef __FreeBSD__
-int ndis_attach (device_t);
-#else /* __NetBSD__ */
void ndis_attach (void *);
-#endif
-#ifdef __FreeBSD__
-int ndis_detach (device_t);
-#else /* __NetBSD__ */
int ndis_detach (device_t, int);
-#endif
int ndis_suspend (device_t);
int ndis_resume (device_t);
void ndis_shutdown (device_t);
-#ifdef __FreeBSD__
-int ndisdrv_modevent (module_t, int, void *);
-#else /* __NetBSD__ */
int ndisdrv_modevent (struct lkm_table *lkmtp, int cmd);
-#endif
/* I moved these to if_ndisvar.h */
/*
@@ -164,11 +120,7 @@
static funcptr ndis_linksts_wrap;
static funcptr ndis_linksts_done_wrap;
-#ifdef __FreeBSD__
-static void ndis_intr (void *);
-#else /* __NetBSD__ */
int ndis_intr(void *);
-#endif
static void ndis_tick (void *);
static void ndis_ticktask (void *);
static void ndis_start (struct ifnet *);
@@ -176,11 +128,7 @@
static int ndis_ioctl (struct ifnet *, u_long, void *);
static int ndis_wi_ioctl_get (struct ifnet *, u_long, void *);
static int ndis_wi_ioctl_set (struct ifnet *, u_long, void *);
-#ifdef __FreeBSD__
-static void ndis_init (void *);
-#else /* __NetBSD__ */
static int ndis_init (struct ifnet *);
-#endif
static void ndis_stop (struct ndis_softc *);
static void ndis_watchdog (struct ifnet *);
static int ndis_ifmedia_upd (struct ifnet *);
@@ -195,12 +143,7 @@
static void ndis_setmulti (struct ndis_softc *);
static void ndis_map_sclist (void *, bus_dma_segment_t *,
int, bus_size_t, int);
-#ifdef __NetBSD__
-static int ndisdrv_loaded = 0;
-#endif /* __NetBSD__ */
-#ifdef __FreeBSD__
static int ndisdrv_loaded = 0;
-#endif
/*
* This routine should call windrv_load() once for each driver
@@ -209,16 +152,9 @@
* saved in our driver database.
*/
int
-#ifdef __FreeBSD__
-ndisdrv_modevent(mod, cmd, arg)
- module_t mod;
- int cmd;
- void *arg;
-#else
ndisdrv_modevent(mod, cmd)
module_t mod;
int cmd;
-#endif
{
int error = 0;
@@ -248,14 +184,6 @@
windrv_unwrap(ndis_linksts_done_wrap);
break;
/* TODO: Do we need a LKM_E_STAT for NetBSD? */
-#ifdef __FreeBSD__
- case MOD_SHUTDOWN:
- windrv_unwrap(ndis_rxeof_wrap);
- windrv_unwrap(ndis_txeof_wrap);
- windrv_unwrap(ndis_linksts_wrap);
- windrv_unwrap(ndis_linksts_done_wrap);
- break;
-#endif /* __FreeBSD__ */
default:
error = EINVAL;
break;
@@ -264,7 +192,6 @@
return (error);
}
-#ifdef __NetBSD__
#ifdef NDIS_LKM
int if_ndis_lkmentry(struct lkm_table *lkmtp, int cmd, int ver);
@@ -303,7 +230,6 @@
}
#endif /* NIDS_LKM */
-#endif /* __NetBSD__ */
/*
* Program the 64-bit multicast hash filter.
@@ -312,11 +238,7 @@
ndis_setmulti(struct ndis_softc *sc)
{
struct ifnet *ifp;
-#ifdef __FreeBSD__
- struct ifmultiaddr *ifma;
-#else /* __NetBSD__ */
struct ether_multi *ifma;
-#endif
int len, mclistsz, error;
uint8_t *mclist;
@@ -337,13 +259,8 @@
return;
}
-#ifdef __FreeBSD__
- if (TAILQ_EMPTY(&ifp->if_multiaddrs))
- return;
-#else /* __NetBSD__ */
if (LIST_EMPTY(&sc->arpcom.ec_multiaddrs))
return;
-#endif
len = sizeof(mclistsz);
ndis_get_info(sc, OID_802_3_MAXIMUM_LIST_SIZE, &mclistsz, &len);
@@ -358,17 +275,7 @@
sc->ndis_filter |= NDIS_PACKET_TYPE_MULTICAST;
len = 0;
-#ifdef __FreeBSD__
- TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-#else /* __NetBSD__ */
LIST_FOREACH(ifma, &sc->arpcom.ec_multiaddrs, enm_list) {
-#endif
-#ifdef __FreeBSD__
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- bcopy(CLLADDR(satosdl(ifma->ifma_addr)),
- mclist + (ETHER_ADDR_LEN * len), ETHER_ADDR_LEN);
-#else /* __NetBSD__ */
/*
*****************************************************************************
* TODO: The NetBSD ether_multi structure (sys/net/if_ether.h) defines a range
@@ -380,7 +287,6 @@
*/
memcpy( mclist + (ETHER_ADDR_LEN * len), ifma->enm_addrlo,
ETHER_ADDR_LEN);
-#endif
len++;
if (len > mclistsz) {
sc->ndis_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
@@ -565,15 +471,9 @@
* Attach the interface. Allocate softc structures, do ifmedia
* setup and ethernet/BPF attach.
*/
-#ifdef __FreeBSD__
-int
-ndis_attach(dev)
- device_t dev;
-#else /* __NetBSD__ */
void
ndis_attach(dev)
void *dev;
-#endif
{
u_char eaddr[ETHER_ADDR_LEN];
struct ndis_softc *sc;
@@ -591,17 +491,10 @@
sc = device_get_softc(dev);
-#ifdef __NetBSD__
/* start out at dispatch level */
win_irql = DISPATCH_LEVEL;
-#endif
-#ifdef __FreeBSD__
- mtx_init(&sc->ndis_mtx, "ndis softc lock",
- MTX_NETWORK_LOCK, MTX_DEF);
-#else /* __NetBSD__ */
simple_lock_init(&sc->ndis_mtx);
-#endif
/*
* Hook interrupt early, since calling the driver's
@@ -609,44 +502,17 @@
* we don't need to do any explicit interrupt setup
* for USB.
*/
-#ifdef __FreeBSD__
- if (sc->ndis_iftype == PCMCIABus || sc->ndis_iftype == PCIBus) {
- error = bus_setup_intr(dev, sc->ndis_irq,
- INTR_TYPE_NET | INTR_MPSAFE,
- ndis_intr, sc, &sc->ndis_intrhand);
-
- if (error) {
- aprint_error_dev(dev, "couldn't set up irq\n");
- goto fail;
- }
- }
-#else /* __NetBSD__ */
/*
* For NetBSD, the interrupt is set up in the bus-dependent
* code. For PCI it's done in ndis_attach_pci()
*/
-#endif
/*
* TODO: remove this #ifdef once if_ndis_pcmcia.c compiles
*/
-#ifdef __FreeBSD__
- if (sc->ndis_iftype == PCMCIABus) {
- error = ndis_alloc_amem(sc);
- if (error) {
- aprint_error_dev(dev, "failed to allocate attribute memory\n");
- goto fail;
- }
- }
-#endif
sc->ndis_regvals = ndis_regvals;
-#ifdef __FreeBSD__
-#if __FreeBSD_version < 502113
- sysctl_ctx_init(&sc->ndis_ctx);
-#endif
-#endif
/* Create sysctl registry nodes */
ndis_create_sysctls(sc);
@@ -658,12 +524,8 @@
pdrv = windrv_lookup(0, "PCCARD Bus");
else
pdrv = windrv_lookup(0, "USB Bus");
-#ifdef __FreeBSD__
- pdo = windrv_find_pdo(pdrv, dev);
-#else /* __NetBSD__ */
/* here dev is actuially just a pointer to the softc */
pdo = windrv_find_pdo(pdrv, sc->ndis_dev->dv_parent);
-#endif
/*
@@ -674,14 +536,12 @@
img = drv_data;
drv = windrv_lookup((vm_offset_t)img, NULL);
-#ifdef __NetBSD__
/*
* Stash a pointer to the softc in the Windows device_object, since
* we can't get it from the NetBSD device structure.
*/
pdo->pdo_sc = sc;
pdo->fdo_sc = sc;
-#endif
if (NdisAddDevice(drv, pdo) != STATUS_SUCCESS) {
aprint_error_dev(sc->ndis_dev, "failed to create FDO!\n");
@@ -694,18 +554,10 @@
sc->ndis_chars->nmc_version_major,
sc->ndis_chars->nmc_version_minor);
-#ifdef __FreeBSD__
- /* Do resource conversion. */
- if (sc->ndis_iftype == PCMCIABus || sc->ndis_iftype == PCIBus)
- ndis_convert_res(sc);
- else
- sc->ndis_block->nmb_rlist = NULL;
-#else /* __NetBSD__ */
/*
* For NetBSD so far we do the resource conversion directly in
* ndis_attach_pci()
*/
-#endif
/* Install our RX and TX interrupt handlers. */
sc->ndis_block->nmb_senddone_func = ndis_txeof_wrap;
@@ -715,11 +567,9 @@
sc->ndis_block->nmb_rlist = sc->ndis_rl;
/* sc->ndis_block->nmb_rlist = &sc->ndis_rl; */
-#ifdef __NetBSD__
/* TODO: Free this memory! */
sc->arpcom.ec_if.if_sadl =
malloc(sizeof(struct sockaddr_dl), M_DEVBUF, M_NOWAIT|M_ZERO);
-#endif
/* Call driver's init routine. */
if (ndis_init_nic(sc)) {
@@ -734,9 +584,6 @@
len = sizeof(eaddr);
ndis_get_info(sc, OID_802_3_CURRENT_ADDRESS, &eaddr, &len);
-#ifdef __FreeBSD__
- memcpy( (char *)&sc->arpcom.ec_if.ac_enaddr, eaddr, ETHER_ADDR_LEN);
-#endif
/*
* Figure out if we're allowed to use multipacket sends
* with this driver, and if so, how many.
@@ -794,15 +641,9 @@
ifp = &sc->arpcom.ac_if;
ifp->if_softc = sc;
-#ifdef __NetBSD__
sc->ic.ic_ifp = ifp;
-#endif
-#ifdef __FreeBSD__
- if_initname(ifp, device_get_name(dev), device_get_unit(dev));
-#else /* __NetBSD__ */
strlcpy(ifp->if_xname, device_xname(sc->ndis_dev), IFNAMSIZ);
-#endif
ifp->if_mtu = ETHERMTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = ndis_ioctl;
@@ -810,32 +651,19 @@
ifp->if_watchdog = ndis_watchdog;
ifp->if_init = ndis_init;
ifp->if_baudrate = 10000000;
-#if __FreeBSD_version < 502114
- ifp->if_snd.ifq_maxlen = 50;
-#else
IFQ_SET_MAXLEN(&ifp->if_snd, 50);
- ifp->if_snd.ifq_drv_maxlen = 25;
IFQ_SET_READY(&ifp->if_snd);
-#endif
ifp->if_capenable = ifp->if_capabilities;
-#ifdef __FreeBSD__
- ifp->if_hwassist = sc->ndis_hwassist;
-#else /* __NetBSD__ */
/*
* TODO: I don't think NetBSD has this field describing "HW offload
* capabilities" as found in FreeBSD's
* if_data structure, but maybe there is something else that
* needs to be done here for NetBSD
*/
-#endif
/* Do media setup */
if (sc->ndis_80211) {
-#ifdef __FreeBSD__
- struct ieee80211com *ic = (void *)ifp;
-#else /* __NetBSD__ */
struct ieee80211com *ic = &sc->ic;
-#endif
ndis_80211_rates_ex rates;
struct ndis_80211_nettype_list *ntl;
uint32_t arg;
@@ -1004,17 +832,11 @@
r = ndis_get_info(sc, OID_802_11_POWER_MODE, &arg, &j);
if (r == 0)
ic->ic_caps |= IEEE80211_C_PMGT;
- memcpy( &ic->ic_myaddr, eaddr, sizeof(eaddr));
-#ifdef __FreeBSD__
- ieee80211_ifattach(ifp);
- ieee80211_media_init(ifp, ieee80211_media_change,
- ndis_media_status);
-#else /* __NetBSD__ */
+ memcpy(&ic->ic_myaddr, eaddr, sizeof(eaddr));
if_attach(ifp);
ieee80211_ifattach(&sc->ic);
ieee80211_media_init(&sc->ic, ieee80211_media_change,
ndis_media_status);
-#endif
ic->ic_ibss_chan = IEEE80211_CHAN_ANYC;
ic->ic_bss->ni_chan = ic->ic_ibss_chan;
@@ -1028,9 +850,7 @@
IFM_ETHER|IFM_100_TX|IFM_FDX, 0, NULL);
ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL);
ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_AUTO);
-#ifdef __NetBSD__
if_attach(ifp);
-#endif
ether_ifattach(ifp, eaddr);
}
@@ -1039,20 +859,12 @@
sc->ndis_block->nmb_statusdone_func = ndis_linksts_done_wrap;
fail:
if (error)
-#ifdef __FreeBSD__
- ndis_detach(dev);
-#else /* __NetBSD__ */
ndis_detach(dev, 0);
-#endif
else
/* We're done talking to the NIC for now; halt it. */
ndis_halt_nic(sc);
-#ifdef __FreeBSD__
- return(error);
-#else /* __NetBSD__ */
return;
-#endif
}
/*
@@ -1063,33 +875,21 @@
* allocated.
*/
int
-#ifdef __FreeBSD__
-ndis_detach(dev)
- device_t dev;
-#else /* __NetBSD__ */
ndis_detach (dev, flags)
device_t dev;
int flags;
-#endif
{
struct ndis_softc *sc;
struct ifnet *ifp;
driver_object *drv;
-#ifdef __NetBSD__
int s;
-#endif
#ifdef NDIS_DBG
printf("in ndis_detach\n");
#endif
sc = device_get_softc(dev);
-#ifdef __FreeBSD__
- KASSERT(mtx_initialized(&sc->ndis_mtx),
- ("ndis mutex not initialized"));
-#else /* __NetBSD__*/
KASSERT(mtx_initialized(&sc->ndis_mtx));
-#endif
NDIS_LOCK(sc);
@@ -1100,55 +900,29 @@
NDIS_UNLOCK(sc);
ndis_stop(sc);
if (sc->ndis_80211)
-#ifdef __FreeBSD__
- ieee80211_ifdetach(ifp);
-#else /* __NetBSD__ */
ieee80211_ifdetach(&sc->ic);
-#endif
else
ether_ifdetach(ifp);
} else {
NDIS_UNLOCK(sc);
}
-#ifdef __FreeBSD__
- bus_generic_detach(dev);
-#endif
-#ifdef __FreeBSD__
- if (sc->ndis_intrhand)
- bus_teardown_intr(dev, sc->ndis_irq, sc->ndis_intrhand);
- if (sc->ndis_irq)
- bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq);
-#else
/*
* TODO: unmap interrupts when unloading in NetBSD
*/
-#endif /* __NetBSD__ */
if (sc->ndis_res_io)
bus_release_resource(dev, SYS_RES_IOPORT,
sc->ndis_io_rid, sc->ndis_res_io);
if (sc->ndis_res_mem)
bus_release_resource(dev, SYS_RES_MEMORY,
sc->ndis_mem_rid, sc->ndis_res_mem);
-#ifdef __FreeBSD__
- if (sc->ndis_res_altmem)
- bus_release_resource(dev, SYS_RES_MEMORY,
- sc->ndis_altmem_rid, sc->ndis_res_altmem);
-
- if (sc->ndis_iftype == PCMCIABus)
- ndis_free_amem(sc);
-#endif
if (sc->ndis_sc)
ndis_destroy_dma(sc);
if (sc->ndis_txarray)
free(sc->ndis_txarray, M_DEVBUF);
-#ifdef __FreeBSD__
- if (!sc->ndis_80211)
- ifmedia_removeall(&sc->ifmedia);
-#endif
ndis_unload_driver((void *)ifp);
@@ -1166,65 +940,19 @@
if (drv == NULL)
panic("couldn't find driver object");
windrv_destroy_pdo(drv, dev);
-#ifdef __FreeBSD__
- if (sc->ndis_iftype == PCIBus)
- bus_dma_tag_destroy(sc->ndis_parent_tag);
-#else /* __NetBSD__ */
/*
* TODO: Unmap dma for NetBSD
*/
-#endif
-#ifdef __FreeBSD__
-#if __FreeBSD_version < 502113
- sysctl_ctx_free(&sc->ndis_ctx);
-#endif
-#endif
mtx_destroy(&sc->ndis_mtx);
return(0);
}
-#ifdef __FreeBSD__
-int
-ndis_suspend(device_t dev)
-{
- struct ndis_softc *sc;
- struct ifnet *ifp;
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
-#ifdef notdef
- if (NDIS_INITIALIZED(sc))
- ndis_stop(sc);
-#endif
-
- return(0);
-}
-#else /* __NetBSD__ */
/* TODO: write a NetBSD version of ndis_suspend() */
-#endif
-
-#ifdef __FreeBSD__
-int
-ndis_resume(device_t dev)
-{
- struct ndis_softc *sc;
- struct ifnet *ifp;
-
- sc = device_get_softc(dev);
- ifp = &sc->arpcom.ac_if;
-
- if (NDIS_INITIALIZED(sc))
- ndis_init(sc);
- return(0);
-}
-#else /* __NetBSD__ */
/* TODO: write a NetBSD version of ndis_resume() */
-#endif
/*
* A frame has been uploaded: pass the resulting mbuf chain up to
@@ -1258,11 +986,7 @@
int i;
block = (ndis_miniport_block *)adapter;
-#ifdef __FreeBSD__
- sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-#else /* __NetBSD__ */
sc = (struct ndis_softc *)block->nmb_physdeviceobj->pdo_sc;
-#endif
ifp = &sc->arpcom.ac_if;
for (i = 0; i < pktcnt; i++) {
@@ -1272,18 +996,10 @@
if (ndis_ptom(&m0, p)) {
aprint_error_dev(sc->ndis_dev, "ptom failed\n");
if (p->np_oob.npo_status == NDIS_STATUS_SUCCESS)
-#ifdef __FreeBSD__
- ndis_return_packet(sc, p);
-#else /* __NetBSD__ */
ndis_return_packet(NULL, (void *)sc, 0, p);
-#endif
} else {
if (p->np_oob.npo_status == NDIS_STATUS_RESOURCES) {
-#ifdef __FreeBSD__
- m = m_dup(m0, M_DONTWAIT);
-#else /* __NetBSD__ */
m = m_dup(m0, 0, m0->m_pkthdr.len, FALSE);
-#endif
/*
* NOTE: we want to destroy the mbuf here, but
* we don't actually want to return it to the
@@ -1304,25 +1020,6 @@
ifp->if_ipackets++;
/* Deal with checksum offload. */
-#ifdef __FreeBSD__
- if (ifp->if_capenable & IFCAP_RXCSUM &&
- p->np_ext.npe_info[ndis_tcpipcsum_info] != NULL) {
- s = (uintptr_t)
- p->np_ext.npe_info[ndis_tcpipcsum_info];
- csum = (ndis_tcpip_csum *)&s;
- if (csum->u.ntc_rxflags &
- NDIS_RXCSUM_IP_PASSED)
- m0->m_pkthdr.csum_flags |=
- CSUM_IP_CHECKED|CSUM_IP_VALID;
- if (csum->u.ntc_rxflags &
- (NDIS_RXCSUM_TCP_PASSED |
- NDIS_RXCSUM_UDP_PASSED)) {
- m0->m_pkthdr.csum_flags |=
- CSUM_DATA_VALID|CSUM_PSEUDO_HDR;
- m0->m_pkthdr.csum_data = 0xFFFF;
- }
- }
-#else /* __NetBSD__ */
/*
* TODO: deal with checksum offload in NetBSD
* (see IFCAP_XXX in sys/net/if.h, these differ from the FreeBSD ones)
@@ -1344,13 +1041,10 @@
m0->m_pkthdr.csum_data = 0xFFFF;
}
}
-#endif
-#ifdef __NetBSD__
if(ifp->if_bpf) {
bpf_mtap(ifp->if_bpf, m0);
}
-#endif
(*ifp->if_input)(ifp, m0);
}
@@ -1375,16 +1069,10 @@
struct ifnet *ifp;
int idx;
struct mbuf *m;
-#ifdef __NetBSD__
int s;
-#endif
block = (ndis_miniport_block *)adapter;
-#ifdef __FreeBSD__
- sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-#else /* __NetBSD__ */
sc = (struct ndis_softc *)block->nmb_physdeviceobj->pdo_sc;
-#endif
ifp = &sc->arpcom.ac_if;
m = packet->np_m0;
@@ -1420,11 +1108,7 @@
struct ndis_softc *sc;
block = adapter;
-#ifdef __FreeBSD__
- sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-#else /* __NetBSD__ */
sc = (struct ndis_softc *)block->nmb_physdeviceobj->pdo_sc;
-#endif
block->nmb_getstat = status;
@@ -1440,11 +1124,7 @@
struct ifnet *ifp;
block = adapter;
-#ifdef __FreeBSD__
- sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-#else /* __NetBSD__ */
sc = (struct ndis_softc *)block->nmb_physdeviceobj->pdo_sc;
-#endif
ifp = &sc->arpcom.ac_if;
if (!NDIS_INITIALIZED(sc))
@@ -1466,13 +1146,8 @@
return;
}
-#ifdef __FreeBSD__
- static void
-ndis_intr(arg)
-#else /* __NetBSD__ */
int
ndis_intr(arg)
-#endif
void *arg;
{
struct ndis_softc *sc;
@@ -1485,7 +1160,6 @@
sc = arg;
ifp = &sc->arpcom.ac_if;
-#ifdef __NetBSD__
/*
* I was getting an interrupt before NdisAddDevice was called,
* which sets up the ndis_block, so...
@@ -1493,16 +1167,11 @@
if(sc->ndis_block == NULL) {
return 0;
}
-#endif
intr = sc->ndis_block->nmb_interrupt;
if (sc->ndis_block->nmb_miniportadapterctx == NULL) {
-#ifdef __FreeBSD__
- return;
-#else /* __NetBSD__ */
return 0;
-#endif
}
KeAcquireSpinLock(&intr->ni_dpccountlock, &irql);
@@ -1520,18 +1189,13 @@
ndis_in_isr = FALSE;
}
-#ifdef __FreeBSD__
- return;
-#else /* __NetBSD__ */
return 0;
-#endif
}
/*
* just here so I can wake up the SWI thread
* in ndis_ticktask
*/
-#ifdef __NetBSD__
struct ndisproc {
struct ndisqhead *np_q;
struct proc *np_p;
@@ -1540,34 +1204,21 @@
int np_needs_wakeup;
};
extern struct ndisproc ndis_iproc;
-#endif
static void
ndis_tick(void *xsc)
{
struct ndis_softc *sc;
-#ifdef __FreeBSD__
- mtx_unlock(&Giant);
-#else /* __NetBSD__ */
/* TODO: do we need the lock for NetBSD? */
-#endif
sc = xsc;
ndis_sched(ndis_ticktask, sc, NDIS_TASKQUEUE);
-#ifdef __FreeBSD__
- sc->ndis_stat_ch = timeout(ndis_tick, sc, hz *
- sc->ndis_block->nmb_checkforhangsecs);
-#else /* __NetBSD__ */
callout_reset(&sc->ndis_stat_ch, hz *
sc->ndis_block->nmb_checkforhangsecs, ndis_tick, sc);
-#endif
-#ifdef __FreeBSD__
- mtx_lock(&Giant);
-#endif
return;
}
@@ -1580,9 +1231,7 @@
uint8_t rval;
ndis_media_state linkstate;
int error, len;
-#ifdef __NetBSD__
int s;
-#endif
sc = xsc;
@@ -1665,11 +1314,7 @@
struct ifnet *ifp;
ifp = arg;
-#if __FreeBSD_version < 502114
- if (ifp->if_snd.ifq_head != NULL)
-#else
- if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
-#endif
+ if (!IFQ_IS_EMPTY(&ifp->if_snd))
ndis_start(ifp);
return;
}
@@ -1694,9 +1339,7 @@
ndis_packet **p0 = NULL, *p = NULL;
ndis_tcpip_csum *csum;
int pcnt = 0, status;
-#ifdef __NetBSD__
int s;
-#endif
sc = ifp->if_softc;
@@ -1710,11 +1353,7 @@
p0 = &sc->ndis_txarray[sc->ndis_txidx];
while(sc->ndis_txpending) {
-#if __FreeBSD_version < 502114
- IF_DEQUEUE(&ifp->if_snd, m);
-#else
- IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
-#endif
+ IFQ_DEQUEUE(&ifp->if_snd, m);
if (m == NULL)
break;
@@ -1749,14 +1388,6 @@
* Do scatter/gather processing, if driver requested it.
*/
if (sc->ndis_sc) {
-#ifdef __FreeBSD__
- bus_dmamap_load_mbuf(sc->ndis_ttag,
- sc->ndis_tmaps[sc->ndis_txidx], m,
- ndis_map_sclist, &p->np_sclist, BUS_DMA_NOWAIT);
- bus_dmamap_sync(sc->ndis_ttag,
- sc->ndis_tmaps[sc->ndis_txidx],
- BUS_DMASYNC_PREREAD);
-#else /* __NetBSD__ */
/*
* TODO: NetBSD's bus_dmamap_load_mbuf dosen't provide a callback function
* argumet as FreeBSD's does figure out what to do about this.
@@ -1779,7 +1410,6 @@
sc->ndis_tmaps[sc->ndis_txidx]->dm_segs->ds_addr,
sc->ndis_tmaps[sc->ndis_txidx]->dm_segs->ds_len,
BUS_DMASYNC_PREREAD);
-#endif
p->np_ext.npe_info[ndis_sclist_info] = &p->np_sclist;
}
@@ -1807,11 +1437,7 @@
* If there's a BPF listener, bounce a copy of this frame
* to him.
*/
-#ifdef __FreeBSD__
- BPF_MTAP(ifp, m);
-#else /* __NetBSD__ */
bpf_mtap(ifp, m);
-#endif
/*
* The array that p0 points to must appear contiguous,
* so we must not wrap past the end of sc->ndis_txarray[].
@@ -1847,24 +1473,13 @@
return;
}
-#ifdef __FreeBSD__
-static void
-ndis_init(xsc)
- void *xsc;
-#else /* __NetBSD__ */
static int
ndis_init(xsc)
struct ifnet *xsc;
-#endif
{
-#ifdef __FreeBSD__
- struct ndis_softc *sc = (struct ndis_softc *)xsc;
- struct ifnet *ifp = &sc->arpcom.ac_if;
-#else /* __NetBSD__ */
struct ndis_softc *sc = xsc->if_softc;
struct ifnet *ifp = xsc;
int s;
-#endif
int i, error;
/*
@@ -1874,22 +1489,14 @@
* call ifp->if_init() quite as often.
*/
if (sc->ndis_link && sc->ndis_skip)
-#ifdef __FreeBSD__
- return;
-#else /* __NetBSD__ */
return 0;
-#endif
/*
* Cancel pending I/O and free all RX/TX buffers.
*/
ndis_stop(sc);
if (ndis_init_nic(sc)) {
-#ifdef __FreeBSD__
- return;
-#else /* __NetBSD__ */
return 0;
-#endif
}
/* Init our MAC address */
@@ -1948,20 +1555,11 @@
if (sc->ndis_block->nmb_checkforhangsecs == 0)
sc->ndis_block->nmb_checkforhangsecs = 3;
-#ifdef __FreeBSD__
- sc->ndis_stat_ch = timeout(ndis_tick, sc,
- hz * sc->ndis_block->nmb_checkforhangsecs);
-#else /* __NetBSD__ */
callout_reset(&sc->ndis_stat_ch,
hz * sc->ndis_block->nmb_checkforhangsecs,
ndis_tick, sc);
-#endif
-#ifdef __FreeBSD__
- return;
-#else /* __NetBSD__ */
return 0;
-#endif
}
/*
@@ -1975,11 +1573,7 @@
sc = ifp->if_softc;
if (NDIS_INITIALIZED(sc))
-#ifdef __FreeBSD__
- ndis_init(sc);
-#else /* __NetBSD__ */
ndis_init(&sc->arpcom.ac_if);
-#endif
return(0);
}
@@ -2045,19 +1639,13 @@
uint32_t arg;
struct ifnet *ifp;
-#ifdef __NetBSD__
#define wk_len wk_keylen
#define ic_wep_txkey ic_def_txkey
-#endif
ic = &sc->ic;
/* TODO: are these equivelant? */
-#ifdef __FreeBSD__
- ifp = &sc->ic.ic_ac.ac_if;
-#else /* __NetBSD__ */
ifp = sc->ic.ic_ifp;
-#endif
if (!NDIS_INITIALIZED(sc))
return;
@@ -2077,15 +1665,7 @@
/* Set WEP */
/* TODO: Clean up these #ifdef's */
-#ifdef __FreeBSD__
-#ifdef IEEE80211_F_WEPON
- if (ic->ic_flags & IEEE80211_F_WEPON) {
-#else
- if (ic->ic_wep_mode >= IEEE80211_WEP_ON) {
-#endif
-#else /* __NetBSD__ */
if (ic->ic_flags & IEEE80211_F_PRIVACY) {
-#endif /* __NetBSD__ */
for (i = 0; i < IEEE80211_WEP_NKID; i++) {
if (ic->ic_nw_keys[i].wk_len) {
memset((char *)&wep, 0, sizeof(wep));
@@ -2118,14 +1698,6 @@
if (rval)
aprint_error_dev(sc->ndis_dev, "enable WEP failed: %d\n",
rval);
-#ifdef __FreeBSD__
-#ifndef IEEE80211_F_WEPON
- if (ic->ic_wep_mode != IEEE80211_WEP_8021X &&
- ic->ic_wep_mode != IEEE80211_WEP_ON)
- arg = NDIS_80211_PRIVFILT_ACCEPTALL;
- else
-#endif
-#endif /* __FreeBSD__ */
arg = NDIS_80211_PRIVFILT_8021XWEP;
len = sizeof(arg);
rval = ndis_set_info(sc, OID_802_11_PRIVACY_FILTER, &arg, &len);
@@ -2289,9 +1861,6 @@
case IEEE80211_MODE_11G:
imr->ifm_active |= IFM_MAKEMODE(IFM_IEEE80211_11G);
break;
-#ifdef __FreeBSD__
- case IEEE80211_MODE_TURBO:
-#endif /* __NetBSD__ */
/*
* TODO: is this correct? (IEEE80211_MODE_TURBO_A and IEEE80211_MODE_TURBO_G
* are defined in _ieee80211.h)
@@ -2368,11 +1937,7 @@
ic = &sc->ic;
/* TODO: are these equivelant? */
-#ifdef __FreeBSD__
- ifp = &sc->ic.ic_ac.ac_if;
-#else /* __NetBSD__ */
ifp = sc->ic.ic_ifp;
-#endif
if (!NDIS_INITIALIZED(sc))
return;
@@ -2503,14 +2068,10 @@
struct ndis_softc *sc = ifp->if_softc;
struct ifreq *ifr = (struct ifreq *) data;
int i, error = 0;
-#ifdef __NetBSD__
int s;
-#endif
/*NDIS_LOCK(sc);*/
-#ifdef __NetBSD__
s = splnet();
-#endif
switch(command) {
case SIOCSIFFLAGS:
@@ -2546,14 +2107,12 @@
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
-#ifdef __NetBSD__
/*
* TODO: I'm really not sure this is the correct thing to do here, but multicast
* address lists weren't getting set in ether_ioctl because they SIOCADDMULTI
* is routed to ndis_setmulti here.
*/
error = ether_ioctl(ifp, command, data);
-#endif
ndis_setmulti(sc);
error = 0;
break;
@@ -2603,9 +2162,7 @@
}
/*NDIS_UNLOCK(sc);*/
-#ifdef __NetBSD__
splx(s);
-#endif
return(error);
}
@@ -2696,12 +2253,8 @@
struct ndis_softc *sc;
uint32_t foo;
int error, len;
-#ifdef __FreeBSD__
- error = suser(curthread);
-#else /* __NetBSD__ */
error = kauth_authorize_generic(curlwp->l_cred,
KAUTH_GENERIC_ISSUSER, NULL);
-#endif
if (error)
return (error);
@@ -2730,9 +2283,7 @@
ndis_watchdog(struct ifnet *ifp)
{
struct ndis_softc *sc;
-#ifdef __NetBSD__
int s;
-#endif
sc = ifp->if_softc;
@@ -2757,16 +2308,10 @@
ndis_stop(struct ndis_softc *sc)
{
struct ifnet *ifp;
-#ifdef __NetBSD__
int s;
-#endif
ifp = &sc->arpcom.ac_if;
-#ifdef __FreeBSD__
- untimeout(ndis_tick, sc, sc->ndis_stat_ch);
-#else /* __NetBSD__ */
callout_stop(&sc->ndis_stat_ch);
-#endif
ndis_halt_nic(sc);
@@ -2786,15 +2331,3 @@
* get confused by errant DMAs when rebooting.
*/
/* TODO: remove this #ifdef once ndis_shutdown_nic() is working on NetBSD */
-#ifdef __FreeBSD__
-void
-ndis_shutdown(device_t dev)
-{
- struct ndis_softc *sc;
-
- sc = device_get_softc(dev);
- ndis_shutdown_nic(sc);
-
- return;
-}
-#endif /* __FreeBSD__ */