win-pvdrivers

changeset 443:a572b7333267

Don't zero entire packet_info structure, to improve performance
author James Harper <james.harper@bendigoit.com.au>
date Thu Nov 06 11:19:22 2008 +1100 (2008-11-06)
parents fdba08195d9d
children 3a2121285fc9
files xennet/xennet.h xennet/xennet_common.c xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.h	Wed Nov 05 17:03:18 2008 +1100
     1.2 +++ b/xennet/xennet.h	Thu Nov 06 11:19:22 2008 +1100
     1.3 @@ -406,7 +406,22 @@ XenNet_GetData(
     1.4    return buffer;
     1.5  }
     1.6  
     1.7 -
     1.8 +static __forceinline VOID
     1.9 +XenNet_ClearPacketInfo(packet_info_t *pi)
    1.10 +{
    1.11 +#if 1
    1.12 +  #if 1
    1.13 +  RtlZeroMemory(&pi->mdl_count, sizeof(packet_info_t) - FIELD_OFFSET(packet_info_t, mdl_count));
    1.14 +  #else
    1.15 +  RtlZeroMemory(pi, sizeof(packet_info_t));
    1.16 +  #endif
    1.17 +#else
    1.18 +  pi->mdl_count = 0;
    1.19 +  pi->curr_mdl = pi->curr_mdl_offset = 0;
    1.20 +  pi->extra_info = pi->more_frags = pi->csum_blank =
    1.21 +    pi->data_validated = pi->split_required = 0;
    1.22 +#endif
    1.23 +}
    1.24  
    1.25  VOID
    1.26  XenFreelist_Init(struct xennet_info *xi, freelist_t *fl, PKSPIN_LOCK lock);
     2.1 --- a/xennet/xennet_common.c	Wed Nov 05 17:03:18 2008 +1100
     2.2 +++ b/xennet/xennet_common.c	Thu Nov 06 11:19:22 2008 +1100
     2.3 @@ -55,14 +55,14 @@ XenNet_ParsePacketHeader(
     2.4      pi->ip4_header_length = (pi->header[XN_HDR_SIZE + 0] & 0x0F) << 2;
     2.5      if (header_length < (ULONG)(XN_HDR_SIZE + pi->ip4_header_length + 20))
     2.6      {
     2.7 -      int i;
     2.8        KdPrint((__DRIVER_NAME "     first buffer is only %d bytes long, must be >= %d (1)\n", header_length, (ULONG)(XN_HDR_SIZE + pi->ip4_header_length + 20)));
     2.9 +#if 0      
    2.10        KdPrint((__DRIVER_NAME "     total_length = %d\n", pi->total_length));
    2.11        for (i = 0; i < pi->mdl_count; i++)
    2.12        {
    2.13          KdPrint((__DRIVER_NAME "     mdl %d length = %d\n", i, MmGetMdlByteCount(pi->mdls[i])));
    2.14        }
    2.15 -      // we need to do something conclusive here...
    2.16 +#endif
    2.17        return PARSE_TOO_SMALL;
    2.18      }
    2.19      break;
     3.1 --- a/xennet/xennet_rx.c	Wed Nov 05 17:03:18 2008 +1100
     3.2 +++ b/xennet/xennet_rx.c	Thu Nov 06 11:19:22 2008 +1100
     3.3 @@ -418,7 +418,7 @@ XenNet_MakePackets(
     3.4      }
     3.5      entry = (PLIST_ENTRY)&packet->MiniportReservedEx[sizeof(PVOID)];
     3.6      InsertTailList(rx_packet_list, entry);
     3.7 -    RtlZeroMemory(&xi->rxpi, sizeof(xi->rxpi));
     3.8 +    XenNet_ClearPacketInfo(&xi->rxpi);
     3.9      return 1;
    3.10    default:
    3.11      packet = XenNet_MakePacket(xi);
    3.12 @@ -431,7 +431,7 @@ XenNet_MakePackets(
    3.13      }
    3.14      entry = (PLIST_ENTRY)&packet->MiniportReservedEx[sizeof(PVOID)];
    3.15      InsertTailList(rx_packet_list, entry);
    3.16 -    RtlZeroMemory(&xi->rxpi, sizeof(xi->rxpi));
    3.17 +    XenNet_ClearPacketInfo(&xi->rxpi);
    3.18      return 1;
    3.19    }
    3.20  
    3.21 @@ -486,7 +486,7 @@ done:
    3.22      NdisAdjustBufferLength(xi->rxpi.mdls[i], PAGE_SIZE);
    3.23      XenFreelist_PutPage(&xi->rx_freelist, xi->rxpi.mdls[i]);
    3.24    }
    3.25 -  RtlZeroMemory(&xi->rxpi, sizeof(xi->rxpi));  
    3.26 +  XenNet_ClearPacketInfo(&xi->rxpi);
    3.27  //  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (split)\n"));
    3.28    return packet_count;
    3.29  }
     4.1 --- a/xennet/xennet_tx.c	Wed Nov 05 17:03:18 2008 +1100
     4.2 +++ b/xennet/xennet_tx.c	Thu Nov 06 11:19:22 2008 +1100
     4.3 @@ -119,7 +119,7 @@ XenNet_HWSendPacket(struct xennet_info *
     4.4    UINT first_buffer_length; /* not used */
     4.5    UINT total_length;
     4.6    
     4.7 -  RtlZeroMemory(&pi, sizeof(pi));
     4.8 +  XenNet_ClearPacketInfo(&pi);
     4.9    NdisGetFirstBufferFromPacketSafe(packet, &in_mdl, &pi.header, &first_buffer_length, &total_length, NormalPagePriority);
    4.10    
    4.11    if (!pi.header)