win-pvdrivers

changeset 516:6d581a6a432b

Fixed xennet when inactive. Now using EVT_ACTION_TYPE_NORMAL instead of a pretend interrupt.
author James Harper <james.harper@bendigoit.com.au>
date Thu Dec 25 17:50:19 2008 +1100 (2008-12-25)
parents 4e7d9cc9f816
children 3341bfff7ead
files xennet/xennet.c xennet/xennet_oid.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.c	Thu Dec 25 17:49:31 2008 +1100
     1.2 +++ b/xennet/xennet.c	Thu Dec 25 17:50:19 2008 +1100
     1.3 @@ -142,8 +142,8 @@ XenNet_ConnectBackend(struct xennet_info
     1.4          FRONT_RING_INIT(&xi->rx, (netif_rx_sring_t *)value, PAGE_SIZE);
     1.5        }
     1.6        break;
     1.7 -    case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ: /* frontend event channel */
     1.8 -      //KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_EVENT_CHANNEL - %s = %d\n", setting, PtrToUlong(value)));
     1.9 +    case XEN_INIT_TYPE_EVENT_CHANNEL: /* frontend event channel */
    1.10 +      KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_EVENT_CHANNEL - %s = %d\n", setting, PtrToUlong(value)));
    1.11        if (strcmp(setting, "event-channel") == 0)
    1.12        {
    1.13          xi->event_channel = PtrToUlong(value);
    1.14 @@ -260,10 +260,12 @@ XenNet_InterruptIsr(
    1.15    *QueueMiniportHandleInterrupt = FALSE;
    1.16    if (!xi->vectors.EvtChn_AckEvent(xi->vectors.context, xi->event_channel))
    1.17    {
    1.18 +    KdPrint((__DRIVER_NAME "     Interrupt NOT for me\n"));
    1.19      /* interrupt was not for us */
    1.20    }
    1.21    else
    1.22    {
    1.23 +    KdPrint((__DRIVER_NAME "     Interrupt for me\n"));
    1.24      //*QueueMiniportHandleInterrupt = (BOOLEAN)!!xi->connected;
    1.25      if (xi->device_state->resume_state != xi->device_state->resume_state_ack)
    1.26      {
    1.27 @@ -271,16 +273,34 @@ XenNet_InterruptIsr(
    1.28      }
    1.29      else if (xi->connected && !xi->inactive && xi->device_state->resume_state == RESUME_STATE_RUNNING)
    1.30      {
    1.31 +      KdPrint((__DRIVER_NAME "     Queuing DPC's\n"));
    1.32        KeInsertQueueDpc(&xi->tx_dpc, NULL, NULL);
    1.33 -      //KdPrint((__DRIVER_NAME "     Queueding Dpc (Isr)\n"));
    1.34        KeInsertQueueDpc(&xi->rx_dpc, UlongToPtr(FALSE), NULL);
    1.35 -      //KdPrint((__DRIVER_NAME "     Dpc Queued (Isr)\n"));
    1.36      }
    1.37    }
    1.38  
    1.39    //FUNCTION_EXIT();
    1.40  }
    1.41  
    1.42 +static DDKAPI BOOLEAN
    1.43 +XenNet_HandleEvent(PVOID context)
    1.44 +{
    1.45 +  struct xennet_info *xi = context;
    1.46 +  
    1.47 +  //FUNCTION_ENTER();
    1.48 +  if (xi->device_state->resume_state != xi->device_state->resume_state_ack)
    1.49 +  {
    1.50 +    KeInsertQueueDpc(&xi->suspend_dpc, NULL, NULL);
    1.51 +  }
    1.52 +  else if (xi->connected && !xi->inactive && xi->device_state->resume_state == RESUME_STATE_RUNNING)
    1.53 +  {
    1.54 +    KeInsertQueueDpc(&xi->tx_dpc, NULL, NULL);
    1.55 +    KeInsertQueueDpc(&xi->rx_dpc, UlongToPtr(FALSE), NULL);
    1.56 +  }
    1.57 +  //FUNCTION_EXIT();
    1.58 +  return TRUE;
    1.59 +}
    1.60 +
    1.61  // Called at <= DISPATCH_LEVEL
    1.62  static DDKAPI NDIS_STATUS
    1.63  XenNet_Init(
    1.64 @@ -300,6 +320,7 @@ XenNet_Init(
    1.65    PCM_PARTIAL_RESOURCE_DESCRIPTOR prd;
    1.66    KIRQL irq_level = 0;
    1.67    ULONG irq_vector = 0;
    1.68 +  ULONG irq_mode = 0;
    1.69    NDIS_HANDLE config_handle;
    1.70    NDIS_STRING config_param_name;
    1.71    PNDIS_CONFIGURATION_PARAMETER config_param;
    1.72 @@ -347,6 +368,7 @@ XenNet_Init(
    1.73    xi->rx_target     = RX_DFL_MIN_TARGET;
    1.74    xi->rx_min_target = RX_DFL_MIN_TARGET;
    1.75    xi->rx_max_target = RX_MAX_TARGET;
    1.76 +  xi->inactive      = TRUE;
    1.77    NdisMSetAttributesEx(xi->adapter_handle, (NDIS_HANDLE) xi,
    1.78      0, NDIS_ATTRIBUTE_DESERIALIZE|NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK
    1.79  #ifdef NDIS51_MINIPORT
    1.80 @@ -390,7 +412,9 @@ XenNet_Init(
    1.81      case CmResourceTypeInterrupt:
    1.82        irq_vector = prd->u.Interrupt.Vector;
    1.83        irq_level = (KIRQL)prd->u.Interrupt.Level;
    1.84 -      KdPrint((__DRIVER_NAME "     irq_vector = %03x, irq_level = %03x\n", irq_vector, irq_level));
    1.85 +      irq_mode = (prd->Flags & CM_RESOURCE_INTERRUPT_LATCHED)?NdisInterruptLatched:NdisInterruptLevelSensitive;
    1.86 +      KdPrint((__DRIVER_NAME "     irq_vector = %03x, irq_level = %03x, irq_mode = %s\n", irq_vector, irq_level,
    1.87 +        (irq_mode == NdisInterruptLatched)?"NdisInterruptLatched":"NdisInterruptLevelSensitive"));
    1.88        break;
    1.89      case CmResourceTypeMemory:
    1.90        if (xi->config_page)
    1.91 @@ -476,6 +500,9 @@ XenNet_Init(
    1.92        KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_DEVICE_STATE - %p\n", PtrToUlong(value)));
    1.93        xi->device_state = (PXENPCI_DEVICE_STATE)value;
    1.94        break;
    1.95 +    case XEN_INIT_TYPE_ACTIVE:
    1.96 +      xi->inactive = FALSE;
    1.97 +      break;
    1.98      default:
    1.99        KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_%d\n", type));
   1.100        break;
   1.101 @@ -600,7 +627,8 @@ XenNet_Init(
   1.102    ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_RUN, NULL, NULL);
   1.103    ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_RING, "tx-ring-ref", NULL);
   1.104    ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_RING, "rx-ring-ref", NULL);
   1.105 -  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_EVENT_CHANNEL_IRQ, "event-channel", NULL);
   1.106 +  //ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_EVENT_CHANNEL_IRQ, "event-channel", NULL);
   1.107 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_EVENT_CHANNEL, "event-channel", NULL);
   1.108    ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_READ_STRING_BACK, "mac", NULL);
   1.109    RtlStringCbPrintfA(buf, ARRAY_SIZE(buf), "%d", !xi->config_csum);
   1.110    ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_WRITE_STRING, "feature-no-csum-offload", buf);
   1.111 @@ -634,8 +662,9 @@ XenNet_Init(
   1.112  
   1.113    KeMemoryBarrier(); // packets could be received anytime after we set Frontent to Connected
   1.114  
   1.115 +  #if 0
   1.116    status = NdisMRegisterInterrupt(&xi->interrupt, MiniportAdapterHandle, irq_vector, irq_level,
   1.117 -    TRUE, TRUE, NdisInterruptLevelSensitive);
   1.118 +    TRUE, TRUE, irq_mode);
   1.119    if (!NT_SUCCESS(status))
   1.120    {
   1.121      KdPrint(("NdisMRegisterInterrupt failed with 0x%x\n", status));
   1.122 @@ -645,8 +674,8 @@ XenNet_Init(
   1.123      XenNet_RxShutdown(xi);
   1.124      goto err;
   1.125    }
   1.126 -
   1.127 -  /* send fake arp? */
   1.128 +  #endif
   1.129 +  xi->vectors.EvtChn_Bind(xi->vectors.context, xi->event_channel, XenNet_HandleEvent, xi);
   1.130  
   1.131    FUNCTION_EXIT();
   1.132  
   1.133 @@ -767,7 +796,7 @@ DriverEntry(
   1.134  
   1.135    mini_chars.HaltHandler = XenNet_Halt;
   1.136    mini_chars.InitializeHandler = XenNet_Init;
   1.137 -  mini_chars.ISRHandler = XenNet_InterruptIsr;
   1.138 +  //mini_chars.ISRHandler = XenNet_InterruptIsr;
   1.139    //mini_chars.HandleInterruptHandler = XenNet_InterruptDpc;
   1.140    mini_chars.QueryInformationHandler = XenNet_QueryInformation;
   1.141    mini_chars.ResetHandler = XenNet_Reset;
     2.1 --- a/xennet/xennet_oid.c	Thu Dec 25 17:49:31 2008 +1100
     2.2 +++ b/xennet/xennet_oid.c	Thu Dec 25 17:50:19 2008 +1100
     2.3 @@ -480,7 +480,7 @@ XenNet_SetInformation(
     2.4        if (*(ULONG *)data & NDIS_PACKET_TYPE_BROADCAST)
     2.5          KdPrint(("  NDIS_PACKET_TYPE_BROADCAST\n"));
     2.6        if (*(ULONG *)data & NDIS_PACKET_TYPE_PROMISCUOUS)
     2.7 -        KdPrint(("  NDIS_PACKET_TYPE_PROMISCUOUS (not supported)\n"));
     2.8 +        KdPrint(("  NDIS_PACKET_TYPE_PROMISCUOUS\n"));
     2.9        if (*(ULONG *)data & NDIS_PACKET_TYPE_ALL_FUNCTIONAL)
    2.10          KdPrint(("  NDIS_PACKET_TYPE_ALL_FUNCTIONAL (not supported)\n"));
    2.11        if (*(ULONG *)data & NDIS_PACKET_TYPE_ALL_LOCAL)
     3.1 --- a/xennet/xennet_tx.c	Thu Dec 25 17:49:31 2008 +1100
     3.2 +++ b/xennet/xennet_tx.c	Thu Dec 25 17:50:19 2008 +1100
     3.3 @@ -490,6 +490,16 @@ XenNet_SendPackets(
     3.4  
     3.5    //FUNCTION_ENTER();
     3.6  
     3.7 +  if (xi->inactive)
     3.8 +  {
     3.9 +    for (i = 0; i < NumberOfPackets; i++)
    3.10 +    {
    3.11 +      NDIS_SET_PACKET_STATUS(PacketArray[i], NDIS_STATUS_FAILURE);
    3.12 +      NdisMSendComplete(xi->adapter_handle, PacketArray[i], NDIS_GET_PACKET_STATUS(PacketArray[i]));
    3.13 +    }
    3.14 +    return;
    3.15 +  }
    3.16 +    
    3.17    KeAcquireSpinLock(&xi->tx_lock, &OldIrql);
    3.18  
    3.19  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (packets = %d, free_requests = %d)\n", NumberOfPackets, free_requests(xi)));