win-pvdrivers

changeset 439:9971dbcc8c2b

More changes to pass WHQL ndistest. All major tests pass now.
Implemented software Multicast filtering.
author James Harper <james.harper@bendigoit.com.au>
date Wed Nov 05 14:52:46 2008 +1100 (2008-11-05)
parents f0fe409ae32e
children 51fae6b70049
files xennet/xennet.c xennet/xennet.h xennet/xennet_oid.c xennet/xennet_rx.c xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.c	Tue Nov 04 22:21:37 2008 +1100
     1.2 +++ b/xennet/xennet.c	Wed Nov 05 14:52:46 2008 +1100
     1.3 @@ -346,7 +346,8 @@ XenNet_Init(
     1.4    NdisMSetAttributesEx(xi->adapter_handle, (NDIS_HANDLE) xi,
     1.5      0, NDIS_ATTRIBUTE_DESERIALIZE|NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK,
     1.6      NdisInterfaceInternal);
     1.7 -
     1.8 +  xi->multicast_list_size = 0;
     1.9 +  
    1.10    nrl_length = 0;
    1.11    NdisMQueryAdapterResources(&status, WrapperConfigurationContext,
    1.12      NULL, (PUINT)&nrl_length);
    1.13 @@ -670,6 +671,18 @@ XenNet_Halt(
    1.14    FUNCTION_EXIT();
    1.15  }
    1.16  
    1.17 +NDIS_STATUS 
    1.18 +XenNet_Reset(
    1.19 +  PBOOLEAN  AddressingReset,
    1.20 +  NDIS_HANDLE  MiniportAdapterContext
    1.21 +)
    1.22 +{
    1.23 +  UNREFERENCED_PARAMETER(MiniportAdapterContext);
    1.24 +
    1.25 +  *AddressingReset = FALSE;
    1.26 +  return NDIS_STATUS_SUCCESS;
    1.27 +}
    1.28 +
    1.29  NTSTATUS DDKAPI
    1.30  DriverEntry(
    1.31    PDRIVER_OBJECT DriverObject,
    1.32 @@ -700,7 +713,7 @@ DriverEntry(
    1.33    mini_chars.ISRHandler = XenNet_InterruptIsr;
    1.34    mini_chars.HandleInterruptHandler = XenNet_InterruptDpc;
    1.35    mini_chars.QueryInformationHandler = XenNet_QueryInformation;
    1.36 -  mini_chars.ResetHandler = NULL; //TODO: fill in
    1.37 +  mini_chars.ResetHandler = XenNet_Reset;
    1.38    mini_chars.SetInformationHandler = XenNet_SetInformation;
    1.39    /* added in v.4 -- use multiple pkts interface */
    1.40    mini_chars.ReturnPacketHandler = XenNet_ReturnPacket;
     2.1 --- a/xennet/xennet.h	Tue Nov 04 22:21:37 2008 +1100
     2.2 +++ b/xennet/xennet.h	Wed Nov 05 14:52:46 2008 +1100
     2.3 @@ -199,6 +199,8 @@ typedef struct {
     2.4  } packet_info_t;
     2.5  
     2.6  #define PAGE_LIST_SIZE (max(NET_RX_RING_SIZE, NET_TX_RING_SIZE) * 4)
     2.7 +#define MULTICAST_LIST_MAX_SIZE 32
     2.8 +
     2.9  typedef struct
    2.10  {
    2.11    struct xennet_info *xi;
    2.12 @@ -240,6 +242,8 @@ struct xennet_info
    2.13    char backend_path[MAX_XENBUS_STR_LEN];
    2.14    ULONG backend_state;
    2.15    PVOID config_page;
    2.16 +  UCHAR multicast_list[MULTICAST_LIST_MAX_SIZE][6];
    2.17 +  ULONG multicast_list_size;
    2.18  
    2.19    /* tx related - protected by tx_lock */
    2.20    KSPIN_LOCK tx_lock;
     3.1 --- a/xennet/xennet_oid.c	Tue Nov 04 22:21:37 2008 +1100
     3.2 +++ b/xennet/xennet_oid.c	Wed Nov 05 14:52:46 2008 +1100
     3.3 @@ -218,10 +218,11 @@ XenNet_QueryInformation(
     3.4        HANDLE_STAT_RETURN;
     3.5        break;
     3.6      case OID_802_3_MULTICAST_LIST:
     3.7 -      data = NULL;
     3.8 -      len = 0;
     3.9 +      data = xi->multicast_list;
    3.10 +      len = xi->multicast_list_size * 6;
    3.11 +      break;
    3.12      case OID_802_3_MAXIMUM_LIST_SIZE:
    3.13 -      temp_data = 0; /* no mcast support */
    3.14 +      temp_data = MULTICAST_LIST_MAX_SIZE; /* no mcast support, but to return 0 is an error */
    3.15        break;
    3.16      case OID_TCP_TASK_OFFLOAD:
    3.17        KdPrint(("Get OID_TCP_TASK_OFFLOAD\n"));
    3.18 @@ -254,7 +255,10 @@ XenNet_QueryInformation(
    3.19        ntoh = (PNDIS_TASK_OFFLOAD_HEADER)InformationBuffer;
    3.20        if (ntoh->Version != NDIS_TASK_OFFLOAD_VERSION
    3.21          || ntoh->Size != sizeof(*ntoh)
    3.22 -        || ntoh->EncapsulationFormat.Encapsulation != IEEE_802_3_Encapsulation)
    3.23 +        || !(
    3.24 +          ntoh->EncapsulationFormat.Encapsulation == IEEE_802_3_Encapsulation
    3.25 +          || (ntoh->EncapsulationFormat.Encapsulation == UNSPECIFIED_Encapsulation
    3.26 +              && ntoh->EncapsulationFormat.EncapsulationHeaderSize == XN_HDR_SIZE)))
    3.27        {
    3.28          status = NDIS_STATUS_NOT_SUPPORTED;
    3.29          break;
    3.30 @@ -394,12 +398,14 @@ XenNet_SetInformation(
    3.31    )
    3.32  {
    3.33    NTSTATUS status;
    3.34 +  ULONG i;
    3.35    struct xennet_info *xi = MiniportAdapterContext;
    3.36    PULONG64 data = InformationBuffer;
    3.37    PNDIS_TASK_OFFLOAD_HEADER ntoh;
    3.38    PNDIS_TASK_OFFLOAD nto;
    3.39    PNDIS_TASK_TCP_IP_CHECKSUM nttic = NULL;
    3.40    PNDIS_TASK_TCP_LARGE_SEND nttls = NULL;
    3.41 +  UCHAR *multicast_list;
    3.42    int offset;
    3.43  
    3.44    //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    3.45 @@ -554,6 +560,29 @@ XenNet_SetInformation(
    3.46        KdPrint(("     Set OID_802_3_MULTICAST_LIST\n"));
    3.47        KdPrint(("       Length = %d\n", InformationBufferLength));
    3.48        KdPrint(("       Entries = %d\n", InformationBufferLength / 6));
    3.49 +      if (InformationBufferLength > MULTICAST_LIST_MAX_SIZE * 6)
    3.50 +      {
    3.51 +        status = NDIS_STATUS_MULTICAST_FULL;
    3.52 +        break;
    3.53 +      }
    3.54 +      
    3.55 +      if (InformationBufferLength % 6 != 0)
    3.56 +      {
    3.57 +        status = NDIS_STATUS_MULTICAST_FULL;
    3.58 +        break;
    3.59 +      }
    3.60 +      multicast_list = InformationBuffer;
    3.61 +      for (i = 0; i < InformationBufferLength / 6; i++)
    3.62 +      {
    3.63 +        if (!(multicast_list[i * 6 + 0] & 0x01))
    3.64 +        {
    3.65 +          KdPrint(("       Address %d is not a multicast address\n", i));
    3.66 +          status = NDIS_STATUS_MULTICAST_FULL;
    3.67 +          break;
    3.68 +        }
    3.69 +      }
    3.70 +      memcpy(xi->multicast_list, InformationBuffer, InformationBufferLength);
    3.71 +      xi->multicast_list_size = InformationBufferLength / 6;
    3.72        status = NDIS_STATUS_SUCCESS;
    3.73        break;
    3.74      case OID_802_3_MAXIMUM_LIST_SIZE:
     4.1 --- a/xennet/xennet_rx.c	Tue Nov 04 22:21:37 2008 +1100
     4.2 +++ b/xennet/xennet_rx.c	Wed Nov 05 14:52:46 2008 +1100
     4.3 @@ -355,6 +355,21 @@ XenNet_MakePackets(
     4.4  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "(packets = %p, packet_count = %d)\n", packets, *packet_count_p));
     4.5  
     4.6    parse_result = XenNet_ParsePacketHeader(&xi->rxpi);
     4.7 +  
     4.8 +  if ((xi->packet_filter & NDIS_PACKET_TYPE_MULTICAST)
     4.9 +    && !(xi->packet_filter & NDIS_PACKET_TYPE_ALL_MULTICAST)
    4.10 +    && (xi->rxpi.header[0] & 0x01)
    4.11 +    && !(xi->rxpi.header[0] == 0xFF && xi->rxpi.header[1] == 0xFF && xi->rxpi.header[2] == 0xFF
    4.12 +        && xi->rxpi.header[3] == 0xFF && xi->rxpi.header[4] == 0xFF && xi->rxpi.header[5] == 0xFF))
    4.13 +  {
    4.14 +    for (i = 0; i < xi->multicast_list_size; i++)
    4.15 +    {
    4.16 +      if (memcmp(xi->multicast_list[i], xi->rxpi.header, 6) == 0)
    4.17 +        break;
    4.18 +    }
    4.19 +    if (i == xi->multicast_list_size)
    4.20 +      goto done;
    4.21 +  }
    4.22    switch (xi->rxpi.ip_proto)
    4.23    {
    4.24    case 6:  // TCP
     5.1 --- a/xennet/xennet_tx.c	Tue Nov 04 22:21:37 2008 +1100
     5.2 +++ b/xennet/xennet_tx.c	Wed Nov 05 14:52:46 2008 +1100
     5.3 @@ -141,8 +141,8 @@ XenNet_HWSendPacket(struct xennet_info *
     5.4      if (csum_info->Transmit.NdisPacketChecksumV6)
     5.5      {
     5.6        KdPrint((__DRIVER_NAME "     NdisPacketChecksumV6 not supported\n"));
     5.7 -      NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
     5.8 -      return TRUE;
     5.9 +      //NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.10 +      //return TRUE;
    5.11      }
    5.12  
    5.13      if (csum_info->Transmit.NdisPacketChecksumV4)
    5.14 @@ -150,25 +150,34 @@ XenNet_HWSendPacket(struct xennet_info *
    5.15        if (csum_info->Transmit.NdisPacketIpChecksum && !xi->setting_csum.V4Transmit.IpChecksum)
    5.16        {
    5.17          KdPrint((__DRIVER_NAME "     IpChecksum not enabled\n"));
    5.18 -        NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.19 -        return TRUE;
    5.20 -      }
    5.21 -      if (csum_info->Transmit.NdisPacketTcpChecksum && !xi->setting_csum.V4Transmit.TcpChecksum)
    5.22 -      {
    5.23 -        KdPrint((__DRIVER_NAME "     TcpChecksum not enabled\n"));
    5.24 -        NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.25 -        return TRUE;
    5.26 +        //NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.27 +        //return TRUE;
    5.28        }
    5.29 -      if (csum_info->Transmit.NdisPacketUdpChecksum && !xi->setting_csum.V4Transmit.UdpChecksum)
    5.30 +      if (csum_info->Transmit.NdisPacketTcpChecksum)
    5.31        {
    5.32 -        KdPrint((__DRIVER_NAME "     UdpChecksum not enabled\n"));
    5.33 -        NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.34 -        return TRUE;
    5.35 +        if (xi->setting_csum.V4Transmit.TcpChecksum)
    5.36 +        {
    5.37 +          flags |= NETTXF_csum_blank | NETTXF_data_validated;
    5.38 +        }
    5.39 +        else
    5.40 +        {
    5.41 +          KdPrint((__DRIVER_NAME "     TcpChecksum not enabled\n"));
    5.42 +          //NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.43 +          //return TRUE;
    5.44 +        }
    5.45        }
    5.46 -      if (csum_info->Transmit.NdisPacketTcpChecksum
    5.47 -        || csum_info->Transmit.NdisPacketUdpChecksum)
    5.48 +      if (csum_info->Transmit.NdisPacketUdpChecksum)
    5.49        {
    5.50 -        flags |= NETTXF_csum_blank | NETTXF_data_validated;
    5.51 +        if (xi->setting_csum.V4Transmit.UdpChecksum)
    5.52 +        {
    5.53 +          flags |= NETTXF_csum_blank | NETTXF_data_validated;
    5.54 +        }
    5.55 +        else
    5.56 +        {
    5.57 +          KdPrint((__DRIVER_NAME "     UdpChecksum not enabled\n"));
    5.58 +          //NDIS_SET_PACKET_STATUS(packet, NDIS_STATUS_FAILURE);
    5.59 +          //return TRUE;
    5.60 +        }
    5.61        }
    5.62      }
    5.63    }