Mailing List Archive

Allocate separate vm areas for rx and tx rings in netback
# HG changeset patch
# User kaf24@firebug.cl.cam.ac.uk
# Node ID 2cc09c21cdba90a7541031d200f590935b9fed58
# Parent 6f62ad959f6b6d7fd98b2adfb3f07a9a15613e07
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>

diff -r 6f62ad959f6b -r 2cc09c21cdba linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Thu Dec 8 15:53:53 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Thu Dec 8 15:58:41 2005
@@ -55,7 +55,8 @@
/* The shared rings and indexes. */
netif_tx_back_ring_t tx;
netif_rx_back_ring_t rx;
- struct vm_struct *comms_area;
+ struct vm_struct *tx_comms_area;
+ struct vm_struct *rx_comms_area;

/* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
RING_IDX rx_req_cons_peek;
diff -r 6f62ad959f6b -r 2cc09c21cdba linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Thu Dec 8 15:53:53 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Thu Dec 8 15:58:41 2005
@@ -117,14 +117,14 @@
struct gnttab_map_grant_ref op;
int ret;

- op.host_addr = (unsigned long)netif->comms_area->addr;
+ op.host_addr = (unsigned long)netif->tx_comms_area->addr;
op.flags = GNTMAP_host_map;
op.ref = tx_ring_ref;
op.dom = netif->domid;

- lock_vm_area(netif->comms_area);
+ lock_vm_area(netif->tx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
- unlock_vm_area(netif->comms_area);
+ unlock_vm_area(netif->tx_comms_area);
BUG_ON(ret);

if (op.status) {
@@ -135,14 +135,14 @@
netif->tx_shmem_ref = tx_ring_ref;
netif->tx_shmem_handle = op.handle;

- op.host_addr = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
+ op.host_addr = (unsigned long)netif->rx_comms_area->addr;
op.flags = GNTMAP_host_map;
op.ref = rx_ring_ref;
op.dom = netif->domid;

- lock_vm_area(netif->comms_area);
+ lock_vm_area(netif->rx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1);
- unlock_vm_area(netif->comms_area);
+ unlock_vm_area(netif->rx_comms_area);
BUG_ON(ret);

if (op.status) {
@@ -161,22 +161,22 @@
struct gnttab_unmap_grant_ref op;
int ret;

- op.host_addr = (unsigned long)netif->comms_area->addr;
+ op.host_addr = (unsigned long)netif->tx_comms_area->addr;
op.handle = netif->tx_shmem_handle;
op.dev_bus_addr = 0;

- lock_vm_area(netif->comms_area);
+ lock_vm_area(netif->tx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
- unlock_vm_area(netif->comms_area);
+ unlock_vm_area(netif->tx_comms_area);
BUG_ON(ret);

- op.host_addr = (unsigned long)netif->comms_area->addr + PAGE_SIZE;
+ op.host_addr = (unsigned long)netif->rx_comms_area->addr;
op.handle = netif->rx_shmem_handle;
op.dev_bus_addr = 0;

- lock_vm_area(netif->comms_area);
+ lock_vm_area(netif->rx_comms_area);
ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1);
- unlock_vm_area(netif->comms_area);
+ unlock_vm_area(netif->rx_comms_area);
BUG_ON(ret);
}

@@ -195,20 +195,23 @@
if (netif->irq)
return 0;

- netif->comms_area = alloc_vm_area(2*PAGE_SIZE);
- if (netif->comms_area == NULL)
+ netif->tx_comms_area = alloc_vm_area(PAGE_SIZE);
+ netif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
+ if (netif->tx_comms_area == NULL || netif->rx_comms_area == NULL)
return -ENOMEM;

err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref);
if (err) {
- free_vm_area(netif->comms_area);
+ free_vm_area(netif->tx_comms_area);
+ free_vm_area(netif->rx_comms_area);
return err;
}

err = HYPERVISOR_event_channel_op(&op);
if (err) {
unmap_frontend_pages(netif);
- free_vm_area(netif->comms_area);
+ free_vm_area(netif->tx_comms_area);
+ free_vm_area(netif->rx_comms_area);
return err;
}

@@ -218,11 +221,11 @@
netif->evtchn, netif_be_int, 0, netif->dev->name, netif);
disable_irq(netif->irq);

- txs = (netif_tx_sring_t *)netif->comms_area->addr;
+ txs = (netif_tx_sring_t *)netif->tx_comms_area->addr;
BACK_RING_INIT(&netif->tx, txs, PAGE_SIZE);

rxs = (netif_rx_sring_t *)
- ((char *)netif->comms_area->addr + PAGE_SIZE);
+ ((char *)netif->rx_comms_area->addr);
BACK_RING_INIT(&netif->rx, rxs, PAGE_SIZE);

netif->rx_req_cons_peek = 0;
@@ -255,7 +258,8 @@

if (netif->tx.sring) {
unmap_frontend_pages(netif);
- free_vm_area(netif->comms_area);
+ free_vm_area(netif->tx_comms_area);
+ free_vm_area(netif->rx_comms_area);
}

free_netdev(netif->dev);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog