direct-io.hg

changeset 6157:22ce5159334e

merge
author iap10@freefall.cl.cam.ac.uk
date Sun Aug 14 21:48:37 2005 +0000 (2005-08-14)
parents 972917cee2fd d47c61f72572
children 3076b3cc3048
files linux-2.6-xen-sparse/drivers/xen/netback/common.h linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c linux-2.6-xen-sparse/include/asm-xen/asm-i386/page.h tools/examples/Makefile tools/python/xen/lowlevel/xu/xu.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/XendRoot.py tools/python/xen/xend/server/netif.py xen/common/grant_table.c xen/include/public/io/domain_controller.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Sun Aug 14 21:45:26 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Sun Aug 14 21:48:37 2005 +0000
     1.3 @@ -20,6 +20,13 @@
     1.4  #include <asm/io.h>
     1.5  #include <asm/pgalloc.h>
     1.6  
     1.7 +#if defined(CONFIG_XEN_NETDEV_GRANT_TX) || defined(CONFIG_XEN_NETDEV_GRANT_RX)
     1.8 +#include <asm-xen/xen-public/grant_table.h>
     1.9 +#include <asm-xen/gnttab.h>
    1.10 +#endif
    1.11 +
    1.12 +
    1.13 +
    1.14  #if 0
    1.15  #define ASSERT(_p) \
    1.16      if ( !(_p) ) { printk("Assertion '%s' failed, line %d, file %s", #_p , \
    1.17 @@ -40,7 +47,17 @@ typedef struct netif_st {
    1.18  
    1.19      /* Physical parameters of the comms window. */
    1.20      unsigned long    tx_shmem_frame;
    1.21 +#ifdef CONFIG_XEN_NETDEV_GRANT_TX
    1.22 +    u16              tx_shmem_handle;
    1.23 +    memory_t         tx_shmem_vaddr; 
    1.24 +    grant_ref_t      tx_shmem_ref; 
    1.25 +#endif
    1.26      unsigned long    rx_shmem_frame;
    1.27 +#ifdef CONFIG_XEN_NETDEV_GRANT_RX
    1.28 +    u16              rx_shmem_handle;
    1.29 +    memory_t         rx_shmem_vaddr; 
    1.30 +    grant_ref_t      rx_shmem_ref; 
    1.31 +#endif
    1.32      unsigned int     evtchn;
    1.33  
    1.34      /* The shared rings and indexes. */
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Sun Aug 14 21:45:26 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Sun Aug 14 21:48:37 2005 +0000
     2.3 @@ -71,12 +71,31 @@ static void __netif_disconnect_complete(
     2.4      netif_t              *netif = (netif_t *)arg;
     2.5      ctrl_msg_t            cmsg;
     2.6      netif_be_disconnect_t disc;
     2.7 +#if defined(CONFIG_XEN_NETDEV_GRANT_RX) || defined(CONFIG_XEN_NETDEV_GRANT_TX)
     2.8 +    struct gnttab_unmap_grant_ref op;
     2.9 +#endif
    2.10  
    2.11      /*
    2.12       * These can't be done in netif_disconnect() because at that point there
    2.13       * may be outstanding requests in the network stack whose asynchronous
    2.14       * responses must still be notified to the remote driver.
    2.15       */
    2.16 +
    2.17 +#ifdef CONFIG_XEN_NETDEV_GRANT_TX
    2.18 +    op.host_addr    = netif->tx_shmem_vaddr;
    2.19 +    op.handle       = netif->tx_shmem_handle;
    2.20 +    op.dev_bus_addr = 0;
    2.21 +    BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    2.22 +#endif
    2.23 +
    2.24 +#ifdef CONFIG_XEN_NETDEV_GRANT_RX
    2.25 +    op.host_addr    = netif->rx_shmem_vaddr;
    2.26 +    op.handle       = netif->rx_shmem_handle;
    2.27 +    op.dev_bus_addr = 0;
    2.28 +    BUG_ON(HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1));
    2.29 +#endif
    2.30 +
    2.31 +
    2.32      vfree(netif->tx); /* Frees netif->rx as well. */
    2.33  
    2.34      /* Construct the deferred response message. */
    2.35 @@ -275,37 +294,107 @@ void netif_connect(netif_be_connect_t *c
    2.36      unsigned long tx_shmem_frame = connect->tx_shmem_frame;
    2.37      unsigned long rx_shmem_frame = connect->rx_shmem_frame;
    2.38      struct vm_struct *vma;
    2.39 -    pgprot_t      prot;
    2.40 +#if !defined(CONFIG_XEN_NETDEV_GRANT_TX)||!defined(CONFIG_XEN_NETDEV_GRANT_RX)
    2.41 +    pgprot_t      prot = __pgprot(_KERNPG_TABLE);
    2.42      int           error;
    2.43 +#endif
    2.44      netif_t      *netif;
    2.45  
    2.46      netif = netif_find_by_handle(domid, handle);
    2.47 -    if ( unlikely(netif == NULL) )
    2.48 -    {
    2.49 +    if ( unlikely(netif == NULL) ) {
    2.50          DPRINTK("netif_connect attempted for non-existent netif (%u,%u)\n", 
    2.51                  connect->domid, connect->netif_handle); 
    2.52          connect->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
    2.53          return;
    2.54      }
    2.55  
    2.56 -    if ( netif->status != DISCONNECTED )
    2.57 -    {
    2.58 +    if ( netif->status != DISCONNECTED ) {
    2.59          connect->status = NETIF_BE_STATUS_INTERFACE_CONNECTED;
    2.60          return;
    2.61      }
    2.62  
    2.63 -    if ( (vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP)) == NULL )
    2.64 -    {
    2.65 +    if ( (vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP)) == NULL ) {
    2.66          connect->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
    2.67          return;
    2.68      }
    2.69  
    2.70 -    prot = __pgprot(_KERNPG_TABLE);
    2.71 -    error  = direct_remap_area_pages(&init_mm, 
    2.72 -                                     VMALLOC_VMADDR(vma->addr),
    2.73 -                                     tx_shmem_frame<<PAGE_SHIFT, PAGE_SIZE,
    2.74 -                                     prot, domid);
    2.75 -    error |= direct_remap_area_pages(&init_mm, 
    2.76 +
    2.77 +#if defined(CONFIG_XEN_NETDEV_GRANT_TX)
    2.78 +    {
    2.79 +        struct gnttab_map_grant_ref op;
    2.80 +        int tx_ref = connect->tx_shmem_ref; 
    2.81 +
    2.82 +        /* Map: Use the Grant table reference */
    2.83 +        op.host_addr = VMALLOC_VMADDR(vma->addr);
    2.84 +        op.flags     = GNTMAP_host_map;
    2.85 +        op.ref       = tx_ref;
    2.86 +        op.dom       = domid;
    2.87 +       
    2.88 +        if ((HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1) < 0) || 
    2.89 +            (op.handle < 0)) { 
    2.90 +            DPRINTK(" Grant table operation failure !\n");
    2.91 +            connect->status = NETIF_BE_STATUS_MAPPING_ERROR;
    2.92 +            vfree(vma->addr);
    2.93 +            return;
    2.94 +        }
    2.95 +
    2.96 +        netif->tx_shmem_ref    = tx_ref;
    2.97 +        netif->tx_shmem_handle = op.handle;
    2.98 +        netif->tx_shmem_vaddr  = VMALLOC_VMADDR(vma->addr);
    2.99 +    }
   2.100 +        
   2.101 +
   2.102 +#else 
   2.103 +    error = direct_remap_area_pages(&init_mm, 
   2.104 +                                    VMALLOC_VMADDR(vma->addr),
   2.105 +                                    tx_shmem_frame<<PAGE_SHIFT, PAGE_SIZE,
   2.106 +                                    prot, domid); 
   2.107 +    if ( error != 0 )
   2.108 +    {
   2.109 +        if ( error == -ENOMEM )
   2.110 +            connect->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
   2.111 +        else if ( error == -EFAULT )
   2.112 +            connect->status = NETIF_BE_STATUS_MAPPING_ERROR;
   2.113 +        else
   2.114 +            connect->status = NETIF_BE_STATUS_ERROR;
   2.115 +        vfree(vma->addr);
   2.116 +        return;
   2.117 +    }
   2.118 +#endif
   2.119 +
   2.120 +
   2.121 +#if defined(CONFIG_XEN_NETDEV_GRANT_RX)
   2.122 +    {
   2.123 +        struct gnttab_map_grant_ref op;
   2.124 +        int rx_ref = connect->rx_shmem_ref; 
   2.125 +
   2.126 +
   2.127 +        /* Map: Use the Grant table reference */
   2.128 +        op.host_addr = VMALLOC_VMADDR(vma->addr) + PAGE_SIZE;
   2.129 +        op.flags     = GNTMAP_host_map;
   2.130 +        op.ref       = rx_ref;
   2.131 +        op.dom       = domid;
   2.132 +
   2.133 +        if ((HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1) < 0) || 
   2.134 +            (op.handle < 0)) { 
   2.135 +            DPRINTK(" Grant table operation failure !\n");
   2.136 +            connect->status = NETIF_BE_STATUS_MAPPING_ERROR;
   2.137 +            vfree(vma->addr);
   2.138 +            return;
   2.139 +        }
   2.140 +
   2.141 +            DPRINTK(" Grant table operation failure !\n");
   2.142 +            connect->status = NETIF_BE_STATUS_MAPPING_ERROR;
   2.143 +            vfree(vma->addr);
   2.144 +            return;
   2.145 +        }
   2.146 +
   2.147 +        netif->rx_shmem_ref    = rx_ref;
   2.148 +        netif->rx_shmem_handle = handle;
   2.149 +        netif->rx_shmem_vaddr  = VMALLOC_VMADDR(vma->addr) + PAGE_SIZE;
   2.150 +    }
   2.151 +#else 
   2.152 +    error = direct_remap_area_pages(&init_mm, 
   2.153                                       VMALLOC_VMADDR(vma->addr) + PAGE_SIZE,
   2.154                                       rx_shmem_frame<<PAGE_SHIFT, PAGE_SIZE,
   2.155                                       prot, domid);
   2.156 @@ -321,6 +410,8 @@ void netif_connect(netif_be_connect_t *c
   2.157          return;
   2.158      }
   2.159  
   2.160 +#endif
   2.161 +
   2.162      netif->evtchn         = evtchn;
   2.163      netif->tx_shmem_frame = tx_shmem_frame;
   2.164      netif->rx_shmem_frame = rx_shmem_frame;
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Sun Aug 14 21:45:26 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Sun Aug 14 21:48:37 2005 +0000
     3.3 @@ -518,7 +518,7 @@ inline static void net_tx_action_dealloc
     3.4          gop++;
     3.5      }
     3.6      BUG_ON(HYPERVISOR_grant_table_op(
     3.7 -        GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
     3.8 +               GNTTABOP_unmap_grant_ref, tx_unmap_ops, gop - tx_unmap_ops));
     3.9  #else
    3.10      mcl = tx_mcl;
    3.11      while ( dc != dp )
    3.12 @@ -697,9 +697,9 @@ static void net_tx_action(unsigned long 
    3.13          skb_reserve(skb, 16);
    3.14  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
    3.15          mop->host_addr = MMAP_VADDR(pending_idx);
    3.16 -        mop->dom = netif->domid;
    3.17 -        mop->ref = txreq.addr >> PAGE_SHIFT;
    3.18 -        mop->flags = GNTMAP_host_map | GNTMAP_readonly;
    3.19 +        mop->dom       = netif->domid;
    3.20 +        mop->ref       = txreq.addr >> PAGE_SHIFT;
    3.21 +        mop->flags     = GNTMAP_host_map | GNTMAP_readonly;
    3.22          mop++;
    3.23  #else
    3.24  	MULTI_update_va_mapping_otherdomain(
    3.25 @@ -752,7 +752,12 @@ static void net_tx_action(unsigned long 
    3.26  
    3.27          /* Check the remap error code. */
    3.28  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
    3.29 -        if ( unlikely(mop->dev_bus_addr == 0) )
    3.30 +        /* 
    3.31 +           XXX SMH: error returns from grant operations are pretty poorly
    3.32 +           specified/thought out, but the below at least conforms with 
    3.33 +           what the rest of the code uses. 
    3.34 +        */
    3.35 +        if ( unlikely(mop->handle < 0) )
    3.36          {
    3.37              printk(KERN_ALERT "#### netback grant fails\n");
    3.38              make_tx_response(netif, txreq.id, NETIF_RSP_ERROR);
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Sun Aug 14 21:45:26 2005 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Sun Aug 14 21:48:37 2005 +0000
     4.3 @@ -59,7 +59,7 @@
     4.4  #include <asm-xen/gnttab.h>
     4.5  #ifdef GRANT_DEBUG
     4.6  static void
     4.7 -dump_packet(int tag, u32 addr, u32 ap)
     4.8 +dump_packet(int tag, void *addr, u32 ap)
     4.9  {
    4.10      unsigned char *p = (unsigned char *)ap;
    4.11      int i;
    4.12 @@ -200,7 +200,7 @@ static char *be_state_name[] = {
    4.13      [BEST_CONNECTED]    = "connected",
    4.14  };
    4.15  
    4.16 -#if DEBUG
    4.17 +#ifdef DEBUG
    4.18  #define DPRINTK(fmt, args...) \
    4.19      printk(KERN_ALERT "xen_net (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args)
    4.20  #else
    4.21 @@ -356,8 +356,12 @@ static void network_tx_buf_gc(struct net
    4.22              id  = np->tx->ring[MASK_NETIF_TX_IDX(i)].resp.id;
    4.23              skb = np->tx_skbs[id];
    4.24  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
    4.25 -            if (gnttab_query_foreign_access(grant_tx_ref[id]) != 0) {
    4.26 -                printk(KERN_ALERT "netfront: query foreign access\n");
    4.27 +            if (unlikey(gnttab_query_foreign_access(grant_tx_ref[id]) != 0)) {
    4.28 +                /* other domain is still using this grant - shouldn't happen
    4.29 +                   but if it does, we'll try to reclaim the grant later */
    4.30 +                printk(KERN_ALERT "network_tx_buf_gc: warning -- grant "
    4.31 +                       "still in use by backend domain.\n");
    4.32 +                goto out; 
    4.33              }
    4.34              gnttab_end_foreign_access(grant_tx_ref[id], GNTMAP_readonly);
    4.35              gnttab_release_grant_reference(&gref_tx_head, grant_tx_ref[id]);
    4.36 @@ -382,6 +386,7 @@ static void network_tx_buf_gc(struct net
    4.37          mb();
    4.38      } while (prod != np->tx->resp_prod);
    4.39  
    4.40 +  out: 
    4.41      if (np->tx_full && ((np->tx->req_prod - prod) < NETIF_TX_RING_SIZE)) {
    4.42          np->tx_full = 0;
    4.43          if (np->user_state == UST_OPEN)
    4.44 @@ -433,13 +438,15 @@ static void network_alloc_rx_buffers(str
    4.45          
    4.46          np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.id = id;
    4.47  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
    4.48 -        if ((ref = gnttab_claim_grant_reference(&gref_rx_head, gref_rx_terminal)) < 0) {
    4.49 +        if (unlikely((ref = gnttab_claim_grant_reference(&gref_rx_head, 
    4.50 +                                                gref_rx_terminal)) < 0)) {
    4.51              printk(KERN_ALERT "#### netfront can't claim rx reference\n");
    4.52              BUG();
    4.53          }
    4.54          grant_rx_ref[id] = ref;
    4.55          gnttab_grant_foreign_transfer_ref(ref, rdomid,
    4.56 -        virt_to_machine(skb->head) >> PAGE_SHIFT);
    4.57 +                                          virt_to_machine(
    4.58 +                                              skb->head) >> PAGE_SHIFT);
    4.59          np->rx->ring[MASK_NETIF_RX_IDX(req_prod + i)].req.gref = ref;
    4.60  #endif
    4.61          rx_pfn_array[i] = virt_to_machine(skb->head) >> PAGE_SHIFT;
    4.62 @@ -528,7 +535,8 @@ static int network_start_xmit(struct sk_
    4.63  
    4.64      tx->id   = id;
    4.65  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
    4.66 -    if ((ref = gnttab_claim_grant_reference(&gref_tx_head, gref_tx_terminal)) < 0) {
    4.67 +    if (unlikely((ref = gnttab_claim_grant_reference(&gref_tx_head, 
    4.68 +                                                     gref_tx_terminal)) < 0)) {
    4.69          printk(KERN_ALERT "#### netfront can't claim tx grant reference\n");
    4.70          BUG();
    4.71      }
    4.72 @@ -638,7 +646,6 @@ static int netif_poll(struct net_device 
    4.73  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
    4.74          ref = grant_rx_ref[rx->id];
    4.75          grant_rx_ref[rx->id] = GRANT_INVALID_REF;
    4.76 -
    4.77          mfn = gnttab_end_foreign_transfer(ref);
    4.78          gnttab_release_grant_reference(&gref_rx_head, ref);
    4.79  #endif
    4.80 @@ -674,18 +681,20 @@ static int netif_poll(struct net_device 
    4.81  				pfn_pte_ma(mfn, PAGE_KERNEL), 0);
    4.82  #else
    4.83  	MULTI_update_va_mapping(mcl, (unsigned long)skb->head,
    4.84 -				pfn_pte_ma(rx->addr >> PAGE_SHIFT, PAGE_KERNEL), 0);
    4.85 +				pfn_pte_ma(rx->addr >> PAGE_SHIFT, 
    4.86 +                                           PAGE_KERNEL), 0);
    4.87  #endif
    4.88          mcl++;
    4.89  
    4.90 +#ifdef CONFIG_XEN_NETDEV_GRANT_RX
    4.91 +        phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = mfn;
    4.92 +#else
    4.93          phys_to_machine_mapping[__pa(skb->head) >> PAGE_SHIFT] = 
    4.94 -#ifdef CONFIG_XEN_NETDEV_GRANT_RX
    4.95 -            mfn;
    4.96 -#else
    4.97              rx->addr >> PAGE_SHIFT;
    4.98  #endif
    4.99 +
   4.100  #ifdef GRANT_DEBUG
   4.101 -        printk(KERN_ALERT "#### rx_poll     enqueue vdata=%08x mfn=%08x ref=%04x\n",
   4.102 +        printk(KERN_ALERT "#### rx_poll     enqueue vdata=%p mfn=%lu ref=%x\n",
   4.103                 skb->data, mfn, ref);
   4.104  #endif
   4.105          __skb_queue_tail(&rxq, skb);
   4.106 @@ -707,9 +716,9 @@ static int netif_poll(struct net_device 
   4.107  
   4.108      while ((skb = __skb_dequeue(&rxq)) != NULL) {
   4.109  #ifdef GRANT_DEBUG
   4.110 -         printk(KERN_ALERT "#### rx_poll     dequeue vdata=%08x mfn=%08x\n",
   4.111 -                skb->data, virt_to_machine(skb->data)>>PAGE_SHIFT);
   4.112 -         dump_packet('d', skb->data, (unsigned long)skb->data);
   4.113 +        printk(KERN_ALERT "#### rx_poll     dequeue vdata=%p mfn=%lu\n",
   4.114 +               skb->data, virt_to_machine(skb->data)>>PAGE_SHIFT);
   4.115 +        dump_packet('d', skb->data, (unsigned long)skb->data);
   4.116  #endif
   4.117          /*
   4.118           * Enough room in skbuff for the data we were passed? Also, Linux 
   4.119 @@ -884,7 +893,7 @@ static void network_connect(struct net_d
   4.120  
   4.121  static void vif_show(struct net_private *np)
   4.122  {
   4.123 -#if DEBUG
   4.124 +#ifdef DEBUG
   4.125      if (np) {
   4.126          IPRINTK("<vif handle=%u %s(%s) evtchn=%u tx=%p rx=%p>\n",
   4.127                 np->handle,
   4.128 @@ -911,8 +920,29 @@ static void send_interface_connect(struc
   4.129  
   4.130      msg->handle = np->handle;
   4.131      msg->tx_shmem_frame = (virt_to_machine(np->tx) >> PAGE_SHIFT);
   4.132 +#ifdef CONFIG_XEN_NETDEV_GRANT_TX
   4.133 +    msg->tx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_tx_head, 
   4.134 +                                                            gref_tx_terminal);
   4.135 +    if(msg->tx_shmem_ref < 0) { 
   4.136 +        printk(KERN_ALERT "#### netfront can't claim tx_shmem reference\n");
   4.137 +        BUG();
   4.138 +    }
   4.139 +    gnttab_grant_foreign_access_ref (msg->tx_shmem_ref, rdomid, 
   4.140 +                                     msg->tx_shmem_frame, 0);
   4.141 +#endif
   4.142 +
   4.143      msg->rx_shmem_frame = (virt_to_machine(np->rx) >> PAGE_SHIFT);
   4.144 -        
   4.145 +#ifdef CONFIG_XEN_NETDEV_GRANT_RX
   4.146 +    msg->rx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_rx_head, 
   4.147 +                                                            gref_rx_terminal);
   4.148 +    if(msg->rx_shmem_ref < 0) {
   4.149 +        printk(KERN_ALERT "#### netfront can't claim rx_shmem reference\n");
   4.150 +        BUG();
   4.151 +    }
   4.152 +    gnttab_grant_foreign_access_ref (msg->rx_shmem_ref, rdomid, 
   4.153 +                                     msg->rx_shmem_frame, 0);
   4.154 +#endif
   4.155 +
   4.156      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
   4.157  }
   4.158  
   4.159 @@ -1380,20 +1410,22 @@ static int __init netif_init(void)
   4.160      if (xen_start_info.flags & SIF_INITDOMAIN)
   4.161          return 0;
   4.162  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
   4.163 -    if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE,
   4.164 +    /* A grant for every ring slot, plus one for the ring itself */
   4.165 +    if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE + 1,
   4.166                                        &gref_tx_head, &gref_tx_terminal) < 0) {
   4.167          printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
   4.168          return 1;
   4.169      }
   4.170 -    printk(KERN_ALERT "#### netfront tx using grant tables\n");
   4.171 +    printk(KERN_ALERT "Netdev frontend (TX) is using grant tables.\n"); 
   4.172  #endif
   4.173  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
   4.174 -    if (gnttab_alloc_grant_references(NETIF_RX_RING_SIZE,
   4.175 +    /* A grant for every ring slot, plus one for the ring itself */
   4.176 +    if (gnttab_alloc_grant_references(NETIF_RX_RING_SIZE + 1,
   4.177                                        &gref_rx_head, &gref_rx_terminal) < 0) {
   4.178          printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
   4.179          return 1;
   4.180      }
   4.181 -    printk(KERN_ALERT "#### netfront rx using grant tables\n");
   4.182 +    printk(KERN_ALERT "Netdev frontend (RX) is using grant tables.\n"); 
   4.183  #endif
   4.184  
   4.185      if ((err = xennet_proc_init()) != 0)
     7.1 --- a/tools/python/xen/lowlevel/xu/xu.c	Sun Aug 14 21:45:26 2005 +0000
     7.2 +++ b/tools/python/xen/lowlevel/xu/xu.c	Sun Aug 14 21:48:37 2005 +0000
     7.3 @@ -655,7 +655,9 @@ static PyObject *xu_message_get_payload(
     7.4      case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_CONNECT):
     7.5          C2P(netif_fe_interface_connect_t, handle,         Int, Long);
     7.6          C2P(netif_fe_interface_connect_t, tx_shmem_frame, Int, Long);
     7.7 +        C2P(netif_fe_interface_connect_t, tx_shmem_ref,   Int, Long);
     7.8          C2P(netif_fe_interface_connect_t, rx_shmem_frame, Int, Long);
     7.9 +        C2P(netif_fe_interface_connect_t, rx_shmem_ref,   Int, Long);
    7.10          return dict;
    7.11      case TYPE(CMSG_NETIF_FE, CMSG_NETIF_FE_INTERFACE_DISCONNECT):
    7.12          C2P(netif_fe_interface_disconnect_t, handle, Int, Long);
    7.13 @@ -681,7 +683,9 @@ static PyObject *xu_message_get_payload(
    7.14          C2P(netif_be_connect_t, domid,          Int, Long);
    7.15          C2P(netif_be_connect_t, netif_handle,   Int, Long);
    7.16          C2P(netif_be_connect_t, tx_shmem_frame, Int, Long);
    7.17 +        C2P(netif_be_connect_t, tx_shmem_ref,   Int, Long);
    7.18          C2P(netif_be_connect_t, rx_shmem_frame, Int, Long);
    7.19 +        C2P(netif_be_connect_t, rx_shmem_ref,   Int, Long);
    7.20          C2P(netif_be_connect_t, evtchn,         Int, Long);
    7.21          C2P(netif_be_connect_t, status,         Int, Long);
    7.22          return dict;
    7.23 @@ -903,8 +907,10 @@ static PyObject *xu_message_new(PyObject
    7.24          P2C(netif_be_connect_t, domid,          u32);
    7.25          P2C(netif_be_connect_t, netif_handle,   u32);
    7.26          P2C(netif_be_connect_t, tx_shmem_frame, memory_t);
    7.27 +        P2C(netif_be_connect_t, tx_shmem_ref,   u32); 
    7.28          P2C(netif_be_connect_t, rx_shmem_frame, memory_t);
    7.29 -        P2C(netif_be_connect_t, evtchn,         u16);
    7.30 +        P2C(netif_be_connect_t, rx_shmem_ref,   u32); 
    7.31 +        P2C(netif_be_connect_t, evtchn,         u16); 
    7.32          break;
    7.33      case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DISCONNECT):
    7.34          P2C(netif_be_disconnect_t, domid,        u32);
     8.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Sun Aug 14 21:45:26 2005 +0000
     8.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Sun Aug 14 21:48:37 2005 +0000
     8.3 @@ -593,7 +593,7 @@ class XendDomainInfo:
     8.4      def delete(self):
     8.5          """Delete the vm's db.
     8.6          """
     8.7 -        if self.dom_get(self.id):
     8.8 +        if dom_get(self.id):
     8.9              return
    8.10          self.id = None
    8.11          self.saveToDB(sync=True)
    10.1 --- a/tools/python/xen/xend/server/netif.py	Sun Aug 14 21:45:26 2005 +0000
    10.2 +++ b/tools/python/xen/xend/server/netif.py	Sun Aug 14 21:48:37 2005 +0000
    10.3 @@ -421,7 +421,9 @@ class NetDev(Dev):
    10.4                          'netif_handle'   : self.vif,
    10.5                          'evtchn'         : self.getEventChannelBackend(),
    10.6                          'tx_shmem_frame' : val['tx_shmem_frame'],
    10.7 -                        'rx_shmem_frame' : val['rx_shmem_frame'] })
    10.8 +                        'tx_shmem_ref'   : val['tx_shmem_ref'],
    10.9 +                        'rx_shmem_frame' : val['rx_shmem_frame'],
   10.10 +                        'rx_shmem_ref'   : val['rx_shmem_ref'] })
   10.11          msg = self.backendChannel.requestResponse(msg)
   10.12          #todo: check return status
   10.13          self.status = NETIF_INTERFACE_STATUS_CONNECTED
    11.1 --- a/xen/common/grant_table.c	Sun Aug 14 21:45:26 2005 +0000
    11.2 +++ b/xen/common/grant_table.c	Sun Aug 14 21:48:37 2005 +0000
    11.3 @@ -771,9 +771,8 @@ gnttab_dump_table(gnttab_dump_table_t *u
    11.4          if ( sha_copy.flags )
    11.5          {
    11.6              DPRINTK("Grant: dom (%hu) SHARED (%d) flags:(%hx) "
    11.7 -                    "dom:(%hu) frame:(%lx)\n",
    11.8 -                    op.dom, i, sha_copy.flags, sha_copy.domid, 
    11.9 -                    (unsigned long) sha_copy.frame);
   11.10 +                    "dom:(%hu) frame:(%x)\n",
   11.11 +                    op.dom, i, sha_copy.flags, sha_copy.domid, sha_copy.frame);
   11.12          }
   11.13      }
   11.14  
   11.15 @@ -826,8 +825,8 @@ gnttab_donate(gnttab_donate_t *uop, unsi
   11.16      for (i = 0; i < count; i++) {
   11.17          gnttab_donate_t *gop = &uop[i];
   11.18  #if GRANT_DEBUG
   11.19 -        printk("gnttab_donate: i=%d mfn=%08x domid=%d gref=%08x\n",
   11.20 -               i, (unsigned int)gop->mfn, gop->domid, gop->handle);
   11.21 +        printk("gnttab_donate: i=%d mfn=%lx domid=%d gref=%08x\n",
   11.22 +               i, gop->mfn, gop->domid, gop->handle);
   11.23  #endif
   11.24          page = &frame_table[gop->mfn];
   11.25  
   11.26 @@ -1033,8 +1032,8 @@ gnttab_check_unmap(
   11.27  #if GRANT_DEBUG_VERBOSE
   11.28      if ( ld->domain_id != 0 )
   11.29      {
   11.30 -        DPRINTK("Foreign unref rd(%d) ld(%d) frm(%x) flgs(%x).\n",
   11.31 -                rd->domain_id, ld->domain_id, (unsigned int)frame, readonly);
   11.32 +        DPRINTK("Foreign unref rd(%d) ld(%d) frm(%lx) flgs(%x).\n",
   11.33 +                rd->domain_id, ld->domain_id, frame, readonly);
   11.34      }
   11.35  #endif
   11.36  
    12.1 --- a/xen/include/public/io/domain_controller.h	Sun Aug 14 21:45:26 2005 +0000
    12.2 +++ b/xen/include/public/io/domain_controller.h	Sun Aug 14 21:48:37 2005 +0000
    12.3 @@ -365,8 +365,10 @@ typedef struct netif_fe_driver_status {
    12.4   */
    12.5  typedef struct netif_fe_interface_connect {
    12.6      u32        handle;
    12.7 -    memory_t   tx_shmem_frame;
    12.8 +    memory_t   tx_shmem_frame; 
    12.9 +    int        tx_shmem_ref;
   12.10      memory_t   rx_shmem_frame;
   12.11 +    int        rx_shmem_ref;
   12.12  } netif_fe_interface_connect_t;
   12.13  
   12.14  /*
   12.15 @@ -487,7 +489,9 @@ typedef struct netif_be_connect {
   12.16      domid_t    domid;          /* Domain attached to new interface.   */
   12.17      u32        netif_handle;   /* Domain-specific interface handle.   */
   12.18      memory_t   tx_shmem_frame; /* Page cont. tx shared comms window.  */
   12.19 +    int        tx_shmem_ref;   /* Grant reference for above           */
   12.20      memory_t   rx_shmem_frame; /* Page cont. rx shared comms window.  */
   12.21 +    int        rx_shmem_ref;   /* Grant reference for above           */
   12.22      u16        evtchn;         /* Event channel for notifications.    */
   12.23      /* OUT */
   12.24      u32        status;