win-pvdrivers

changeset 205:3cc68cacff38

Turned on checksum offloading. Doesn't seem to make much difference yet though...
author James Harper <james.harper@bendigoit.com.au>
date Sun Mar 02 22:13:49 2008 +1100 (2008-03-02)
parents 9e4a4650518a
children d841932ba7ae
files common.inc xennet/xennet.c xennet/xennet.h xennet/xennet_oid.c xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/common.inc	Sun Mar 02 16:54:23 2008 +1100
     1.2 +++ b/common.inc	Sun Mar 02 22:13:49 2008 +1100
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.8.4.39
     1.5 +VERSION=0.8.4.46
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  KMDF_VERSION=1
     1.8  !IF $(_NT_TOOLS_VERSION) > 0x700
     2.1 --- a/xennet/xennet.c	Sun Mar 02 16:54:23 2008 +1100
     2.2 +++ b/xennet/xennet.c	Sun Mar 02 22:13:49 2008 +1100
     2.3 @@ -46,6 +46,11 @@ int ProfCount_SendQueuedPackets;
     2.4  int ProfCount_GrantAccess;
     2.5  int ProfCount_EndAccess;
     2.6  
     2.7 +int ProfCount_TxPacketsTotal;
     2.8 +int ProfCount_TxPacketsOffload;
     2.9 +int ProfCount_RxPacketsTotal;
    2.10 +int ProfCount_RxPacketsOffload;
    2.11 +
    2.12  /* This function copied from linux's lib/vsprintf.c, see it for attribution */
    2.13  static unsigned long
    2.14  simple_strtoul(const char *cp,char **endp,unsigned int base)
    2.15 @@ -269,7 +274,7 @@ XenNet_Init(
    2.16      {"event-channel", 0},
    2.17      {"request-rx-copy", 1},
    2.18      {"feature-rx-notify", 1},
    2.19 -    {"feature-no-csum-offload", 1},
    2.20 +//    {"feature-no-csum-offload", 1},
    2.21      {"feature-sg", 1},
    2.22      {"feature-gso-tcpv4", 0},
    2.23      {NULL, 0},
    2.24 @@ -687,6 +692,11 @@ DriverEntry(
    2.25    ProfCount_GrantAccess = 0;
    2.26    ProfCount_EndAccess = 0;
    2.27  
    2.28 +  ProfCount_TxPacketsTotal = 0;
    2.29 +  ProfCount_TxPacketsOffload = 0;
    2.30 +  ProfCount_RxPacketsTotal = 0;
    2.31 +  ProfCount_RxPacketsOffload = 0;
    2.32 +
    2.33    RtlZeroMemory(&mini_chars, sizeof(mini_chars));
    2.34  
    2.35    WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK);
     3.1 --- a/xennet/xennet.h	Sun Mar 02 16:54:23 2008 +1100
     3.2 +++ b/xennet/xennet.h	Sun Mar 02 22:13:49 2008 +1100
     3.3 @@ -72,6 +72,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     3.4  
     3.5  #pragma warning(disable: 4127) // conditional expression is constant
     3.6  
     3.7 +#define XEN_PROFILE
     3.8 +
     3.9  /* TODO: crank this up if we support higher mtus? */
    3.10  #define XN_DATA_SIZE 1500
    3.11  #define XN_HDR_SIZE 14
    3.12 @@ -171,8 +173,6 @@ extern LARGE_INTEGER ProfTime_RxBufferCh
    3.13  extern LARGE_INTEGER ProfTime_Linearize;
    3.14  extern LARGE_INTEGER ProfTime_SendPackets;
    3.15  extern LARGE_INTEGER ProfTime_SendQueuedPackets;
    3.16 -extern LARGE_INTEGER ProfTime_GrantAccess;
    3.17 -extern LARGE_INTEGER ProfTime_EndAccess;
    3.18  
    3.19  extern int ProfCount_TxBufferGC;
    3.20  extern int ProfCount_TxBufferFree;
    3.21 @@ -183,8 +183,11 @@ extern int ProfCount_RxBufferCheck;
    3.22  extern int ProfCount_Linearize;
    3.23  extern int ProfCount_SendPackets;
    3.24  extern int ProfCount_SendQueuedPackets;
    3.25 -extern int ProfCount_GrantAccess;
    3.26 -extern int ProfCount_EndAccess;
    3.27 +
    3.28 +extern int ProfCount_TxPacketsTotal;
    3.29 +extern int ProfCount_TxPacketsOffload;
    3.30 +extern int ProfCount_RxPacketsTotal;
    3.31 +extern int ProfCount_RxPacketsOffload;
    3.32  
    3.33  NDIS_STATUS
    3.34  XenNet_RxBufferCheck(struct xennet_info *xi);
     4.1 --- a/xennet/xennet_oid.c	Sun Mar 02 16:54:23 2008 +1100
     4.2 +++ b/xennet/xennet_oid.c	Sun Mar 02 22:13:49 2008 +1100
     4.3 @@ -244,16 +244,16 @@ XenNet_QueryInformation(
     4.4  
     4.5        /* fill in checksum offload struct */
     4.6        nttic = (PNDIS_TASK_TCP_IP_CHECKSUM)nto->TaskBuffer;
     4.7 -      nttic->V4Transmit.IpOptionsSupported = 0;
     4.8 -      nttic->V4Transmit.TcpOptionsSupported = 0;
     4.9 -      nttic->V4Transmit.TcpChecksum = 0;
    4.10 -      nttic->V4Transmit.UdpChecksum = 0;
    4.11        nttic->V4Transmit.IpChecksum = 0;
    4.12 -      nttic->V4Receive.IpOptionsSupported = 1;
    4.13 +      nttic->V4Transmit.IpOptionsSupported = 0;
    4.14 +      nttic->V4Transmit.TcpChecksum = 1;
    4.15 +      nttic->V4Transmit.TcpOptionsSupported = 1;
    4.16 +      nttic->V4Transmit.UdpChecksum = 1;
    4.17 +      nttic->V4Receive.IpChecksum = 0;
    4.18 +      nttic->V4Receive.IpOptionsSupported = 0;
    4.19 +      nttic->V4Receive.TcpChecksum = 1;
    4.20        nttic->V4Receive.TcpOptionsSupported = 1;
    4.21 -      nttic->V4Receive.TcpChecksum = 1;
    4.22        nttic->V4Receive.UdpChecksum = 1;
    4.23 -      nttic->V4Receive.IpChecksum = 1;
    4.24        nttic->V6Transmit.IpOptionsSupported = 0;
    4.25        nttic->V6Transmit.TcpOptionsSupported = 0;
    4.26        nttic->V6Transmit.TcpChecksum = 0;
     5.1 --- a/xennet/xennet_rx.c	Sun Mar 02 16:54:23 2008 +1100
     5.2 +++ b/xennet/xennet_rx.c	Sun Mar 02 22:13:49 2008 +1100
     5.3 @@ -110,6 +110,7 @@ XenNet_RxBufferCheck(struct xennet_info 
     5.4    NDIS_STATUS status;
     5.5    LARGE_INTEGER time_received;
     5.6    USHORT id;
     5.7 +  PNDIS_TCP_IP_CHECKSUM_PACKET_INFO csum_info;
     5.8  #if defined(XEN_PROFILE)
     5.9    LARGE_INTEGER tsc, dummy;
    5.10  #endif
    5.11 @@ -149,6 +150,16 @@ XenNet_RxBufferCheck(struct xennet_info 
    5.12          NdisAllocatePacket(&status, &packets[packet_count], xi->packet_pool);
    5.13          ASSERT(status == NDIS_STATUS_SUCCESS);
    5.14          NDIS_SET_PACKET_HEADER_SIZE(packets[packet_count], XN_HDR_SIZE);
    5.15 +        if (rxrsp->flags & (NETRXF_csum_blank|NETRXF_data_validated)) // and we are enabled for offload...
    5.16 +        {
    5.17 +          csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(packets[packet_count], TcpIpChecksumPacketInfo);
    5.18 +          csum_info->Receive.NdisPacketTcpChecksumSucceeded = 1;
    5.19 +          csum_info->Receive.NdisPacketUdpChecksumSucceeded = 1;
    5.20 +          csum_info->Receive.NdisPacketIpChecksumSucceeded = 1;
    5.21 +#if defined(XEN_PROFILE)
    5.22 +          ProfCount_RxPacketsOffload++;
    5.23 +#endif
    5.24 +        }
    5.25        }
    5.26  
    5.27        NdisAdjustBufferLength(mdl, rxrsp->status);
    5.28 @@ -161,6 +172,9 @@ XenNet_RxBufferCheck(struct xennet_info 
    5.29        /* Packet done, pass it up */
    5.30        if (!more_frags)
    5.31        {
    5.32 +#if defined(XEN_PROFILE)
    5.33 +        ProfCount_RxPacketsTotal++;
    5.34 +#endif
    5.35          xi->stat_rx_ok++;
    5.36          InterlockedIncrement(&xi->rx_outstanding);
    5.37          NDIS_SET_PACKET_STATUS(packets[packet_count], NDIS_STATUS_SUCCESS);
    5.38 @@ -204,6 +218,8 @@ XenNet_RxBufferCheck(struct xennet_info 
    5.39    return NDIS_STATUS_SUCCESS;
    5.40  }
    5.41  
    5.42 +/* called at DISPATCH_LEVEL with rx_lock held (as it gets called from IndicateReceived) */
    5.43 +
    5.44  VOID
    5.45  XenNet_ReturnPacket(
    5.46    IN NDIS_HANDLE MiniportAdapterContext,
     6.1 --- a/xennet/xennet_tx.c	Sun Mar 02 16:54:23 2008 +1100
     6.2 +++ b/xennet/xennet_tx.c	Sun Mar 02 22:13:49 2008 +1100
     6.3 @@ -86,12 +86,13 @@ XenNet_Linearize(struct xennet_info *xi,
     6.4    return pmdl;
     6.5  }
     6.6  
     6.7 +/* Called at DISPATCH_LEVEL with tx_lock held */
     6.8 +
     6.9  static VOID
    6.10  XenNet_SendQueuedPackets(struct xennet_info *xi)
    6.11  {
    6.12    PLIST_ENTRY entry;
    6.13    PNDIS_PACKET packet;
    6.14 -  KIRQL OldIrql;
    6.15    struct netif_tx_request *tx;
    6.16    unsigned short id;
    6.17    int notify;
    6.18 @@ -99,16 +100,13 @@ XenNet_SendQueuedPackets(struct xennet_i
    6.19    UINT pkt_size;
    6.20  #if defined(XEN_PROFILE)
    6.21    LARGE_INTEGER tsc, dummy;
    6.22 -  KIRQL OldIrql2;
    6.23  #endif
    6.24 +  PNDIS_TCP_IP_CHECKSUM_PACKET_INFO csum_info;
    6.25  
    6.26  #if defined(XEN_PROFILE)
    6.27 -  KeRaiseIrql(DISPATCH_LEVEL, &OldIrql2);
    6.28    tsc = KeQueryPerformanceCounter(&dummy);
    6.29  #endif
    6.30  
    6.31 -  KeAcquireSpinLock(&xi->tx_lock, &OldIrql);
    6.32 -
    6.33    entry = RemoveHeadList(&xi->tx_waiting_pkt_list);
    6.34    /* if empty, the above returns head*, not NULL */
    6.35    while (entry != &xi->tx_waiting_pkt_list)
    6.36 @@ -148,8 +146,19 @@ XenNet_SendQueuedPackets(struct xennet_i
    6.37      tx->gref = get_grant_ref(pmdl);
    6.38      tx->offset = (uint16_t)MmGetMdlByteOffset(pmdl);
    6.39      tx->size = (UINT16)pkt_size;
    6.40 -    // NETTXF_csum_blank should only be used for tcp and udp packets...    
    6.41 -    tx->flags = 0; //NETTXF_csum_blank;
    6.42 +    
    6.43 +    tx->flags = 0;
    6.44 +#if defined(XEN_PROFILE)
    6.45 +    ProfCount_TxPacketsTotal++;
    6.46 +#endif
    6.47 +    csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpIpChecksumPacketInfo);
    6.48 +    if (csum_info->Transmit.NdisPacketTcpChecksum || csum_info->Transmit.NdisPacketUdpChecksum)
    6.49 +    {
    6.50 +      tx->flags |= NETTXF_csum_blank|NETTXF_data_validated;
    6.51 +#if defined(XEN_PROFILE)
    6.52 +      ProfCount_TxPacketsOffload++;
    6.53 +#endif
    6.54 +    }
    6.55  
    6.56      xi->tx.req_prod_pvt++;
    6.57  
    6.58 @@ -163,11 +172,9 @@ XenNet_SendQueuedPackets(struct xennet_i
    6.59        xi->event_channel);
    6.60    }
    6.61  
    6.62 -  KeReleaseSpinLock(&xi->tx_lock, OldIrql);
    6.63  #if defined(XEN_PROFILE)
    6.64    ProfTime_SendQueuedPackets.QuadPart += KeQueryPerformanceCounter(&dummy).QuadPart - tsc.QuadPart;
    6.65    ProfCount_SendQueuedPackets++;
    6.66 -  KeLowerIrql(OldIrql2);
    6.67  #endif
    6.68  }
    6.69  
    6.70 @@ -198,7 +205,8 @@ XenNet_TxBufferGC(struct xennet_info *xi
    6.71      prod = xi->tx.sring->rsp_prod;
    6.72      KeMemoryBarrier(); /* Ensure we see responses up to 'rp'. */
    6.73  
    6.74 -    for (cons = xi->tx.rsp_cons; cons != prod; cons++) {
    6.75 +    for (cons = xi->tx.rsp_cons; cons != prod; cons++)
    6.76 +    {
    6.77        struct netif_tx_response *txrsp;
    6.78  
    6.79        txrsp = RING_GET_RESPONSE(&xi->tx, cons);
    6.80 @@ -220,11 +228,11 @@ XenNet_TxBufferGC(struct xennet_info *xi
    6.81      RING_FINAL_CHECK_FOR_RESPONSES(&xi->tx, moretodo);
    6.82    } while (moretodo);
    6.83  
    6.84 -  KeReleaseSpinLockFromDpcLevel(&xi->tx_lock);
    6.85 -
    6.86    /* if queued packets, send them now */
    6.87    XenNet_SendQueuedPackets(xi);
    6.88  
    6.89 +  KeReleaseSpinLockFromDpcLevel(&xi->tx_lock);
    6.90 +
    6.91  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.92  
    6.93  #if defined(XEN_PROFILE)
    6.94 @@ -268,6 +276,9 @@ XenNet_SendPackets(
    6.95      InsertTailList(&xi->tx_waiting_pkt_list, entry);
    6.96      InterlockedIncrement(&xi->tx_outstanding);
    6.97    }
    6.98 +
    6.99 +  XenNet_SendQueuedPackets(xi);
   6.100 +
   6.101    KeReleaseSpinLock(&xi->tx_lock, OldIrql);
   6.102  
   6.103  #if defined(XEN_PROFILE)
   6.104 @@ -276,22 +287,19 @@ XenNet_SendPackets(
   6.105    KeLowerIrql(OldIrql2);
   6.106  #endif
   6.107  
   6.108 -  XenNet_SendQueuedPackets(xi);
   6.109 -
   6.110  #if defined(XEN_PROFILE)
   6.111    if ((ProfCount_SendPackets & 1023) == 0)
   6.112    {
   6.113 -    KdPrint((__DRIVER_NAME "     TxBufferGC        Count = %10d, Avg Time = %10ld\n", ProfCount_TxBufferGC, (ProfCount_TxBufferGC == 0)?0:(ProfTime_TxBufferGC.QuadPart / ProfCount_TxBufferGC)));
   6.114 -    KdPrint((__DRIVER_NAME "     TxBufferFree      Count = %10d, Avg Time = %10ld\n", ProfCount_TxBufferFree, (ProfCount_TxBufferFree == 0)?0:(ProfTime_TxBufferFree.QuadPart / ProfCount_TxBufferFree)));
   6.115 +    KdPrint((__DRIVER_NAME "     ***\n"));
   6.116      KdPrint((__DRIVER_NAME "     RxBufferAlloc     Count = %10d, Avg Time = %10ld\n", ProfCount_RxBufferAlloc, (ProfCount_RxBufferAlloc == 0)?0:(ProfTime_RxBufferAlloc.QuadPart / ProfCount_RxBufferAlloc)));
   6.117 -    KdPrint((__DRIVER_NAME "     RxBufferFree      Count = %10d, Avg Time = %10ld\n", ProfCount_RxBufferFree, (ProfCount_RxBufferFree == 0)?0:(ProfTime_RxBufferFree.QuadPart / ProfCount_RxBufferFree)));
   6.118      KdPrint((__DRIVER_NAME "     ReturnPacket      Count = %10d, Avg Time = %10ld\n", ProfCount_ReturnPacket, (ProfCount_ReturnPacket == 0)?0:(ProfTime_ReturnPacket.QuadPart / ProfCount_ReturnPacket)));
   6.119      KdPrint((__DRIVER_NAME "     RxBufferCheck     Count = %10d, Avg Time = %10ld\n", ProfCount_RxBufferCheck, (ProfCount_RxBufferCheck == 0)?0:(ProfTime_RxBufferCheck.QuadPart / ProfCount_RxBufferCheck)));
   6.120      KdPrint((__DRIVER_NAME "     Linearize         Count = %10d, Avg Time = %10ld\n", ProfCount_Linearize, (ProfCount_Linearize == 0)?0:(ProfTime_Linearize.QuadPart / ProfCount_Linearize)));
   6.121      KdPrint((__DRIVER_NAME "     SendPackets       Count = %10d, Avg Time = %10ld\n", ProfCount_SendPackets, (ProfCount_SendPackets == 0)?0:(ProfTime_SendPackets.QuadPart / ProfCount_SendPackets)));
   6.122      KdPrint((__DRIVER_NAME "     SendQueuedPackets Count = %10d, Avg Time = %10ld\n", ProfCount_SendQueuedPackets, (ProfCount_SendQueuedPackets == 0)?0:(ProfTime_SendQueuedPackets.QuadPart / ProfCount_SendQueuedPackets)));
   6.123 -    KdPrint((__DRIVER_NAME "     GrantAccess       Count = %10d, Avg Time = %10ld\n", ProfCount_GrantAccess, (ProfCount_GrantAccess == 0)?0:(ProfTime_GrantAccess.QuadPart / ProfCount_GrantAccess)));
   6.124 -    KdPrint((__DRIVER_NAME "     EndAccess         Count = %10d, Avg Time = %10ld\n", ProfCount_EndAccess, (ProfCount_EndAccess == 0)?0:(ProfTime_EndAccess.QuadPart / ProfCount_EndAccess)));
   6.125 +    KdPrint((__DRIVER_NAME "     TxBufferGC        Count = %10d, Avg Time = %10ld\n", ProfCount_TxBufferGC, (ProfCount_TxBufferGC == 0)?0:(ProfTime_TxBufferGC.QuadPart / ProfCount_TxBufferGC)));
   6.126 +    KdPrint((__DRIVER_NAME "     RxPackets         Total = %10d, Offload  = %10d\n", ProfCount_RxPacketsTotal, ProfCount_RxPacketsOffload));
   6.127 +    KdPrint((__DRIVER_NAME "     TxPackets         Total = %10d, Offload  = %10d\n", ProfCount_TxPacketsTotal, ProfCount_TxPacketsOffload));
   6.128    }
   6.129  #endif
   6.130    //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));