win-pvdrivers

changeset 458:e28aaf63e174

Fixed broken save/restore code.
Reduced rx timer down to a more reasonable limit
author James Harper <james.harper@bendigoit.com.au>
date Thu Nov 20 12:26:52 2008 +1100 (2008-11-20)
parents 7190a6747e2e
children ae1c232e7d4a
files xennet/xennet.c xennet/xennet.h xennet/xennet_rx.c
line diff
     1.1 --- a/xennet/xennet.c	Wed Nov 19 23:27:31 2008 +1100
     1.2 +++ b/xennet/xennet.c	Thu Nov 20 12:26:52 2008 +1100
     1.3 @@ -117,40 +117,6 @@ unsigned long simple_strtoul(const char 
     1.4  /* end vsprintf.c code */
     1.5  /* ----- END Other people's code --------- */
     1.6  
     1.7 -// Called at DISPATCH_LEVEL
     1.8 -
     1.9 -static DDKAPI VOID
    1.10 -XenNet_InterruptIsr(
    1.11 -  PBOOLEAN InterruptRecognized,
    1.12 -  PBOOLEAN QueueMiniportHandleInterrupt,
    1.13 -  NDIS_HANDLE MiniportAdapterContext)
    1.14 -{
    1.15 -  struct xennet_info *xi = MiniportAdapterContext;
    1.16 -  
    1.17 -  //FUNCTION_ENTER();
    1.18 -  *InterruptRecognized = FALSE;
    1.19 -  *QueueMiniportHandleInterrupt = FALSE;
    1.20 -  if (!xi->vectors.EvtChn_AckEvent(xi->vectors.context, xi->event_channel))
    1.21 -  {
    1.22 -    /* interrupt was not for us */
    1.23 -  }
    1.24 -  else
    1.25 -  {
    1.26 -    //*QueueMiniportHandleInterrupt = (BOOLEAN)!!xi->connected;
    1.27 -    if (xi->connected)
    1.28 -    {
    1.29 -      KeInsertQueueDpc(&xi->tx_dpc, NULL, NULL);
    1.30 -      //KdPrint((__DRIVER_NAME "     Queueding Dpc (Isr)\n"));
    1.31 -      xi->last_dpc_isr = TRUE;
    1.32 -      KeQuerySystemTime(&xi->last_dpc_scheduled);
    1.33 -      KeInsertQueueDpc(&xi->rx_dpc, UlongToPtr(FALSE), NULL);
    1.34 -      //KdPrint((__DRIVER_NAME "     Dpc Queued (Isr)\n"));
    1.35 -    }
    1.36 -  }
    1.37 -
    1.38 -  //FUNCTION_EXIT();
    1.39 -}
    1.40 -
    1.41  static NDIS_STATUS
    1.42  XenNet_ConnectBackend(struct xennet_info *xi)
    1.43  {
    1.44 @@ -244,6 +210,79 @@ XenNet_Resume(PDEVICE_OBJECT device_obje
    1.45    XenNet_TxResumeEnd(xi);
    1.46  }
    1.47  
    1.48 +static VOID
    1.49 +XenNet_SuspendResume(PKDPC dpc, PVOID context, PVOID arg1, PVOID arg2)
    1.50 +{
    1.51 +  struct xennet_info *xi = context;
    1.52 +  PIO_WORKITEM work_item;
    1.53 +
    1.54 +  UNREFERENCED_PARAMETER(dpc);
    1.55 +  UNREFERENCED_PARAMETER(arg1);
    1.56 +  UNREFERENCED_PARAMETER(arg2);
    1.57 +
    1.58 +  FUNCTION_ENTER();
    1.59 +  
    1.60 +  switch (xi->device_state->resume_state)
    1.61 +  {
    1.62 +  case RESUME_STATE_SUSPENDING:
    1.63 +    KdPrint((__DRIVER_NAME "     New state SUSPENDING\n"));
    1.64 +    // there should be a better way to synchronise with rx and tx...
    1.65 +    KeAcquireSpinLockAtDpcLevel(&xi->rx_lock);
    1.66 +    KeReleaseSpinLockFromDpcLevel(&xi->rx_lock);
    1.67 +    KeAcquireSpinLockAtDpcLevel(&xi->tx_lock);
    1.68 +    KeReleaseSpinLockFromDpcLevel(&xi->tx_lock);
    1.69 +    break;
    1.70 +  case RESUME_STATE_FRONTEND_RESUME:
    1.71 +    KdPrint((__DRIVER_NAME "     New state RESUME_STATE_FRONTEND_RESUME\n"));
    1.72 +    work_item = IoAllocateWorkItem(xi->fdo);
    1.73 +    IoQueueWorkItem(work_item, XenNet_Resume, DelayedWorkQueue, xi);
    1.74 +    break;
    1.75 +  default:
    1.76 +    KdPrint((__DRIVER_NAME "     New state %d\n", xi->device_state->resume_state));
    1.77 +    break;
    1.78 +  }
    1.79 +  xi->device_state->resume_state_ack = xi->device_state->resume_state;
    1.80 +  KeMemoryBarrier();
    1.81 +  
    1.82 +  FUNCTION_EXIT();
    1.83 +}
    1.84 +
    1.85 +static DDKAPI VOID
    1.86 +XenNet_InterruptIsr(
    1.87 +  PBOOLEAN InterruptRecognized,
    1.88 +  PBOOLEAN QueueMiniportHandleInterrupt,
    1.89 +  NDIS_HANDLE MiniportAdapterContext)
    1.90 +{
    1.91 +  struct xennet_info *xi = MiniportAdapterContext;
    1.92 +  
    1.93 +  //FUNCTION_ENTER();
    1.94 +  *InterruptRecognized = FALSE;
    1.95 +  *QueueMiniportHandleInterrupt = FALSE;
    1.96 +  if (!xi->vectors.EvtChn_AckEvent(xi->vectors.context, xi->event_channel))
    1.97 +  {
    1.98 +    /* interrupt was not for us */
    1.99 +  }
   1.100 +  else
   1.101 +  {
   1.102 +    //*QueueMiniportHandleInterrupt = (BOOLEAN)!!xi->connected;
   1.103 +    if (xi->device_state->resume_state != xi->device_state->resume_state_ack)
   1.104 +    {
   1.105 +      KeInsertQueueDpc(&xi->suspend_dpc, NULL, NULL);
   1.106 +    }
   1.107 +    else if (xi->connected && !xi->inactive && xi->device_state->resume_state == RESUME_STATE_RUNNING)
   1.108 +    {
   1.109 +      KeInsertQueueDpc(&xi->tx_dpc, NULL, NULL);
   1.110 +      //KdPrint((__DRIVER_NAME "     Queueding Dpc (Isr)\n"));
   1.111 +      xi->last_dpc_isr = TRUE;
   1.112 +      KeQuerySystemTime(&xi->last_dpc_scheduled);
   1.113 +      KeInsertQueueDpc(&xi->rx_dpc, UlongToPtr(FALSE), NULL);
   1.114 +      //KdPrint((__DRIVER_NAME "     Dpc Queued (Isr)\n"));
   1.115 +    }
   1.116 +  }
   1.117 +
   1.118 +  //FUNCTION_EXIT();
   1.119 +}
   1.120 +
   1.121  #if 0
   1.122  static DDKAPI VOID
   1.123  XenNet_InterruptDpc(NDIS_HANDLE MiniportAdapterContext)
   1.124 @@ -425,6 +464,7 @@ XenNet_Init(
   1.125    }
   1.126  
   1.127    KeInitializeSpinLock(&xi->rx_lock);
   1.128 +  KeInitializeDpc(&xi->suspend_dpc, XenNet_SuspendResume, xi);
   1.129  
   1.130    InitializeListHead(&xi->tx_waiting_pkt_list);
   1.131    InitializeListHead(&xi->tx_sent_pkt_list);
     2.1 --- a/xennet/xennet.h	Wed Nov 19 23:27:31 2008 +1100
     2.2 +++ b/xennet/xennet.h	Thu Nov 20 12:26:52 2008 +1100
     2.3 @@ -246,6 +246,7 @@ struct xennet_info
     2.4    PVOID config_page;
     2.5    UCHAR multicast_list[MULTICAST_LIST_MAX_SIZE][6];
     2.6    ULONG multicast_list_size;
     2.7 +  KDPC suspend_dpc;
     2.8  
     2.9    /* tx related - protected by tx_lock */
    2.10    KSPIN_LOCK tx_lock;
     3.1 --- a/xennet/xennet_rx.c	Wed Nov 19 23:27:31 2008 +1100
     3.2 +++ b/xennet/xennet_rx.c	Thu Nov 20 12:26:52 2008 +1100
     3.3 @@ -723,7 +723,7 @@ XenNet_RxBufferCheck(PKDPC dpc, PVOID co
     3.4    if (set_timer)
     3.5    {
     3.6      LARGE_INTEGER due_time;
     3.7 -    due_time.QuadPart = -50 * 1000 * 10; /* 30ms */
     3.8 +    due_time.QuadPart = -10 * 1000 * 10; /* 10ms */
     3.9      KeSetTimer(&xi->rx_timer, due_time, &xi->rx_timer_dpc);
    3.10    }
    3.11    //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));