win-pvdrivers

changeset 71:0d06cc4c5fc9 0.5.0.0

Merged
author James Harper <james.harper@bendigoit.com.au>
date Thu Dec 20 10:57:59 2007 +1100 (2007-12-20)
parents 21502e79acc3 a41314faf255
children 74afe8d3db57
files xenpci/xenpci.c
line diff
     1.1 --- a/xennet/xennet.c	Thu Dec 20 10:54:59 2007 +1100
     1.2 +++ b/xennet/xennet.c	Thu Dec 20 10:57:59 2007 +1100
     1.3 @@ -187,7 +187,6 @@ static NDIS_STATUS
     1.4  XenNet_TxBufferGC(struct xennet_info *xi)
     1.5  {
     1.6    RING_IDX cons, prod;
     1.7 -
     1.8    unsigned short id;
     1.9    PNDIS_PACKET pkt;
    1.10    PMDL pmdl;
    1.11 @@ -214,7 +213,7 @@ XenNet_TxBufferGC(struct xennet_info *xi
    1.12  
    1.13        /* free linearized data page */
    1.14        pmdl = *(PMDL *)pkt->MiniportReservedEx;
    1.15 -      MmFreePagesFromMdl(pmdl);
    1.16 +      NdisFreeMemory(MmGetMdlVirtualAddress(pmdl), 0, 0);
    1.17        IoFreeMdl(pmdl);
    1.18  
    1.19        xi->stat_tx_ok++;
    1.20 @@ -1019,6 +1018,7 @@ XenNet_ReturnPacket(
    1.21  PMDL
    1.22  XenNet_Linearize(PNDIS_PACKET Packet)
    1.23  {
    1.24 +  NDIS_STATUS status;
    1.25    PMDL pmdl;
    1.26    char *start;
    1.27    PNDIS_BUFFER buffer;
    1.28 @@ -1026,17 +1026,24 @@ XenNet_Linearize(PNDIS_PACKET Packet)
    1.29    UINT buff_len;
    1.30    UINT tot_buff_len;
    1.31  
    1.32 -  pmdl = AllocatePage();
    1.33 +  NdisGetFirstBufferFromPacketSafe(Packet, &buffer, &buff_va, &buff_len,
    1.34 +    &tot_buff_len, NormalPagePriority);
    1.35 +  ASSERT(tot_buff_len <= XN_MAX_PKT_SIZE);
    1.36  
    1.37 -  start = MmGetSystemAddressForMdlSafe(pmdl, NormalPagePriority);
    1.38 -  if (!start)
    1.39 +  status = NdisAllocateMemoryWithTag(&start, tot_buff_len, XENNET_POOL_TAG);
    1.40 +  if (!NT_SUCCESS(status))
    1.41    {
    1.42 +    KdPrint(("Could not allocate memory for linearization\n"));
    1.43      return NULL;
    1.44    }
    1.45 -
    1.46 -  NdisGetFirstBufferFromPacketSafe(Packet, &buffer, &buff_va, &buff_len,
    1.47 -    &tot_buff_len, NormalPagePriority);
    1.48 -  ASSERT(tot_buff_len <= PAGE_SIZE);
    1.49 +  pmdl = IoAllocateMdl(start, tot_buff_len, FALSE, FALSE, FALSE);
    1.50 +  if (!pmdl)
    1.51 +  {
    1.52 +    KdPrint(("Could not allocate MDL for linearization\n"));
    1.53 +    NdisFreeMemory(start, 0, 0);
    1.54 +    return NULL;
    1.55 +  }
    1.56 +  MmBuildMdlForNonPagedPool(pmdl);
    1.57  
    1.58    while (buffer)
    1.59    {
    1.60 @@ -1094,7 +1101,7 @@ XenNet_SendPackets(
    1.61        *MmGetMdlPfnArray(pmdl),
    1.62        TRUE);
    1.63      xi->grant_tx_ref[id] = tx->gref;
    1.64 -    tx->offset = 0;
    1.65 +    tx->offset = (uint16_t)MmGetMdlByteOffset(pmdl);
    1.66      tx->size = (UINT16)pkt_size;
    1.67      tx->flags = NETTXF_csum_blank;
    1.68  
     2.1 --- a/xenpci/evtchn.c	Thu Dec 20 10:54:59 2007 +1100
     2.2 +++ b/xenpci/evtchn.c	Thu Dec 20 10:57:59 2007 +1100
     2.3 @@ -25,6 +25,25 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
     2.4  {
     2.5    int cpu = 0;
     2.6    vcpu_info_t *vcpu_info;
     2.7 +  PXENPCI_DEVICE_DATA xpdd = GetDeviceData(WdfInterruptGetDevice(Interrupt));
     2.8 +  shared_info_t *shared_info_area = xpdd->shared_info_area;
     2.9 +
    2.10 +  UNREFERENCED_PARAMETER(MessageID);
    2.11 +
    2.12 +  vcpu_info = &shared_info_area->vcpu_info[cpu];
    2.13 +
    2.14 +  vcpu_info->evtchn_upcall_pending = 0;
    2.15 +
    2.16 +  WdfInterruptQueueDpcForIsr(Interrupt);
    2.17 +
    2.18 +  return TRUE;
    2.19 +}
    2.20 +
    2.21 +VOID
    2.22 +EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject)
    2.23 +{
    2.24 +  int cpu = 0;
    2.25 +  vcpu_info_t *vcpu_info;
    2.26    unsigned long evt_words, evt_word;
    2.27    unsigned long evt_bit;
    2.28    unsigned long port;
    2.29 @@ -33,15 +52,10 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    2.30    shared_info_t *shared_info_area = xpdd->shared_info_area;
    2.31  
    2.32    UNREFERENCED_PARAMETER(Interrupt);
    2.33 -  UNREFERENCED_PARAMETER(MessageID);
    2.34 -
    2.35 -  //KdPrint((__DRIVER_NAME "     I+\n"));
    2.36 -  //KdPrint((__DRIVER_NAME " --> XenPCI_ISR\n"));
    2.37 +  UNREFERENCED_PARAMETER(AssociatedObject);
    2.38  
    2.39    vcpu_info = &shared_info_area->vcpu_info[cpu];
    2.40  
    2.41 -  vcpu_info->evtchn_upcall_pending = 0;
    2.42 -
    2.43    evt_words = _InterlockedExchange((volatile LONG *)&vcpu_info->evtchn_pending_sel, 0);
    2.44    
    2.45    while (_BitScanForward(&evt_word, evt_words))
    2.46 @@ -63,13 +77,6 @@ EvtChn_Interrupt(WDFINTERRUPT Interrupt,
    2.47        _interlockedbittestandreset((volatile LONG *)&shared_info_area->evtchn_pending[0], port);
    2.48      }
    2.49    }
    2.50 -
    2.51 -  //KdPrint((__DRIVER_NAME " <-- XenPCI_ISR\n"));
    2.52 -
    2.53 -  //KdPrint((__DRIVER_NAME "     I-\n"));
    2.54 -
    2.55 -//  return TRUE;
    2.56 -  return FALSE;
    2.57  }
    2.58  
    2.59  NTSTATUS
     3.1 --- a/xenpci/xenpci.c	Thu Dec 20 10:54:59 2007 +1100
     3.2 +++ b/xenpci/xenpci.c	Thu Dec 20 10:57:59 2007 +1100
     3.3 @@ -75,10 +75,10 @@ static BOOLEAN AutoEnumerate;
     3.4  static LIST_ENTRY ShutdownMsgList;
     3.5  
     3.6  typedef struct {
     3.7 -  LIST_ENTRY Entry;
     3.8 +  LIST_ENTRY ListEntry;
     3.9    ULONG Ptr;
    3.10  //  ULONG Len;
    3.11 -  UCHAR Buf[0];
    3.12 +  CHAR Buf[0];
    3.13  } SHUTDOWN_MSG_ENTRY, *PSHUTDOWN_MSG_ENTRY;
    3.14  
    3.15  static KSPIN_LOCK ShutdownMsgLock;
    3.16 @@ -373,7 +373,7 @@ XenPCI_AddDevice(
    3.17  
    3.18    WdfDeviceSetBusInformationForChildren(Device, &busInfo);
    3.19  
    3.20 -  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, NULL);
    3.21 +  WDF_INTERRUPT_CONFIG_INIT(&InterruptConfig, EvtChn_Interrupt, EvtChn_InterruptDpc);
    3.22    InterruptConfig.EvtInterruptEnable = XenPCI_InterruptEnable;
    3.23    InterruptConfig.EvtInterruptDisable = XenPCI_InterruptDisable;
    3.24    Status = WdfInterruptCreate(Device, &InterruptConfig, WDF_NO_OBJECT_ATTRIBUTES, &xpdd->XenInterrupt);
    3.25 @@ -653,10 +653,11 @@ XenPCI_IoRead(WDFQUEUE Queue, WDFREQUEST
    3.26    ULONG Remaining;
    3.27    ULONG CopyLen;
    3.28    PCHAR Buffer;
    3.29 -  ULONG BufLen;
    3.30 +  size_t BufLen;
    3.31    KIRQL OldIrql;
    3.32  
    3.33    UNREFERENCED_PARAMETER(Queue);
    3.34 +  UNREFERENCED_PARAMETER(Length);
    3.35  
    3.36    KdPrint((__DRIVER_NAME " --> IoRead\n"));
    3.37  
    3.38 @@ -687,7 +688,7 @@ XenPCI_IoRead(WDFQUEUE Queue, WDFREQUEST
    3.39    {    
    3.40      KdPrint((__DRIVER_NAME "     More to do...\n"));
    3.41      Entry->Ptr += CopyLen;
    3.42 -    InsertHeadList(&ShutdownMsgList, Entry);
    3.43 +    InsertHeadList(&ShutdownMsgList, &Entry->ListEntry);
    3.44    }
    3.45  
    3.46    KeReleaseSpinLock(&ShutdownMsgLock, OldIrql);
    3.47 @@ -942,10 +943,6 @@ XenBus_ShutdownHandler(char *Path, PVOID
    3.48    char *Value;
    3.49    xenbus_transaction_t xbt;
    3.50    int retry;
    3.51 -  WDFREQUEST Request;
    3.52 -  PCHAR Buffer;
    3.53 -  size_t BufLen;
    3.54 -  PCHAR Ptr;
    3.55    PSHUTDOWN_MSG_ENTRY Entry;
    3.56  
    3.57    UNREFERENCED_PARAMETER(Path);
    3.58 @@ -976,7 +973,7 @@ XenBus_ShutdownHandler(char *Path, PVOID
    3.59      Entry = (PSHUTDOWN_MSG_ENTRY)ExAllocatePoolWithTag(NonPagedPool, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, XENPCI_POOL_TAG);
    3.60      Entry->Ptr = 0;
    3.61      RtlStringCbPrintfA(Entry->Buf, sizeof(SHUTDOWN_MSG_ENTRY) + strlen(Value) + 1 + 1, "%s\n", Value);
    3.62 -    InsertTailList(&ShutdownMsgList, Entry);
    3.63 +    InsertTailList(&ShutdownMsgList, &Entry->ListEntry);
    3.64      WdfIoQueueStart(ReadQueue);
    3.65    }
    3.66    KdPrint((__DRIVER_NAME " <-- XenBus_ShutdownHandler\n"));
     4.1 --- a/xenpci/xenpci.h	Thu Dec 20 10:54:59 2007 +1100
     4.2 +++ b/xenpci/xenpci.h	Thu Dec 20 10:57:59 2007 +1100
     4.3 @@ -183,7 +183,7 @@ NTSTATUS
     4.4  EvtChn_Init(WDFDEVICE Device);
     4.5  BOOLEAN
     4.6  EvtChn_Interrupt(WDFINTERRUPT Interrupt, ULONG MessageID);
     4.7 -BOOLEAN
     4.8 +VOID
     4.9  EvtChn_InterruptDpc(WDFINTERRUPT Interrupt, WDFOBJECT AssociatedObject);
    4.10  NTSTATUS
    4.11  EvtChn_Mask(PVOID Context, evtchn_port_t Port);