win-pvdrivers

changeset 562:8ab116a713f4

Filter updates.
Fixed some overflow problems vs Linux SG limits
author James Harper <james.harper@bendigoit.com.au>
date Sun May 10 20:17:31 2009 +1000 (2009-05-10)
parents d56ecda9e61f
children c16b24b438aa
files xennet/xennet.c xennet/xennet.inx xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.c	Sun May 10 20:17:05 2009 +1000
     1.2 +++ b/xennet/xennet.c	Sun May 10 20:17:31 2009 +1000
     1.3 @@ -738,7 +738,7 @@ DriverEntry(
     1.4    IoAllocateDriverObjectExtension(DriverObject, UlongToPtr(XEN_DMA_DRIVER_EXTENSION_MAGIC), sizeof(dma_driver_extension_t), &dma_driver_extension);  
     1.5    dma_driver_extension->need_virtual_address = NULL;
     1.6    dma_driver_extension->get_alignment = NULL;
     1.7 -  dma_driver_extension->max_sg_elements = 17;
     1.8 +  dma_driver_extension->max_sg_elements = 19; /* header + 18 fragments */
     1.9  
    1.10    KdPrint((__DRIVER_NAME "     DriverObject = %p, RegistryPath = %p\n", DriverObject, RegistryPath));
    1.11    RtlZeroMemory(&mini_chars, sizeof(mini_chars));
     2.1 --- a/xennet/xennet.inx	Sun May 10 20:17:05 2009 +1000
     2.2 +++ b/xennet/xennet.inx	Sun May 10 20:17:31 2009 +1000
     2.3 @@ -103,7 +103,6 @@ AddReg = XenNet_Service_AddReg
     2.4  [XenNet_Service_AddReg]
     2.5  ; 5 = PciBus, 0 = Internal, 15 = PnpBus
     2.6  HKR,"Parameters\PnpInterface", "15", 0x00010001, 0x00000001
     2.7 -HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318},UpperFilters,0x00010008,XenHide
     2.8  
     2.9  [Strings]
    2.10  XenGplPv = "Xen GPL PV Driver Developers"
     3.1 --- a/xennet/xennet_tx.c	Sun May 10 20:17:05 2009 +1000
     3.2 +++ b/xennet/xennet_tx.c	Sun May 10 20:17:31 2009 +1000
     3.3 @@ -105,9 +105,6 @@ XenNet_HWSendPacket(struct xennet_info *
     3.4    parse_result = XenNet_ParsePacketHeader(&pi);  
     3.5    //KdPrint((__DRIVER_NAME "     B\n"));
     3.6  
     3.7 -  if (pi.header && *((PUCHAR)pi.header + 12) != 0x08)
     3.8 -    KdPrint((__DRIVER_NAME "     %02x %02x\n", (int)*((PUCHAR)pi.header + 12), (int)*((PUCHAR)pi.header + 13)));
     3.9 -
    3.10    if (NDIS_GET_PACKET_PROTOCOL_TYPE(packet) == NDIS_PROTOCOL_ID_TCP_IP)
    3.11    {
    3.12      csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(
    3.13 @@ -173,15 +170,23 @@ XenNet_HWSendPacket(struct xennet_info *
    3.14      }
    3.15    }
    3.16  
    3.17 -  if (pi.mdl_count + !!ndis_lso > xi->tx_ring_free)
    3.18 +  sg = (PSCATTER_GATHER_LIST)NDIS_PER_PACKET_INFO_FROM_PACKET(packet, ScatterGatherListPacketInfo);
    3.19 +  ASSERT(sg != NULL);
    3.20 +
    3.21 +  if (sg->NumberOfElements > 19)
    3.22    {
    3.23 -    KdPrint((__DRIVER_NAME "     Full on send - required = %d, available = %d\n", pi.mdl_count + !!ndis_lso, xi->tx_ring_free));
    3.24 +    KdPrint((__DRIVER_NAME "     sg->NumberOfElements = %d\n", sg->NumberOfElements));
    3.25 +    NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_SUCCESS);
    3.26 +    return TRUE; // we'll pretend we sent the packet here for now...
    3.27 +  }
    3.28 +  //ASSERT(sg->NumberOfElements <= 19);
    3.29 +  if (sg->NumberOfElements + !!ndis_lso > xi->tx_ring_free)
    3.30 +  {
    3.31 +    KdPrint((__DRIVER_NAME "     Full on send - required = %d, available = %d\n", sg->NumberOfElements + !!ndis_lso, xi->tx_ring_free));
    3.32      //FUNCTION_EXIT();
    3.33      return FALSE;
    3.34    }
    3.35  
    3.36 -  sg = (PSCATTER_GATHER_LIST)NDIS_PER_PACKET_INFO_FROM_PACKET(packet, ScatterGatherListPacketInfo);
    3.37 -  ASSERT(sg != NULL);
    3.38  
    3.39    if (ndis_lso || (pi.header_length && pi.header_length > sg->Elements[sg_element].Length && pi.header == pi.header_data))
    3.40    {
    3.41 @@ -281,7 +286,6 @@ XenNet_HWSendPacket(struct xennet_info *
    3.42      //KdPrint((__DRIVER_NAME "     Using extra_info\n"));
    3.43      ASSERT(flags & NETTXF_extra_info);
    3.44      ei = (struct netif_extra_info *)RING_GET_REQUEST(&xi->tx, xi->tx.req_prod_pvt);
    3.45 -    chunks++;
    3.46      xi->tx_ring_free--;
    3.47      ei->type = XEN_NETIF_EXTRA_TYPE_GSO;
    3.48      ei->flags = 0;
    3.49 @@ -300,6 +304,7 @@ XenNet_HWSendPacket(struct xennet_info *
    3.50      //KdPrint((__DRIVER_NAME "     H - address = %p, length = %d\n",
    3.51      //  sg->Elements[sg_element].Address.LowPart + sg_offset, sg->Elements[sg_element].Length - sg_offset));
    3.52      txN = RING_GET_REQUEST(&xi->tx, xi->tx.req_prod_pvt);
    3.53 +    chunks++;
    3.54      xi->tx_ring_free--;
    3.55      txN->id = 0xFFFF;
    3.56      txN->gref = (grant_ref_t)(sg->Elements[sg_element].Address.QuadPart >> PAGE_SHIFT);
    3.57 @@ -319,6 +324,7 @@ XenNet_HWSendPacket(struct xennet_info *
    3.58    txN->id = get_id_from_freelist(xi);
    3.59  //KdPrint((__DRIVER_NAME "     send - id = %d\n", tx0->id));
    3.60    //KdPrint((__DRIVER_NAME "     TX: id = %d, hb = %p, xi->tx_shadows[txN->id].hb = %p\n", txN->id, header_buf, xi->tx_shadows[txN->id].hb));
    3.61 +  ASSERT(tx0->size == pi.total_length);
    3.62    ASSERT(!xi->tx_shadows[txN->id].hb);
    3.63    ASSERT(!xi->tx_shadows[txN->id].packet);
    3.64    xi->tx_shadows[txN->id].packet = packet;
    3.65 @@ -330,7 +336,7 @@ XenNet_HWSendPacket(struct xennet_info *
    3.66      NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpLargeSendPacketInfo) = UlongToPtr(pi.tcp_length);
    3.67    }
    3.68  
    3.69 -  if (chunks > 12)
    3.70 +  if (chunks > 19)
    3.71    {
    3.72      KdPrint((__DRIVER_NAME "     chunks = %d\n", chunks));
    3.73    }