win-pvdrivers

changeset 80:43f57f42508c

Removed hiding code from xenhide - use 'type=netfront' instead.
Added spinlock to xennet to avoid crash.
author James Harper <james.harper@bendigoit.com.au>
date Mon Dec 31 12:46:47 2007 +1100 (2007-12-31)
parents 17319a4920eb
children 5d116e9b87fa
files xenenum/sources xenenum/xenenum.c xenhide/sources xenhide/xenhide.c xennet/sources xennet/xennet.c
line diff
     1.1 --- a/xenenum/sources	Sun Dec 30 21:47:46 2007 +1100
     1.2 +++ b/xenenum/sources	Mon Dec 31 12:46:47 2007 +1100
     1.3 @@ -1,7 +1,7 @@
     1.4  TARGETNAME=xenenum
     1.5  TARGETTYPE=DRIVER
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7 -VERSION=0.5.0.12
     1.8 +VERSION=0.5.0.13
     1.9  KMDF_VERSION=1
    1.10  MSC_WARNING_LEVEL=/W4
    1.11  INF_NAME=xenenum
     2.1 --- a/xenenum/xenenum.c	Sun Dec 30 21:47:46 2007 +1100
     2.2 +++ b/xenenum/xenenum.c	Mon Dec 31 12:46:47 2007 +1100
     2.3 @@ -305,8 +305,10 @@ XenEnum_D0EntryPostInterruptsEnabled(WDF
     2.4    KeInitializeEvent(&WaitDevicesEvent, SynchronizationEvent, FALSE);  
     2.5  
     2.6    // TODO: Should probably do this in an EvtChildListScanForChildren
     2.7 +/*
     2.8    if (AutoEnumerate)
     2.9    {
    2.10 +*/
    2.11      // TODO: Get the correct path from parent here...
    2.12      msg = XenInterface.XenBus_List(XenInterface.InterfaceHeader.Context, XBT_NIL, PdoDeviceData->Path, &Devices);
    2.13      if (!msg)
    2.14 @@ -333,7 +335,7 @@ XenEnum_D0EntryPostInterruptsEnabled(WDF
    2.15        }  
    2.16  */
    2.17      }
    2.18 -  }
    2.19 +//  }
    2.20  
    2.21    KdPrint((__DRIVER_NAME " <-- EvtDeviceD0EntryPostInterruptsEnabled\n"));
    2.22  
     3.1 --- a/xenhide/sources	Sun Dec 30 21:47:46 2007 +1100
     3.2 +++ b/xenhide/sources	Mon Dec 31 12:46:47 2007 +1100
     3.3 @@ -1,7 +1,7 @@
     3.4  TARGETNAME=XENHIDE
     3.5  TARGETTYPE=DRIVER
     3.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     3.7 -VERSION=0.5.0.4
     3.8 +VERSION=0.5.0.5
     3.9  KMDF_VERSION=1
    3.10  MSC_WARNING_LEVEL=/W4
    3.11  INF_NAME=xenhide
     4.1 --- a/xenhide/xenhide.c	Sun Dec 30 21:47:46 2007 +1100
     4.2 +++ b/xenhide/xenhide.c	Mon Dec 31 12:46:47 2007 +1100
     4.3 @@ -237,10 +237,12 @@ XenHide_IoCompletion(PDEVICE_OBJECT Devi
     4.4          break;
     4.5        }
     4.6        // Qemu Network
     4.7 +#if 0 // we don't need this because we can specify type=netfront instead of type=ioemu
     4.8        if (XenHide_StringMatches(Ptr, L"PCI\\VEN_10EC&DEV_8139&SUBSYS_00015853")) {
     4.9          Match = 1;
    4.10          break;
    4.11        }
    4.12 +#endif
    4.13        RtlStringCchLengthW(Ptr, Length, &StrLen);
    4.14      }
    4.15      if (Match)
     5.1 --- a/xennet/sources	Sun Dec 30 21:47:46 2007 +1100
     5.2 +++ b/xennet/sources	Mon Dec 31 12:46:47 2007 +1100
     5.3 @@ -1,7 +1,7 @@
     5.4  TARGETNAME=XENNET
     5.5  TARGETTYPE=DRIVER
     5.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     5.7 -VERSION=0.5.0.28
     5.8 +VERSION=0.5.0.31
     5.9  KMDF_VERSION=1
    5.10  MSC_WARNING_LEVEL=/W4
    5.11  INF_NAME=xennet
     6.1 --- a/xennet/xennet.c	Sun Dec 30 21:47:46 2007 +1100
     6.2 +++ b/xennet/xennet.c	Mon Dec 31 12:46:47 2007 +1100
     6.3 @@ -109,6 +109,7 @@ struct xennet_info
     6.4    ULONG64 stat_rx_no_buffer;
     6.5  
     6.6    KEVENT backend_ready_event;
     6.7 +  KSPIN_LOCK Lock;
     6.8  };
     6.9  
    6.10  /* This function copied from linux's lib/vsprintf.c, see it for attribution */
    6.11 @@ -156,6 +157,7 @@ get_id_from_freelist(NDIS_PACKET **list)
    6.12    return id;
    6.13  }
    6.14  
    6.15 +// Called at DISPATCH_LEVEL with spinlock held
    6.16  static NDIS_STATUS
    6.17  XenNet_TxBufferGC(struct xennet_info *xi)
    6.18  {
    6.19 @@ -300,7 +302,7 @@ XenNet_AllocRXBuffers(struct xennet_info
    6.20    return NDIS_STATUS_SUCCESS;
    6.21  }
    6.22  
    6.23 -// Called at DIRQL
    6.24 +// Called at DISPATCH_LEVEL with spinlock held
    6.25  static NDIS_STATUS
    6.26  XenNet_RxBufferCheck(struct xennet_info *xi)
    6.27  {
    6.28 @@ -328,7 +330,7 @@ XenNet_RxBufferCheck(struct xennet_info 
    6.29        if (rxrsp->status == NETIF_RSP_NULL)
    6.30          continue;
    6.31  
    6.32 -//      KdPrint((__DRIVER_NAME "     Got a packet\n"));
    6.33 +    //  KdPrint((__DRIVER_NAME "     Got a packet\n"));
    6.34  
    6.35        pkt = xi->rx_pkts[rxrsp->id];
    6.36        xi->rx_pkts[rxrsp->id] = NULL;
    6.37 @@ -346,9 +348,9 @@ XenNet_RxBufferCheck(struct xennet_info 
    6.38        NDIS_SET_PACKET_STATUS(pkt, NDIS_STATUS_SUCCESS);
    6.39  
    6.40        /* just indicate 1 packet for now */
    6.41 -//      KdPrint((__DRIVER_NAME "     Indicating Received\n"));
    6.42 +    //  KdPrint((__DRIVER_NAME "     Indicating Received\n"));
    6.43        NdisMIndicateReceivePacket(xi->adapter_handle, &pkt, 1);
    6.44 -//      KdPrint((__DRIVER_NAME "     Done Indicating Received\n"));
    6.45 +    //  KdPrint((__DRIVER_NAME "     Done Indicating Received\n"));
    6.46      }
    6.47  
    6.48      xi->rx.rsp_cons = prod;
    6.49 @@ -380,7 +382,7 @@ XenNet_RxBufferCheck(struct xennet_info 
    6.50    return NDIS_STATUS_SUCCESS;
    6.51  }
    6.52  
    6.53 -// Called at DIRQL
    6.54 +// Called at DISPATCH_LEVEL
    6.55  static BOOLEAN
    6.56  XenNet_Interrupt(
    6.57    PKINTERRUPT Interrupt,
    6.58 @@ -388,12 +390,14 @@ XenNet_Interrupt(
    6.59    )
    6.60  {
    6.61    struct xennet_info *xi = ServiceContext;
    6.62 -  // KIRQL KIrql;
    6.63 +  KIRQL OldIrql;
    6.64  
    6.65    UNREFERENCED_PARAMETER(Interrupt);
    6.66  
    6.67  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    6.68  
    6.69 +  KeAcquireSpinLock(xi->Lock, &OldIrql);
    6.70 +
    6.71    //KdPrint((__DRIVER_NAME "     ***XenNet Interrupt***\n"));  
    6.72  
    6.73    if (xi->connected)
    6.74 @@ -402,6 +406,8 @@ XenNet_Interrupt(
    6.75      XenNet_RxBufferCheck(xi);
    6.76    }
    6.77  
    6.78 +  KeReleaseSpinLock(xi->Lock, OldIrql);
    6.79 +
    6.80  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.81  
    6.82    return TRUE;
    6.83 @@ -609,6 +615,8 @@ XenNet_Init(
    6.84    xi->rx_min_target = RX_DFL_MIN_TARGET;
    6.85    xi->rx_max_target = RX_MAX_TARGET;
    6.86  
    6.87 +  KeInitializeSpinLock(&xi->Lock);
    6.88 +
    6.89    NdisAllocatePacketPool(&status, &xi->packet_pool, NET_RX_RING_SIZE,
    6.90      PROTOCOL_RESERVED_SIZE_IN_PACKET);
    6.91    if (status != NDIS_STATUS_SUCCESS)
    6.92 @@ -912,14 +920,14 @@ XenNet_QueryInformation(
    6.93  
    6.94    if (!NT_SUCCESS(status))
    6.95    {
    6.96 -//    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returned error)\n"));
    6.97 +  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returned error)\n"));
    6.98      return status;
    6.99    }
   6.100  
   6.101    if (len > InformationBufferLength)
   6.102    {
   6.103      *BytesNeeded = len;
   6.104 -//    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returned error)\n"));
   6.105 +  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (returned error)\n"));
   6.106      return NDIS_STATUS_BUFFER_TOO_SHORT;
   6.107    }
   6.108  
   6.109 @@ -1176,9 +1184,12 @@ XenNet_SendPackets(
   6.110    int notify;
   6.111    PMDL pmdl;
   6.112    UINT pkt_size;
   6.113 +  PKIRQL OldIrql;
   6.114  
   6.115  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   6.116  
   6.117 +  KeAcquireSpinLock(xi->Lock, &OldIrql);
   6.118 +
   6.119    for (i = 0; i < NumberOfPackets; i++)
   6.120    {
   6.121      curr_packet = PacketArray[i];
   6.122 @@ -1226,6 +1237,8 @@ XenNet_SendPackets(
   6.123        xi->event_channel);
   6.124    }
   6.125  
   6.126 +  KeReleaseSpinLock(xi->Lock, OldIrql);
   6.127 +
   6.128  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   6.129  }
   6.130