win-pvdrivers

changeset 224:0e71aec16493

fixed a stupid bug (- instead of +). Seems to work now but still sometimes crashes on init.
author James Harper <james.harper@bendigoit.com.au>
date Wed Mar 26 20:42:58 2008 +1100 (2008-03-26)
parents 26f8a3615539
children e90d63d5d794
files common.inc xennet/xennet.c xennet/xennet.h xennet/xennet_oid.c xennet/xennet_rx.c
line diff
     1.1 --- a/common.inc	Tue Mar 25 14:06:35 2008 +1100
     1.2 +++ b/common.inc	Wed Mar 26 20:42:58 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.5.74
     1.5 +VERSION=0.8.5.89
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/xennet/xennet.c	Tue Mar 25 14:06:35 2008 +1100
     2.2 +++ b/xennet/xennet.c	Wed Mar 26 20:42:58 2008 +1100
     2.3 @@ -325,7 +325,7 @@ XenNet_Init(
     2.4  
     2.5    InitializeListHead(&xi->tx_waiting_pkt_list);
     2.6  
     2.7 -  NdisAllocatePacketPool(&status, &xi->packet_pool, XN_RX_QUEUE_LEN,
     2.8 +  NdisAllocatePacketPool(&status, &xi->packet_pool, XN_RX_QUEUE_LEN * 8,
     2.9      PROTOCOL_RESERVED_SIZE_IN_PACKET);
    2.10    if (status != NDIS_STATUS_SUCCESS)
    2.11    {
     3.1 --- a/xennet/xennet.h	Tue Mar 25 14:06:35 2008 +1100
     3.2 +++ b/xennet/xennet.h	Wed Mar 26 20:42:58 2008 +1100
     3.3 @@ -181,12 +181,6 @@ struct xennet_info
     3.4    ULONG page_free;
     3.5  
     3.6    rx_packet_info_t rxpi;
     3.7 -/*
     3.8 -  PNDIS_PACKET rx_current_packet;
     3.9 -  PMDL rx_first_mdl;
    3.10 -  USHORT rx_extra_info;
    3.11 -  USHORT rx_first_buffer_length;
    3.12 -*/
    3.13  
    3.14    /* Receive-ring batched refills. */
    3.15    ULONG rx_target;
     4.1 --- a/xennet/xennet_oid.c	Tue Mar 25 14:06:35 2008 +1100
     4.2 +++ b/xennet/xennet_oid.c	Wed Mar 26 20:42:58 2008 +1100
     4.3 @@ -231,7 +231,6 @@ XenNet_QueryInformation(
     4.4        KdPrint(("len = %d\n", len));
     4.5  
     4.6        ntoh = (PNDIS_TASK_OFFLOAD_HEADER)InformationBuffer;
     4.7 -      KdPrint(("ntoh = %p\n", ntoh));
     4.8        if (ntoh->Version != NDIS_TASK_OFFLOAD_VERSION
     4.9          || ntoh->Size != sizeof(*ntoh)
    4.10          || ntoh->EncapsulationFormat.Encapsulation != IEEE_802_3_Encapsulation)
    4.11 @@ -239,30 +238,37 @@ XenNet_QueryInformation(
    4.12          status = NDIS_STATUS_NOT_SUPPORTED;
    4.13          break;
    4.14        }
    4.15 +      KdPrint(("ntoh = %p\n", ntoh));
    4.16 +      KdPrint(("ntoh->Size = %d\n", ntoh->Size));
    4.17        ntoh->OffsetFirstTask = 0; 
    4.18        nto = NULL;
    4.19  
    4.20        if (xi->config_csum)
    4.21        {
    4.22 -        KdPrint(("config_csum enabled\n"));
    4.23          if (ntoh->OffsetFirstTask == 0)
    4.24          {
    4.25            ntoh->OffsetFirstTask = ntoh->Size;
    4.26 +          KdPrint(("ntoh->OffsetFirstTask = %d\n", ntoh->OffsetFirstTask));
    4.27            nto = (PNDIS_TASK_OFFLOAD)((PCHAR)(ntoh) + ntoh->OffsetFirstTask);
    4.28          }
    4.29          else
    4.30          {
    4.31            nto->OffsetNextTask = FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
    4.32              + nto->TaskBufferLength;
    4.33 +          KdPrint(("nto->OffsetNextTask = %d\n", nto->OffsetNextTask));
    4.34            nto = (PNDIS_TASK_OFFLOAD)((PCHAR)(nto) + nto->OffsetNextTask);
    4.35          }
    4.36 -        KdPrint(("nto = %p\n", nto));
    4.37          /* fill in first nto */
    4.38          nto->Version = NDIS_TASK_OFFLOAD_VERSION;
    4.39          nto->Size = sizeof(NDIS_TASK_OFFLOAD);
    4.40          nto->Task = TcpIpChecksumNdisTask;
    4.41          nto->TaskBufferLength = sizeof(NDIS_TASK_TCP_IP_CHECKSUM);
    4.42  
    4.43 +        KdPrint(("config_csum enabled\n"));
    4.44 +        KdPrint(("nto = %p\n", nto));
    4.45 +        KdPrint(("nto->Size = %d\n", nto->Size));
    4.46 +        KdPrint(("nto->TaskBufferLength = %d\n", nto->TaskBufferLength));
    4.47 +
    4.48          /* fill in checksum offload struct */
    4.49          nttic = (PNDIS_TASK_TCP_IP_CHECKSUM)nto->TaskBuffer;
    4.50          nttic->V4Transmit.IpChecksum = 0;
    4.51 @@ -286,25 +292,30 @@ XenNet_QueryInformation(
    4.52        }
    4.53        if (xi->config_gso)
    4.54        {
    4.55 -        KdPrint(("config_gso enabled\n"));
    4.56          if (ntoh->OffsetFirstTask == 0)
    4.57          {
    4.58            ntoh->OffsetFirstTask = ntoh->Size;
    4.59 +          KdPrint(("ntoh->OffsetFirstTask = %d\n", ntoh->OffsetFirstTask));
    4.60            nto = (PNDIS_TASK_OFFLOAD)((PCHAR)(ntoh) + ntoh->OffsetFirstTask);
    4.61          }
    4.62          else
    4.63          {
    4.64            nto->OffsetNextTask = FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
    4.65              + nto->TaskBufferLength;
    4.66 +          KdPrint(("nto->OffsetNextTask = %d\n", nto->OffsetNextTask));
    4.67            nto = (PNDIS_TASK_OFFLOAD)((PCHAR)(nto) + nto->OffsetNextTask);
    4.68          }
    4.69 -        KdPrint(("nto = %p\n", nto));
    4.70    
    4.71          /* fill in second nto */
    4.72          nto->Version = NDIS_TASK_OFFLOAD_VERSION;
    4.73          nto->Size = sizeof(NDIS_TASK_OFFLOAD);
    4.74          nto->Task = TcpLargeSendNdisTask;
    4.75          nto->TaskBufferLength = sizeof(NDIS_TASK_TCP_LARGE_SEND);
    4.76 +
    4.77 +        KdPrint(("config_gso enabled\n"));
    4.78 +        KdPrint(("nto = %p\n", nto));
    4.79 +        KdPrint(("nto->Size = %d\n", nto->Size));
    4.80 +        KdPrint(("nto->TaskBufferLength = %d\n", nto->TaskBufferLength));
    4.81    
    4.82          /* fill in large send struct */
    4.83          nttls = (PNDIS_TASK_TCP_LARGE_SEND)nto->TaskBuffer;
    4.84 @@ -369,7 +380,7 @@ XenNet_SetInformation(
    4.85    PNDIS_TASK_TCP_LARGE_SEND nttls;
    4.86    int offset;
    4.87  
    4.88 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    4.89 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    4.90  
    4.91    UNREFERENCED_PARAMETER(MiniportAdapterContext);
    4.92    UNREFERENCED_PARAMETER(InformationBufferLength);
    4.93 @@ -502,7 +513,6 @@ XenNet_SetInformation(
    4.94        KdPrint(("Unsupported set OID_802_3_MAXIMUM_LIST_SIZE\n"));
    4.95        break;
    4.96      case OID_TCP_TASK_OFFLOAD:
    4.97 -      // Just fake this for now... ultimately we need to manually calc rx checksum if offload is disabled by windows
    4.98        status = NDIS_STATUS_SUCCESS;
    4.99        KdPrint(("Set OID_TCP_TASK_OFFLOAD\n"));
   4.100        // we should disable everything here, then enable what has been set
   4.101 @@ -559,6 +569,6 @@ XenNet_SetInformation(
   4.102        status = NDIS_STATUS_NOT_SUPPORTED;
   4.103        break;
   4.104    }
   4.105 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   4.106 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   4.107    return status;
   4.108  }
     5.1 --- a/xennet/xennet_rx.c	Tue Mar 25 14:06:35 2008 +1100
     5.2 +++ b/xennet/xennet_rx.c	Wed Mar 26 20:42:58 2008 +1100
     5.3 @@ -112,7 +112,11 @@ XenNet_RxBufferAlloc(struct xennet_info 
     5.4        break;
     5.5      mdl = get_page_from_freelist(xi);
     5.6      if (mdl == NULL)
     5.7 +    {
     5.8 +      KdPrint((__DRIVER_NAME "     Added %d out of %d buffers to rx ring\n", i, batch_target));
     5.9 +      KdPrint((__DRIVER_NAME "     (rx_outstanding = %d)\n", xi->rx_outstanding));
    5.10        break;
    5.11 +    }
    5.12      xi->rx_id_free--;
    5.13  
    5.14      /* Give to netback */
    5.15 @@ -133,7 +137,6 @@ XenNet_RxBufferAlloc(struct xennet_info 
    5.16        xi->event_channel);
    5.17    }
    5.18  
    5.19 -//KdPrint((__DRIVER_NAME "     Added %d out of %d buffers to rx ring\n", i, batch_target));
    5.20  
    5.21  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    5.22  
    5.23 @@ -159,8 +162,6 @@ XenNet_ParseHeader(
    5.24    struct xennet_info *xi
    5.25  )
    5.26  {
    5.27 -  USHORT i;
    5.28 -  PMDL mdl;
    5.29    UINT header_length;
    5.30  
    5.31  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.32 @@ -228,6 +229,7 @@ XenNet_SumIpHeader(
    5.33    USHORT i;
    5.34  
    5.35    NdisGetFirstBufferFromPacketSafe(packet, &mdl, &buffer, &buffer_length, &total_length, NormalPagePriority);
    5.36 +  ASSERT(mdl);
    5.37  
    5.38    buffer[XN_HDR_SIZE + 10] = 0;
    5.39    buffer[XN_HDR_SIZE + 11] = 0;
    5.40 @@ -260,10 +262,10 @@ XenNet_SumTcpPacket(
    5.41    UINT total_length;
    5.42    UINT buffer_length;
    5.43    USHORT buffer_offset;
    5.44 -  ULONG csum, pre_csum;
    5.45 +  ULONG csum;
    5.46    PUSHORT csum_ptr;
    5.47    USHORT remaining;
    5.48 -  USHORT tcp_length;
    5.49 +  USHORT ip4_length;
    5.50  
    5.51    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.52  
    5.53 @@ -274,19 +276,22 @@ XenNet_SumTcpPacket(
    5.54    NdisGetFirstBufferFromPacketSafe(packet, &mdl, &buffer, &buffer_length, &total_length, NormalPagePriority);
    5.55    ASSERT(mdl);
    5.56  
    5.57 +  ip4_length = GET_NET_USHORT(buffer[XN_HDR_SIZE + 2]);
    5.58 +
    5.59 +  if ((USHORT)(ip4_length + XN_HDR_SIZE) != total_length)
    5.60 +  {
    5.61 +    KdPrint((__DRIVER_NAME "     Size Mismatch %d (ip4_length + XN_HDR_SIZE) != %d (total_length)\n", ip4_length + XN_HDR_SIZE, total_length));
    5.62 +  }
    5.63 +
    5.64    csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + xi->rxpi.ip4_header_length + 16];
    5.65    *csum_ptr = 0;
    5.66  
    5.67 -  ASSERT((USHORT)(xi->rxpi.ip4_length + XN_HDR_SIZE) == xi->rxpi.total_length);
    5.68 -
    5.69 -  remaining = xi->rxpi.ip4_length - xi->rxpi.ip4_header_length - xi->rxpi.tcp_header_length;
    5.70    csum = 0;
    5.71    csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + 12]) + GET_NET_USHORT(buffer[XN_HDR_SIZE + 14]); // seq
    5.72    csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + 16]) + GET_NET_USHORT(buffer[XN_HDR_SIZE + 18]); // ack
    5.73    csum += ((USHORT)buffer[XN_HDR_SIZE + 9]);
    5.74  
    5.75 -  // can't use ip4_length here as we might have split the packet up
    5.76 -  remaining = GET_NET_USHORT(buffer[XN_HDR_SIZE + 2]) - xi->rxpi.ip4_header_length;
    5.77 +  remaining = ip4_length - xi->rxpi.ip4_header_length;
    5.78  
    5.79    csum += remaining;
    5.80  
    5.81 @@ -304,7 +309,7 @@ XenNet_SumTcpPacket(
    5.82        NdisQueryBufferSafe(mdl, &buffer, &buffer_length, NormalPagePriority);
    5.83        KdPrint((__DRIVER_NAME "     New buffer - unaligned...\n"));
    5.84        csum += ((USHORT)buffer[0]);
    5.85 -      buffer_offset = -1;
    5.86 +      buffer_offset = (USHORT)-1;
    5.87      }
    5.88      else
    5.89      {
    5.90 @@ -350,11 +355,11 @@ XenNet_GetData(
    5.91  
    5.92    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.93  
    5.94 -  *length = min(req_length, MmGetMdlByteCount(mdl) - xi->rxpi.curr_mdl_offset);
    5.95 +  *length = (USHORT)min(req_length, MmGetMdlByteCount(mdl) - xi->rxpi.curr_mdl_offset);
    5.96  
    5.97    KdPrint((__DRIVER_NAME "     req_length = %d, length = %d\n", req_length, *length));
    5.98  
    5.99 -  xi->rxpi.curr_mdl_offset += *length;
   5.100 +  xi->rxpi.curr_mdl_offset = xi->rxpi.curr_mdl_offset + *length;
   5.101    if (xi->rxpi.curr_mdl_offset == MmGetMdlByteCount(mdl))
   5.102    {
   5.103      xi->rxpi.curr_mdl++;
   5.104 @@ -380,12 +385,13 @@ XenNet_MakePacket(
   5.105    USHORT length;
   5.106    USHORT new_ip4_length;
   5.107    NDIS_STATUS status;
   5.108 -  int i;
   5.109 +  USHORT i;
   5.110  
   5.111    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   5.112  
   5.113    NdisAllocatePacket(&status, &packet, xi->packet_pool);
   5.114    ASSERT(status == NDIS_STATUS_SUCCESS);
   5.115 +  xi->rx_outstanding++;
   5.116    NDIS_SET_PACKET_HEADER_SIZE(packet, XN_HDR_SIZE);
   5.117  
   5.118    if (!xi->rxpi.split_required)
   5.119 @@ -406,15 +412,15 @@ XenNet_MakePacket(
   5.120      SET_NET_USHORT(out_buffer[XN_HDR_SIZE + 2], new_ip4_length);
   5.121      SET_NET_ULONG(out_buffer[XN_HDR_SIZE + xi->rxpi.ip4_header_length + 4], xi->rxpi.tcp_seq);
   5.122      xi->rxpi.tcp_seq += out_remaining;
   5.123 -    xi->rxpi.tcp_remaining -= out_remaining;
   5.124 +    xi->rxpi.tcp_remaining = xi->rxpi.tcp_remaining - out_remaining;
   5.125      do 
   5.126      {
   5.127 +      ASSERT(xi->rxpi.curr_mdl < xi->rxpi.mdl_count);
   5.128        in_buffer = XenNet_GetData(xi, out_remaining, &length);
   5.129        memcpy(&out_buffer[out_offset], in_buffer, length);
   5.130 -      out_remaining -= length;
   5.131 -      out_offset += length;
   5.132 -    } while (out_remaining != 0 && in_buffer != NULL);
   5.133 -    //length = xi->rxpi.mss - out_remaining;
   5.134 +      out_remaining = out_remaining - length;
   5.135 +      out_offset = out_offset + length;
   5.136 +    } while (out_remaining != 0); // && in_buffer != NULL);
   5.137      NdisChainBufferAtBack(packet, out_mdl);
   5.138      XenNet_SumIpHeader(xi, packet);
   5.139      NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_SUCCESS);
   5.140 @@ -431,21 +437,8 @@ XenNet_MakePackets(
   5.141    PULONG packet_count_p
   5.142  )
   5.143  {
   5.144 -  PNDIS_PACKET first_packet;
   5.145 -  PNDIS_PACKET curr_packet;
   5.146 -  PNDIS_BUFFER mdls[MAX_BUFFERS_PER_PACKET];
   5.147 -  ULONG mdl_count = 0;
   5.148 -  ULONG curr_in_mdl_index;
   5.149 -  PNDIS_BUFFER curr_out_mdl;
   5.150 -  ULONG curr_in_offset;
   5.151 -  ULONG curr_out_offset;
   5.152 -  PUCHAR curr_in_buffer;
   5.153 -  PUCHAR curr_out_buffer;
   5.154    USHORT i;
   5.155  
   5.156 -  ULONG total_in_remaining;
   5.157 -  ULONG buffer_in_remaining;
   5.158 -
   5.159    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "(packets = %p, packet_count = %d)\n", packets, *packet_count_p));
   5.160  
   5.161    XenNet_ParseHeader(xi);
   5.162 @@ -470,7 +463,7 @@ XenNet_MakePackets(
   5.163    }
   5.164    KdPrint((__DRIVER_NAME "     splitting packet\n"));
   5.165    xi->rxpi.tcp_remaining = xi->rxpi.tcp_length;
   5.166 -  if (MmGetMdlByteCount(xi->rxpi.mdls[0]) > XN_HDR_SIZE + xi->rxpi.ip4_header_length + xi->rxpi.tcp_header_length)
   5.167 +  if (MmGetMdlByteCount(xi->rxpi.mdls[0]) > (ULONG)(XN_HDR_SIZE + xi->rxpi.ip4_header_length + xi->rxpi.tcp_header_length))
   5.168      xi->rxpi.curr_mdl_offset = XN_HDR_SIZE + xi->rxpi.ip4_header_length + xi->rxpi.tcp_header_length;
   5.169    else
   5.170      xi->rxpi.curr_mdl = 1;
   5.171 @@ -482,12 +475,13 @@ XenNet_MakePackets(
   5.172      XenNet_SumTcpPacket(xi, packets[*packet_count_p]);
   5.173      (*packet_count_p)++;
   5.174    }
   5.175 +  ASSERT(xi->rxpi.curr_mdl == xi->rxpi.mdl_count);
   5.176    KdPrint((__DRIVER_NAME "     tcp_remaining = %d\n", xi->rxpi.tcp_remaining));
   5.177    // TODO: restore psh status to last packet
   5.178 -  for (i = 0; i < mdl_count; i++)
   5.179 +  for (i = 0; i < xi->rxpi.mdl_count; i++)
   5.180    {
   5.181 -    NdisAdjustBufferLength(mdls[i], PAGE_SIZE);
   5.182 -    put_page_on_freelist(xi, mdls[i]);
   5.183 +    NdisAdjustBufferLength(xi->rxpi.mdls[i], PAGE_SIZE);
   5.184 +    put_page_on_freelist(xi, xi->rxpi.mdls[i]);
   5.185    }
   5.186    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (split)\n"));
   5.187  }
   5.188 @@ -503,7 +497,6 @@ XenNet_RxBufferCheck(struct xennet_info 
   5.189    int moretodo;
   5.190    struct netif_rx_response *rxrsp = NULL;
   5.191    struct netif_extra_info *ei;
   5.192 -  NDIS_STATUS status;
   5.193    USHORT id;
   5.194    int cycles = 0;
   5.195  #if defined(XEN_PROFILE)
   5.196 @@ -537,14 +530,14 @@ XenNet_RxBufferCheck(struct xennet_info 
   5.197        {
   5.198          put_page_on_freelist(xi, mdl);
   5.199          ei = (struct netif_extra_info *)RING_GET_RESPONSE(&xi->rx, cons);
   5.200 -        xi->rxpi.extra_info = !!(ei->flags & XEN_NETIF_EXTRA_FLAG_MORE);
   5.201 +        xi->rxpi.extra_info = (BOOLEAN)!!(ei->flags & XEN_NETIF_EXTRA_FLAG_MORE);
   5.202          switch (ei->type)
   5.203          {
   5.204          case XEN_NETIF_EXTRA_TYPE_GSO:
   5.205            switch (ei->u.gso.type)
   5.206            {
   5.207            case XEN_NETIF_GSO_TYPE_TCPV4:
   5.208 -            xi->rxpi.mss = (PVOID)(xen_ulong_t)(ei->u.gso.size);
   5.209 +            xi->rxpi.mss = ei->u.gso.size;
   5.210              // TODO - put this assertion somewhere ASSERT(header_len + xi->rxpi.mss <= PAGE_SIZE); // this limits MTU to PAGE_SIZE - XN_HEADER_LEN
   5.211              break;
   5.212            default:
   5.213 @@ -581,9 +574,9 @@ XenNet_RxBufferCheck(struct xennet_info 
   5.214          }
   5.215          NdisAdjustBufferLength(mdl, rxrsp->status);
   5.216          xi->rxpi.mdls[xi->rxpi.mdl_count++] = mdl;
   5.217 -        xi->rxpi.extra_info = !!(rxrsp->flags & NETRXF_extra_info);
   5.218 -        xi->rxpi.more_frags = !!(rxrsp->flags & NETRXF_more_data);
   5.219 -        xi->rxpi.total_length += rxrsp->status;
   5.220 +        xi->rxpi.extra_info = (BOOLEAN)!!(rxrsp->flags & NETRXF_extra_info);
   5.221 +        xi->rxpi.more_frags = (BOOLEAN)!!(rxrsp->flags & NETRXF_more_data);
   5.222 +        xi->rxpi.total_length = xi->rxpi.total_length + rxrsp->status;
   5.223        }
   5.224  
   5.225        /* Packet done, add it to the list */
   5.226 @@ -593,8 +586,8 @@ XenNet_RxBufferCheck(struct xennet_info 
   5.227          RtlZeroMemory(&xi->rxpi, sizeof(xi->rxpi));
   5.228        }
   5.229      }
   5.230 +    ASSERT(packet_count < NET_RX_RING_SIZE);
   5.231      xi->rx.rsp_cons = prod;
   5.232 -
   5.233      RING_FINAL_CHECK_FOR_RESPONSES(&xi->rx, moretodo);
   5.234    } while (moretodo);
   5.235  
   5.236 @@ -616,7 +609,7 @@ XenNet_RxBufferCheck(struct xennet_info 
   5.237  #endif
   5.238    }
   5.239  
   5.240 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   5.241 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (rx_outstanding = %d)\n", xi->rx_outstanding));
   5.242  
   5.243  #if defined(XEN_PROFILE)
   5.244    ProfTime_RxBufferCheck.QuadPart += KeQueryPerformanceCounter(&dummy).QuadPart - tsc.QuadPart;
   5.245 @@ -659,6 +652,7 @@ XenNet_ReturnPacket(
   5.246      NdisUnchainBufferAtBack(Packet, &mdl);
   5.247    }
   5.248  
   5.249 +  xi->rx_outstanding--;
   5.250    NdisFreePacket(Packet);
   5.251  
   5.252    KeReleaseSpinLockFromDpcLevel(&xi->rx_lock);
   5.253 @@ -715,6 +709,7 @@ XenNet_RxInit(xennet_info_t *xi)
   5.254      xi->rx_buffers[i] = NULL;
   5.255    }
   5.256  
   5.257 +  xi->rx_outstanding = 0;
   5.258    XenNet_RxBufferAlloc(xi);
   5.259  
   5.260    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));