win-pvdrivers

changeset 180:a4744cb1e51a

remove free packet list to simplify xennet
author Andy Grover <andy.grover@oracle.com>
date Mon Feb 11 13:48:53 2008 -0800 (2008-02-11)
parents d65135fd2390
children 762547e8a0db
files xennet/xennet.c
line diff
     1.1 --- a/xennet/xennet.c	Mon Feb 11 13:47:29 2008 -0800
     1.2 +++ b/xennet/xennet.c	Mon Feb 11 13:48:53 2008 -0800
     1.3 @@ -84,7 +84,6 @@ struct xennet_info
     1.4  
     1.5    LIST_ENTRY tx_waiting_pkt_list;
     1.6    LIST_ENTRY rx_free_buf_list;
     1.7 -  LIST_ENTRY rx_free_pkt_list;
     1.8  
     1.9    struct netif_tx_front_ring tx;
    1.10    struct netif_rx_front_ring rx;
    1.11 @@ -360,7 +359,6 @@ XenNet_RxBufferFree(struct xennet_info *
    1.12    int i;
    1.13    grant_ref_t ref;
    1.14    PNDIS_BUFFER buffer;
    1.15 -  PNDIS_PACKET packet;
    1.16    KIRQL OldIrql;
    1.17    PVOID buff_va;
    1.18    PLIST_ENTRY entry;
    1.19 @@ -399,12 +397,6 @@ XenNet_RxBufferFree(struct xennet_info *
    1.20      NdisFreeMemory(buff_va, 0, 0); // <= DISPATCH_LEVEL
    1.21    }
    1.22  
    1.23 -  while ((entry = RemoveHeadList(&xi->rx_free_pkt_list)) != &xi->rx_free_pkt_list)
    1.24 -  {
    1.25 -    packet = CONTAINING_RECORD(entry, NDIS_PACKET, MiniportReservedEx[sizeof(PVOID)]);
    1.26 -    NdisFreePacket(packet);
    1.27 -  }
    1.28 -
    1.29    KeReleaseSpinLock(&xi->rx_lock, OldIrql);
    1.30  }
    1.31  
    1.32 @@ -416,16 +408,10 @@ XenNet_ReturnPacket(
    1.33  {
    1.34    struct xennet_info *xi = MiniportAdapterContext;
    1.35    PNDIS_BUFFER buffer;
    1.36 -//  PNDIS_BUFFER next_buffer;
    1.37 -  // PVOID buff_va;
    1.38 -  // UINT buff_len;
    1.39 -  UINT tot_buff_len;
    1.40    buffer_entry_t *buffer_entry;
    1.41  
    1.42  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    1.43  
    1.44 -  NdisQueryPacketLength(Packet, &tot_buff_len);
    1.45 -
    1.46    NdisUnchainBufferAtBack(Packet, &buffer);
    1.47    while (buffer)
    1.48    {
    1.49 @@ -435,8 +421,7 @@ XenNet_ReturnPacket(
    1.50      NdisUnchainBufferAtBack(Packet, &buffer);
    1.51    }
    1.52  
    1.53 -  NdisReinitializePacket(Packet);
    1.54 -  InsertTailList(&xi->rx_free_pkt_list, (PLIST_ENTRY)&Packet->MiniportReservedEx[sizeof(PVOID)]);
    1.55 +  NdisFreePacket(Packet);
    1.56    
    1.57    InterlockedDecrement(&xi->rx_outstanding);
    1.58  
    1.59 @@ -452,15 +437,14 @@ static NDIS_STATUS
    1.60  XenNet_RxBufferCheck(struct xennet_info *xi)
    1.61  {
    1.62    RING_IDX cons, prod;
    1.63 -  PLIST_ENTRY entry;
    1.64    PNDIS_PACKET packet = NULL;
    1.65    PNDIS_BUFFER buffer;
    1.66    int moretodo;
    1.67    KIRQL OldIrql;
    1.68    struct netif_rx_response *rxrsp = NULL;
    1.69    int more_frags = 0;
    1.70 -  UINT length;
    1.71 -
    1.72 +  NDIS_STATUS status;
    1.73 +  
    1.74  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    1.75  
    1.76    ASSERT(xi->connected);
    1.77 @@ -477,18 +461,15 @@ XenNet_RxBufferCheck(struct xennet_info 
    1.78  
    1.79        if (!more_frags) // handling the packet's 1st buffer
    1.80        {
    1.81 -        entry = RemoveHeadList(&xi->rx_free_pkt_list);
    1.82 -        ASSERT(entry != &xi->rx_free_pkt_list);
    1.83 -        packet = CONTAINING_RECORD(entry, NDIS_PACKET, MiniportReservedEx[sizeof(PVOID)]);
    1.84 +        NdisAllocatePacket(&status, &packet, xi->packet_pool);
    1.85 +        ASSERT(status == NDIS_STATUS_SUCCESS);
    1.86          NDIS_SET_PACKET_HEADER_SIZE(packet, XN_HDR_SIZE);
    1.87 -        NdisQueryPacketLength(packet, &length);
    1.88        }
    1.89  
    1.90        buffer = xi->rx_buffers[rxrsp->id];
    1.91        xi->rx_buffers[rxrsp->id] = NULL;
    1.92        NdisAdjustBufferLength(buffer, rxrsp->status);
    1.93        NdisChainBufferAtBack(packet, buffer);
    1.94 -      NdisQueryPacketLength(packet, &length);
    1.95        xi->XenInterface.GntTbl_EndAccess(xi->XenInterface.InterfaceHeader.Context,
    1.96          xi->grant_rx_ref[rxrsp->id]);
    1.97        xi->grant_rx_ref[rxrsp->id] = GRANT_INVALID_REF;
    1.98 @@ -668,9 +649,7 @@ XenNet_Init(
    1.99    char *err;
   1.100    xenbus_transaction_t xbt = 0;
   1.101    KIRQL OldIrql;
   1.102 -  PNDIS_PACKET packet;
   1.103    buffer_entry_t *buffer_entry;
   1.104 -  PLIST_ENTRY entry;
   1.105  
   1.106    UNREFERENCED_PARAMETER(OpenErrorStatus);
   1.107    UNREFERENCED_PARAMETER(WrapperConfigurationContext);
   1.108 @@ -717,7 +696,6 @@ XenNet_Init(
   1.109    KeInitializeSpinLock(&xi->rx_lock);
   1.110  
   1.111    InitializeListHead(&xi->rx_free_buf_list);
   1.112 -  InitializeListHead(&xi->rx_free_pkt_list);
   1.113    InitializeListHead(&xi->tx_waiting_pkt_list);
   1.114    
   1.115    NdisAllocatePacketPool(&status, &xi->packet_pool, XN_RX_QUEUE_LEN,
   1.116 @@ -901,10 +879,6 @@ XenNet_Init(
   1.117      NdisAllocateBuffer(&status, &buffer_entry->buffer, xi->buffer_pool, buffer_entry, sizeof(buffer_entry->data));
   1.118      ASSERT(status == NDIS_STATUS_SUCCESS); // should never fail
   1.119      InsertTailList(&xi->rx_free_buf_list, &buffer_entry->entry);
   1.120 -
   1.121 -    NdisAllocatePacket(&status, &packet, xi->packet_pool);
   1.122 -    entry = (PLIST_ENTRY)&packet->MiniportReservedEx[sizeof(PVOID)];
   1.123 -    InsertTailList(&xi->rx_free_pkt_list, entry);
   1.124    }
   1.125  
   1.126    XenNet_RxBufferAlloc(xi);