win-pvdrivers

changeset 248:7c395bd04ec1

Some tweaking to get gso working properly again.
author James Harper <james.harper@bendigoit.com.au>
date Sat Apr 05 23:32:53 2008 +1100 (2008-04-05)
parents 565483912dc0
children 1e47fb7bce04
files common.inc xennet/xennet.h xennet/xennet_common.c xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/common.inc	Sat Apr 05 22:20:00 2008 +1100
     1.2 +++ b/common.inc	Sat Apr 05 23:32:53 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.8.22
     1.5 +VERSION=0.8.8.26
     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	Sat Apr 05 22:20:00 2008 +1100
     2.2 +++ b/xennet/xennet.h	Sat Apr 05 23:32:53 2008 +1100
     2.3 @@ -324,6 +324,6 @@ XenNet_ParsePacketHeader(
     2.4  
     2.5  VOID
     2.6  XenNet_SumIpHeader(
     2.7 -  packet_info_t *pi,  
     2.8 -  PNDIS_PACKET packet
     2.9 +  PUCHAR header,
    2.10 +  USHORT ip4_header_length
    2.11  );
     3.1 --- a/xennet/xennet_common.c	Sat Apr 05 22:20:00 2008 +1100
     3.2 +++ b/xennet/xennet_common.c	Sat Apr 05 23:32:53 2008 +1100
     3.3 @@ -81,30 +81,23 @@ XenNet_ParsePacketHeader(
     3.4  
     3.5  VOID
     3.6  XenNet_SumIpHeader(
     3.7 -  packet_info_t *pi,  
     3.8 -  PNDIS_PACKET packet
     3.9 +  PUCHAR header,
    3.10 +  USHORT ip4_header_length
    3.11  )
    3.12  {
    3.13 -  PMDL mdl;
    3.14 -  UINT total_length;
    3.15 -  UINT buffer_length;
    3.16 -  PUCHAR buffer;
    3.17    ULONG csum = 0;
    3.18    USHORT i;
    3.19  
    3.20 -  NdisGetFirstBufferFromPacketSafe(packet, &mdl, &buffer, &buffer_length, &total_length, NormalPagePriority);
    3.21 -  ASSERT(mdl);
    3.22 -
    3.23 -  buffer[XN_HDR_SIZE + 10] = 0;
    3.24 -  buffer[XN_HDR_SIZE + 11] = 0;
    3.25 -  for (i = 0; i < pi->ip4_header_length; i += 2)
    3.26 +  header[XN_HDR_SIZE + 10] = 0;
    3.27 +  header[XN_HDR_SIZE + 11] = 0;
    3.28 +  for (i = 0; i < ip4_header_length; i += 2)
    3.29    {
    3.30 -    csum += GET_NET_USHORT(buffer[XN_HDR_SIZE + i]);
    3.31 +    csum += GET_NET_USHORT(header[XN_HDR_SIZE + i]);
    3.32    }
    3.33    while (csum & 0xFFFF0000)
    3.34      csum = (csum & 0xFFFF) + (csum >> 16);
    3.35    csum = ~csum;
    3.36 -  SET_NET_USHORT(buffer[XN_HDR_SIZE + 10], csum);
    3.37 +  SET_NET_USHORT(header[XN_HDR_SIZE + 10], csum);
    3.38  }
    3.39  
    3.40  PUCHAR
     4.1 --- a/xennet/xennet_rx.c	Sat Apr 05 22:20:00 2008 +1100
     4.2 +++ b/xennet/xennet_rx.c	Sat Apr 05 23:32:53 2008 +1100
     4.3 @@ -307,7 +307,7 @@ XenNet_MakePacket(
     4.4        out_offset = out_offset + length;
     4.5      } while (out_remaining != 0); // && in_buffer != NULL);
     4.6      NdisChainBufferAtBack(packet, out_mdl);
     4.7 -    XenNet_SumIpHeader(&xi->rxpi, packet);
     4.8 +    XenNet_SumIpHeader(out_buffer, xi->rxpi.ip4_header_length);
     4.9      NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_SUCCESS);
    4.10    }
    4.11  
     5.1 --- a/xennet/xennet_tx.c	Sat Apr 05 22:20:00 2008 +1100
     5.2 +++ b/xennet/xennet_tx.c	Sat Apr 05 23:32:53 2008 +1100
     5.3 @@ -84,56 +84,6 @@ put_gref_on_freelist(struct xennet_info 
     5.4  
     5.5  #define SWAP_USHORT(x) (USHORT)((((x & 0xFF) << 8)|((x >> 8) & 0xFF)))
     5.6  
     5.7 -#if 0
     5.8 -/*
     5.9 - * Windows assumes that if we can do large send offload then we can
    5.10 - * do IP header csum offload, so we have to fake it!
    5.11 - */
    5.12 -VOID
    5.13 -XenNet_SumIpHeader(
    5.14 - PMDL mdl /* first buffer of the packet - containing the header */
    5.15 -)
    5.16 -{
    5.17 -  PVOID buffer = MmGetSystemAddressForMdlSafe(mdl, NormalPagePriority);
    5.18 -  USHORT buffer_length = (USHORT)MmGetMdlByteCount(mdl);
    5.19 -  PUSHORT ushorts = (PUSHORT)buffer;
    5.20 -
    5.21 -  USHORT length_in_ushorts;
    5.22 -  USHORT i;
    5.23 -  ULONG csum = 0;
    5.24 -
    5.25 -  ASSERT(buffer);
    5.26 -  switch (SWAP_USHORT(ushorts[6]))
    5.27 -  {
    5.28 -  case 0x0800:
    5.29 -    if (buffer_length < XN_HDR_SIZE + 20)
    5.30 -    {
    5.31 -      KdPrint((__DRIVER_NAME "     tx packet too small for ip header - only %d bytes long but needs %d bytes\n", buffer_length, XN_HDR_SIZE + 20));
    5.32 -      return;
    5.33 -    }
    5.34 -    /* check if buffer is long enough to contain ethernet header + minimum ip header */
    5.35 -    ushorts = &ushorts[0x07];
    5.36 -    length_in_ushorts = ((SWAP_USHORT(ushorts[0]) >> 8) & 0x0F) * 2;
    5.37 -    if (buffer_length < XN_HDR_SIZE + length_in_ushorts * 2)
    5.38 -    {
    5.39 -      KdPrint((__DRIVER_NAME "     tx packet too small for ip header + options - only %d bytes long but needs %d bytes\n", buffer_length, XN_HDR_SIZE + length_in_ushorts));
    5.40 -      return;
    5.41 -    }
    5.42 -    break;
    5.43 -  default:
    5.44 -    return;
    5.45 -  }
    5.46 -  ushorts[5] = 0;
    5.47 -  for (i = 0; i < length_in_ushorts; i++)
    5.48 -  {
    5.49 -    csum += SWAP_USHORT(ushorts[i]);
    5.50 -  }
    5.51 -  while (csum & 0xFFFF0000)
    5.52 -    csum = (csum & 0xFFFF) + (csum >> 16);
    5.53 -  ushorts[5] = SWAP_USHORT(~csum);
    5.54 -}
    5.55 -#endif
    5.56 -
    5.57  typedef struct
    5.58  {
    5.59    PFN_NUMBER pfn;
    5.60 @@ -239,6 +189,7 @@ XenNet_HWSendPacket(struct xennet_info *
    5.61  
    5.62    csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(
    5.63      packet, TcpIpChecksumPacketInfo);
    5.64 +  mss = PtrToUlong(NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpLargeSendPacketInfo));
    5.65  
    5.66    NdisQueryPacket(packet, NULL, NULL, &buffer, &total_packet_length);
    5.67  
    5.68 @@ -246,7 +197,8 @@ XenNet_HWSendPacket(struct xennet_info *
    5.69    pi.mdl_count = 1;
    5.70    // only if csum offload
    5.71    if ((csum_info->Transmit.NdisPacketTcpChecksum
    5.72 -    || csum_info->Transmit.NdisPacketUdpChecksum)
    5.73 +    || csum_info->Transmit.NdisPacketUdpChecksum
    5.74 +    || mss > 0)
    5.75      && XenNet_ParsePacketHeader(&pi) == PARSE_TOO_SMALL)
    5.76    {
    5.77      pi.mdls[0] = merged_buffer = AllocatePage();
    5.78 @@ -272,7 +224,6 @@ XenNet_HWSendPacket(struct xennet_info *
    5.79    
    5.80    num_elements = NET_TX_RING_SIZE;
    5.81    XenNet_BuildPageList(&pi, elements, &num_elements);
    5.82 -  mss = PtrToUlong(NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpLargeSendPacketInfo));
    5.83  
    5.84    if (num_elements + !!mss > (int)free_requests(xi))
    5.85      return FALSE;
    5.86 @@ -287,7 +238,7 @@ XenNet_HWSendPacket(struct xennet_info *
    5.87    if (mss > 0)
    5.88    {
    5.89      flags |= NETTXF_extra_info;
    5.90 -//    XenNet_SumIpHeader(first_buffer);
    5.91 +    XenNet_SumIpHeader(MmGetSystemAddressForMdlSafe(pi.mdls[0], NormalPagePriority), pi.ip4_header_length);
    5.92      PC_INC(ProfCount_TxPacketsLargeOffload);
    5.93    }
    5.94