win-pvdrivers

changeset 421:dcfc2f91a501

Fixed a crash on xennet driver unload where a buffer wasn't being set back to PAGE_SIZE.
Notified windows when an rx packet had already had its checksum verified.
author James Harper <james.harper@bendigoit.com.au>
date Thu Aug 21 14:19:03 2008 +1000 (2008-08-21)
parents b3f2f9aef0fc
children 9b7614f440b1
files xennet/xennet.h xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.h	Thu Aug 21 13:44:24 2008 +1000
     1.2 +++ b/xennet/xennet.h	Thu Aug 21 14:19:03 2008 +1000
     1.3 @@ -129,7 +129,8 @@ typedef struct {
     1.4    USHORT curr_mdl_offset;
     1.5    USHORT mss;
     1.6    NDIS_TCP_IP_CHECKSUM_PACKET_INFO csum_info;
     1.7 -  BOOLEAN csum_calc_required;
     1.8 +  BOOLEAN csum_blank;
     1.9 +  BOOLEAN data_validated;
    1.10    BOOLEAN split_required;
    1.11    UCHAR ip_version;
    1.12    PUCHAR header;
     2.1 --- a/xennet/xennet_rx.c	Thu Aug 21 13:44:24 2008 +1000
     2.2 +++ b/xennet/xennet_rx.c	Thu Aug 21 14:19:03 2008 +1000
     2.3 @@ -153,6 +153,7 @@ XenNet_MakePacket(struct xennet_info *xi
     2.4      xi->rx_outstanding++;
     2.5      for (i = 0; i < xi->rxpi.mdl_count; i++)
     2.6        NdisChainBufferAtBack(packet, xi->rxpi.mdls[i]);
     2.7 +
     2.8      NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_SUCCESS);
     2.9    }
    2.10    else
    2.11 @@ -307,6 +308,7 @@ XenNet_MakePackets(
    2.12    PNDIS_PACKET packet;
    2.13    PLIST_ENTRY entry;
    2.14    UCHAR psh;
    2.15 +  PNDIS_TCP_IP_CHECKSUM_PACKET_INFO csum_info;
    2.16  
    2.17  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "(packets = %p, packet_count = %d)\n", packets, *packet_count_p));
    2.18  
    2.19 @@ -325,8 +327,14 @@ XenNet_MakePackets(
    2.20        packet_count = 0;
    2.21        goto done;
    2.22      }
    2.23 -    if (xi->rxpi.csum_calc_required)
    2.24 +    if (xi->rxpi.csum_blank)
    2.25        XenNet_SumPacketData(&xi->rxpi, packet);
    2.26 +    if (xi->rxpi.csum_blank || xi->rxpi.data_validated)
    2.27 +    {
    2.28 +      csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(
    2.29 +        packet, TcpIpChecksumPacketInfo);
    2.30 +      csum_info->Receive.NdisPacketTcpChecksumSucceeded = TRUE;
    2.31 +    }
    2.32      entry = (PLIST_ENTRY)&packet->MiniportReservedEx[sizeof(PVOID)];
    2.33      InsertTailList(rx_packet_list, entry);
    2.34      RtlZeroMemory(&xi->rxpi, sizeof(xi->rxpi));
    2.35 @@ -351,7 +359,7 @@ XenNet_MakePackets(
    2.36    else
    2.37      xi->rxpi.curr_mdl = 1;
    2.38  
    2.39 -  // we can make this assumption as we are only ever doing this for tcp4
    2.40 +  /* we can make certain assumptions here as the following code is only for tcp4 */
    2.41    psh = xi->rxpi.header[XN_HDR_SIZE + xi->rxpi.ip4_header_length + 14] & 16;
    2.42    while (xi->rxpi.tcp_remaining)
    2.43    {
    2.44 @@ -365,6 +373,9 @@ XenNet_MakePackets(
    2.45        xi->stat_rx_no_buffer++;
    2.46        break; /* we are out of memory - just drop the packets */
    2.47      }
    2.48 +    csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(
    2.49 +      packet, TcpIpChecksumPacketInfo);
    2.50 +    csum_info->Receive.NdisPacketTcpChecksumSucceeded = TRUE;
    2.51      if (psh)
    2.52      {
    2.53        NdisGetFirstBufferFromPacketSafe(packet, &mdl, &buffer, &buffer_length, &total_length, NormalPagePriority);
    2.54 @@ -469,7 +480,9 @@ XenNet_RxBufferCheck(struct xennet_info 
    2.55          if (!xi->rxpi.more_frags) // handling the packet's 1st buffer
    2.56          {
    2.57            if (rxrsp->flags & NETRXF_csum_blank)
    2.58 -            xi->rxpi.csum_calc_required = TRUE;
    2.59 +            xi->rxpi.csum_blank = TRUE;
    2.60 +          if (rxrsp->flags & NETRXF_data_validated)
    2.61 +            xi->rxpi.data_validated = TRUE;
    2.62          }
    2.63          NdisAdjustBufferLength(mdl, rxrsp->status);
    2.64          xi->rxpi.mdls[xi->rxpi.mdl_count++] = mdl;
     3.1 --- a/xennet/xennet_tx.c	Thu Aug 21 13:44:24 2008 +1000
     3.2 +++ b/xennet/xennet_tx.c	Thu Aug 21 14:19:03 2008 +1000
     3.3 @@ -145,7 +145,10 @@ XenNet_HWSendPacket(struct xennet_info *
     3.4        KdPrint((__DRIVER_NAME "     Out of buffers on send\n"));
     3.5        pages_required = page_num;
     3.6        for (page_num = 0; page_num < pages_required; page_num++)
     3.7 +      {
     3.8 +        NdisAdjustBufferLength(pi.mdls[page_num], PAGE_SIZE);
     3.9          XenFreelist_PutPage(&xi->tx_freelist, pi.mdls[page_num]);
    3.10 +      }
    3.11        return FALSE;
    3.12      }
    3.13      out_buffer = MmGetMdlVirtualAddress(pi.mdls[page_num]);
    3.14 @@ -406,6 +409,7 @@ XenNet_TxResumeStart(xennet_info_t *xi)
    3.15    {
    3.16      if (xi->tx_mdls[i])
    3.17      {
    3.18 +      NdisAdjustBufferLength(xi->tx_mdls[i], PAGE_SIZE);
    3.19        XenFreelist_PutPage(&xi->tx_freelist, xi->tx_mdls[i]);
    3.20        xi->tx_mdls[i] = NULL;
    3.21      }
    3.22 @@ -499,7 +503,10 @@ XenNet_TxShutdown(xennet_info_t *xi)
    3.23  */
    3.24      mdl = xi->tx_mdls[i];
    3.25      if (mdl)
    3.26 +    {
    3.27 +      NdisAdjustBufferLength(xi->tx_mdls[i], PAGE_SIZE);
    3.28        XenFreelist_PutPage(&xi->tx_freelist, xi->tx_mdls[i]);
    3.29 +    }
    3.30    }
    3.31  
    3.32    XenFreelist_Dispose(&xi->tx_freelist);