aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netback/netback.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/xen-netback/netback.c')
-rw-r--r--drivers/net/xen-netback/netback.c80
1 files changed, 17 insertions, 63 deletions
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
1590void xen_netbk_unmap_frontend_rings(struct xenvif *vif) 1590void 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
1615int xen_netbk_map_frontend_rings(struct xenvif *vif, 1600int 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
1676err: 1630err: