ia64/xen-unstable

changeset 8292:2cc09c21cdba

Allocate separate vm areas for rx and tx rings in netback
driver as part of preparation for ia64 support.

Signed-off-by: Dan Magenheimer <dan.magenheimer@hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Dec 08 16:58:41 2005 +0100 (2005-12-08)
parents 6f62ad959f6b
children cd434888abdc
files linux-2.6-xen-sparse/drivers/xen/netback/common.h linux-2.6-xen-sparse/drivers/xen/netback/interface.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Thu Dec 08 16:53:53 2005 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Thu Dec 08 16:58:41 2005 +0100
     1.3 @@ -55,7 +55,8 @@ typedef struct netif_st {
     1.4  	/* The shared rings and indexes. */
     1.5  	netif_tx_back_ring_t tx;
     1.6  	netif_rx_back_ring_t rx;
     1.7 -	struct vm_struct *comms_area;
     1.8 +	struct vm_struct *tx_comms_area;
     1.9 +	struct vm_struct *rx_comms_area;
    1.10  
    1.11  	/* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
    1.12  	RING_IDX rx_req_cons_peek;
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Dec 08 16:53:53 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Dec 08 16:58:41 2005 +0100
     2.3 @@ -117,14 +117,14 @@ static int map_frontend_pages(
     2.4  	struct gnttab_map_grant_ref op;
     2.5  	int ret;
     2.6  
     2.7 -	op.host_addr = (unsigned long)netif->comms_area->addr;
     2.8 +	op.host_addr = (unsigned long)netif->tx_comms_area->addr;
     2.9  	op.flags     = GNTMAP_host_map;
    2.10  	op.ref       = tx_ring_ref;
    2.11  	op.dom       = netif->domid;
    2.12      
    2.13 -	lock_vm_area(netif->comms_area);
    2.14 +	lock_vm_area(netif->tx_comms_area);
    2.15  	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    2.16 -	unlock_vm_area(netif->comms_area);
    2.17 +	unlock_vm_area(netif->tx_comms_area);
    2.18  	BUG_ON(ret);
    2.19  
    2.20  	if (op.status) { 
    2.21 @@ -135,14 +135,14 @@ static int map_frontend_pages(
    2.22  	netif->tx_shmem_ref    = tx_ring_ref;
    2.23  	netif->tx_shmem_handle = op.handle;
    2.24  
    2.25 -	op.host_addr = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
    2.26 +	op.host_addr = (unsigned long)netif->rx_comms_area->addr;
    2.27  	op.flags     = GNTMAP_host_map;
    2.28  	op.ref       = rx_ring_ref;
    2.29  	op.dom       = netif->domid;
    2.30  
    2.31 -	lock_vm_area(netif->comms_area);
    2.32 +	lock_vm_area(netif->rx_comms_area);
    2.33  	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
    2.34 -	unlock_vm_area(netif->comms_area);
    2.35 +	unlock_vm_area(netif->rx_comms_area);
    2.36  	BUG_ON(ret);
    2.37  
    2.38  	if (op.status) {
    2.39 @@ -161,22 +161,22 @@ static void unmap_frontend_pages(netif_t
    2.40  	struct gnttab_unmap_grant_ref op;
    2.41  	int ret;
    2.42  
    2.43 -	op.host_addr    = (unsigned long)netif->comms_area->addr;
    2.44 +	op.host_addr    = (unsigned long)netif->tx_comms_area->addr;
    2.45  	op.handle       = netif->tx_shmem_handle;
    2.46  	op.dev_bus_addr = 0;
    2.47  
    2.48 -	lock_vm_area(netif->comms_area);
    2.49 +	lock_vm_area(netif->tx_comms_area);
    2.50  	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    2.51 -	unlock_vm_area(netif->comms_area);
    2.52 +	unlock_vm_area(netif->tx_comms_area);
    2.53  	BUG_ON(ret);
    2.54  
    2.55 -	op.host_addr    = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
    2.56 +	op.host_addr    = (unsigned long)netif->rx_comms_area->addr;
    2.57  	op.handle       = netif->rx_shmem_handle;
    2.58  	op.dev_bus_addr = 0;
    2.59  
    2.60 -	lock_vm_area(netif->comms_area);
    2.61 +	lock_vm_area(netif->rx_comms_area);
    2.62  	ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
    2.63 -	unlock_vm_area(netif->comms_area);
    2.64 +	unlock_vm_area(netif->rx_comms_area);
    2.65  	BUG_ON(ret);
    2.66  }
    2.67  
    2.68 @@ -195,20 +195,23 @@ int netif_map(netif_t *netif, unsigned l
    2.69  	if (netif->irq)
    2.70  		return 0;
    2.71  
    2.72 -	netif->comms_area = alloc_vm_area(2*PAGE_SIZE);
    2.73 -	if (netif->comms_area == NULL)
    2.74 +	netif->tx_comms_area = alloc_vm_area(PAGE_SIZE);
    2.75 +	netif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
    2.76 +	if (netif->tx_comms_area == NULL || netif->rx_comms_area == NULL)
    2.77  		return -ENOMEM;
    2.78  
    2.79  	err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref);
    2.80  	if (err) {
    2.81 -		free_vm_area(netif->comms_area);
    2.82 +		free_vm_area(netif->tx_comms_area);
    2.83 +		free_vm_area(netif->rx_comms_area);
    2.84  		return err;
    2.85  	}
    2.86  
    2.87  	err = HYPERVISOR_event_channel_op(&op);
    2.88  	if (err) {
    2.89  		unmap_frontend_pages(netif);
    2.90 -		free_vm_area(netif->comms_area);
    2.91 +		free_vm_area(netif->tx_comms_area);
    2.92 +		free_vm_area(netif->rx_comms_area);
    2.93  		return err;
    2.94  	}
    2.95  
    2.96 @@ -218,11 +221,11 @@ int netif_map(netif_t *netif, unsigned l
    2.97  		netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
    2.98  	disable_irq(netif->irq);
    2.99  
   2.100 -	txs = (netif_tx_sring_t *)netif->comms_area->addr;
   2.101 +	txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
   2.102  	BACK_RING_INIT(&netif->tx, txs, PAGE_SIZE);
   2.103  
   2.104  	rxs = (netif_rx_sring_t *)
   2.105 -		((char *)netif->comms_area->addr + PAGE_SIZE);
   2.106 +		((char *)netif->rx_comms_area->addr);
   2.107  	BACK_RING_INIT(&netif->rx, rxs, PAGE_SIZE);
   2.108  
   2.109  	netif->rx_req_cons_peek = 0;
   2.110 @@ -255,7 +258,8 @@ static void free_netif_callback(void *ar
   2.111  
   2.112  	if (netif->tx.sring) {
   2.113  		unmap_frontend_pages(netif);
   2.114 -		free_vm_area(netif->comms_area);
   2.115 +		free_vm_area(netif->tx_comms_area);
   2.116 +		free_vm_area(netif->rx_comms_area);
   2.117  	}
   2.118  
   2.119  	free_netdev(netif->dev);