win-pvdrivers

changeset 1048:fba0ce4d9e54

Fix checksum problem on lso for xp/2003. Tidy up.
author James Harper <james.harper@bendigoit.com.au>
date Mon May 13 21:14:35 2013 +1000 (2013-05-13)
parents 0248483f90cc
children 4de2eb034713
files xennet/xennet.h xennet/xennet_common.c xennet/xennet_rx.c
line diff
     1.1 --- a/xennet/xennet.h	Mon May 13 20:50:48 2013 +1000
     1.2 +++ b/xennet/xennet.h	Mon May 13 21:14:35 2013 +1000
     1.3 @@ -45,8 +45,10 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  
     1.5  #define __DRIVER_NAME "XenNet"
     1.6  
     1.7 -#define PACKET_NEXT_PACKET_FIELD MiniportReservedEx[sizeof(PVOID)] // RX & TX
     1.8 -#define PACKET_FIRST_PB_FIELD MiniportReservedEx[0] // RX
     1.9 +//#define PACKET_NEXT_PACKET_FIELD MiniportReservedEx[sizeof(PVOID)] // RX & TX
    1.10 +//#define PACKET_FIRST_PB_FIELD MiniportReservedEx[0] // RX
    1.11 +#define PACKET_NEXT_PACKET_FIELD MiniportReservedEx[0] // RX & TX
    1.12 +#define PACKET_FIRST_PB_FIELD MiniportReservedEx[sizeof(PVOID)] // RX
    1.13  #define PACKET_LIST_ENTRY_FIELD MiniportReservedEx[sizeof(PVOID)] // TX (2 entries)
    1.14  #define PACKET_NEXT_PACKET(_packet) (*(PNDIS_PACKET *)&(_packet)->PACKET_NEXT_PACKET_FIELD)
    1.15  #define PACKET_LIST_ENTRY(_packet) (*(PLIST_ENTRY)&(_packet)->PACKET_LIST_ENTRY_FIELD)
    1.16 @@ -184,7 +186,7 @@ SET_NET_ULONG(PVOID ptr, ULONG data) {
    1.17  #define MIN_LOOKAHEAD_LENGTH (MAX_IP4_HEADER_LENGTH + MAX_TCP_HEADER_LENGTH)
    1.18  #define MAX_LOOKAHEAD_LENGTH PAGE_SIZE
    1.19  
    1.20 -#define LINUX_MAX_SG_ELEMENTS 19
    1.21 +#define LINUX_MAX_SG_ELEMENTS 18
    1.22  
    1.23  #define PAGE_LIST_SIZE (max(NET_RX_RING_SIZE, NET_TX_RING_SIZE) * 4)
    1.24  #define MULTICAST_LIST_MAX_SIZE 32
     2.1 --- a/xennet/xennet_common.c	Mon May 13 20:50:48 2013 +1000
     2.2 +++ b/xennet/xennet_common.c	Mon May 13 21:14:35 2013 +1000
     2.3 @@ -43,7 +43,6 @@ XenNet_BuildHeader(packet_info_t *pi, PU
     2.4    if (header == pi->first_mdl_virtual) {
     2.5      /* still working in the first buffer */
     2.6      if (new_header_size <= pi->first_mdl_length) {
     2.7 -      //KdPrint((__DRIVER_NAME "     new_header_size <= pi->first_mdl_length\n"));
     2.8        pi->header_length = new_header_size;
     2.9        if (pi->header_length == pi->first_mdl_length) {
    2.10          #if NTDDI_VERSION < NTDDI_VISTA
    2.11 @@ -60,7 +59,6 @@ XenNet_BuildHeader(packet_info_t *pi, PU
    2.12        //FUNCTION_EXIT();
    2.13        return TRUE;
    2.14      } else {
    2.15 -      //KdPrint((__DRIVER_NAME "     Switching to header_data\n"));
    2.16        memcpy(pi->header_data, header, pi->header_length);
    2.17        header = pi->header = pi->header_data;
    2.18      }
    2.19 @@ -69,12 +67,10 @@ XenNet_BuildHeader(packet_info_t *pi, PU
    2.20    bytes_remaining = new_header_size - pi->header_length;
    2.21    // TODO: if there are only a small number of bytes left in the current buffer then increase to consume that too... it would have to be no more than the size of header+mss though
    2.22  
    2.23 -  //KdPrint((__DRIVER_NAME "     A bytes_remaining = %d, pi->curr_mdl = %p\n", bytes_remaining, pi->curr_mdl));
    2.24    while (bytes_remaining && pi->curr_mdl) {
    2.25      ULONG copy_size;
    2.26      
    2.27      XN_ASSERT(pi->curr_mdl);
    2.28 -    //KdPrint((__DRIVER_NAME "     B bytes_remaining = %d, pi->curr_mdl = %p\n", bytes_remaining, pi->curr_mdl));
    2.29      if (MmGetMdlByteCount(pi->curr_mdl)) {
    2.30        PUCHAR src_addr;
    2.31        src_addr = MmGetSystemAddressForMdlSafe(pi->curr_mdl, NormalPagePriority);
    2.32 @@ -83,7 +79,6 @@ XenNet_BuildHeader(packet_info_t *pi, PU
    2.33          return FALSE;
    2.34        }
    2.35        copy_size = min(bytes_remaining, MmGetMdlByteCount(pi->curr_mdl) - pi->curr_mdl_offset);
    2.36 -      //KdPrint((__DRIVER_NAME "     B copy_size = %d\n", copy_size));
    2.37        memcpy(header + pi->header_length,
    2.38          src_addr + pi->curr_mdl_offset, copy_size);
    2.39        pi->curr_mdl_offset = (USHORT)(pi->curr_mdl_offset + copy_size);
     3.1 --- a/xennet/xennet_rx.c	Mon May 13 20:50:48 2013 +1000
     3.2 +++ b/xennet/xennet_rx.c	Mon May 13 21:14:35 2013 +1000
     3.3 @@ -232,8 +232,6 @@ XenNet_SumPacketData(
     3.4    USHORT ip4_length;
     3.5    BOOLEAN csum_span = TRUE; /* when the USHORT to be checksummed spans a buffer */
     3.6    
     3.7 -  //FUNCTION_ENTER();
     3.8 -
     3.9    NdisGetFirstBufferFromPacketSafe(packet, &mdl, &buffer, &buffer_length, &total_length, NormalPagePriority);
    3.10    if (!buffer) {
    3.11      FUNCTION_MSG("NdisGetFirstBufferFromPacketSafe failed, buffer == NULL\n");
    3.12 @@ -259,7 +257,7 @@ XenNet_SumPacketData(
    3.13      csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + pi->ip4_header_length + 6];
    3.14      break;
    3.15    default:
    3.16 -    KdPrint((__DRIVER_NAME "     Don't know how to calc sum for IP Proto %d\n", pi->ip_proto));
    3.17 +    FUNCTION_MSG("Don't know how to calc sum for IP Proto %d\n", pi->ip_proto);
    3.18      //FUNCTION_EXIT();
    3.19      return FALSE; // should never happen
    3.20    }
    3.21 @@ -489,10 +487,12 @@ XenNet_MakePacket(struct xennet_info *xi
    3.22        }
    3.23        out_remaining -= out_length;
    3.24      }
    3.25 +    #if NTDDI_VERSION < NTDDI_VISTA
    3.26      if (pi->split_required) {
    3.27        // TODO: only if Ip checksum is disabled...
    3.28 -      //XenNet_SumIpHeader(header_va, pi->ip4_header_length);
    3.29 +      XenNet_SumIpHeader(header_va, pi->ip4_header_length);
    3.30      }
    3.31 +    #endif
    3.32      if (header_extra > 0)
    3.33        pi->header_length -= header_extra;
    3.34    }
    3.35 @@ -508,7 +508,7 @@ XenNet_MakePacket(struct xennet_info *xi
    3.36      csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(
    3.37        packet, TcpIpChecksumPacketInfo);
    3.38      XN_ASSERT(csum_info->Value == 0);
    3.39 -    if (pi->csum_blank || pi->data_validated) {
    3.40 +    if (pi->csum_blank || pi->data_validated || pi->split_required) {
    3.41        BOOLEAN checksum_offload = FALSE;
    3.42        /* we know this is IPv4, and we know Linux always validates the IPv4 checksum for us */
    3.43        if (xi->setting_csum.V4Receive.IpChecksum) {
    3.44 @@ -606,7 +606,7 @@ XenNet_MakePacket(struct xennet_info *xi
    3.45    #if NTDDI_VERSION < NTDDI_VISTA
    3.46    /* windows gets lazy about ack packets and holds on to them forever under high load situations. we don't like this */
    3.47    NdisQueryPacketLength(packet, &packet_length);
    3.48 -  if (pi->ip_proto == 6 && packet_length <= NDIS_STATUS_RESOURCES_MAX_LENGTH)
    3.49 +  if (pi->parse_result != PARSE_OK || (pi->ip_proto == 6 && packet_length <= NDIS_STATUS_RESOURCES_MAX_LENGTH))
    3.50      NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_RESOURCES);
    3.51    else
    3.52      NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_SUCCESS);
    3.53 @@ -695,9 +695,6 @@ XenNet_MakePackets(struct xennet_info *x
    3.54        else
    3.55          pi->header[XN_HDR_SIZE + pi->ip4_header_length + 13] |= 8;
    3.56      }
    3.57 -    //XenNet_SumPacketData(pi, packet, TRUE);
    3.58 -    //entry = (PLIST_ENTRY)&packet->MiniportReservedEx[sizeof(PVOID)];
    3.59 -    //InsertTailList(rx_packet_list, entry);
    3.60    }
    3.61  done:
    3.62    page_buf = pi->first_pb;