if_ndis.c (188939) | if_ndis.c (189488) |
---|---|
1/*- 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * WPA support originally contributed by Arvind Srinivasan <arvind@celar.us> 33 * then hacked upon mercilessly by my. 34 */ 35 36#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 3 * Bill Paul <wpaul@windriver.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 * 32 * WPA support originally contributed by Arvind Srinivasan <arvind@celar.us> 33 * then hacked upon mercilessly by my. 34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/dev/if_ndis/if_ndis.c 188939 2009-02-23 18:16:17Z thompsa $"); | 37__FBSDID("$FreeBSD: head/sys/dev/if_ndis/if_ndis.c 189488 2009-03-07 07:26:22Z weongyo $"); |
38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/sockio.h> 42#include <sys/mbuf.h> 43#include <sys/malloc.h> 44#include <sys/endian.h> 45#include <sys/priv.h> --- 23 unchanged lines hidden (view full) --- 69#include <sys/rman.h> 70 71#include <net80211/ieee80211_var.h> 72#include <net80211/ieee80211_ioctl.h> 73#include <net80211/ieee80211_regdomain.h> 74 75#include <dev/pci/pcireg.h> 76#include <dev/pci/pcivar.h> | 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/sockio.h> 42#include <sys/mbuf.h> 43#include <sys/malloc.h> 44#include <sys/endian.h> 45#include <sys/priv.h> --- 23 unchanged lines hidden (view full) --- 69#include <sys/rman.h> 70 71#include <net80211/ieee80211_var.h> 72#include <net80211/ieee80211_ioctl.h> 73#include <net80211/ieee80211_regdomain.h> 74 75#include <dev/pci/pcireg.h> 76#include <dev/pci/pcivar.h> |
77#include <legacy/dev/usb/usb.h> 78#include <legacy/dev/usb/usbdi.h> | 77#include 78#include <dev/usb/usb_core.h> |
79 80#include <compat/ndis/pe_var.h> 81#include <compat/ndis/cfg_var.h> 82#include <compat/ndis/resource_var.h> 83#include <compat/ndis/ntoskrnl_var.h> 84#include <compat/ndis/hal_var.h> 85#include <compat/ndis/ndis_var.h> 86#include <compat/ndis/usbd_var.h> --- 465 unchanged lines hidden (view full) --- 552 uint8_t bands = 0; 553 int i; 554 555 sc = device_get_softc(dev); 556 557 mtx_init(&sc->ndis_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 558 MTX_DEF); 559 KeInitializeSpinLock(&sc->ndis_rxlock); | 79 80#include <compat/ndis/pe_var.h> 81#include <compat/ndis/cfg_var.h> 82#include <compat/ndis/resource_var.h> 83#include <compat/ndis/ntoskrnl_var.h> 84#include <compat/ndis/hal_var.h> 85#include <compat/ndis/ndis_var.h> 86#include <compat/ndis/usbd_var.h> --- 465 unchanged lines hidden (view full) --- 552 uint8_t bands = 0; 553 int i; 554 555 sc = device_get_softc(dev); 556 557 mtx_init(&sc->ndis_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 558 MTX_DEF); 559 KeInitializeSpinLock(&sc->ndis_rxlock); |
560 KeInitializeSpinLock(&sc->ndisusb_xferlock); | 560 KeInitializeSpinLock(&sc->ndisusb_xferdonelock); |
561 InitializeListHead(&sc->ndis_shlist); | 561 InitializeListHead(&sc->ndis_shlist); |
562 InitializeListHead(&sc->ndisusb_xferlist); | 562 InitializeListHead(&sc->ndisusb_xferdonelist); |
563 callout_init(&sc->ndis_stat_callout, CALLOUT_MPSAFE); 564 565 if (sc->ndis_iftype == PCMCIABus) { 566 error = ndis_alloc_amem(sc); 567 if (error) { 568 device_printf(dev, "failed to allocate " 569 "attribute memory\n"); 570 goto fail; --- 47 unchanged lines hidden (view full) --- 618 sc->ndis_block->nmb_status_func = ndis_linksts_wrap; 619 sc->ndis_block->nmb_statusdone_func = ndis_linksts_done_wrap; 620 621 /* Set up work item handlers. */ 622 sc->ndis_tickitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 623 sc->ndis_startitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 624 sc->ndis_resetitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 625 sc->ndis_inputitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); | 563 callout_init(&sc->ndis_stat_callout, CALLOUT_MPSAFE); 564 565 if (sc->ndis_iftype == PCMCIABus) { 566 error = ndis_alloc_amem(sc); 567 if (error) { 568 device_printf(dev, "failed to allocate " 569 "attribute memory\n"); 570 goto fail; --- 47 unchanged lines hidden (view full) --- 618 sc->ndis_block->nmb_status_func = ndis_linksts_wrap; 619 sc->ndis_block->nmb_statusdone_func = ndis_linksts_done_wrap; 620 621 /* Set up work item handlers. */ 622 sc->ndis_tickitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 623 sc->ndis_startitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 624 sc->ndis_resetitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 625 sc->ndis_inputitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); |
626 sc->ndisusb_xferitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); | 626 sc->ndisusb_xferdoneitem = 627 IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); |
627 KeInitializeDpc(&sc->ndis_rxdpc, ndis_rxeof_xfr_wrap, sc->ndis_block); 628 629 /* Call driver's init routine. */ 630 if (ndis_init_nic(sc)) { 631 device_printf (dev, "init handler failed\n"); 632 error = ENXIO; 633 goto fail; 634 } --- 78 unchanged lines hidden (view full) --- 713 ifp->if_softc = sc; 714 715 /* Check for task offload support. */ 716 ndis_probe_offload(sc); 717 718 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 719 ifp->if_mtu = ETHERMTU; 720 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; | 628 KeInitializeDpc(&sc->ndis_rxdpc, ndis_rxeof_xfr_wrap, sc->ndis_block); 629 630 /* Call driver's init routine. */ 631 if (ndis_init_nic(sc)) { 632 device_printf (dev, "init handler failed\n"); 633 error = ENXIO; 634 goto fail; 635 } --- 78 unchanged lines hidden (view full) --- 714 ifp->if_softc = sc; 715 716 /* Check for task offload support. */ 717 ndis_probe_offload(sc); 718 719 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 720 ifp->if_mtu = ETHERMTU; 721 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; |
721 if (sc->ndis_iftype == PNPBus) 722 ifp->if_flags |= IFF_NEEDSGIANT; | |
723 ifp->if_ioctl = ndis_ioctl; 724 ifp->if_start = ndis_start; 725 ifp->if_init = ndis_init; 726 ifp->if_baudrate = 10000000; 727 IFQ_SET_MAXLEN(&ifp->if_snd, 50); 728 ifp->if_snd.ifq_drv_maxlen = 25; 729 IFQ_SET_READY(&ifp->if_snd); 730 ifp->if_capenable = ifp->if_capabilities; --- 230 unchanged lines hidden (view full) --- 961 if (error) { 962 ndis_detach(dev); 963 return (error); 964 } 965 966 if (sc->ndis_iftype == PNPBus && ndisusb_halt == 0) 967 return (error); 968 | 722 ifp->if_ioctl = ndis_ioctl; 723 ifp->if_start = ndis_start; 724 ifp->if_init = ndis_init; 725 ifp->if_baudrate = 10000000; 726 IFQ_SET_MAXLEN(&ifp->if_snd, 50); 727 ifp->if_snd.ifq_drv_maxlen = 25; 728 IFQ_SET_READY(&ifp->if_snd); 729 ifp->if_capenable = ifp->if_capabilities; --- 230 unchanged lines hidden (view full) --- 960 if (error) { 961 ndis_detach(dev); 962 return (error); 963 } 964 965 if (sc->ndis_iftype == PNPBus && ndisusb_halt == 0) 966 return (error); 967 |
968 DPRINTF(("attach done.\n")); |
|
969 /* We're done talking to the NIC for now; halt it. */ 970 ndis_halt_nic(sc); | 969 /* We're done talking to the NIC for now; halt it. */ 970 ndis_halt_nic(sc); |
971 DPRINTF(("halting done.\n")); |
|
971 972 return(error); 973} 974 975static struct ieee80211vap * 976ndis_vap_create(struct ieee80211com *ic, 977 const char name[IFNAMSIZ], int unit, int opmode, int flags, 978 const uint8_t bssid[IEEE80211_ADDR_LEN], --- 74 unchanged lines hidden (view full) --- 1053 if (sc->ndis_tickitem != NULL) 1054 IoFreeWorkItem(sc->ndis_tickitem); 1055 if (sc->ndis_startitem != NULL) 1056 IoFreeWorkItem(sc->ndis_startitem); 1057 if (sc->ndis_resetitem != NULL) 1058 IoFreeWorkItem(sc->ndis_resetitem); 1059 if (sc->ndis_inputitem != NULL) 1060 IoFreeWorkItem(sc->ndis_inputitem); | 972 973 return(error); 974} 975 976static struct ieee80211vap * 977ndis_vap_create(struct ieee80211com *ic, 978 const char name[IFNAMSIZ], int unit, int opmode, int flags, 979 const uint8_t bssid[IEEE80211_ADDR_LEN], --- 74 unchanged lines hidden (view full) --- 1054 if (sc->ndis_tickitem != NULL) 1055 IoFreeWorkItem(sc->ndis_tickitem); 1056 if (sc->ndis_startitem != NULL) 1057 IoFreeWorkItem(sc->ndis_startitem); 1058 if (sc->ndis_resetitem != NULL) 1059 IoFreeWorkItem(sc->ndis_resetitem); 1060 if (sc->ndis_inputitem != NULL) 1061 IoFreeWorkItem(sc->ndis_inputitem); |
1061 if (sc->ndisusb_xferitem != NULL) 1062 IoFreeWorkItem(sc->ndisusb_xferitem); | 1062 if (sc->ndisusb_xferdoneitem != NULL) 1063 IoFreeWorkItem(sc->ndisusb_xferdoneitem); |
1063 1064 bus_generic_detach(dev); 1065 ndis_unload_driver(sc); 1066 1067 if (sc->ndis_irq) 1068 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq); 1069 if (sc->ndis_res_io) 1070 bus_release_resource(dev, SYS_RES_IOPORT, --- 493 unchanged lines hidden (view full) --- 1564 m = packet->np_m0; 1565 idx = packet->np_txidx; 1566 if (sc->ndis_sc) 1567 bus_dmamap_unload(sc->ndis_ttag, sc->ndis_tmaps[idx]); 1568 1569 ndis_free_packet(packet); 1570 m_freem(m); 1571 | 1064 1065 bus_generic_detach(dev); 1066 ndis_unload_driver(sc); 1067 1068 if (sc->ndis_irq) 1069 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq); 1070 if (sc->ndis_res_io) 1071 bus_release_resource(dev, SYS_RES_IOPORT, --- 493 unchanged lines hidden (view full) --- 1565 m = packet->np_m0; 1566 idx = packet->np_txidx; 1567 if (sc->ndis_sc) 1568 bus_dmamap_unload(sc->ndis_ttag, sc->ndis_tmaps[idx]); 1569 1570 ndis_free_packet(packet); 1571 m_freem(m); 1572 |
1572 NDISMTX_LOCK(sc); | 1573 NDIS_LOCK(sc); |
1573 sc->ndis_txarray[idx] = NULL; 1574 sc->ndis_txpending++; 1575 1576 if (status == NDIS_STATUS_SUCCESS) 1577 ifp->if_opackets++; 1578 else 1579 ifp->if_oerrors++; 1580 1581 sc->ndis_tx_timer = 0; 1582 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1583 | 1574 sc->ndis_txarray[idx] = NULL; 1575 sc->ndis_txpending++; 1576 1577 if (status == NDIS_STATUS_SUCCESS) 1578 ifp->if_opackets++; 1579 else 1580 ifp->if_oerrors++; 1581 1582 sc->ndis_tx_timer = 0; 1583 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1584 |
1584 NDISMTX_UNLOCK(sc); | 1585 NDIS_UNLOCK(sc); |
1585 1586 IoQueueWorkItem(sc->ndis_startitem, 1587 (io_workitem_func)ndis_starttask_wrap, 1588 WORKQUEUE_CRITICAL, ifp); 1589 1590 return; 1591} 1592 --- 8 unchanged lines hidden (view full) --- 1601 struct ndis_softc *sc; 1602 1603 block = adapter; 1604 sc = device_get_softc(block->nmb_physdeviceobj->do_devext); 1605 sc->ndis_sts = status; 1606 1607 /* Event list is all full up, drop this one. */ 1608 | 1586 1587 IoQueueWorkItem(sc->ndis_startitem, 1588 (io_workitem_func)ndis_starttask_wrap, 1589 WORKQUEUE_CRITICAL, ifp); 1590 1591 return; 1592} 1593 --- 8 unchanged lines hidden (view full) --- 1602 struct ndis_softc *sc; 1603 1604 block = adapter; 1605 sc = device_get_softc(block->nmb_physdeviceobj->do_devext); 1606 sc->ndis_sts = status; 1607 1608 /* Event list is all full up, drop this one. */ 1609 |
1609 NDISMTX_LOCK(sc); | 1610 NDIS_LOCK(sc); |
1610 if (sc->ndis_evt[sc->ndis_evtpidx].ne_sts) { | 1611 if (sc->ndis_evt[sc->ndis_evtpidx].ne_sts) { |
1611 NDISMTX_UNLOCK(sc); | 1612 NDIS_UNLOCK(sc); |
1612 return; 1613 } 1614 1615 /* Cache the event. */ 1616 1617 if (slen) { 1618 sc->ndis_evt[sc->ndis_evtpidx].ne_buf = malloc(slen, 1619 M_TEMP, M_NOWAIT); 1620 if (sc->ndis_evt[sc->ndis_evtpidx].ne_buf == NULL) { | 1613 return; 1614 } 1615 1616 /* Cache the event. */ 1617 1618 if (slen) { 1619 sc->ndis_evt[sc->ndis_evtpidx].ne_buf = malloc(slen, 1620 M_TEMP, M_NOWAIT); 1621 if (sc->ndis_evt[sc->ndis_evtpidx].ne_buf == NULL) { |
1621 NDISMTX_UNLOCK(sc); | 1622 NDIS_UNLOCK(sc); |
1622 return; 1623 } 1624 bcopy((char *)sbuf, 1625 sc->ndis_evt[sc->ndis_evtpidx].ne_buf, slen); 1626 } 1627 sc->ndis_evt[sc->ndis_evtpidx].ne_sts = status; 1628 sc->ndis_evt[sc->ndis_evtpidx].ne_len = slen; 1629 NDIS_EVTINC(sc->ndis_evtpidx); | 1623 return; 1624 } 1625 bcopy((char *)sbuf, 1626 sc->ndis_evt[sc->ndis_evtpidx].ne_buf, slen); 1627 } 1628 sc->ndis_evt[sc->ndis_evtpidx].ne_sts = status; 1629 sc->ndis_evt[sc->ndis_evtpidx].ne_len = slen; 1630 NDIS_EVTINC(sc->ndis_evtpidx); |
1630 NDISMTX_UNLOCK(sc); | 1631 NDIS_UNLOCK(sc); |
1631 1632 return; 1633} 1634 1635static void 1636ndis_linksts_done(adapter) 1637 ndis_handle adapter; 1638{ --- 1871 unchanged lines hidden --- | 1632 1633 return; 1634} 1635 1636static void 1637ndis_linksts_done(adapter) 1638 ndis_handle adapter; 1639{ --- 1871 unchanged lines hidden --- |