win-pvdrivers

changeset 595:63a4d934929f

renamed header buffer to coalesce buffer (hb -> cb etc) ready for changes to make xennet work without sg
author James Harper <james.harper@bendigoit.com.au>
date Thu Jun 25 21:09:37 2009 +1000 (2009-06-25)
parents 309e3de49a48
children 214866b0a8fd
files xennet/xennet.h xennet/xennet_tx.c
line diff
     1.1 --- a/xennet/xennet.h	Thu Jun 25 21:03:17 2009 +1000
     1.2 +++ b/xennet/xennet.h	Thu Jun 25 21:09:37 2009 +1000
     1.3 @@ -193,7 +193,7 @@ typedef struct
     1.4  typedef struct
     1.5  {
     1.6    PNDIS_PACKET packet; /* only set on the last packet */
     1.7 -  shared_buffer_t *hb;
     1.8 +  shared_buffer_t *cb;
     1.9  } tx_shadow_t;
    1.10  
    1.11  typedef struct {
    1.12 @@ -270,15 +270,15 @@ struct xennet_info
    1.13    tx_shadow_t tx_shadows[NET_TX_RING_SIZE];
    1.14    NDIS_HANDLE tx_buffer_pool;
    1.15  #define TX_HEADER_BUFFER_SIZE 512
    1.16 -//#define TX_HEADER_BUFFERS (NET_TX_RING_SIZE >> 2)
    1.17 -#define TX_HEADER_BUFFERS (NET_TX_RING_SIZE)
    1.18 +//#define TX_COALESCE_BUFFERS (NET_TX_RING_SIZE >> 2)
    1.19 +#define TX_COALESCE_BUFFERS (NET_TX_RING_SIZE)
    1.20    KEVENT tx_idle_event;
    1.21    ULONG tx_outstanding;
    1.22    ULONG tx_id_free;
    1.23    USHORT tx_id_list[NET_TX_RING_SIZE];
    1.24 -  ULONG tx_hb_free;
    1.25 -  ULONG tx_hb_list[TX_HEADER_BUFFERS];
    1.26 -  shared_buffer_t tx_hbs[TX_HEADER_BUFFERS];
    1.27 +  ULONG tx_cb_free;
    1.28 +  ULONG tx_cb_list[TX_COALESCE_BUFFERS];
    1.29 +  shared_buffer_t tx_cbs[TX_COALESCE_BUFFERS];
    1.30    KDPC tx_dpc;
    1.31  
    1.32    /* rx_related - protected by rx_lock */
     2.1 --- a/xennet/xennet_tx.c	Thu Jun 25 21:03:17 2009 +1000
     2.2 +++ b/xennet/xennet_tx.c	Thu Jun 25 21:09:37 2009 +1000
     2.3 @@ -37,35 +37,35 @@ put_id_on_freelist(struct xennet_info *x
     2.4  }
     2.5  
     2.6  static __inline shared_buffer_t *
     2.7 -get_hb_from_freelist(struct xennet_info *xi)
     2.8 +get_cb_from_freelist(struct xennet_info *xi)
     2.9  {
    2.10 -  shared_buffer_t *hb;
    2.11 +  shared_buffer_t *cb;
    2.12    
    2.13    //FUNCTION_ENTER();
    2.14 -  if (xi->tx_hb_free == 0)
    2.15 +  if (xi->tx_cb_free == 0)
    2.16    {
    2.17      //FUNCTION_EXIT();
    2.18      return NULL;
    2.19    }
    2.20 -  xi->tx_hb_free--;
    2.21 -  //KdPrint((__DRIVER_NAME "     xi->tx_hb_free = %d\n", xi->tx_hb_free));
    2.22 -  //KdPrint((__DRIVER_NAME "     xi->tx_hb_list[xi->tx_hb_free] = %d\n", xi->tx_hb_list[xi->tx_hb_free]));
    2.23 -  hb = &xi->tx_hbs[xi->tx_hb_list[xi->tx_hb_free]];
    2.24 -  //KdPrint((__DRIVER_NAME "     hb = %p\n", hb));
    2.25 +  xi->tx_cb_free--;
    2.26 +  //KdPrint((__DRIVER_NAME "     xi->tx_cb_free = %d\n", xi->tx_cb_free));
    2.27 +  //KdPrint((__DRIVER_NAME "     xi->tx_cb_list[xi->tx_cb_free] = %d\n", xi->tx_cb_list[xi->tx_cb_free]));
    2.28 +  cb = &xi->tx_cbs[xi->tx_cb_list[xi->tx_cb_free]];
    2.29 +  //KdPrint((__DRIVER_NAME "     cb = %p\n", cb));
    2.30    //FUNCTION_EXIT();
    2.31 -  return hb;
    2.32 +  return cb;
    2.33  }
    2.34  
    2.35  static __inline VOID
    2.36 -put_hb_on_freelist(struct xennet_info *xi, shared_buffer_t *hb)
    2.37 +put_cb_on_freelist(struct xennet_info *xi, shared_buffer_t *cb)
    2.38  {
    2.39    //FUNCTION_ENTER();
    2.40    
    2.41 -  //KdPrint((__DRIVER_NAME "     hb = %p\n", hb));
    2.42 -  //KdPrint((__DRIVER_NAME "     xi->tx_hb_free = %d\n", xi->tx_hb_free));
    2.43 -  ASSERT(hb);
    2.44 -  xi->tx_hb_list[xi->tx_hb_free] = hb->id;
    2.45 -  xi->tx_hb_free++;
    2.46 +  //KdPrint((__DRIVER_NAME "     cb = %p\n", cb));
    2.47 +  //KdPrint((__DRIVER_NAME "     xi->tx_cb_free = %d\n", xi->tx_cb_free));
    2.48 +  ASSERT(cb);
    2.49 +  xi->tx_cb_list[xi->tx_cb_free] = cb->id;
    2.50 +  xi->tx_cb_free++;
    2.51    //FUNCTION_EXIT();
    2.52  }
    2.53  
    2.54 @@ -190,10 +190,10 @@ XenNet_HWSendPacket(struct xennet_info *
    2.55  
    2.56    if (ndis_lso || (pi.header_length && pi.header_length > sg->Elements[sg_element].Length && pi.header == pi.header_data))
    2.57    {
    2.58 -    header_buf = get_hb_from_freelist(xi);
    2.59 +    header_buf = get_cb_from_freelist(xi);
    2.60      if (!header_buf)
    2.61      {
    2.62 -      KdPrint((__DRIVER_NAME "     Full on send - no free hb's\n"));
    2.63 +      KdPrint((__DRIVER_NAME "     Full on send - no free cb's\n"));
    2.64        return FALSE;
    2.65      }
    2.66    }
    2.67 @@ -323,12 +323,12 @@ XenNet_HWSendPacket(struct xennet_info *
    2.68    txN->flags &= ~NETTXF_more_data;
    2.69    txN->id = get_id_from_freelist(xi);
    2.70  //KdPrint((__DRIVER_NAME "     send - id = %d\n", tx0->id));
    2.71 -  //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));
    2.72 +  //KdPrint((__DRIVER_NAME "     TX: id = %d, cb = %p, xi->tx_shadows[txN->id].cb = %p\n", txN->id, header_buf, xi->tx_shadows[txN->id].cb));
    2.73    ASSERT(tx0->size == pi.total_length);
    2.74 -  ASSERT(!xi->tx_shadows[txN->id].hb);
    2.75 +  ASSERT(!xi->tx_shadows[txN->id].cb);
    2.76    ASSERT(!xi->tx_shadows[txN->id].packet);
    2.77    xi->tx_shadows[txN->id].packet = packet;
    2.78 -  xi->tx_shadows[txN->id].hb = header_buf;
    2.79 +  xi->tx_shadows[txN->id].cb = header_buf;
    2.80  
    2.81    if (ndis_lso)
    2.82    {
    2.83 @@ -426,11 +426,11 @@ XenNet_TxBufferGC(PKDPC dpc, PVOID conte
    2.84        if (txrsp->status == NETIF_RSP_NULL || txrsp->id == 0xFFFF)
    2.85          continue;
    2.86  
    2.87 -      //KdPrint((__DRIVER_NAME "     GC: id = %d, hb = %p\n", txrsp->id, xi->tx_shadows[txrsp->id].hb));
    2.88 -      if (xi->tx_shadows[txrsp->id].hb)
    2.89 +      //KdPrint((__DRIVER_NAME "     GC: id = %d, cb = %p\n", txrsp->id, xi->tx_shadows[txrsp->id].cb));
    2.90 +      if (xi->tx_shadows[txrsp->id].cb)
    2.91        {
    2.92 -        put_hb_on_freelist(xi, xi->tx_shadows[txrsp->id].hb);
    2.93 -        xi->tx_shadows[txrsp->id].hb = NULL;
    2.94 +        put_cb_on_freelist(xi, xi->tx_shadows[txrsp->id].cb);
    2.95 +        xi->tx_shadows[txrsp->id].cb = NULL;
    2.96        }
    2.97        
    2.98        if (xi->tx_shadows[txrsp->id].packet)
    2.99 @@ -567,7 +567,7 @@ XenNet_TxInit(xennet_info_t *xi)
   2.100    xi->tx_outstanding = 0;
   2.101    xi->tx_ring_free = NET_TX_RING_SIZE;
   2.102  
   2.103 -  for (i = 0; i < TX_HEADER_BUFFERS / (PAGE_SIZE / TX_HEADER_BUFFER_SIZE); i++)
   2.104 +  for (i = 0; i < TX_COALESCE_BUFFERS / (PAGE_SIZE / TX_HEADER_BUFFER_SIZE); i++)
   2.105    {
   2.106      PVOID virtual;
   2.107      NDIS_PHYSICAL_ADDRESS logical;
   2.108 @@ -578,10 +578,10 @@ XenNet_TxInit(xennet_info_t *xi)
   2.109      for (j = 0; j < PAGE_SIZE / TX_HEADER_BUFFER_SIZE; j++)
   2.110      {
   2.111        USHORT index = i * (PAGE_SIZE / TX_HEADER_BUFFER_SIZE) + j;
   2.112 -      xi->tx_hbs[index].id = index;
   2.113 -      xi->tx_hbs[index].virtual = (PUCHAR)virtual + j * TX_HEADER_BUFFER_SIZE;
   2.114 -      xi->tx_hbs[index].logical.QuadPart = logical.QuadPart + j * TX_HEADER_BUFFER_SIZE;
   2.115 -      put_hb_on_freelist(xi, &xi->tx_hbs[index]);
   2.116 +      xi->tx_cbs[index].id = index;
   2.117 +      xi->tx_cbs[index].virtual = (PUCHAR)virtual + j * TX_HEADER_BUFFER_SIZE;
   2.118 +      xi->tx_cbs[index].logical.QuadPart = logical.QuadPart + j * TX_HEADER_BUFFER_SIZE;
   2.119 +      put_cb_on_freelist(xi, &xi->tx_cbs[index]);
   2.120      }
   2.121    }
   2.122    if (i == 0)
   2.123 @@ -609,7 +609,7 @@ XenNet_TxShutdown(xennet_info_t *xi)
   2.124    //PMDL mdl;
   2.125    //ULONG i;
   2.126    KIRQL OldIrql;
   2.127 -  shared_buffer_t *hb;
   2.128 +  shared_buffer_t *cb;
   2.129  
   2.130    FUNCTION_ENTER();
   2.131  
   2.132 @@ -637,11 +637,11 @@ XenNet_TxShutdown(xennet_info_t *xi)
   2.133  
   2.134    KeAcquireSpinLock(&xi->tx_lock, &OldIrql);
   2.135  
   2.136 -  while((hb = get_hb_from_freelist(xi)) != NULL)
   2.137 +  while((cb = get_cb_from_freelist(xi)) != NULL)
   2.138    {
   2.139      /* only free the actual buffers which were aligned on a page boundary */
   2.140 -    if ((PtrToUlong(hb->virtual) & (PAGE_SIZE - 1)) == 0)
   2.141 -      NdisMFreeSharedMemory(xi->adapter_handle, PAGE_SIZE, TRUE, hb->virtual, hb->logical);
   2.142 +    if ((PtrToUlong(cb->virtual) & (PAGE_SIZE - 1)) == 0)
   2.143 +      NdisMFreeSharedMemory(xi->adapter_handle, PAGE_SIZE, TRUE, cb->virtual, cb->logical);
   2.144    }
   2.145  
   2.146    KeReleaseSpinLock(&xi->tx_lock, OldIrql);