win-pvdrivers

changeset 438:f0fe409ae32e

(Re-)Added code to stop the halt completing if there are un-returned packets from ndis
author James Harper <james.harper@bendigoit.com.au>
date Tue Nov 04 22:21:37 2008 +1100 (2008-11-04)
parents 3b1ba2d7056c
children 9971dbcc8c2b
files xennet/xennet.c xennet/xennet.h xennet/xennet_rx.c
line diff
     1.1 --- a/xennet/xennet.c	Tue Nov 04 20:28:26 2008 +1100
     1.2 +++ b/xennet/xennet.c	Tue Nov 04 22:21:37 2008 +1100
     1.3 @@ -577,8 +577,6 @@ XenNet_Init(
     1.4  
     1.5    status = XenNet_ConnectBackend(xi);
     1.6    
     1.7 -  KeInitializeEvent(&xi->shutdown_event, SynchronizationEvent, FALSE);  
     1.8 -
     1.9    XenNet_TxInit(xi);
    1.10    XenNet_RxInit(xi);
    1.11  
     2.1 --- a/xennet/xennet.h	Tue Nov 04 20:28:26 2008 +1100
     2.2 +++ b/xennet/xennet.h	Tue Nov 04 22:21:37 2008 +1100
     2.3 @@ -237,14 +237,10 @@ struct xennet_info
     2.4    PXENPCI_DEVICE_STATE device_state;
     2.5    evtchn_port_t event_channel;
     2.6    ULONG state;
     2.7 -  KEVENT shutdown_event;
     2.8    char backend_path[MAX_XENBUS_STR_LEN];
     2.9    ULONG backend_state;
    2.10    PVOID config_page;
    2.11  
    2.12 -  /* Xen ring-related vars */
    2.13 -  KSPIN_LOCK rx_lock;
    2.14 -
    2.15    /* tx related - protected by tx_lock */
    2.16    KSPIN_LOCK tx_lock;
    2.17    LIST_ENTRY tx_waiting_pkt_list;
    2.18 @@ -258,6 +254,7 @@ struct xennet_info
    2.19    freelist_t tx_freelist;
    2.20  
    2.21    /* rx_related - protected by rx_lock */
    2.22 +  KSPIN_LOCK rx_lock;
    2.23    struct netif_rx_front_ring rx;
    2.24    ULONG rx_id_free;
    2.25    PNDIS_BUFFER rx_mdls[NET_RX_RING_SIZE];
    2.26 @@ -265,6 +262,8 @@ struct xennet_info
    2.27    packet_info_t rxpi;
    2.28    PNDIS_PACKET rx_packet_list[NET_RX_RING_SIZE * 2];
    2.29    ULONG rx_packet_free;
    2.30 +  BOOLEAN rx_shutting_down;
    2.31 +  KEVENT packet_returned_event;
    2.32  
    2.33    /* Receive-ring batched refills. */
    2.34    ULONG rx_target;
     3.1 --- a/xennet/xennet_rx.c	Tue Nov 04 20:28:26 2008 +1100
     3.2 +++ b/xennet/xennet_rx.c	Tue Nov 04 22:21:37 2008 +1100
     3.3 @@ -657,6 +657,9 @@ XenNet_ReturnPacket(
     3.4  
     3.5    put_packet_on_freelist(xi, Packet);
     3.6    xi->rx_outstanding--;
     3.7 +  
     3.8 +  if (!xi->rx_outstanding && xi->rx_shutting_down)
     3.9 +    KeSetEvent(&xi->packet_returned_event, IO_NO_INCREMENT, FALSE);
    3.10  
    3.11    KeReleaseSpinLockFromDpcLevel(&xi->rx_lock);
    3.12    
    3.13 @@ -728,6 +731,10 @@ XenNet_RxInit(xennet_info_t *xi)
    3.14  
    3.15    FUNCTION_ENTER();
    3.16  
    3.17 +  KeInitializeEvent(&xi->packet_returned_event, SynchronizationEvent, FALSE);
    3.18 +
    3.19 +  xi->rx_shutting_down = FALSE;
    3.20 +  
    3.21    xi->rx_id_free = NET_RX_RING_SIZE;
    3.22  
    3.23    for (i = 0; i < NET_RX_RING_SIZE; i++)
    3.24 @@ -753,6 +760,16 @@ XenNet_RxShutdown(xennet_info_t *xi)
    3.25    FUNCTION_ENTER();
    3.26  
    3.27    KeAcquireSpinLock(&xi->rx_lock, &OldIrql);
    3.28 +  xi->rx_shutting_down = TRUE;
    3.29 +  KeReleaseSpinLock(&xi->rx_lock, OldIrql);
    3.30 +  
    3.31 +  while (xi->rx_outstanding)
    3.32 +  {
    3.33 +    KdPrint((__DRIVER_NAME "     Waiting for all packets to be returned\n"));
    3.34 +    KeWaitForSingleObject(&xi->packet_returned_event, Executive, KernelMode, FALSE, NULL);
    3.35 +  }
    3.36 +
    3.37 +  KeAcquireSpinLock(&xi->rx_lock, &OldIrql);
    3.38  
    3.39    XenNet_RxBufferFree(xi);
    3.40  
    3.41 @@ -760,10 +777,6 @@ XenNet_RxShutdown(xennet_info_t *xi)
    3.42  
    3.43    packet_freelist_dispose(xi);
    3.44  
    3.45 -  /* free RX resources */
    3.46 -
    3.47 -  ASSERT(xi->rx_outstanding == 0);
    3.48 -
    3.49    KeReleaseSpinLock(&xi->rx_lock, OldIrql);
    3.50  
    3.51    FUNCTION_EXIT();