win-pvdrivers

changeset 234:dffb6524631b

Saved values we get from the offload SET function, not really using it yet though. Now calculating UDP checksums correctly.
author James Harper <james.harper@bendigoit.com.au>
date Fri Mar 28 23:05:40 2008 +1100 (2008-03-28)
parents 098898889f00
children f126c95d8205
files common.inc xennet/xennet.h xennet/xennet_oid.c xennet/xennet_rx.c
line diff
     1.1 --- a/common.inc	Thu Mar 27 16:39:55 2008 -0700
     1.2 +++ b/common.inc	Fri Mar 28 23:05:40 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.5.96
     1.5 +VERSION=0.8.5.101
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/xennet/xennet.h	Thu Mar 27 16:39:55 2008 -0700
     2.2 +++ b/xennet/xennet.h	Fri Mar 28 23:05:40 2008 +1100
     2.3 @@ -197,6 +197,9 @@ struct xennet_info
     2.4    ULONG config_gso;
     2.5    ULONG config_mtu;
     2.6  
     2.7 +  NDIS_TASK_TCP_IP_CHECKSUM setting_csum;
     2.8 +  ULONG setting_max_offload;
     2.9 +
    2.10    /* config stuff calculated from the above */
    2.11    ULONG config_max_pkt_size;
    2.12  
     3.1 --- a/xennet/xennet_oid.c	Thu Mar 27 16:39:55 2008 -0700
     3.2 +++ b/xennet/xennet_oid.c	Fri Mar 28 23:05:40 2008 +1100
     3.3 @@ -538,6 +538,7 @@ XenNet_SetInformation(
     3.4            *BytesRead += sizeof(NDIS_TASK_TCP_IP_CHECKSUM);
     3.5            KdPrint(("TcpIpChecksumNdisTask\n"));
     3.6            nttic = (PNDIS_TASK_TCP_IP_CHECKSUM)nto->TaskBuffer;
     3.7 +          xi->setting_csum = *nttic;
     3.8            KdPrint(("  V4Transmit.IpOptionsSupported  = %d\n", nttic->V4Transmit.IpOptionsSupported));
     3.9            KdPrint(("  V4Transmit.TcpOptionsSupported = %d\n", nttic->V4Transmit.TcpOptionsSupported));
    3.10            KdPrint(("  V4Transmit.TcpChecksum         = %d\n", nttic->V4Transmit.TcpChecksum));
    3.11 @@ -561,6 +562,7 @@ XenNet_SetInformation(
    3.12            *BytesRead += sizeof(NDIS_TASK_TCP_LARGE_SEND);
    3.13            KdPrint(("TcpLargeSendNdisTask\n"));
    3.14            nttls = (PNDIS_TASK_TCP_LARGE_SEND)nto->TaskBuffer;
    3.15 +          xi->setting_max_offload = nttls->MaxOffLoadSize;
    3.16            KdPrint(("  MaxOffLoadSize                 = %d\n", nttls->MaxOffLoadSize));
    3.17            KdPrint(("  MinSegmentCount                = %d\n", nttls->MinSegmentCount));
    3.18            KdPrint(("  TcpOptions                     = %d\n", nttls->TcpOptions));
     4.1 --- a/xennet/xennet_rx.c	Thu Mar 27 16:39:55 2008 -0700
     4.2 +++ b/xennet/xennet_rx.c	Fri Mar 28 23:05:40 2008 +1100
     4.3 @@ -251,7 +251,7 @@ XenNet_SumIpHeader(
     4.4   This is only for TCP and UDP packets. IP checksums appear to be correct anyways.
     4.5  */
     4.6  static VOID
     4.7 -XenNet_SumTcpPacket(
     4.8 +XenNet_SumPacketData(
     4.9    struct xennet_info *xi,  
    4.10    PNDIS_PACKET packet
    4.11  )
    4.12 @@ -283,12 +283,24 @@ XenNet_SumTcpPacket(
    4.13      KdPrint((__DRIVER_NAME "     Size Mismatch %d (ip4_length + XN_HDR_SIZE) != %d (total_length)\n", ip4_length + XN_HDR_SIZE, total_length));
    4.14    }
    4.15  
    4.16 -  csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + xi->rxpi.ip4_header_length + 16];
    4.17 +  switch (xi->rxpi.ip_proto)
    4.18 +  {
    4.19 +  case 6:
    4.20 +    csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + xi->rxpi.ip4_header_length + 16];
    4.21 +    break;
    4.22 +  case 17:
    4.23 +    csum_ptr = (USHORT *)&buffer[XN_HDR_SIZE + xi->rxpi.ip4_header_length + 6];
    4.24 +    break;
    4.25 +  default:
    4.26 +    KdPrint((__DRIVER_NAME "     Don't know how to calc sum for IP Proto %d\n", xi->rxpi.ip_proto));
    4.27 +    return;
    4.28 +  }
    4.29 +    
    4.30    *csum_ptr = 0;
    4.31  
    4.32    csum = 0;
    4.33 -  csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + 12]) + GET_NET_USHORT(buffer[XN_HDR_SIZE + 14]); // seq
    4.34 -  csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + 16]) + GET_NET_USHORT(buffer[XN_HDR_SIZE + 18]); // ack
    4.35 +  csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + 12]) + GET_NET_USHORT(buffer[XN_HDR_SIZE + 14]); // src
    4.36 +  csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + 16]) + GET_NET_USHORT(buffer[XN_HDR_SIZE + 18]); // dst
    4.37    csum += ((USHORT)buffer[XN_HDR_SIZE + 9]);
    4.38  
    4.39    remaining = ip4_length - xi->rxpi.ip4_header_length;
    4.40 @@ -326,12 +338,10 @@ XenNet_SumTcpPacket(
    4.41          buffer_offset = 0;
    4.42        }
    4.43        csum += GET_NET_USHORT(buffer[buffer_offset]);
    4.44 -//KdPrint((__DRIVER_NAME "     %04X\n", GET_NET_USHORT(buffer[buffer_offset])));
    4.45      }
    4.46    }
    4.47    if (i != total_length) // last odd byte
    4.48    {
    4.49 -//KdPrint((__DRIVER_NAME "    *%04X\n", (USHORT)buffer[buffer_offset] << 8));
    4.50      csum += ((USHORT)buffer[buffer_offset] << 8);
    4.51    }
    4.52    while (csum & 0xFFFF0000)
    4.53 @@ -451,7 +461,7 @@ XenNet_MakePackets(
    4.54    case 17:  // UDP
    4.55      packets[*packet_count_p] = XenNet_MakePacket(xi);
    4.56      if (xi->rxpi.csum_calc_required)
    4.57 -      XenNet_SumTcpPacket(xi, packets[*packet_count_p]);
    4.58 +      XenNet_SumPacketData(xi, packets[*packet_count_p]);
    4.59      (*packet_count_p)++;
    4.60  //    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (TCP/UDP)\n"));
    4.61      return;
    4.62 @@ -472,7 +482,7 @@ XenNet_MakePackets(
    4.63    {
    4.64  //    KdPrint((__DRIVER_NAME "     tcp_remaining = %d\n", xi->rxpi.tcp_remaining));
    4.65      packets[*packet_count_p] = XenNet_MakePacket(xi);
    4.66 -    XenNet_SumTcpPacket(xi, packets[*packet_count_p]);
    4.67 +    XenNet_SumPacketData(xi, packets[*packet_count_p]);
    4.68      (*packet_count_p)++;
    4.69    }
    4.70    ASSERT(xi->rxpi.curr_mdl == xi->rxpi.mdl_count);
    4.71 @@ -564,13 +574,16 @@ XenNet_RxBufferCheck(struct xennet_info 
    4.72          ASSERT(rxrsp->id == id);
    4.73          if (!xi->rxpi.more_frags) // handling the packet's 1st buffer
    4.74          {
    4.75 -          
    4.76 +          if (rxrsp->flags & NETRXF_csum_blank)
    4.77 +            xi->rxpi.csum_calc_required = TRUE;
    4.78 +#if 0
    4.79            if (rxrsp->flags & (NETRXF_csum_blank|NETRXF_data_validated) && xi->config_csum)
    4.80            {
    4.81              //KdPrint((__DRIVER_NAME "     RX csum blank = %d, validated = %d\n", !!(rxrsp->flags & NETRXF_csum_blank), !!(rxrsp->flags & NETRXF_data_validated)));
    4.82              if (rxrsp->flags & NETRXF_csum_blank)
    4.83                xi->rxpi.csum_calc_required = TRUE;
    4.84            }
    4.85 +#endif
    4.86          }
    4.87          NdisAdjustBufferLength(mdl, rxrsp->status);
    4.88          xi->rxpi.mdls[xi->rxpi.mdl_count++] = mdl;