win-pvdrivers

changeset 105:2f6159eaf2b1

Still trying to get csum offload working properly...
this commit doesn't appear to boot properly for me though.
author James Harper <james.harper@bendigoit.com.au>
date Wed Jan 09 23:32:54 2008 +1100 (2008-01-09)
parents 4ad735c07462
children 64f2791889f4
files xenenum/sources xennet/sources xennet/xennet.c xenpci/sources
line diff
     1.1 --- a/xenenum/sources	Tue Jan 08 18:14:17 2008 -0800
     1.2 +++ b/xenenum/sources	Wed Jan 09 23:32:54 2008 +1100
     1.3 @@ -1,7 +1,7 @@
     1.4  TARGETNAME=xenenum
     1.5  TARGETTYPE=DRIVER
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7 -VERSION=0.5.0.13
     1.8 +VERSION=0.5.0.14
     1.9  KMDF_VERSION=1
    1.10  MSC_WARNING_LEVEL=/W4
    1.11  INF_NAME=xenenum
     2.1 --- a/xennet/sources	Tue Jan 08 18:14:17 2008 -0800
     2.2 +++ b/xennet/sources	Wed Jan 09 23:32:54 2008 +1100
     2.3 @@ -1,7 +1,7 @@
     2.4  TARGETNAME=XENNET
     2.5  TARGETTYPE=DRIVER
     2.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     2.7 -VERSION=0.5.0.51
     2.8 +VERSION=0.5.0.66
     2.9  KMDF_VERSION=1
    2.10  MSC_WARNING_LEVEL=/W4
    2.11  INF_NAME=xennet
     3.1 --- a/xennet/xennet.c	Tue Jan 08 18:14:17 2008 -0800
     3.2 +++ b/xennet/xennet.c	Wed Jan 09 23:32:54 2008 +1100
     3.3 @@ -421,17 +421,21 @@ XenNet_RxBufferCheck(struct xennet_info 
     3.4  
     3.5  #if 0
     3.6        KdPrint((__DRIVER_NAME "     Flags = %sNETRXF_data_validated|%sNETRXF_csum_blank|%sNETRXF_more_data|%sNETRXF_extra_info\n",
     3.7 -        (rxrsp->flags|NETRXF_data_validated)?"":"!",
     3.8 -        (rxrsp->flags|NETRXF_csum_blank)?"":"!",
     3.9 -        (rxrsp->flags|NETRXF_more_data)?"":"!",
    3.10 -        (rxrsp->flags|NETRXF_extra_info)?"":"!"));
    3.11 +        (rxrsp->flags&NETRXF_data_validated)?"":"!",
    3.12 +        (rxrsp->flags&NETRXF_csum_blank)?"":"!",
    3.13 +        (rxrsp->flags&NETRXF_more_data)?"":"!",
    3.14 +        (rxrsp->flags&NETRXF_extra_info)?"":"!"));
    3.15  #endif
    3.16 -// maybe use NDIS_GET_PACKET_PROTOCOL_TYPE(Packet) here and check for == NDIS_PROTOCOL_ID_TCP_IP etc
    3.17  
    3.18 -      csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpIpChecksumPacketInfo);
    3.19 -      csum_info->Receive.NdisPacketTcpChecksumSucceeded = 1;
    3.20 -      csum_info->Receive.NdisPacketUdpChecksumSucceeded = 1;
    3.21 -      csum_info->Receive.NdisPacketIpChecksumSucceeded = 1;
    3.22 +      if (NDIS_GET_PACKET_PROTOCOL_TYPE(packet) == NDIS_PROTOCOL_ID_TCP_IP
    3.23 +        && (rxrsp->flags & (NETRXF_csum_blank|NETRXF_data_validated)))
    3.24 +      {
    3.25 +        csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpIpChecksumPacketInfo);
    3.26 +        csum_info->Receive.NdisPacketTcpChecksumSucceeded = 1;
    3.27 +        csum_info->Receive.NdisPacketUdpChecksumSucceeded = 0;
    3.28 +        csum_info->Receive.NdisPacketIpChecksumSucceeded = 1;
    3.29 +//        KdPrint((__DRIVER_NAME "     Offload = %08x\n", NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpIpChecksumPacketInfo)));
    3.30 +      }
    3.31  
    3.32        xi->stat_rx_ok++;
    3.33        NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_SUCCESS);
    3.34 @@ -506,7 +510,7 @@ XenNet_BackEndStateHandler(char *Path, P
    3.35      {"event-channel", 0},
    3.36      {"request-rx-copy", 1},
    3.37      {"feature-rx-notify", 1},
    3.38 -    {"feature-no-csum-offload", 0},
    3.39 +    {"feature-no-csum-offload", 1},
    3.40      {"feature-sg", 1},
    3.41      {"feature-gso-tcpv4", 0},
    3.42      {NULL, 0},
    3.43 @@ -710,6 +714,7 @@ XenNet_Init(
    3.44      status = NDIS_STATUS_RESOURCES;
    3.45      goto err;
    3.46    }
    3.47 +  NdisSetPacketPoolProtocolId(xi->packet_pool, NDIS_PROTOCOL_ID_TCP_IP);
    3.48  
    3.49    NdisAllocateBufferPool(&status, &xi->buffer_pool, NET_RX_RING_SIZE);
    3.50    if (status != NDIS_STATUS_SUCCESS)
    3.51 @@ -786,6 +791,19 @@ XenNet_Init(
    3.52    RtlStringCbCopyA(xi->BackendPath, ARRAY_SIZE(xi->BackendPath), Value);
    3.53    KdPrint((__DRIVER_NAME "backend path = %s\n", xi->BackendPath));
    3.54  
    3.55 +  RtlStringCbPrintfA(TmpPath, ARRAY_SIZE(TmpPath), "%s/type", xi->BackendPath);
    3.56 +  res = xi->XenInterface.XenBus_Read(xi->XenInterface.InterfaceHeader.Context,
    3.57 +      XBT_NIL, TmpPath, &Value);
    3.58 +
    3.59 +#if 0
    3.60 +  if (res || strcmp(Value, "netfront") != 0)
    3.61 +  {
    3.62 +    KdPrint((__DRIVER_NAME "    Backend type is not 'netfront'\n"));
    3.63 +    status = NDIS_STATUS_FAILURE;
    3.64 +    goto err;
    3.65 +  }
    3.66 +#endif
    3.67 +
    3.68    KeInitializeEvent(&xi->backend_state_change_event, SynchronizationEvent, FALSE);  
    3.69  
    3.70    /* Add watch on backend state */
    3.71 @@ -907,7 +925,6 @@ XenNet_QueryInformation(
    3.72    UCHAR vendor_desc[] = XN_VENDOR_DESC;
    3.73    ULONG64 temp_data;
    3.74    PVOID data = &temp_data;
    3.75 -  ULONG offset = 0;
    3.76    UINT len = 4;
    3.77    BOOLEAN used_temp_buffer = TRUE;
    3.78    NDIS_STATUS status = NDIS_STATUS_SUCCESS;
    3.79 @@ -1035,10 +1052,12 @@ XenNet_QueryInformation(
    3.80      case OID_TCP_TASK_OFFLOAD:
    3.81        KdPrint(("Get OID_TCP_TASK_OFFLOAD\n"));
    3.82        /* it's times like this that C really sucks */
    3.83 -      len = sizeof(NDIS_TASK_OFFLOAD_HEADER)
    3.84 -        + FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
    3.85 +
    3.86 +      len = sizeof(NDIS_TASK_OFFLOAD_HEADER);
    3.87 +
    3.88 +      len += FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
    3.89          + sizeof(NDIS_TASK_TCP_IP_CHECKSUM);
    3.90 -#ifdef LARGE_SEND
    3.91 +#ifdef OFFLOAD_LARGE_SEND
    3.92        len += FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
    3.93          + sizeof(NDIS_TASK_TCP_LARGE_SEND);
    3.94  #endif
    3.95 @@ -1048,7 +1067,7 @@ XenNet_QueryInformation(
    3.96            break;
    3.97        }
    3.98  
    3.99 -      ntoh = InformationBuffer;
   3.100 +      ntoh = (PNDIS_TASK_OFFLOAD_HEADER)InformationBuffer;
   3.101        ASSERT(ntoh->Version == NDIS_TASK_OFFLOAD_VERSION);
   3.102        ASSERT(ntoh->Size == sizeof(*ntoh));
   3.103        ASSERT(ntoh->EncapsulationFormat.Encapsulation == IEEE_802_3_Encapsulation);
   3.104 @@ -1081,10 +1100,10 @@ XenNet_QueryInformation(
   3.105        nttic->V6Receive.TcpOptionsSupported = 0;
   3.106        nttic->V6Receive.TcpChecksum = 0;
   3.107        nttic->V6Receive.UdpChecksum = 0;
   3.108 -#ifdef LARGE_SEND
   3.109 -      nto->OffsetNextTask = sizeof(NDIS_TASK_OFFLOAD_HEADER)
   3.110 -        + FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
   3.111 -        + sizeof(NDIS_TASK_TCP_IP_CHECKSUM);
   3.112 +
   3.113 +#ifdef OFFLOAD_LARGE_SEND
   3.114 +      nto->OffsetNextTask = FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer)
   3.115 +        + pto->TaskBufferLength;
   3.116  
   3.117        /* fill in second nto */
   3.118        nto = (PNDIS_TASK_OFFLOAD)((PCHAR)(ntoh) + nto->OffsetNextTask);
   3.119 @@ -1126,7 +1145,7 @@ XenNet_QueryInformation(
   3.120    *BytesWritten = len;
   3.121    if (len && used_temp_buffer)
   3.122    {
   3.123 -    NdisMoveMemory(((PUCHAR)InformationBuffer) + offset, data, len - offset);
   3.124 +    NdisMoveMemory((PUCHAR)InformationBuffer, data, len);
   3.125    }
   3.126  
   3.127    //KdPrint(("Got OID 0x%x\n", Oid));
   3.128 @@ -1148,6 +1167,10 @@ XenNet_SetInformation(
   3.129    NTSTATUS status;
   3.130    struct xennet_info *xi = MiniportAdapterContext;
   3.131    PULONG64 data = InformationBuffer;
   3.132 +  PNDIS_TASK_OFFLOAD_HEADER ntoh;
   3.133 +  PNDIS_TASK_OFFLOAD nto;
   3.134 +  PNDIS_TASK_TCP_IP_CHECKSUM nttic;
   3.135 +  int offset;
   3.136  
   3.137    KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   3.138  
   3.139 @@ -1282,9 +1305,48 @@ XenNet_SetInformation(
   3.140        KdPrint(("Unsupported set OID_802_3_MAXIMUM_LIST_SIZE\n"));
   3.141        break;
   3.142      case OID_TCP_TASK_OFFLOAD:
   3.143 -      // Just fake this for now... not sure if we will do anything different as a result...
   3.144 +      // Just fake this for now... ultimately we need to manually calc rx checksum if offload is disabled by windows
   3.145 +      status = NDIS_STATUS_SUCCESS;
   3.146        KdPrint(("Set OID_TCP_TASK_OFFLOAD\n"));
   3.147 -      status = NDIS_STATUS_SUCCESS;
   3.148 +      // we should disable everything here, then enable what has been set
   3.149 +      ntoh = (PNDIS_TASK_OFFLOAD_HEADER)InformationBuffer;
   3.150 +      *BytesRead = sizeof(NDIS_TASK_OFFLOAD_HEADER);
   3.151 +      offset = ntoh->OffsetFirstTask;
   3.152 +      nto = (PNDIS_TASK_OFFLOAD)ntoh; // not really, just to get the first offset right
   3.153 +      while (offset != 0)
   3.154 +      {
   3.155 +        *BytesRead += FIELD_OFFSET(NDIS_TASK_OFFLOAD, TaskBuffer);
   3.156 +        nto = (PNDIS_TASK_OFFLOAD)(((PUCHAR)nto) + offset);
   3.157 +        switch (nto->Task)
   3.158 +        {
   3.159 +        case TcpIpChecksumNdisTask:
   3.160 +          *BytesRead += sizeof(NDIS_TASK_TCP_IP_CHECKSUM);
   3.161 +          KdPrint(("TcpIpChecksumNdisTask\n"));
   3.162 +          nttic = (PNDIS_TASK_TCP_IP_CHECKSUM)nto->TaskBuffer;
   3.163 +          KdPrint(("  V4Transmit.IpOptionsSupported  = %d\n", nttic->V4Transmit.IpOptionsSupported));
   3.164 +          KdPrint(("  V4Transmit.TcpOptionsSupported = %d\n", nttic->V4Transmit.TcpOptionsSupported));
   3.165 +          KdPrint(("  V4Transmit.TcpChecksum         = %d\n", nttic->V4Transmit.TcpChecksum));
   3.166 +          KdPrint(("  V4Transmit.UdpChecksum         = %d\n", nttic->V4Transmit.UdpChecksum));
   3.167 +          KdPrint(("  V4Transmit.IpChecksum          = %d\n", nttic->V4Transmit.IpChecksum));
   3.168 +          KdPrint(("  V4Receive.IpOptionsSupported   = %d\n", nttic->V4Receive.IpOptionsSupported));
   3.169 +          KdPrint(("  V4Receive.TcpOptionsSupported  = %d\n", nttic->V4Receive.TcpOptionsSupported));
   3.170 +          KdPrint(("  V4Receive.TcpChecksum          = %d\n", nttic->V4Receive.TcpChecksum));
   3.171 +          KdPrint(("  V4Receive.UdpChecksum          = %d\n", nttic->V4Receive.UdpChecksum));
   3.172 +          KdPrint(("  V4Receive.IpChecksum           = %d\n", nttic->V4Receive.IpChecksum));
   3.173 +          KdPrint(("  V6Transmit.IpOptionsSupported  = %d\n", nttic->V6Transmit.IpOptionsSupported));
   3.174 +          KdPrint(("  V6Transmit.TcpOptionsSupported = %d\n", nttic->V6Transmit.TcpOptionsSupported));
   3.175 +          KdPrint(("  V6Transmit.TcpChecksum         = %d\n", nttic->V6Transmit.TcpChecksum));
   3.176 +          KdPrint(("  V6Transmit.UdpChecksum         = %d\n", nttic->V6Transmit.UdpChecksum));
   3.177 +          KdPrint(("  V6Receive.IpOptionsSupported   = %d\n", nttic->V6Receive.IpOptionsSupported));
   3.178 +          KdPrint(("  V6Receive.TcpOptionsSupported  = %d\n", nttic->V6Receive.TcpOptionsSupported));
   3.179 +          KdPrint(("  V6Receive.TcpChecksum          = %d\n", nttic->V6Receive.TcpChecksum));
   3.180 +          KdPrint(("  V6Receive.UdpChecksum          = %d\n", nttic->V6Receive.UdpChecksum));
   3.181 +          break;
   3.182 +        default:
   3.183 +          KdPrint(("  Unknown Task %d\n", nto->Task));
   3.184 +        }
   3.185 +        offset = nto->OffsetNextTask;
   3.186 +      }
   3.187        break;
   3.188      default:
   3.189        KdPrint(("Set Unknown OID 0x%x\n", Oid));
     4.1 --- a/xenpci/sources	Tue Jan 08 18:14:17 2008 -0800
     4.2 +++ b/xenpci/sources	Wed Jan 09 23:32:54 2008 +1100
     4.3 @@ -1,7 +1,7 @@
     4.4  TARGETNAME=XENPCI
     4.5  TARGETTYPE=DRIVER
     4.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     4.7 -VERSION=0.5.0.21
     4.8 +VERSION=0.5.0.22
     4.9  KMDF_VERSION=1
    4.10  MSC_WARNING_LEVEL=/W4
    4.11  INF_NAME=xenpci