win-pvdrivers

changeset 129:cf3c845b4ae4

xennet: clean up some old code. implement cleanup of tx wait queue on halt. Whitespace/comments.
author Andy Grover <andy.grover@oracle.com>
date Thu Jan 17 12:03:47 2008 -0800 (2008-01-17)
parents 9ebc64a86e57
children 1c286bc336b0
files xennet/xennet.c
line diff
     1.1 --- a/xennet/xennet.c	Thu Jan 17 12:47:04 2008 +1100
     1.2 +++ b/xennet/xennet.c	Thu Jan 17 12:03:47 2008 -0800
     1.3 @@ -91,7 +91,7 @@ struct xennet_info
     1.4    PMDL tx_mdl;
     1.5    PMDL rx_mdl;
     1.6  
     1.7 -  /* Outstanding packets. The first entry in tx_pkts
     1.8 +  /* Packets given to netback. The first entry in tx_pkts
     1.9     * is an index into a chain of free entries. */
    1.10    int tx_pkt_ids_used;
    1.11    PNDIS_PACKET tx_pkts[NET_TX_RING_SIZE+1];
    1.12 @@ -110,6 +110,7 @@ struct xennet_info
    1.13    ULONG rx_max_target;
    1.14    ULONG rx_min_target;
    1.15  
    1.16 +  /* how many packets are in the net stack atm */
    1.17    LONG rx_outstanding;
    1.18  
    1.19    /* stats */
    1.20 @@ -170,7 +171,8 @@ get_id_from_freelist(struct xennet_info 
    1.21    return id;
    1.22  }
    1.23  
    1.24 -VOID XenNet_SendQueuedPackets(struct xennet_info *xi);
    1.25 +VOID
    1.26 +XenNet_SendQueuedPackets(struct xennet_info *xi);
    1.27  
    1.28  // Called at DISPATCH_LEVEL
    1.29  static NDIS_STATUS
    1.30 @@ -240,13 +242,31 @@ XenNet_TxBufferGC(struct xennet_info *xi
    1.31    return NDIS_STATUS_SUCCESS;
    1.32  }
    1.33  
    1.34 -static void XenNet_TxBufferFree(struct xennet_info *xi)
    1.35 +static void
    1.36 +XenNet_TxBufferFree(struct xennet_info *xi)
    1.37  {
    1.38    PNDIS_PACKET packet;
    1.39    PMDL pmdl;
    1.40 +  PLIST_ENTRY entry;
    1.41    unsigned short id;
    1.42  
    1.43 -  /* TODO: free packets in tx queue (once implemented) */
    1.44 +  ASSERT(!xi->connected);
    1.45 +
    1.46 +  /* Free packets in tx queue */
    1.47 +  entry = RemoveHeadList(&xi->tx_waiting_pkt_list);
    1.48 +  while (entry != &xi->tx_waiting_pkt_list)
    1.49 +  {
    1.50 +    packet = CONTAINING_RECORD(entry, NDIS_PACKET, MiniportReservedEx[4]);
    1.51 +
    1.52 +    /* free linearized data page */
    1.53 +    pmdl = *(PMDL *)packet->MiniportReservedEx;
    1.54 +    NdisFreeMemory(MmGetMdlVirtualAddress(pmdl), 0, 0); // <= DISPATCH_LEVEL
    1.55 +    IoFreeMdl(pmdl);
    1.56 +
    1.57 +    NdisMSendComplete(xi->adapter_handle, packet, NDIS_STATUS_FAILURE);
    1.58 +
    1.59 +    entry = RemoveHeadList(&xi->tx_waiting_pkt_list);
    1.60 +  }
    1.61  
    1.62    /* free sent-but-not-completed packets */
    1.63    for (id = 1; id < NET_TX_RING_SIZE+1; id++) {
    1.64 @@ -435,17 +455,6 @@ XenNet_RxBufferCheck(struct xennet_info 
    1.65          NdisAllocatePacket(&status, &packet, xi->packet_pool);
    1.66          ASSERT(status == NDIS_STATUS_SUCCESS);
    1.67          NDIS_SET_PACKET_HEADER_SIZE(packet, XN_HDR_SIZE);
    1.68 -/*
    1.69 -        if (NDIS_GET_PACKET_PROTOCOL_TYPE(packet) == NDIS_PROTOCOL_ID_TCP_IP
    1.70 -          && (rxrsp->flags & (NETRXF_csum_blank|NETRXF_data_validated)))
    1.71 -        {
    1.72 -          csum_info = (PNDIS_TCP_IP_CHECKSUM_PACKET_INFO)&NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpIpChecksumPacketInfo);
    1.73 -          csum_info->Receive.NdisPacketTcpChecksumSucceeded = 1;
    1.74 -          csum_info->Receive.NdisPacketUdpChecksumSucceeded = 1;
    1.75 -          csum_info->Receive.NdisPacketIpChecksumSucceeded = 1;
    1.76 -//          KdPrint((__DRIVER_NAME "     Offload = %08x\n", NDIS_PER_PACKET_INFO_FROM_PACKET(packet, TcpIpChecksumPacketInfo)));
    1.77 -        }
    1.78 -*/
    1.79        }
    1.80  
    1.81        buffer = xi->rx_buffers[rxrsp->id];
    1.82 @@ -591,7 +600,7 @@ XenNet_BackEndStateHandler(char *Path, P
    1.83      /* TODO: must free pages in MDL as well as MDL using MmFreePagesFromMdl and ExFreePool */
    1.84      // or, allocate mem and then get mdl, then free mdl
    1.85      xi->tx_mdl = AllocatePage();
    1.86 -    xi->tx_pgs = MmGetMdlVirtualAddress(xi->tx_mdl); //MmMapLockedPagesSpecifyCache(xi->tx_mdl, KernelMode, MmNonCached, NULL, FALSE, NormalPagePriority);
    1.87 +    xi->tx_pgs = MmGetMdlVirtualAddress(xi->tx_mdl);
    1.88      SHARED_RING_INIT(xi->tx_pgs);
    1.89      FRONT_RING_INIT(&xi->tx, xi->tx_pgs, PAGE_SIZE);
    1.90      xi->tx_ring_ref = xi->XenInterface.GntTbl_GrantAccess(
    1.91 @@ -599,7 +608,7 @@ XenNet_BackEndStateHandler(char *Path, P
    1.92        *MmGetMdlPfnArray(xi->tx_mdl), FALSE);
    1.93  
    1.94      xi->rx_mdl = AllocatePage();
    1.95 -    xi->rx_pgs = MmGetMdlVirtualAddress(xi->rx_mdl); //MmMapLockedPagesSpecifyCache(xi->rx_mdl, KernelMode, MmNonCached, NULL, FALSE, NormalPagePriority);
    1.96 +    xi->rx_pgs = MmGetMdlVirtualAddress(xi->rx_mdl);
    1.97      SHARED_RING_INIT(xi->rx_pgs);
    1.98      FRONT_RING_INIT(&xi->rx, xi->rx_pgs, PAGE_SIZE);
    1.99      xi->rx_ring_ref = xi->XenInterface.GntTbl_GrantAccess(