win-pvdrivers

diff xennet/xennet_tx.c @ 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 4cda50fe71d5
children 1ce315b193d1
line diff
     1.1 --- a/xennet/xennet_tx.c	Mon Feb 11 17:27:11 2013 +1100
     1.2 +++ b/xennet/xennet_tx.c	Mon Feb 11 17:27:48 2013 +1100
     1.3 @@ -59,6 +59,7 @@ XenNet_PutCbOnRing(struct xennet_info *x
     1.4    return tx;
     1.5  }
     1.6  
     1.7 +#if 0
     1.8  static VOID dump_packet_data(PNDIS_PACKET packet, PCHAR header) {
     1.9    UINT mdl_count;
    1.10    PMDL first_mdl;
    1.11 @@ -67,20 +68,26 @@ static VOID dump_packet_data(PNDIS_PACKE
    1.12    NdisQueryPacket(packet, NULL, (PUINT)&mdl_count, &first_mdl, (PUINT)&total_length);
    1.13    FUNCTION_MSG("%s mdl_count = %d, first_mdl = %p, total_length = %d\n", header, mdl_count, first_mdl, total_length);
    1.14  }
    1.15 +#endif
    1.16    
    1.17  /* Called at DISPATCH_LEVEL with tx_lock held */
    1.18  /*
    1.19   * Send one NDIS_PACKET. This may involve multiple entries on TX ring.
    1.20   */
    1.21 +#if NTDDI_VERSION < NTDDI_VISTA
    1.22  static BOOLEAN
    1.23 -XenNet_HWSendPacket(struct xennet_info *xi, PNDIS_PACKET packet)
    1.24 -{
    1.25 +XenNet_HWSendPacket(struct xennet_info *xi, PNDIS_PACKET packet) {
    1.26 +#else
    1.27 +static BOOLEAN
    1.28 +XenNet_HWSendPacket(struct xennet_info *xi, PNET_BUFFER packet) {
    1.29 +#endif
    1.30    struct netif_tx_request *tx0 = NULL;
    1.31    struct netif_tx_request *txN = NULL;
    1.32    struct netif_extra_info *ei = NULL;
    1.33    ULONG mss = 0;
    1.34    #if NTDDI_VERSION < NTDDI_VISTA
    1.35    PNDIS_TCP_IP_CHECKSUM_PACKET_INFO csum_info;
    1.36 +  UINT mdl_count;
    1.37    #else
    1.38    NDIS_TCP_LARGE_SEND_OFFLOAD_NET_BUFFER_LIST_INFO lso_info;
    1.39    NDIS_TCP_IP_CHECKSUM_NET_BUFFER_LIST_INFO csum_info;
    1.40 @@ -96,7 +103,6 @@ XenNet_HWSendPacket(struct xennet_info *
    1.41    ULONG coalesce_remaining = 0;
    1.42    grant_ref_t gref;
    1.43    ULONG tx_length = 0;
    1.44 -  UINT mdl_count;
    1.45    
    1.46    gref = XnAllocateGrant(xi->handle, (ULONG)'XNTX');
    1.47    if (gref == INVALID_GRANT_REF)
    1.48 @@ -119,10 +125,10 @@ XenNet_HWSendPacket(struct xennet_info *
    1.49    /* create a new MDL over the data portion of the first MDL in the packet... it's just easier this way */
    1.50    IoBuildPartialMdl(packet->CurrentMdl,
    1.51      &pi.first_mdl_storage,
    1.52 -    (PUCHAR)MmGetMdlVirtualAddress(nb->CurrentMdl) + nb->CurrentMdlOffset,
    1.53 -    MmGetMdlByteCount(nb->CurrentMdl) - nb->CurrentMdlOffset);
    1.54 -  pi.total_length = nb->DataLength;
    1.55 -  pi.first_mdl_storage.Next = nb->CurrentMdl->Next;
    1.56 +    (PUCHAR)MmGetMdlVirtualAddress(packet->CurrentMdl) + packet->CurrentMdlOffset,
    1.57 +    MmGetMdlByteCount(packet->CurrentMdl) - packet->CurrentMdlOffset);
    1.58 +  pi.total_length = packet->DataLength;
    1.59 +  pi.first_mdl_storage.Next = packet->CurrentMdl->Next;
    1.60    pi.first_mdl = pi.curr_mdl = &pi.first_mdl_storage;
    1.61    #endif
    1.62    pi.first_mdl_offset = pi.curr_mdl_offset = 0;
    1.63 @@ -177,7 +183,7 @@ XenNet_HWSendPacket(struct xennet_info *
    1.64      }
    1.65    }
    1.66    #else
    1.67 -  csum_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(nb), TcpIpChecksumNetBufferListInfo);
    1.68 +  csum_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(packet), TcpIpChecksumNetBufferListInfo);
    1.69    if (csum_info.Transmit.IsIPv4) {
    1.70      if (csum_info.Transmit.TcpChecksum) {
    1.71        flags |= NETTXF_csum_blank | NETTXF_data_validated;
    1.72 @@ -192,7 +198,7 @@ XenNet_HWSendPacket(struct xennet_info *
    1.73    #if NTDDI_VERSION < NTDDI_VISTA
    1.74    mss = PtrToUlong(NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpLargeSendPacketInfo));
    1.75    #else
    1.76 -  lso_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(nb), TcpLargeSendNetBufferListInfo);
    1.77 +  lso_info.Value = NET_BUFFER_LIST_INFO(NB_NBL(packet), TcpLargeSendNetBufferListInfo);
    1.78    switch (lso_info.Transmit.Type) {
    1.79    case NDIS_TCP_LARGE_SEND_OFFLOAD_V1_TYPE:
    1.80      mss = lso_info.LsoV1Transmit.MSS;
    1.81 @@ -460,26 +466,26 @@ XenNet_TxBufferGC(struct xennet_info *xi
    1.82          header = MmGetSystemAddressForMdlSafe(mdl, LowPagePriority);
    1.83          #if NTDDI_VERSION < NTDDI_VISTA
    1.84          #else
    1.85 -        header += NET_BUFFER_CURRENT_MDL_OFFSET(nb);
    1.86 +        header += NET_BUFFER_CURRENT_MDL_OFFSET(packet);
    1.87          #endif
    1.88  
    1.89          #if NTDDI_VERSION < NTDDI_VISTA
    1.90          #else
    1.91 -        xi->stats.ifHCOutOctets += nb->DataLength;
    1.92 -        if (nb->DataLength < XN_HDR_SIZE || !(header[0] & 0x01)) {
    1.93 +        xi->stats.ifHCOutOctets += packet->DataLength;
    1.94 +        if (packet->DataLength < XN_HDR_SIZE || !(header[0] & 0x01)) {
    1.95            /* unicast or tiny packet */
    1.96            xi->stats.ifHCOutUcastPkts++;
    1.97 -          xi->stats.ifHCOutUcastOctets += nb->DataLength;
    1.98 +          xi->stats.ifHCOutUcastOctets += packet->DataLength;
    1.99          }
   1.100          else if (header[0] == 0xFF && header[1] == 0xFF && header[2] == 0xFF
   1.101                   && header[3] == 0xFF && header[4] == 0xFF && header[5] == 0xFF) {
   1.102            /* broadcast */
   1.103            xi->stats.ifHCOutBroadcastPkts++;
   1.104 -          xi->stats.ifHCOutBroadcastOctets += nb->DataLength;
   1.105 +          xi->stats.ifHCOutBroadcastOctets += packet->DataLength;
   1.106          } else {
   1.107            /* multicast */
   1.108            xi->stats.ifHCOutMulticastPkts++;
   1.109 -          xi->stats.ifHCOutMulticastOctets += nb->DataLength;
   1.110 +          xi->stats.ifHCOutMulticastOctets += packet->DataLength;
   1.111          }
   1.112          #endif
   1.113          
   1.114 @@ -492,16 +498,16 @@ XenNet_TxBufferGC(struct xennet_info *xi
   1.115          }
   1.116          tail = packet;
   1.117          #else
   1.118 -        nbl = NB_NBL(nb);
   1.119 +        nbl = NB_NBL(packet);
   1.120          NBL_REF(nbl)--;
   1.121          if (!NBL_REF(nbl)) {
   1.122            NET_BUFFER_LIST_NEXT_NBL(nbl) = NULL;
   1.123 -          if (nbl_head) {
   1.124 -            NET_BUFFER_LIST_NEXT_NBL(nbl_tail) = nbl;
   1.125 -            nbl_tail = nbl;
   1.126 +          if (head) {
   1.127 +            NET_BUFFER_LIST_NEXT_NBL(tail) = nbl;
   1.128 +            tail = nbl;
   1.129            } else {
   1.130 -            nbl_head = nbl;
   1.131 -            nbl_tail = nbl;
   1.132 +            head = nbl;
   1.133 +            tail = nbl;
   1.134            }
   1.135          }
   1.136          #endif
   1.137 @@ -531,8 +537,8 @@ XenNet_TxBufferGC(struct xennet_info *xi
   1.138      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_SUCCESS);
   1.139    }
   1.140    #else
   1.141 -  if (nbl_head)
   1.142 -    NdisMSendNetBufferListsComplete(xi->adapter_handle, nbl_head, NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL);
   1.143 +  if (head)
   1.144 +    NdisMSendNetBufferListsComplete(xi->adapter_handle, head, NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL);
   1.145    #endif
   1.146  
   1.147    /* must be done after we have truly given back all packets */
   1.148 @@ -620,7 +626,6 @@ XenNet_SendNetBufferLists(
   1.149  }
   1.150  #endif
   1.151  
   1.152 -#if 0
   1.153  VOID
   1.154  XenNet_CancelSend(NDIS_HANDLE adapter_context, PVOID cancel_id)
   1.155  {
   1.156 @@ -630,7 +635,6 @@ XenNet_CancelSend(NDIS_HANDLE adapter_co
   1.157      
   1.158    FUNCTION_EXIT();
   1.159  }
   1.160 -#endif
   1.161  
   1.162  BOOLEAN
   1.163  XenNet_TxInit(xennet_info_t *xi) {
   1.164 @@ -695,8 +699,8 @@ XenNet_TxShutdown(xennet_info_t *xi) {
   1.165      NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_FAILURE);
   1.166      entry = RemoveHeadList(&xi->tx_waiting_pkt_list);
   1.167      #else
   1.168 -    packet = CONTAINING_RECORD(nb_entry, NET_BUFFER, NB_LIST_ENTRY_FIELD);
   1.169 -    nbl = NB_NBL(nb);
   1.170 +    packet = CONTAINING_RECORD(entry, NET_BUFFER, NB_LIST_ENTRY_FIELD);
   1.171 +    nbl = NB_NBL(packet);
   1.172      NBL_REF(nbl)--;
   1.173      if (!NBL_REF(nbl)) {
   1.174        nbl->Status = NDIS_STATUS_FAILURE;