if_ndis.c (151241) | if_ndis.c (151451) |
---|---|
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 151241 2005-10-11 21:31:23Z wpaul $"); | 37__FBSDID("$FreeBSD: head/sys/dev/if_ndis/if_ndis.c 151451 2005-10-18 19:52:15Z wpaul $"); |
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/kernel.h> 45#include <sys/socket.h> --- 69 unchanged lines hidden (view full) --- 115static funcptr ndis_rxeof_done_wrap; 116static funcptr ndis_rxeof_xfr_wrap; 117static funcptr ndis_rxeof_xfr_done_wrap; 118static funcptr ndis_linksts_wrap; 119static funcptr ndis_linksts_done_wrap; 120static funcptr ndis_ticktask_wrap; 121static funcptr ndis_starttask_wrap; 122static funcptr ndis_resettask_wrap; | 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/kernel.h> 45#include <sys/socket.h> --- 69 unchanged lines hidden (view full) --- 115static funcptr ndis_rxeof_done_wrap; 116static funcptr ndis_rxeof_xfr_wrap; 117static funcptr ndis_rxeof_xfr_done_wrap; 118static funcptr ndis_linksts_wrap; 119static funcptr ndis_linksts_done_wrap; 120static funcptr ndis_ticktask_wrap; 121static funcptr ndis_starttask_wrap; 122static funcptr ndis_resettask_wrap; |
123static funcptr ndis_inputtask_wrap; |
|
123 124static void ndis_tick (void *); 125static void ndis_ticktask (device_object *, void *); 126static void ndis_start (struct ifnet *); 127static void ndis_starttask (device_object *, void *); 128static void ndis_resettask (device_object *, void *); | 124 125static void ndis_tick (void *); 126static void ndis_ticktask (device_object *, void *); 127static void ndis_start (struct ifnet *); 128static void ndis_starttask (device_object *, void *); 129static void ndis_resettask (device_object *, void *); |
130static void ndis_inputtask (device_object *, void *); |
|
129static int ndis_ioctl (struct ifnet *, u_long, caddr_t); 130static int ndis_wi_ioctl_get (struct ifnet *, u_long, caddr_t); 131static int ndis_wi_ioctl_set (struct ifnet *, u_long, caddr_t); 132static int ndis_80211_ioctl_get (struct ifnet *, u_long, caddr_t); 133static int ndis_80211_ioctl_set (struct ifnet *, u_long, caddr_t); 134static void ndis_init (void *); 135static void ndis_stop (struct ndis_softc *); 136static void ndis_watchdog (struct ifnet *); --- 57 unchanged lines hidden (view full) --- 194 windrv_wrap((funcptr)ndis_linksts_done, 195 &ndis_linksts_done_wrap, 1, WINDRV_WRAP_STDCALL); 196 windrv_wrap((funcptr)ndis_ticktask, &ndis_ticktask_wrap, 197 2, WINDRV_WRAP_STDCALL); 198 windrv_wrap((funcptr)ndis_starttask, &ndis_starttask_wrap, 199 2, WINDRV_WRAP_STDCALL); 200 windrv_wrap((funcptr)ndis_resettask, &ndis_resettask_wrap, 201 2, WINDRV_WRAP_STDCALL); | 131static int ndis_ioctl (struct ifnet *, u_long, caddr_t); 132static int ndis_wi_ioctl_get (struct ifnet *, u_long, caddr_t); 133static int ndis_wi_ioctl_set (struct ifnet *, u_long, caddr_t); 134static int ndis_80211_ioctl_get (struct ifnet *, u_long, caddr_t); 135static int ndis_80211_ioctl_set (struct ifnet *, u_long, caddr_t); 136static void ndis_init (void *); 137static void ndis_stop (struct ndis_softc *); 138static void ndis_watchdog (struct ifnet *); --- 57 unchanged lines hidden (view full) --- 196 windrv_wrap((funcptr)ndis_linksts_done, 197 &ndis_linksts_done_wrap, 1, WINDRV_WRAP_STDCALL); 198 windrv_wrap((funcptr)ndis_ticktask, &ndis_ticktask_wrap, 199 2, WINDRV_WRAP_STDCALL); 200 windrv_wrap((funcptr)ndis_starttask, &ndis_starttask_wrap, 201 2, WINDRV_WRAP_STDCALL); 202 windrv_wrap((funcptr)ndis_resettask, &ndis_resettask_wrap, 203 2, WINDRV_WRAP_STDCALL); |
204 windrv_wrap((funcptr)ndis_inputtask, &ndis_inputtask_wrap, 205 2, WINDRV_WRAP_STDCALL); |
|
202 break; 203 case MOD_UNLOAD: 204 ndisdrv_loaded--; 205 if (ndisdrv_loaded > 0) 206 break; 207 /* fallthrough */ 208 case MOD_SHUTDOWN: 209 windrv_unwrap(ndis_rxeof_wrap); 210 windrv_unwrap(ndis_rxeof_eth_wrap); 211 windrv_unwrap(ndis_rxeof_done_wrap); 212 windrv_unwrap(ndis_rxeof_xfr_wrap); 213 windrv_unwrap(ndis_rxeof_xfr_done_wrap); 214 windrv_unwrap(ndis_txeof_wrap); 215 windrv_unwrap(ndis_linksts_wrap); 216 windrv_unwrap(ndis_linksts_done_wrap); 217 windrv_unwrap(ndis_ticktask_wrap); 218 windrv_unwrap(ndis_starttask_wrap); 219 windrv_unwrap(ndis_resettask_wrap); | 206 break; 207 case MOD_UNLOAD: 208 ndisdrv_loaded--; 209 if (ndisdrv_loaded > 0) 210 break; 211 /* fallthrough */ 212 case MOD_SHUTDOWN: 213 windrv_unwrap(ndis_rxeof_wrap); 214 windrv_unwrap(ndis_rxeof_eth_wrap); 215 windrv_unwrap(ndis_rxeof_done_wrap); 216 windrv_unwrap(ndis_rxeof_xfr_wrap); 217 windrv_unwrap(ndis_rxeof_xfr_done_wrap); 218 windrv_unwrap(ndis_txeof_wrap); 219 windrv_unwrap(ndis_linksts_wrap); 220 windrv_unwrap(ndis_linksts_done_wrap); 221 windrv_unwrap(ndis_ticktask_wrap); 222 windrv_unwrap(ndis_starttask_wrap); 223 windrv_unwrap(ndis_resettask_wrap); |
224 windrv_unwrap(ndis_inputtask_wrap); |
|
220 break; 221 default: 222 error = EINVAL; 223 break; 224 } 225 226 return (error); 227} --- 255 unchanged lines hidden (view full) --- 483 if (ifp == NULL) { 484 error = ENOSPC; 485 goto fail; 486 } 487#endif 488 ifp->if_softc = sc; 489 490 KeInitializeSpinLock(&sc->ndis_spinlock); | 225 break; 226 default: 227 error = EINVAL; 228 break; 229 } 230 231 return (error); 232} --- 255 unchanged lines hidden (view full) --- 488 if (ifp == NULL) { 489 error = ENOSPC; 490 goto fail; 491 } 492#endif 493 ifp->if_softc = sc; 494 495 KeInitializeSpinLock(&sc->ndis_spinlock); |
496 KeInitializeSpinLock(&sc->ndis_rxlock); |
|
491 InitializeListHead(&sc->ndis_shlist); 492 493 if (sc->ndis_iftype == PCMCIABus) { 494 error = ndis_alloc_amem(sc); 495 if (error) { 496 device_printf(dev, "failed to allocate " 497 "attribute memory\n"); 498 goto fail; --- 67 unchanged lines hidden (view full) --- 566 len = sizeof(sc->ndis_maxpkts); 567 if (ndis_get_info(sc, OID_GEN_MAXIMUM_SEND_PACKETS, 568 &sc->ndis_maxpkts, &len)) { 569 device_printf (dev, "failed to get max TX packets\n"); 570 error = ENXIO; 571 goto fail; 572 } 573 | 497 InitializeListHead(&sc->ndis_shlist); 498 499 if (sc->ndis_iftype == PCMCIABus) { 500 error = ndis_alloc_amem(sc); 501 if (error) { 502 device_printf(dev, "failed to allocate " 503 "attribute memory\n"); 504 goto fail; --- 67 unchanged lines hidden (view full) --- 572 len = sizeof(sc->ndis_maxpkts); 573 if (ndis_get_info(sc, OID_GEN_MAXIMUM_SEND_PACKETS, 574 &sc->ndis_maxpkts, &len)) { 575 device_printf (dev, "failed to get max TX packets\n"); 576 error = ENXIO; 577 goto fail; 578 } 579 |
580 /* 581 * If this is a deserialized miniport, we don't have 582 * to honor the OID_GEN_MAXIMUM_SEND_PACKETS result. 583 */ 584 585 if (!NDIS_SERIALIZED(sc->ndis_block)) 586 sc->ndis_maxpkts = NDIS_TXPKTS; 587 |
|
574 /* Enforce some sanity, just in case. */ 575 576 if (sc->ndis_maxpkts == 0) 577 sc->ndis_maxpkts = 10; 578 579 sc->ndis_txarray = malloc(sizeof(ndis_packet *) * 580 sc->ndis_maxpkts, M_DEVBUF, M_NOWAIT|M_ZERO); 581 582 /* Allocate a pool of ndis_packets for TX encapsulation. */ 583 584 NdisAllocatePacketPool(&i, &sc->ndis_txpool, | 588 /* Enforce some sanity, just in case. */ 589 590 if (sc->ndis_maxpkts == 0) 591 sc->ndis_maxpkts = 10; 592 593 sc->ndis_txarray = malloc(sizeof(ndis_packet *) * 594 sc->ndis_maxpkts, M_DEVBUF, M_NOWAIT|M_ZERO); 595 596 /* Allocate a pool of ndis_packets for TX encapsulation. */ 597 598 NdisAllocatePacketPool(&i, &sc->ndis_txpool, |
585 sc->ndis_maxpkts, PROTOCOL_RESERVED_SIZE_IN_PACKET); | 599 NDIS_TXPKTS, PROTOCOL_RESERVED_SIZE_IN_PACKET); |
586 587 if (i != NDIS_STATUS_SUCCESS) { 588 sc->ndis_txpool = NULL; 589 device_printf(dev, "failed to allocate TX packet pool"); 590 error = ENOMEM; 591 goto fail; 592 } 593 --- 17 unchanged lines hidden (view full) --- 611 sc->ndis_80211++; 612 break; 613 } 614 } 615 616 /* Check for task offload support. */ 617 ndis_probe_offload(sc); 618 | 600 601 if (i != NDIS_STATUS_SUCCESS) { 602 sc->ndis_txpool = NULL; 603 device_printf(dev, "failed to allocate TX packet pool"); 604 error = ENOMEM; 605 goto fail; 606 } 607 --- 17 unchanged lines hidden (view full) --- 625 sc->ndis_80211++; 626 break; 627 } 628 } 629 630 /* Check for task offload support. */ 631 ndis_probe_offload(sc); 632 |
633#if __FreeBSD_version < 502109 634 /* 635 * An NDIS device was detected. Inform the world. 636 */ 637 device_printf(dev, "%s address: %6D\n", 638 sc->ndis_80211 ? "802.11" : "Ethernet", eaddr, ":"); 639#endif 640 |
|
619 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 620 ifp->if_mtu = ETHERMTU; 621 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 622 ifp->if_ioctl = ndis_ioctl; 623 ifp->if_start = ndis_start; 624 ifp->if_watchdog = ndis_watchdog; 625 ifp->if_init = ndis_init; 626 ifp->if_baudrate = 10000000; --- 256 unchanged lines hidden (view full) --- 883 /* Override the status handler so we can detect link changes. */ 884 sc->ndis_block->nmb_status_func = ndis_linksts_wrap; 885 sc->ndis_block->nmb_statusdone_func = ndis_linksts_done_wrap; 886 887 /* Set up work item handlers. */ 888 sc->ndis_tickitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 889 sc->ndis_startitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 890 sc->ndis_resetitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); | 641 if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 642 ifp->if_mtu = ETHERMTU; 643 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 644 ifp->if_ioctl = ndis_ioctl; 645 ifp->if_start = ndis_start; 646 ifp->if_watchdog = ndis_watchdog; 647 ifp->if_init = ndis_init; 648 ifp->if_baudrate = 10000000; --- 256 unchanged lines hidden (view full) --- 905 /* Override the status handler so we can detect link changes. */ 906 sc->ndis_block->nmb_status_func = ndis_linksts_wrap; 907 sc->ndis_block->nmb_statusdone_func = ndis_linksts_done_wrap; 908 909 /* Set up work item handlers. */ 910 sc->ndis_tickitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 911 sc->ndis_startitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); 912 sc->ndis_resetitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); |
913 sc->ndis_inputitem = IoAllocateWorkItem(sc->ndis_block->nmb_deviceobj); |
|
891 KeInitializeDpc(&sc->ndis_rxdpc, ndis_rxeof_xfr_wrap, sc->ndis_block); 892 893 894fail: 895 if (error) 896 ndis_detach(dev); 897 else 898 /* We're done talking to the NIC for now; halt it. */ --- 37 unchanged lines hidden (view full) --- 936 NDIS_UNLOCK(sc); 937 938 if (sc->ndis_tickitem != NULL) 939 IoFreeWorkItem(sc->ndis_tickitem); 940 if (sc->ndis_startitem != NULL) 941 IoFreeWorkItem(sc->ndis_startitem); 942 if (sc->ndis_resetitem != NULL) 943 IoFreeWorkItem(sc->ndis_resetitem); | 914 KeInitializeDpc(&sc->ndis_rxdpc, ndis_rxeof_xfr_wrap, sc->ndis_block); 915 916 917fail: 918 if (error) 919 ndis_detach(dev); 920 else 921 /* We're done talking to the NIC for now; halt it. */ --- 37 unchanged lines hidden (view full) --- 959 NDIS_UNLOCK(sc); 960 961 if (sc->ndis_tickitem != NULL) 962 IoFreeWorkItem(sc->ndis_tickitem); 963 if (sc->ndis_startitem != NULL) 964 IoFreeWorkItem(sc->ndis_startitem); 965 if (sc->ndis_resetitem != NULL) 966 IoFreeWorkItem(sc->ndis_resetitem); |
967 if (sc->ndis_inputitem != NULL) 968 IoFreeWorkItem(sc->ndis_inputitem); |
|
944 945 bus_generic_detach(dev); 946 947 if (sc->ndis_irq) 948 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq); 949 if (sc->ndis_res_io) 950 bus_release_resource(dev, SYS_RES_IOPORT, 951 sc->ndis_io_rid, sc->ndis_res_io); --- 80 unchanged lines hidden (view full) --- 1032 ndis_init(sc); 1033 1034 return(0); 1035} 1036 1037/* 1038 * The following bunch of routines are here to support drivers that 1039 * use the NdisMEthIndicateReceive()/MiniportTransferData() mechanism. | 969 970 bus_generic_detach(dev); 971 972 if (sc->ndis_irq) 973 bus_release_resource(dev, SYS_RES_IRQ, 0, sc->ndis_irq); 974 if (sc->ndis_res_io) 975 bus_release_resource(dev, SYS_RES_IOPORT, 976 sc->ndis_io_rid, sc->ndis_res_io); --- 80 unchanged lines hidden (view full) --- 1057 ndis_init(sc); 1058 1059 return(0); 1060} 1061 1062/* 1063 * The following bunch of routines are here to support drivers that 1064 * use the NdisMEthIndicateReceive()/MiniportTransferData() mechanism. |
1065 * The NdisMEthIndicateReceive() handler runs at DISPATCH_LEVEL for 1066 * serialized miniports, or IRQL <= DISPATCH_LEVEL for deserialized 1067 * miniports. |
|
1040 */ 1041 1042static void 1043ndis_rxeof_eth(adapter, ctx, addr, hdr, hdrlen, lookahead, lookaheadlen, pktlen) 1044 ndis_handle adapter; 1045 ndis_handle ctx; 1046 char *addr; 1047 void *hdr; --- 50 unchanged lines hidden (view full) --- 1098 p->np_private.npp_totlen = m->m_pkthdr.len; 1099 1100 /* Save the packet RX context somewhere. */ 1101 priv = (ndis_ethpriv *)&p->np_protocolreserved; 1102 priv->nep_ctx = ctx; 1103 1104 KeAcquireSpinLock(&block->nmb_lock, &irql); 1105 | 1068 */ 1069 1070static void 1071ndis_rxeof_eth(adapter, ctx, addr, hdr, hdrlen, lookahead, lookaheadlen, pktlen) 1072 ndis_handle adapter; 1073 ndis_handle ctx; 1074 char *addr; 1075 void *hdr; --- 50 unchanged lines hidden (view full) --- 1126 p->np_private.npp_totlen = m->m_pkthdr.len; 1127 1128 /* Save the packet RX context somewhere. */ 1129 priv = (ndis_ethpriv *)&p->np_protocolreserved; 1130 priv->nep_ctx = ctx; 1131 1132 KeAcquireSpinLock(&block->nmb_lock, &irql); 1133 |
1106 InsertTailList((&block->nmb_packetlist), 1107 ((list_entry *)&p->u.np_clrsvd.np_miniport_rsvd)); | 1134 InsertTailList((&block->nmb_packetlist), (&p->np_list)); |
1108 1109 KeReleaseSpinLock(&block->nmb_lock, irql); 1110 1111 return; 1112} 1113 | 1135 1136 KeReleaseSpinLock(&block->nmb_lock, irql); 1137 1138 return; 1139} 1140 |
1141/* 1142 * NdisMEthIndicateReceiveComplete() handler, runs at DISPATCH_LEVEL 1143 * for serialized miniports, or IRQL <= DISPATCH_LEVEL for deserialized 1144 * miniports. 1145 */ 1146 |
|
1114static void 1115ndis_rxeof_done(adapter) 1116 ndis_handle adapter; 1117{ 1118 struct ndis_softc *sc; 1119 ndis_miniport_block *block; 1120 1121 block = adapter; 1122 1123 /* Schedule transfer/RX of queued packets. */ 1124 1125 sc = device_get_softc(block->nmb_physdeviceobj->do_devext); 1126 1127 KeInsertQueueDpc(&sc->ndis_rxdpc, NULL, NULL); 1128 1129 return; 1130} 1131 1132/* | 1147static void 1148ndis_rxeof_done(adapter) 1149 ndis_handle adapter; 1150{ 1151 struct ndis_softc *sc; 1152 ndis_miniport_block *block; 1153 1154 block = adapter; 1155 1156 /* Schedule transfer/RX of queued packets. */ 1157 1158 sc = device_get_softc(block->nmb_physdeviceobj->do_devext); 1159 1160 KeInsertQueueDpc(&sc->ndis_rxdpc, NULL, NULL); 1161 1162 return; 1163} 1164 1165/* |
1133 * Runs at DISPATCH_LEVEL. | 1166 * MiniportTransferData() handler, runs at DISPATCH_LEVEL. |
1134 */ 1135static void 1136ndis_rxeof_xfr(dpc, adapter, sysarg1, sysarg2) 1137 kdpc *dpc; 1138 ndis_handle adapter; 1139 void *sysarg1; 1140 void *sysarg2; 1141{ --- 10 unchanged lines hidden (view full) --- 1152 sc = device_get_softc(block->nmb_physdeviceobj->do_devext); 1153 ifp = sc->ifp; 1154 1155 KeAcquireSpinLockAtDpcLevel(&block->nmb_lock); 1156 1157 l = block->nmb_packetlist.nle_flink; 1158 while(!IsListEmpty(&block->nmb_packetlist)) { 1159 l = RemoveHeadList((&block->nmb_packetlist)); | 1167 */ 1168static void 1169ndis_rxeof_xfr(dpc, adapter, sysarg1, sysarg2) 1170 kdpc *dpc; 1171 ndis_handle adapter; 1172 void *sysarg1; 1173 void *sysarg2; 1174{ --- 10 unchanged lines hidden (view full) --- 1185 sc = device_get_softc(block->nmb_physdeviceobj->do_devext); 1186 ifp = sc->ifp; 1187 1188 KeAcquireSpinLockAtDpcLevel(&block->nmb_lock); 1189 1190 l = block->nmb_packetlist.nle_flink; 1191 while(!IsListEmpty(&block->nmb_packetlist)) { 1192 l = RemoveHeadList((&block->nmb_packetlist)); |
1160 p = CONTAINING_RECORD(l, ndis_packet, 1161 u.np_clrsvd.np_miniport_rsvd); | 1193 p = CONTAINING_RECORD(l, ndis_packet, np_list); 1194 InitializeListHead((&p->np_list)); |
1162 1163 priv = (ndis_ethpriv *)&p->np_protocolreserved; 1164 m = p->np_m0; 1165 p->np_softc = sc; 1166 p->np_m0 = NULL; 1167 1168 KeReleaseSpinLockFromDpcLevel(&block->nmb_lock); 1169 --- 10 unchanged lines hidden (view full) --- 1180 */ 1181 1182 m->m_len = m->m_pkthdr.len; 1183 m->m_pkthdr.rcvif = ifp; 1184 1185 if (status == NDIS_STATUS_SUCCESS) { 1186 IoFreeMdl(p->np_private.npp_head); 1187 NdisFreePacket(p); | 1195 1196 priv = (ndis_ethpriv *)&p->np_protocolreserved; 1197 m = p->np_m0; 1198 p->np_softc = sc; 1199 p->np_m0 = NULL; 1200 1201 KeReleaseSpinLockFromDpcLevel(&block->nmb_lock); 1202 --- 10 unchanged lines hidden (view full) --- 1213 */ 1214 1215 m->m_len = m->m_pkthdr.len; 1216 m->m_pkthdr.rcvif = ifp; 1217 1218 if (status == NDIS_STATUS_SUCCESS) { 1219 IoFreeMdl(p->np_private.npp_head); 1220 NdisFreePacket(p); |
1188 ifp->if_ipackets++; 1189 (*ifp->if_input)(ifp, m); | 1221 KeAcquireSpinLockAtDpcLevel(&sc->ndis_rxlock); 1222 _IF_ENQUEUE(&sc->ndis_rxqueue, m); 1223 KeReleaseSpinLockFromDpcLevel(&sc->ndis_rxlock); 1224 IoQueueWorkItem(sc->ndis_inputitem, 1225 (io_workitem_func)ndis_inputtask_wrap, 1226 WORKQUEUE_CRITICAL, ifp); |
1190 } 1191 1192 if (status == NDIS_STATUS_FAILURE) 1193 m_freem(m); 1194 1195 /* Advance to next packet */ 1196 l = block->nmb_packetlist.nle_flink; 1197 } 1198 1199 KeReleaseSpinLockFromDpcLevel(&block->nmb_lock); 1200 1201 return; 1202} 1203 | 1227 } 1228 1229 if (status == NDIS_STATUS_FAILURE) 1230 m_freem(m); 1231 1232 /* Advance to next packet */ 1233 l = block->nmb_packetlist.nle_flink; 1234 } 1235 1236 KeReleaseSpinLockFromDpcLevel(&block->nmb_lock); 1237 1238 return; 1239} 1240 |
1241/* 1242 * NdisMTransferDataComplete() handler, runs at DISPATCH_LEVEL. 1243 */ |
|
1204static void 1205ndis_rxeof_xfr_done(adapter, packet, status, len) 1206 ndis_handle adapter; 1207 ndis_packet *packet; 1208 uint32_t status; 1209 uint32_t len; 1210{ 1211 ndis_miniport_block *block; --- 11 unchanged lines hidden (view full) --- 1223 1224 if (status != NDIS_STATUS_SUCCESS) { 1225 m_freem(m); 1226 return; 1227 } 1228 1229 m->m_len = m->m_pkthdr.len; 1230 m->m_pkthdr.rcvif = ifp; | 1244static void 1245ndis_rxeof_xfr_done(adapter, packet, status, len) 1246 ndis_handle adapter; 1247 ndis_packet *packet; 1248 uint32_t status; 1249 uint32_t len; 1250{ 1251 ndis_miniport_block *block; --- 11 unchanged lines hidden (view full) --- 1263 1264 if (status != NDIS_STATUS_SUCCESS) { 1265 m_freem(m); 1266 return; 1267 } 1268 1269 m->m_len = m->m_pkthdr.len; 1270 m->m_pkthdr.rcvif = ifp; |
1231 ifp->if_ipackets++; 1232 (*ifp->if_input)(ifp, m); | 1271 KeAcquireSpinLockAtDpcLevel(&sc->ndis_rxlock); 1272 _IF_ENQUEUE(&sc->ndis_rxqueue, m); 1273 KeReleaseSpinLockFromDpcLevel(&sc->ndis_rxlock); 1274 IoQueueWorkItem(sc->ndis_inputitem, 1275 (io_workitem_func)ndis_inputtask_wrap, 1276 WORKQUEUE_CRITICAL, ifp); 1277 |
1233 return; 1234} 1235/* 1236 * A frame has been uploaded: pass the resulting mbuf chain up to 1237 * the higher level protocols. 1238 * 1239 * When handling received NDIS packets, the 'status' field in the 1240 * out-of-band portion of the ndis_packet has special meaning. In the --- 65 unchanged lines hidden (view full) --- 1306 p->np_oob.npo_status = NDIS_STATUS_PENDING; 1307 m_freem(m0); 1308 if (m == NULL) { 1309 ifp->if_ierrors++; 1310 continue; 1311 } 1312 m0 = m; 1313 m0->m_pkthdr.rcvif = ifp; | 1278 return; 1279} 1280/* 1281 * A frame has been uploaded: pass the resulting mbuf chain up to 1282 * the higher level protocols. 1283 * 1284 * When handling received NDIS packets, the 'status' field in the 1285 * out-of-band portion of the ndis_packet has special meaning. In the --- 65 unchanged lines hidden (view full) --- 1351 p->np_oob.npo_status = NDIS_STATUS_PENDING; 1352 m_freem(m0); 1353 if (m == NULL) { 1354 ifp->if_ierrors++; 1355 continue; 1356 } 1357 m0 = m; 1358 m0->m_pkthdr.rcvif = ifp; |
1314 ifp->if_ipackets++; | |
1315 1316 /* Deal with checksum offload. */ 1317 1318 if (ifp->if_capenable & IFCAP_RXCSUM && 1319 p->np_ext.npe_info[ndis_tcpipcsum_info] != NULL) { 1320 s = (uintptr_t) 1321 p->np_ext.npe_info[ndis_tcpipcsum_info]; 1322 csum = (ndis_tcpip_csum *)&s; --- 5 unchanged lines hidden (view full) --- 1328 (NDIS_RXCSUM_TCP_PASSED | 1329 NDIS_RXCSUM_UDP_PASSED)) { 1330 m0->m_pkthdr.csum_flags |= 1331 CSUM_DATA_VALID|CSUM_PSEUDO_HDR; 1332 m0->m_pkthdr.csum_data = 0xFFFF; 1333 } 1334 } 1335 | 1359 1360 /* Deal with checksum offload. */ 1361 1362 if (ifp->if_capenable & IFCAP_RXCSUM && 1363 p->np_ext.npe_info[ndis_tcpipcsum_info] != NULL) { 1364 s = (uintptr_t) 1365 p->np_ext.npe_info[ndis_tcpipcsum_info]; 1366 csum = (ndis_tcpip_csum *)&s; --- 5 unchanged lines hidden (view full) --- 1372 (NDIS_RXCSUM_TCP_PASSED | 1373 NDIS_RXCSUM_UDP_PASSED)) { 1374 m0->m_pkthdr.csum_flags |= 1375 CSUM_DATA_VALID|CSUM_PSEUDO_HDR; 1376 m0->m_pkthdr.csum_data = 0xFFFF; 1377 } 1378 } 1379 |
1336 (*ifp->if_input)(ifp, m0); | 1380 KeAcquireSpinLockAtDpcLevel(&sc->ndis_rxlock); 1381 _IF_ENQUEUE(&sc->ndis_rxqueue, m); 1382 KeReleaseSpinLockFromDpcLevel(&sc->ndis_rxlock); 1383 IoQueueWorkItem(sc->ndis_inputitem, 1384 (io_workitem_func)ndis_inputtask_wrap, 1385 WORKQUEUE_CRITICAL, ifp); |
1337 } 1338 } 1339 1340 return; 1341} 1342 1343/* | 1386 } 1387 } 1388 1389 return; 1390} 1391 1392/* |
1393 * This routine is run at PASSIVE_LEVEL. We use this routine to pass 1394 * packets into the stack in order to avoid calling (*ifp->if_input)() 1395 * with any locks held (at DISPATCH_LEVEL, we'll be holding the 1396 * 'dispatch level' per-cpu sleep lock). 1397 */ 1398 1399static void 1400ndis_inputtask(dobj, arg) 1401 device_object *dobj; 1402 void *arg; 1403{ 1404 ndis_miniport_block *block; 1405 struct ifnet *ifp; 1406 struct ndis_softc *sc; 1407 struct mbuf *m; 1408 uint8_t irql; 1409 1410 ifp = arg; 1411 sc = ifp->if_softc; 1412 block = dobj->do_devext; 1413 1414 KeAcquireSpinLock(&sc->ndis_rxlock, &irql); 1415 while(1) { 1416 _IF_DEQUEUE(&sc->ndis_rxqueue, m); 1417 if (m == NULL) 1418 break; 1419 KeReleaseSpinLock(&sc->ndis_rxlock, irql); 1420 ifp->if_ipackets++; 1421 (*ifp->if_input)(ifp, m); 1422 KeAcquireSpinLock(&sc->ndis_rxlock, &irql); 1423 } 1424 KeReleaseSpinLock(&sc->ndis_rxlock, irql); 1425 1426 return; 1427} 1428 1429/* |
|
1344 * A frame was downloaded to the chip. It's safe for us to clean up 1345 * the list buffers. 1346 */ 1347static void 1348ndis_txeof(adapter, packet, status) 1349 ndis_handle adapter; 1350 ndis_packet *packet; 1351 ndis_status status; --- 1971 unchanged lines hidden --- | 1430 * A frame was downloaded to the chip. It's safe for us to clean up 1431 * the list buffers. 1432 */ 1433static void 1434ndis_txeof(adapter, packet, status) 1435 ndis_handle adapter; 1436 ndis_packet *packet; 1437 ndis_status status; --- 1971 unchanged lines hidden --- |