win-pvdrivers

changeset 132:1f482a9da56e

Merge with head
author James Harper <james.harper@bendigoit.com.au>
date Fri Jan 18 20:11:03 2008 +1100 (2008-01-18)
parents 415597314479
children e5e6978fd09e
files xenenum/xenenum.c xennet/sources xennet/xennet.c xenpci/sources xenpci/xenbus.c
line diff
     1.1 --- a/xenenum/xenenum.c	Thu Jan 17 12:25:54 2008 -0800
     1.2 +++ b/xenenum/xenenum.c	Fri Jan 18 20:11:03 2008 +1100
     1.3 @@ -305,37 +305,19 @@ XenEnum_D0EntryPostInterruptsEnabled(WDF
     1.4    KeInitializeEvent(&WaitDevicesEvent, SynchronizationEvent, FALSE);  
     1.5  
     1.6    // TODO: Should probably do this in an EvtChildListScanForChildren
     1.7 -/*
     1.8 -  if (AutoEnumerate)
     1.9 +  // TODO: Get the correct path from parent here...
    1.10 +  msg = XenInterface.XenBus_List(XenInterface.InterfaceHeader.Context, XBT_NIL, PdoDeviceData->Path, &Devices);
    1.11 +  if (!msg)
    1.12    {
    1.13 -*/
    1.14 -    // TODO: Get the correct path from parent here...
    1.15 -    msg = XenInterface.XenBus_List(XenInterface.InterfaceHeader.Context, XBT_NIL, PdoDeviceData->Path, &Devices);
    1.16 -    if (!msg)
    1.17 +    for (i = 0; Devices[i]; i++)
    1.18      {
    1.19 -      for (i = 0; Devices[i]; i++)
    1.20 -      {
    1.21 -        KdPrint((__DRIVER_NAME "     found existing device %s\n", Devices[i]));
    1.22 -        KdPrint((__DRIVER_NAME "     faking watch event for %s/%s", PdoDeviceData->Path, Devices[i]));
    1.23 -        RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "%s/%s", PdoDeviceData->Path, Devices[i]);
    1.24 -        XenEnum_WatchHandler(buffer, Device);
    1.25 -        //ExFreePoolWithTag(Devices[i], XENPCI_POOL_TAG);
    1.26 -      }
    1.27 -/*
    1.28 -      KdPrint((__DRIVER_NAME "     Waiting for devices to be enumerated\n"));
    1.29 -      while (EnumeratedDevices != i)
    1.30 -      {
    1.31 -        WaitTimeout.QuadPart = -600000000;
    1.32 -        if (KeWaitForSingleObject(&WaitDevicesEvent, Executive, KernelMode, FALSE, &WaitTimeout) == STATUS_TIMEOUT)
    1.33 -        {
    1.34 -          KdPrint((__DRIVER_NAME "     Wait timed out\n"));
    1.35 -          break;
    1.36 -        }
    1.37 -        KdPrint((__DRIVER_NAME "     %d out of %d devices enumerated\n", EnumeratedDevices, i));
    1.38 -      }  
    1.39 -*/
    1.40 +      KdPrint((__DRIVER_NAME "     found existing device %s\n", Devices[i]));
    1.41 +      KdPrint((__DRIVER_NAME "     faking watch event for %s/%s", PdoDeviceData->Path, Devices[i]));
    1.42 +      RtlStringCbPrintfA(buffer, ARRAY_SIZE(buffer), "%s/%s", PdoDeviceData->Path, Devices[i]);
    1.43 +      XenEnum_WatchHandler(buffer, Device);
    1.44 +      //ExFreePoolWithTag(Devices[i], XENPCI_POOL_TAG);
    1.45      }
    1.46 -//  }
    1.47 +  }
    1.48  
    1.49    KdPrint((__DRIVER_NAME " <-- EvtDeviceD0EntryPostInterruptsEnabled\n"));
    1.50  
     2.1 --- a/xennet/sources	Thu Jan 17 12:25:54 2008 -0800
     2.2 +++ b/xennet/sources	Fri Jan 18 20:11:03 2008 +1100
     2.3 @@ -1,7 +1,7 @@
     2.4  TARGETNAME=XENNET
     2.5  TARGETTYPE=DRIVER
     2.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     2.7 -VERSION=0.5.0.86
     2.8 +VERSION=0.5.0.92
     2.9  KMDF_VERSION=1
    2.10  MSC_WARNING_LEVEL=/W4
    2.11  INF_NAME=xennet
     3.1 --- a/xennet/xennet.c	Thu Jan 17 12:25:54 2008 -0800
     3.2 +++ b/xennet/xennet.c	Fri Jan 18 20:11:03 2008 +1100
     3.3 @@ -112,6 +112,7 @@ struct xennet_info
     3.4  
     3.5    /* how many packets are in the net stack atm */
     3.6    LONG rx_outstanding;
     3.7 +  LONG tx_outstanding;
     3.8  
     3.9    /* stats */
    3.10    ULONG64 stat_tx_ok;
    3.11 @@ -155,7 +156,7 @@ static void
    3.12  add_id_to_freelist(struct xennet_info *xi, unsigned short id)
    3.13  {
    3.14    xi->tx_pkts[id] = xi->tx_pkts[0];
    3.15 -  xi->tx_pkts[0]  = (void *)(int)id;
    3.16 +  xi->tx_pkts[0]  = (void *)id;
    3.17    xi->tx_pkt_ids_used--;
    3.18  }
    3.19  
    3.20 @@ -213,6 +214,7 @@ XenNet_TxBufferGC(struct xennet_info *xi
    3.21        NdisFreeMemory(MmGetMdlVirtualAddress(pmdl), 0, 0); // <= DISPATCH_LEVEL
    3.22        IoFreeMdl(pmdl);
    3.23  
    3.24 +      InterlockedDecrement(&xi->tx_outstanding);
    3.25        xi->stat_tx_ok++;
    3.26        NdisMSendComplete(xi->adapter_handle, pkt, NDIS_STATUS_SUCCESS);
    3.27      }
    3.28 @@ -401,12 +403,12 @@ XenNet_ReturnPacket(
    3.29    NdisGetFirstBufferFromPacketSafe(Packet, &buffer, &buff_va, &buff_len,
    3.30      &tot_buff_len, NormalPagePriority);
    3.31    ASSERT(tot_buff_len <= XN_MAX_PKT_SIZE);
    3.32 +  ASSERT(buff_va != NULL);
    3.33  
    3.34    while (buffer)
    3.35    {
    3.36      NdisGetNextBuffer(buffer, &next_buffer);
    3.37 -    NdisQueryBufferSafe(buffer, &buff_va, &buff_len, NormalPagePriority);
    3.38 -    NdisFreeMemory(buff_va, 0, 0);
    3.39 +    NdisFreeMemory(NdisBufferVirtualAddressSafe(buffer, NormalPagePriority), 0, 0);
    3.40      NdisFreeBuffer(buffer);
    3.41      buffer = next_buffer;
    3.42    }
    3.43 @@ -414,6 +416,7 @@ XenNet_ReturnPacket(
    3.44    NdisFreePacket(Packet);
    3.45  
    3.46    InterlockedDecrement(&xi->rx_outstanding);
    3.47 +
    3.48    // if we are no longer connected then _halt probably needs to know when rx_outstanding reaches zero
    3.49    if (!xi->connected && !xi->rx_outstanding)
    3.50      KeSetEvent(&xi->shutdown_event, 1, FALSE);  
    3.51 @@ -779,7 +782,7 @@ XenNet_Init(
    3.52  
    3.53    /* Initialize tx_pkts as a free chain containing every entry. */
    3.54    for (i = 0; i < NET_TX_RING_SIZE+1; i++) {
    3.55 -    xi->tx_pkts[i] = (PNDIS_PACKET)(i + 1);
    3.56 +    xi->tx_pkts[i] = i + 1;
    3.57      xi->grant_tx_ref[i] = GRANT_INVALID_REF;
    3.58    }
    3.59  
    3.60 @@ -1551,6 +1554,7 @@ XenNet_SendPackets(
    3.61  
    3.62      entry = (PLIST_ENTRY)&curr_packet->MiniportReservedEx[4];
    3.63      ExInterlockedInsertTailList(&xi->tx_waiting_pkt_list, entry, &xi->tx_lock);
    3.64 +    InterlockedIncrement(&xi->tx_outstanding);
    3.65    }
    3.66  
    3.67    XenNet_SendQueuedPackets(xi);
    3.68 @@ -1600,6 +1604,8 @@ XenNet_Halt(
    3.69  
    3.70    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.71    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    3.72 +  KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
    3.73 +  KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
    3.74  
    3.75    // this disables the interrupt
    3.76    XenNet_Shutdown(xi);
    3.77 @@ -1634,6 +1640,9 @@ XenNet_Halt(
    3.78  
    3.79    // TODO: remove event channel xenbus entry (how?)
    3.80  
    3.81 +  KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
    3.82 +  KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
    3.83 +
    3.84    /* free TX resources */
    3.85    if (xi->XenInterface.GntTbl_EndAccess(if_cxt, xi->tx_ring_ref))
    3.86    {
    3.87 @@ -1645,6 +1654,9 @@ XenNet_Halt(
    3.88    xi->tx_pgs = NULL;
    3.89    XenNet_TxBufferFree(xi);
    3.90  
    3.91 +  KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
    3.92 +  KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
    3.93 +
    3.94    /* free RX resources */
    3.95    if (xi->XenInterface.GntTbl_EndAccess(if_cxt, xi->rx_ring_ref))
    3.96    {
    3.97 @@ -1665,6 +1677,10 @@ XenNet_Halt(
    3.98  
    3.99    NdisFreeBufferPool(xi->buffer_pool);
   3.100    NdisFreePacketPool(xi->packet_pool);
   3.101 +
   3.102 +  KdPrint((__DRIVER_NAME "     tx_outstanding = %d\n", xi->tx_outstanding));
   3.103 +  KdPrint((__DRIVER_NAME "     rx_outstanding = %d\n", xi->rx_outstanding));
   3.104 +
   3.105    NdisFreeMemory(xi, 0, 0); // <= DISPATCH_LEVEL
   3.106  
   3.107    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
     4.1 --- a/xenpci/sources	Thu Jan 17 12:25:54 2008 -0800
     4.2 +++ b/xenpci/sources	Fri Jan 18 20:11:03 2008 +1100
     4.3 @@ -1,7 +1,7 @@
     4.4  TARGETNAME=XENPCI
     4.5  TARGETTYPE=DRIVER
     4.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     4.7 -VERSION=0.5.0.30
     4.8 +VERSION=0.5.0.32
     4.9  KMDF_VERSION=1
    4.10  MSC_WARNING_LEVEL=/W4
    4.11  INF_NAME=xenpci
     5.1 --- a/xenpci/xenbus.c	Thu Jan 17 12:25:54 2008 -0800
     5.2 +++ b/xenpci/xenbus.c	Fri Jan 18 20:11:03 2008 +1100
     5.3 @@ -692,7 +692,9 @@ XenBus_RemWatch(
     5.4  
     5.5    while (xpdd->XenBus_WatchEntries[i].Running)
     5.6    {
     5.7 +    KeReleaseSpinLock(&xpdd->WatchLock, OldIrql);
     5.8      KeWaitForSingleObject(&xpdd->XenBus_WatchEntries[i].CompleteEvent, Executive, KernelMode, FALSE, NULL);
     5.9 +    KeAcquireSpinLock(&xpdd->WatchLock, &OldIrql);
    5.10    }
    5.11  
    5.12    xpdd->XenBus_WatchEntries[i].Active = 0;
    5.13 @@ -712,14 +714,11 @@ XenBus_RemWatch(
    5.14    msg = errmsg(rep);
    5.15    if (msg)
    5.16    {
    5.17 -    KeReleaseSpinLock(&xpdd->WatchLock, OldIrql);
    5.18      return msg;
    5.19    }
    5.20  
    5.21    ExFreePoolWithTag(rep, XENPCI_POOL_TAG);
    5.22  
    5.23 -  KeReleaseSpinLock(&xpdd->WatchLock, OldIrql);
    5.24 -
    5.25    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.26  
    5.27    return NULL;