diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-06 21:31:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-06 21:31:36 -0500 |
commit | 06d381484fe8fb1ba2996c22e89595a273e3634c (patch) | |
tree | 0d39c57cb8c501341ab8ed1d740f076b0b8c0bd0 /drivers/net/xen-netback | |
parent | 5d5a8d2d9d6cca979efe4fe1552d787fdc542603 (diff) | |
parent | c9d6369978411f690513994e6e53e2e6410874a4 (diff) |
Merge branch 'stable/vmalloc-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
* 'stable/vmalloc-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen:
net: xen-netback: use API provided by xenbus module to map rings
block: xen-blkback: use API provided by xenbus module to map rings
xen: use generic functions instead of xen_{alloc, free}_vm_area()
Diffstat (limited to 'drivers/net/xen-netback')
-rw-r--r-- | drivers/net/xen-netback/common.h | 11 | ||||
-rw-r--r-- | drivers/net/xen-netback/netback.c | 80 |
2 files changed, 22 insertions, 69 deletions
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h index 161f207786a4..94b79c3338c4 100644 --- a/drivers/net/xen-netback/common.h +++ b/drivers/net/xen-netback/common.h | |||
@@ -58,10 +58,6 @@ struct xenvif { | |||
58 | u8 fe_dev_addr[6]; | 58 | u8 fe_dev_addr[6]; |
59 | 59 | ||
60 | /* Physical parameters of the comms window. */ | 60 | /* Physical parameters of the comms window. */ |
61 | grant_handle_t tx_shmem_handle; | ||
62 | grant_ref_t tx_shmem_ref; | ||
63 | grant_handle_t rx_shmem_handle; | ||
64 | grant_ref_t rx_shmem_ref; | ||
65 | unsigned int irq; | 61 | unsigned int irq; |
66 | 62 | ||
67 | /* List of frontends to notify after a batch of frames sent. */ | 63 | /* List of frontends to notify after a batch of frames sent. */ |
@@ -70,8 +66,6 @@ struct xenvif { | |||
70 | /* The shared rings and indexes. */ | 66 | /* The shared rings and indexes. */ |
71 | struct xen_netif_tx_back_ring tx; | 67 | struct xen_netif_tx_back_ring tx; |
72 | struct xen_netif_rx_back_ring rx; | 68 | struct xen_netif_rx_back_ring rx; |
73 | struct vm_struct *tx_comms_area; | ||
74 | struct vm_struct *rx_comms_area; | ||
75 | 69 | ||
76 | /* Frontend feature information. */ | 70 | /* Frontend feature information. */ |
77 | u8 can_sg:1; | 71 | u8 can_sg:1; |
@@ -106,6 +100,11 @@ struct xenvif { | |||
106 | wait_queue_head_t waiting_to_free; | 100 | wait_queue_head_t waiting_to_free; |
107 | }; | 101 | }; |
108 | 102 | ||
103 | static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif) | ||
104 | { | ||
105 | return to_xenbus_device(vif->dev->dev.parent); | ||
106 | } | ||
107 | |||
109 | #define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) | 108 | #define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE) |
110 | #define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) | 109 | #define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE) |
111 | 110 | ||
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index d5508957200e..0cb594c86090 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
@@ -1589,88 +1589,42 @@ static int xen_netbk_kthread(void *data) | |||
1589 | 1589 | ||
1590 | void xen_netbk_unmap_frontend_rings(struct xenvif *vif) | 1590 | void xen_netbk_unmap_frontend_rings(struct xenvif *vif) |
1591 | { | 1591 | { |
1592 | struct gnttab_unmap_grant_ref op; | 1592 | if (vif->tx.sring) |
1593 | 1593 | xenbus_unmap_ring_vfree(xenvif_to_xenbus_device(vif), | |
1594 | if (vif->tx.sring) { | 1594 | vif->tx.sring); |
1595 | gnttab_set_unmap_op(&op, (unsigned long)vif->tx_comms_area->addr, | 1595 | if (vif->rx.sring) |
1596 | GNTMAP_host_map, vif->tx_shmem_handle); | 1596 | xenbus_unmap_ring_vfree(xenvif_to_xenbus_device(vif), |
1597 | 1597 | vif->rx.sring); | |
1598 | if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1)) | ||
1599 | BUG(); | ||
1600 | } | ||
1601 | |||
1602 | if (vif->rx.sring) { | ||
1603 | gnttab_set_unmap_op(&op, (unsigned long)vif->rx_comms_area->addr, | ||
1604 | GNTMAP_host_map, vif->rx_shmem_handle); | ||
1605 | |||
1606 | if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1)) | ||
1607 | BUG(); | ||
1608 | } | ||
1609 | if (vif->rx_comms_area) | ||
1610 | free_vm_area(vif->rx_comms_area); | ||
1611 | if (vif->tx_comms_area) | ||
1612 | free_vm_area(vif->tx_comms_area); | ||
1613 | } | 1598 | } |
1614 | 1599 | ||
1615 | int xen_netbk_map_frontend_rings(struct xenvif *vif, | 1600 | int xen_netbk_map_frontend_rings(struct xenvif *vif, |
1616 | grant_ref_t tx_ring_ref, | 1601 | grant_ref_t tx_ring_ref, |
1617 | grant_ref_t rx_ring_ref) | 1602 | grant_ref_t rx_ring_ref) |
1618 | { | 1603 | { |
1619 | struct gnttab_map_grant_ref op; | 1604 | void *addr; |
1620 | struct xen_netif_tx_sring *txs; | 1605 | struct xen_netif_tx_sring *txs; |
1621 | struct xen_netif_rx_sring *rxs; | 1606 | struct xen_netif_rx_sring *rxs; |
1622 | 1607 | ||
1623 | int err = -ENOMEM; | 1608 | int err = -ENOMEM; |
1624 | 1609 | ||
1625 | vif->tx_comms_area = alloc_vm_area(PAGE_SIZE); | 1610 | err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif), |
1626 | if (vif->tx_comms_area == NULL) | 1611 | tx_ring_ref, &addr); |
1612 | if (err) | ||
1627 | goto err; | 1613 | goto err; |
1628 | 1614 | ||
1629 | vif->rx_comms_area = alloc_vm_area(PAGE_SIZE); | 1615 | txs = (struct xen_netif_tx_sring *)addr; |
1630 | if (vif->rx_comms_area == NULL) | ||
1631 | goto err; | ||
1632 | |||
1633 | gnttab_set_map_op(&op, (unsigned long)vif->tx_comms_area->addr, | ||
1634 | GNTMAP_host_map, tx_ring_ref, vif->domid); | ||
1635 | |||
1636 | if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1)) | ||
1637 | BUG(); | ||
1638 | |||
1639 | if (op.status) { | ||
1640 | netdev_warn(vif->dev, | ||
1641 | "failed to map tx ring. err=%d status=%d\n", | ||
1642 | err, op.status); | ||
1643 | err = op.status; | ||
1644 | goto err; | ||
1645 | } | ||
1646 | |||
1647 | vif->tx_shmem_ref = tx_ring_ref; | ||
1648 | vif->tx_shmem_handle = op.handle; | ||
1649 | |||
1650 | txs = (struct xen_netif_tx_sring *)vif->tx_comms_area->addr; | ||
1651 | BACK_RING_INIT(&vif->tx, txs, PAGE_SIZE); | 1616 | BACK_RING_INIT(&vif->tx, txs, PAGE_SIZE); |
1652 | 1617 | ||
1653 | gnttab_set_map_op(&op, (unsigned long)vif->rx_comms_area->addr, | 1618 | err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif), |
1654 | GNTMAP_host_map, rx_ring_ref, vif->domid); | 1619 | rx_ring_ref, &addr); |
1655 | 1620 | if (err) | |
1656 | if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1)) | ||
1657 | BUG(); | ||
1658 | |||
1659 | if (op.status) { | ||
1660 | netdev_warn(vif->dev, | ||
1661 | "failed to map rx ring. err=%d status=%d\n", | ||
1662 | err, op.status); | ||
1663 | err = op.status; | ||
1664 | goto err; | 1621 | goto err; |
1665 | } | ||
1666 | |||
1667 | vif->rx_shmem_ref = rx_ring_ref; | ||
1668 | vif->rx_shmem_handle = op.handle; | ||
1669 | vif->rx_req_cons_peek = 0; | ||
1670 | 1622 | ||
1671 | rxs = (struct xen_netif_rx_sring *)vif->rx_comms_area->addr; | 1623 | rxs = (struct xen_netif_rx_sring *)addr; |
1672 | BACK_RING_INIT(&vif->rx, rxs, PAGE_SIZE); | 1624 | BACK_RING_INIT(&vif->rx, rxs, PAGE_SIZE); |
1673 | 1625 | ||
1626 | vif->rx_req_cons_peek = 0; | ||
1627 | |||
1674 | return 0; | 1628 | return 0; |
1675 | 1629 | ||
1676 | err: | 1630 | err: |