win-pvdrivers

changeset 42:5dc3e004cf94

xennet: implement tx ring cleanup on xen interrupt
author Andy Grover <andy.grover@oracle.com>
date Wed Dec 05 14:56:01 2007 -0800 (2007-12-05)
parents 932802ddab71
children 59691f2a99f6
files xennet/xennet.c
line diff
     1.1 --- a/xennet/xennet.c	Wed Dec 05 12:39:59 2007 -0800
     1.2 +++ b/xennet/xennet.c	Wed Dec 05 14:56:01 2007 -0800
     1.3 @@ -175,44 +175,41 @@ AllocatePage()
     1.4  static NDIS_STATUS
     1.5  XenNet_TxBufGC(struct xennet_info *xi)
     1.6  {
     1.7 -//  RING_IDX cons, prod;
     1.8 -  UNREFERENCED_PARAMETER(xi);
     1.9 -#if 0
    1.10 +  RING_IDX cons, prod;
    1.11 +
    1.12    unsigned short id;
    1.13 -  struct sk_buff *skb;
    1.14 +  PNDIS_PACKET pkt;
    1.15 +  PMDL pmdl;
    1.16  
    1.17 -  BUG_ON(!netfront_carrier_ok(np));
    1.18 +  ASSERT(xi->connected);
    1.19  
    1.20    do {
    1.21 -    prod = np->tx.sring->rsp_prod;
    1.22 -    rmb(); /* Ensure we see responses up to 'rp'. */
    1.23 +    prod = xi->tx.sring->rsp_prod;
    1.24 +    KeMemoryBarrier(); /* Ensure we see responses up to 'rp'. */
    1.25  
    1.26 -    for (cons = np->tx.rsp_cons; cons != prod; cons++) {
    1.27 +    for (cons = xi->tx.rsp_cons; cons != prod; cons++) {
    1.28        struct netif_tx_response *txrsp;
    1.29  
    1.30 -      txrsp = RING_GET_RESPONSE(&np->tx, cons);
    1.31 +      txrsp = RING_GET_RESPONSE(&xi->tx, cons);
    1.32        if (txrsp->status == NETIF_RSP_NULL)
    1.33          continue;
    1.34  
    1.35        id  = txrsp->id;
    1.36 -      skb = np->tx_skbs[id];
    1.37 -      if (unlikely(gnttab_query_foreign_access(
    1.38 -        np->grant_tx_ref[id]) != 0)) {
    1.39 -        printk(KERN_ALERT "network_tx_buf_gc: warning "
    1.40 -               "-- grant still in use by backend "
    1.41 -               "domain.\n");
    1.42 -        BUG();
    1.43 -      }
    1.44 -      gnttab_end_foreign_access_ref(
    1.45 -        np->grant_tx_ref[id], GNTMAP_readonly);
    1.46 -      gnttab_release_grant_reference(
    1.47 -        &np->gref_tx_head, np->grant_tx_ref[id]);
    1.48 -      np->grant_tx_ref[id] = GRANT_INVALID_REF;
    1.49 -      add_id_to_freelist(np->tx_skbs, id);
    1.50 -      dev_kfree_skb_irq(skb);
    1.51 +      pkt = xi->tx_pkts[id];
    1.52 +      xi->GntTblInterface.EndAccess(xi->GntTblInterface.InterfaceHeader.Context,
    1.53 +        xi->grant_tx_ref[id]);
    1.54 +      xi->grant_tx_ref[id] = GRANT_INVALID_REF;
    1.55 +      add_id_to_freelist(xi->tx_pkts, id);
    1.56 +
    1.57 +      /* free page for linearized data */
    1.58 +      pmdl = *(PMDL *)pkt->MiniportReservedEx;
    1.59 +      MmFreePagesFromMdl(pmdl);
    1.60 +      IoFreeMdl(pmdl);
    1.61 +
    1.62 +      NdisMSendComplete(xi->adapter_handle, pkt, NDIS_STATUS_SUCCESS);
    1.63      }
    1.64  
    1.65 -    np->tx.rsp_cons = prod;
    1.66 +    xi->tx.rsp_cons = prod;
    1.67  
    1.68      /*
    1.69       * Set a new event, then check for race with update of tx_cons.
    1.70 @@ -222,17 +219,13 @@ XenNet_TxBufGC(struct xennet_info *xi)
    1.71       * data is outstanding: in such cases notification from Xen is
    1.72       * likely to be the only kick that we'll get.
    1.73       */
    1.74 -    np->tx.sring->rsp_event =
    1.75 -      prod + ((np->tx.sring->req_prod - prod) >> 1) + 1;
    1.76 +    xi->tx.sring->rsp_event =
    1.77 +      prod + ((xi->tx.sring->req_prod - prod) >> 1) + 1;
    1.78      mb();
    1.79 -  } while ((cons == prod) && (prod != np->tx.sring->rsp_prod));
    1.80 +  } while ((cons == prod) && (prod != xi->tx.sring->rsp_prod));
    1.81  
    1.82 -  network_maybe_wake_tx(dev);
    1.83 -
    1.84 -
    1.85 -
    1.86 -#endif
    1.87 -
    1.88 +  /* if queued packets, send them now?
    1.89 +  network_maybe_wake_tx(dev); */
    1.90  
    1.91    return NDIS_STATUS_SUCCESS;
    1.92  }
    1.93 @@ -260,7 +253,7 @@ XenNet_Interrupt(
    1.94    // KeReleaseSpinLock(&ChildDeviceData->Lock, KIrql);
    1.95    // KdPrint((__DRIVER_NAME " --> Dpc Event Set\n"));
    1.96  
    1.97 -  /* do something */
    1.98 +  /* handle RX packets */
    1.99  
   1.100    return TRUE;
   1.101  }
   1.102 @@ -923,6 +916,7 @@ XenNet_SendPackets(
   1.103        0,
   1.104        pfn,
   1.105        TRUE);
   1.106 +    xi->grant_tx_ref[id] = tx->gref;
   1.107      tx->offset = 0;
   1.108      tx->size = (UINT16)pkt_size;
   1.109      tx->flags = NETTXF_csum_blank;