ia64/xen-unstable

changeset 6388:ccfc31779d36

Don't use the grant pre-allocation system for the ring grants.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Wed Aug 24 09:31:52 2005 +0000 (2005-08-24)
parents ac57c81692b2
children 342a53ce078b
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 24 08:55:14 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Wed Aug 24 09:31:52 2005 +0000
     1.3 @@ -200,6 +200,7 @@ static char *be_state_name[] = {
     1.4      [BEST_CONNECTED]    = "connected",
     1.5  };
     1.6  
     1.7 +#define DEBUG
     1.8  #ifdef DEBUG
     1.9  #define DPRINTK(fmt, args...) \
    1.10      printk(KERN_ALERT "xen_net (%s:%d) " fmt, __FUNCTION__, __LINE__, ##args)
    1.11 @@ -919,6 +920,7 @@ static void vif_show(struct net_private 
    1.12  /* Send a connect message to xend to tell it to bring up the interface. */
    1.13  static void send_interface_connect(struct net_private *np)
    1.14  {
    1.15 +    int err;
    1.16      ctrl_msg_t cmsg = {
    1.17          .type    = CMSG_NETIF_FE,
    1.18          .subtype = CMSG_NETIF_FE_INTERFACE_CONNECT,
    1.19 @@ -929,24 +931,22 @@ static void send_interface_connect(struc
    1.20      msg->handle = np->handle;
    1.21      msg->tx_shmem_frame = virt_to_mfn(np->tx);
    1.22  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
    1.23 -    msg->tx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_tx_head);
    1.24 -    if(msg->tx_shmem_ref < 0) { 
    1.25 -        printk(KERN_ALERT "#### netfront can't claim tx_shmem reference\n");
    1.26 +    err = gnttab_grant_foreign_access(rdomid, msg->tx_shmem_frame, 0);
    1.27 +    if (err < 0) {
    1.28 +        printk(KERN_ALERT "#### netfront can't grant access to tx_shmem\n");
    1.29          BUG();
    1.30      }
    1.31 -    gnttab_grant_foreign_access_ref (msg->tx_shmem_ref, rdomid, 
    1.32 -                                     msg->tx_shmem_frame, 0);
    1.33 +    msg->tx_shmem_ref = err;
    1.34  #endif
    1.35  
    1.36      msg->rx_shmem_frame = virt_to_mfn(np->rx);
    1.37  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
    1.38 -    msg->rx_shmem_ref   = (u32)gnttab_claim_grant_reference(&gref_rx_head);
    1.39 -    if(msg->rx_shmem_ref < 0) {
    1.40 -        printk(KERN_ALERT "#### netfront can't claim rx_shmem reference\n");
    1.41 +    err = gnttab_grant_foreign_access(rdomid, msg->rx_shmem_frame, 0);
    1.42 +    if (err < 0) {
    1.43 +        printk(KERN_ALERT "#### netfront can't grant access to rx_shmem\n");
    1.44          BUG();
    1.45      }
    1.46 -    gnttab_grant_foreign_access_ref (msg->rx_shmem_ref, rdomid, 
    1.47 -                                     msg->rx_shmem_frame, 0);
    1.48 +    msg->rx_shmem_ref = err;
    1.49  #endif
    1.50  
    1.51      ctrl_if_send_message_block(&cmsg, NULL, 0, TASK_UNINTERRUPTIBLE);
    1.52 @@ -1416,8 +1416,8 @@ static int __init netif_init(void)
    1.53      if (xen_start_info.flags & SIF_INITDOMAIN)
    1.54          return 0;
    1.55  #ifdef CONFIG_XEN_NETDEV_GRANT_TX
    1.56 -    /* A grant for every ring slot, plus one for the ring itself */
    1.57 -    if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE + 1,
    1.58 +    /* A grant for every ring slot */
    1.59 +    if (gnttab_alloc_grant_references(NETIF_TX_RING_SIZE,
    1.60                                        &gref_tx_head) < 0) {
    1.61          printk(KERN_ALERT "#### netfront can't alloc tx grant refs\n");
    1.62          return 1;
    1.63 @@ -1425,8 +1425,8 @@ static int __init netif_init(void)
    1.64      printk(KERN_ALERT "Netdev frontend (TX) is using grant tables.\n"); 
    1.65  #endif
    1.66  #ifdef CONFIG_XEN_NETDEV_GRANT_RX
    1.67 -    /* A grant for every ring slot, plus one for the ring itself */
    1.68 -    if (gnttab_alloc_grant_references(NETIF_RX_RING_SIZE + 1,
    1.69 +    /* A grant for every ring slot */
    1.70 +    if (gnttab_alloc_grant_references(NETIF_RX_RING_SIZE,
    1.71                                        &gref_rx_head) < 0) {
    1.72          printk(KERN_ALERT "#### netfront can't alloc rx grant refs\n");
    1.73          return 1;