win-pvdrivers

changeset 1011:c21a4feb4a27

Fix build under 2008
author James Harper <james.harper@bendigoit.com.au>
date Mon Feb 11 17:27:48 2013 +1100 (2013-02-11)
parents e06c60a6fe3f
children 9e076343bb8e
files xennet/xennet.c xennet/xennet.h xennet/xennet_common.c xennet/xennet_oid.c xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.c	Mon Feb 11 17:27:11 2013 +1100
     1.2 +++ b/xennet/xennet.c	Mon Feb 11 17:27:48 2013 +1100
     1.3 @@ -740,7 +740,7 @@ DriverEntry(PDRIVER_OBJECT driver_object
     1.4    }
     1.5  
     1.6    mini_chars.SendNetBufferListsHandler = XenNet_SendNetBufferLists;
     1.7 -  //mini_chars.CancelSendHandler = XenNet_CancelSend;
     1.8 +  mini_chars.CancelSendHandler = XenNet_CancelSend;
     1.9  
    1.10    mini_chars.ReturnNetBufferListsHandler = XenNet_ReturnNetBufferLists;
    1.11  
     2.1 --- a/xennet/xennet.h	Mon Feb 11 17:27:11 2013 +1100
     2.2 +++ b/xennet/xennet.h	Mon Feb 11 17:27:48 2013 +1100
     2.3 @@ -221,8 +221,11 @@ struct _shared_buffer_t {
     2.4  };
     2.5  
     2.6  typedef struct {
     2.7 -  //PNET_BUFFER packet; /* only set on the last packet */
     2.8 -  PNDIS_PACKET packet;
     2.9 +  #if NTDDI_VERSION < NTDDI_VISTA
    2.10 +  PNDIS_PACKET packet; /* only set on the last packet */
    2.11 +  #else
    2.12 +  PNET_BUFFER packet; /* only set on the last packet */
    2.13 +  #endif
    2.14    PVOID *cb;
    2.15    grant_ref_t gref;
    2.16  } tx_shadow_t;
     3.1 --- a/xennet/xennet_common.c	Mon Feb 11 17:27:11 2013 +1100
     3.2 +++ b/xennet/xennet_common.c	Mon Feb 11 17:27:48 2013 +1100
     3.3 @@ -523,7 +523,10 @@ XenNet_Disconnect(PVOID context, BOOLEAN
     3.4      KeWaitForSingleObject(&xi->backend_event, Executive, KernelMode, FALSE, NULL);
     3.5    }
     3.6    XnUnbindEvent(xi->handle, xi->event_channel);
     3.7 +  
     3.8 +#if NTDDI_VERSION < WINXP
     3.9    KeFlushQueuedDpcs();
    3.10 +#endif
    3.11    XenNet_TxShutdown(xi);
    3.12    XenNet_RxShutdown(xi);
    3.13    //pfn = (PFN_NUMBER)(MmGetPhysicalAddress(xi->rx_sring).QuadPart >> PAGE_SHIFT);
    3.14 @@ -537,7 +540,7 @@ XenNet_Disconnect(PVOID context, BOOLEAN
    3.15    }
    3.16    xi->device_state = DEVICE_STATE_DISCONNECTED;
    3.17    return STATUS_SUCCESS;
    3.18 -};
    3.19 +}
    3.20  
    3.21  VOID
    3.22  XenNet_DeviceCallback(PVOID context, ULONG callback_type, PVOID value) {
     4.1 --- a/xennet/xennet_oid.c	Mon Feb 11 17:27:11 2013 +1100
     4.2 +++ b/xennet/xennet_oid.c	Mon Feb 11 17:27:48 2013 +1100
     4.3 @@ -521,13 +521,15 @@ NDIS_STATUS
     4.4  XenNet_QueryOID_GEN_INTERRUPT_MODERATION(NDIS_HANDLE context, PVOID information_buffer, ULONG information_buffer_length, PULONG bytes_written, PULONG bytes_needed) {
     4.5    PNDIS_INTERRUPT_MODERATION_PARAMETERS nimp;
     4.6    UNREFERENCED_PARAMETER(context);
     4.7 +  UNREFERENCED_PARAMETER(bytes_needed);
     4.8 +  UNREFERENCED_PARAMETER(information_buffer_length);
     4.9    nimp = (PNDIS_INTERRUPT_MODERATION_PARAMETERS)information_buffer;
    4.10    nimp->Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
    4.11    nimp->Header.Revision = NDIS_INTERRUPT_MODERATION_PARAMETERS_REVISION_1;
    4.12    nimp->Header.Size = NDIS_SIZEOF_INTERRUPT_MODERATION_PARAMETERS_REVISION_1;
    4.13    nimp->Flags = 0;
    4.14    nimp->InterruptModeration = NdisInterruptModerationNotSupported;
    4.15 -  *bytes_read = sizeof(NDIS_INTERRUPT_MODERATION_PARAMETERS);
    4.16 +  *bytes_written = sizeof(NDIS_INTERRUPT_MODERATION_PARAMETERS);
    4.17    return STATUS_SUCCESS;
    4.18  }
    4.19  
    4.20 @@ -544,17 +546,21 @@ XenNet_SetOID_GEN_INTERRUPT_MODERATION(N
    4.21  NDIS_STATUS
    4.22  XenNet_QueryOID_GEN_STATISTICS(NDIS_HANDLE context, PVOID information_buffer, ULONG information_buffer_length, PULONG bytes_written, PULONG bytes_needed) {
    4.23    struct xennet_info *xi = context;
    4.24 +  UNREFERENCED_PARAMETER(bytes_needed);
    4.25 +  UNREFERENCED_PARAMETER(information_buffer_length);
    4.26  
    4.27    NdisMoveMemory(information_buffer, &xi->stats, sizeof(NDIS_STATISTICS_INFO));
    4.28 -  *bytes_read = sizeof(NDIS_STATISTICS_INFO);
    4.29 +  *bytes_written = sizeof(NDIS_STATISTICS_INFO);
    4.30    return STATUS_SUCCESS;
    4.31  }
    4.32  
    4.33  NDIS_STATUS
    4.34  XenNet_SetOID_OFFLOAD_ENCAPSULATION(NDIS_HANDLE context, PVOID information_buffer, ULONG information_buffer_length, PULONG bytes_read, PULONG bytes_needed) {
    4.35    struct xennet_info *xi = context;
    4.36 +  PNDIS_OFFLOAD_ENCAPSULATION noe = (PNDIS_OFFLOAD_ENCAPSULATION)information_buffer;
    4.37 +  UNREFERENCED_PARAMETER(bytes_needed);
    4.38 +  UNREFERENCED_PARAMETER(information_buffer_length);
    4.39    /* mostly assume that NDIS vets the settings for us */
    4.40 -  PNDIS_OFFLOAD_ENCAPSULATION noe = (PNDIS_OFFLOAD_ENCAPSULATION)information_buffer;
    4.41    if (noe->IPv4.EncapsulationType != NDIS_ENCAPSULATION_IEEE_802_3) {
    4.42      FUNCTION_MSG("Unknown Encapsulation Type %d\n", noe->IPv4.EncapsulationType);
    4.43      return NDIS_STATUS_NOT_SUPPORTED;
    4.44 @@ -588,6 +594,7 @@ XenNet_SetOID_OFFLOAD_ENCAPSULATION(NDIS
    4.45      FUNCTION_MSG(" IPv6.Enabled = NDIS_OFFLOAD_NO_CHANGE\n");
    4.46      break;
    4.47    }
    4.48 +  *bytes_read = sizeof(NDIS_OFFLOAD_ENCAPSULATION);
    4.49    FUNCTION_MSG(" IPv6.HeaderSize = %d\n", noe->IPv6.HeaderSize);
    4.50    return NDIS_STATUS_SUCCESS;
    4.51  }
    4.52 @@ -800,7 +807,6 @@ XenNet_OidRequest(NDIS_HANDLE adapter_co
    4.53    NTSTATUS status;
    4.54    int i;
    4.55    NDIS_OID oid;
    4.56 -  MINIPORT_OID_REQUEST *routine;
    4.57    
    4.58    //FUNCTION_ENTER();
    4.59    switch(oid_request->RequestType)
    4.60 @@ -828,7 +834,6 @@ XenNet_OidRequest(NDIS_HANDLE adapter_co
    4.61      return NDIS_STATUS_NOT_SUPPORTED;
    4.62    }
    4.63    //FUNCTION_MSG("Oid = %s\n", xennet_oids[i].oid_name);
    4.64 -  routine = NULL;
    4.65    switch(oid_request->RequestType)
    4.66    {
    4.67    case NdisRequestQueryInformation:
    4.68 @@ -838,12 +843,11 @@ XenNet_OidRequest(NDIS_HANDLE adapter_co
    4.69        oid_request->DATA.QUERY_INFORMATION.BytesNeeded = xennet_oids[i].min_length;
    4.70        return NDIS_STATUS_BUFFER_TOO_SHORT;
    4.71      }
    4.72 -    routine =  xennet_oids[i].query_routine;
    4.73 -    if (!routine) {
    4.74 +    if (!xennet_oids[i].query_routine) {
    4.75        //FUNCTION_MSG("Operation not supported\n");
    4.76        return NDIS_STATUS_NOT_SUPPORTED;
    4.77      }
    4.78 -    status = routine(adapter_context, oid_request->DATA.QUERY_INFORMATION.InformationBuffer, oid_request->DATA.QUERY_INFORMATION.InformationBufferLength, &oid_request->DATA.QUERY_INFORMATION.BytesWritten, &oid_request->DATA.QUERY_INFORMATION.BytesNeeded);
    4.79 +    status = xennet_oids[i].query_routine(adapter_context, oid_request->DATA.QUERY_INFORMATION.InformationBuffer, oid_request->DATA.QUERY_INFORMATION.InformationBufferLength, (PULONG)&oid_request->DATA.QUERY_INFORMATION.BytesWritten, (PULONG)&oid_request->DATA.QUERY_INFORMATION.BytesNeeded);
    4.80      break;
    4.81    case NdisRequestSetInformation:
    4.82      if (oid_request->DATA.SET_INFORMATION.InformationBufferLength < xennet_oids[i].min_length) {
    4.83 @@ -851,22 +855,15 @@ XenNet_OidRequest(NDIS_HANDLE adapter_co
    4.84        oid_request->DATA.SET_INFORMATION.BytesNeeded = xennet_oids[i].min_length;
    4.85        return NDIS_STATUS_BUFFER_TOO_SHORT;
    4.86      }
    4.87 -    routine =  xennet_oids[i].set_routine;
    4.88 -    if (!routine) {
    4.89 +    if (!xennet_oids[i].set_routine) {
    4.90        //FUNCTION_MSG("Operation not supported\n");
    4.91        return NDIS_STATUS_NOT_SUPPORTED;
    4.92      }
    4.93 -    XenNet_Query##oid(NDIS_HANDLE context, PVOID information_buffer, ULONG information_buffer_length, PULONG bytes_written, PULONG bytes_needed) { \
    4.94 -
    4.95 +    status = xennet_oids[i].set_routine(adapter_context, oid_request->DATA.SET_INFORMATION.InformationBuffer, oid_request->DATA.SET_INFORMATION.InformationBufferLength, (PULONG)&oid_request->DATA.SET_INFORMATION.BytesRead, (PULONG)&oid_request->DATA.SET_INFORMATION.BytesNeeded);
    4.96      break;
    4.97 -  }
    4.98 -  if (!routine) {
    4.99 -    //FUNCTION_MSG("Operation not supported\n");
   4.100 +  default:
   4.101      return NDIS_STATUS_NOT_SUPPORTED;
   4.102    }
   4.103 -  status = routine(adapter_context, oid_request);
   4.104 -  //FUNCTION_MSG("status = %08x\n", status);
   4.105 -  
   4.106    //FUNCTION_EXIT();
   4.107    return status;
   4.108  }
     5.1 --- a/xennet/xennet_rx.c	Mon Feb 11 17:27:11 2013 +1100
     5.2 +++ b/xennet/xennet_rx.c	Mon Feb 11 17:27:48 2013 +1100
     5.3 @@ -206,6 +206,7 @@ typedef struct {
     5.4  } rx_context_t;
     5.5  #endif
     5.6  
     5.7 +#if NTDDI_VERSION < NTDDI_VISTA
     5.8  /*
     5.9   NDIS5 appears to insist that the checksum on received packets is correct, and won't
    5.10   believe us when we lie about it, which happens when the packet is generated on the
    5.11 @@ -325,11 +326,12 @@ XenNet_SumPacketData(
    5.12    }
    5.13    return TRUE;
    5.14  }
    5.15 +#endif
    5.16  
    5.17  static BOOLEAN
    5.18  XenNet_MakePacket(struct xennet_info *xi, rx_context_t *rc, packet_info_t *pi) {
    5.19 +  #if NTDDI_VERSION < NTDDI_VISTA
    5.20    NDIS_STATUS status;
    5.21 -  #if NTDDI_VERSION < NTDDI_VISTA
    5.22    PNDIS_PACKET packet;
    5.23    #else
    5.24    PNET_BUFFER_LIST nbl;
    5.25 @@ -588,11 +590,11 @@ XenNet_MakePacket(struct xennet_info *xi
    5.26    } else if (pi->is_broadcast) {
    5.27      /* broadcast */
    5.28      xi->stats.ifHCInBroadcastPkts++;
    5.29 -    xi->stats.ifHCInBroadcastOctets += NET_BUFFER_DATA_LENGTH(nb);
    5.30 +    xi->stats.ifHCInBroadcastOctets += NET_BUFFER_DATA_LENGTH(packet);
    5.31    } else {
    5.32      /* unicast */
    5.33      xi->stats.ifHCInUcastPkts++;
    5.34 -    xi->stats.ifHCInUcastOctets += NET_BUFFER_DATA_LENGTH(nb);
    5.35 +    xi->stats.ifHCInUcastOctets += NET_BUFFER_DATA_LENGTH(packet);
    5.36    }
    5.37    #endif
    5.38  
    5.39 @@ -1207,9 +1209,9 @@ XenNet_RxInit(xennet_info_t *xi) {
    5.40    nb_pool_parameters.Header.Size = NDIS_SIZEOF_NET_BUFFER_POOL_PARAMETERS_REVISION_1;
    5.41    nb_pool_parameters.PoolTag = XENNET_POOL_TAG;
    5.42    nb_pool_parameters.DataSize = 0; /* the buffers come from the ring */
    5.43 -  xi->rx_nb_pool = NdisAllocateNetBufferPool(xi->adapter_handle, &nb_pool_parameters);
    5.44 -  if (!xi->rx_nb_pool) {
    5.45 -    KdPrint(("NdisAllocateNetBufferPool (rx_nb_pool) failed\n"));
    5.46 +  xi->rx_packet_pool = NdisAllocateNetBufferPool(xi->adapter_handle, &nb_pool_parameters);
    5.47 +  if (!xi->rx_packet_pool) {
    5.48 +    KdPrint(("NdisAllocateNetBufferPool (rx_packet_pool) failed\n"));
    5.49      return FALSE;
    5.50    }
    5.51    #endif
    5.52 @@ -1254,7 +1256,7 @@ FUNCTION_MSG("GGG\n");
    5.53    #if NTDDI_VERSION < NTDDI_VISTA
    5.54    NdisFreePacketPool(xi->rx_packet_pool);
    5.55    #else
    5.56 -  NdisFreeNetBufferPool(xi->rx_nb_pool);
    5.57 +  NdisFreeNetBufferPool(xi->rx_packet_pool);
    5.58    NdisFreeNetBufferListPool(xi->rx_nbl_pool);
    5.59    #endif
    5.60  
     6.1 --- a/xennet/xennet_tx.c	Mon Feb 11 17:27:11 2013 +1100
     6.2 +++ b/xennet/xennet_tx.c	Mon Feb 11 17:27:48 2013 +1100
     6.3 @@ -59,6 +59,7 @@ XenNet_PutCbOnRing(struct xennet_info *x
     6.4    return tx;
     6.5  }
     6.6  
     6.7 +#if 0
     6.8  static VOID dump_packet_data(PNDIS_PACKET packet, PCHAR header) {
     6.9    UINT mdl_count;
    6.10    PMDL first_mdl;
    6.11 @@ -67,20 +68,26 @@ static VOID dump_packet_data(PNDIS_PACKE
    6.12    NdisQueryPacket(packet, NULL, (PUINT)&mdl_count, &first_mdl, (PUINT)&total_length);
    6.13    FUNCTION_MSG("%s mdl_count = %d, first_mdl = %p, total_length = %d\n", header, mdl_count, first_mdl, total_length);
    6.14  }
    6.15 +#endif
    6.16    
    6.17  /* Called at DISPATCH_LEVEL with tx_lock held */
    6.18  /*
    6.19   * Send one NDIS_PACKET. This may involve multiple entries on TX ring.
    6.20   */
    6.21 +#if NTDDI_VERSION < NTDDI_VISTA
    6.22  static BOOLEAN
    6.23 -XenNet_HWSendPacket(struct xennet_info *xi, PNDIS_PACKET packet)
    6.24 -{
    6.25 +XenNet_HWSendPacket(struct xennet_info *xi, PNDIS_PACKET packet) {
    6.26 +#else
    6.27 +static BOOLEAN
    6.28 +XenNet_HWSendPacket(struct xennet_info *xi, PNET_BUFFER packet) {
    6.29 +#endif
    6.30    struct netif_tx_request *tx0 = NULL;
    6.31    struct netif_tx_request *txN = NULL;
    6.32    struct netif_extra_info *ei = NULL;
    6.33    ULONG mss = 0;
    6.34    #if NTDDI_VERSION < NTDDI_VISTA
    6.35    PNDIS_TCP_IP_CHECKSUM_PACKET_INFO csum_info;
    6.36 +  UINT mdl_count;
    6.37    #else
    6.38    NDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO lso_info;
    6.39    NDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO csum_info;
    6.40 @@ -96,7 +103,6 @@ XenNet_HWSendPacket(struct xennet_info *
    6.41    ULONG coalesce_remaining = 0;
    6.42    grant_ref_t gref;
    6.43    ULONG tx_length = 0;
    6.44 -  UINT mdl_count;
    6.45    
    6.46    gref = XnAllocateGrant(xi->handle, (ULONG)'XNTX');
    6.47    if (gref == INVALID_GRANT_REF)
    6.48 @@ -119,10 +125,10 @@ XenNet_HWSendPacket(struct xennet_info *
    6.49    /* create a new MDL over the data portion of the first MDL in the packet... it's just easier this way */
    6.50    IoBuildPartialMdl(packet->CurrentMdl,
    6.51      &pi.first_mdl_storage,
    6.52 -    (PUCHAR)MmGetMdlVirtualAddress(nb->CurrentMdl) + nb->CurrentMdlOffset,
    6.53 -    MmGetMdlByteCount(nb->CurrentMdl) - nb->CurrentMdlOffset);
    6.54 -  pi.total_length = nb->DataLength;
    6.55 -  pi.first_mdl_storage.Next = nb->CurrentMdl->Next;
    6.56 +    (PUCHAR)MmGetMdlVirtualAddress(packet->CurrentMdl) + packet->CurrentMdlOffset,
    6.57 +    MmGetMdlByteCount(packet->CurrentMdl) - packet->CurrentMdlOffset);
    6.58 +  pi.total_length = packet->DataLength;
    6.59 +  pi.first_mdl_storage.Next = packet->CurrentMdl->Next;
    6.60    pi.first_mdl = pi.curr_mdl = &pi.first_mdl_storage;
    6.61    #endif
    6.62    pi.first_mdl_offset = pi.curr_mdl_offset = 0;
    6.63 @@ -177,7 +183,7 @@ XenNet_HWSendPacket(struct xennet_info *
    6.64      }
    6.65    }
    6.66    #else
    6.67 -  csum_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(nb), TcpIpChecksumNetBufferListInfo);
    6.68 +  csum_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(packet), TcpIpChecksumNetBufferListInfo);
    6.69    if (csum_info.Transmit.IsIPv4) {
    6.70      if (csum_info.Transmit.TcpChecksum) {
    6.71        flags |= NETTXF_csum_blank | NETTXF_data_validated;
    6.72 @@ -192,7 +198,7 @@ XenNet_HWSendPacket(struct xennet_info *
    6.73    #if NTDDI_VERSION < NTDDI_VISTA
    6.74    mss = PtrToUlong(NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpLargeSendPacketInfo));
    6.75    #else
    6.76 -  lso_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(nb), TcpLargeSendNetBufferListInfo);
    6.77 +  lso_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(packet), TcpLargeSendNetBufferListInfo);
    6.78    switch (lso_info.Transmit.Type) {
    6.79    case NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE:
    6.80      mss = lso_info.LsoV1Transmit.MSS;
    6.81 @@ -460,26 +466,26 @@ XenNet_TxBufferGC(struct xennet_info *xi
    6.82          header = MmGetSystemAddressForMdlSafe(mdl, LowPagePriority);
    6.83          #if NTDDI_VERSION < NTDDI_VISTA
    6.84          #else
    6.85 -        header += NET_BUFFER_CURRENT_MDL_OFFSET(nb);
    6.86 +        header += NET_BUFFER_CURRENT_MDL_OFFSET(packet);
    6.87          #endif
    6.88  
    6.89          #if NTDDI_VERSION < NTDDI_VISTA
    6.90          #else
    6.91 -        xi->stats.ifHCOutOctets += nb->DataLength;
    6.92 -        if (nb->DataLength < XN_HDR_SIZE || !(header[0] & 0x01)) {
    6.93 +        xi->stats.ifHCOutOctets += packet->DataLength;
    6.94 +        if (packet->DataLength < XN_HDR_SIZE || !(header[0] & 0x01)) {
    6.95            /* unicast or tiny packet */
    6.96            xi->stats.ifHCOutUcastPkts++;
    6.97 -          xi->stats.ifHCOutUcastOctets += nb->DataLength;
    6.98 +          xi->stats.ifHCOutUcastOctets += packet->DataLength;
    6.99          }
   6.100          else if (header[0] == 0xFF && header[1] == 0xFF && header[2] == 0xFF
   6.101                   && header[3] == 0xFF && header[4] == 0xFF && header[5] == 0xFF) {
   6.102            /* broadcast */
   6.103            xi->stats.ifHCOutBroadcastPkts++;
   6.104 -          xi->stats.ifHCOutBroadcastOctets += nb->DataLength;
   6.105 +          xi->stats.ifHCOutBroadcastOctets += packet->DataLength;
   6.106          } else {
   6.107            /* multicast */
   6.108            xi->stats.ifHCOutMulticastPkts++;
   6.109 -          xi->stats.ifHCOutMulticastOctets += nb->DataLength;
   6.110 +          xi->stats.ifHCOutMulticastOctets += packet->DataLength;
   6.111          }
   6.112          #endif
   6.113          
   6.114 @@ -492,16 +498,16 @@ XenNet_TxBufferGC(struct xennet_info *xi
   6.115          }
   6.116          tail = packet;
   6.117          #else
   6.118 -        nbl = NB_NBL(nb);
   6.119 +        nbl = NB_NBL(packet);
   6.120          NBL_REF(nbl)--;
   6.121          if (!NBL_REF(nbl)) {
   6.122            NET_BUFFER_LIST_NEXT_NBL(nbl) = NULL;
   6.123 -          if (nbl_head) {
   6.124 -            NET_BUFFER_LIST_NEXT_NBL(nbl_tail) = nbl;
   6.125 -            nbl_tail = nbl;
   6.126 +          if (head) {
   6.127 +            NET_BUFFER_LIST_NEXT_NBL(tail) = nbl;
   6.128 +            tail = nbl;
   6.129            } else {
   6.130 -            nbl_head = nbl;
   6.131 -            nbl_tail = nbl;
   6.132 +            head = nbl;
   6.133 +            tail = nbl;
   6.134            }
   6.135          }
   6.136          #endif
   6.137 @@ -531,8 +537,8 @@ XenNet_TxBufferGC(struct xennet_info *xi
   6.138      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_SUCCESS);
   6.139    }
   6.140    #else
   6.141 -  if (nbl_head)
   6.142 -    NdisMSendNetBufferListsComplete(xi->adapter_handle, nbl_head, NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL);
   6.143 +  if (head)
   6.144 +    NdisMSendNetBufferListsComplete(xi->adapter_handle, head, NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL);
   6.145    #endif
   6.146  
   6.147    /* must be done after we have truly given back all packets */
   6.148 @@ -620,7 +626,6 @@ XenNet_SendNetBufferLists(
   6.149  }
   6.150  #endif
   6.151  
   6.152 -#if 0
   6.153  VOID
   6.154  XenNet_CancelSend(NDIS_HANDLE adapter_context, PVOID cancel_id)
   6.155  {
   6.156 @@ -630,7 +635,6 @@ XenNet_CancelSend(NDIS_HANDLE adapter_co
   6.157      
   6.158    FUNCTION_EXIT();
   6.159  }
   6.160 -#endif
   6.161  
   6.162  BOOLEAN
   6.163  XenNet_TxInit(xennet_info_t *xi) {
   6.164 @@ -695,8 +699,8 @@ XenNet_TxShutdown(xennet_info_t *xi) {
   6.165      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_FAILURE);
   6.166      entry = RemoveHeadList(&xi->tx_waiting_pkt_list);
   6.167      #else
   6.168 -    packet = CONTAINING_RECORD(nb_entry, NET_BUFFER, NB_LIST_ENTRY_FIELD);
   6.169 -    nbl = NB_NBL(nb);
   6.170 +    packet = CONTAINING_RECORD(entry, NET_BUFFER, NB_LIST_ENTRY_FIELD);
   6.171 +    nbl = NB_NBL(packet);
   6.172      NBL_REF(nbl)--;
   6.173      if (!NBL_REF(nbl)) {
   6.174        nbl->Status = NDIS_STATUS_FAILURE;