aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/xen-netback
diff options
context:
space:
mode:
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>2012-09-14 10:26:59 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2012-09-21 09:23:51 -0400
commitc571898ffc24a1768e1b2dabeac0fc7dd4c14601 (patch)
tree65070baf01dd31aecfb9c15d2a3c1fa20fdba0da /drivers/net/xen-netback
parentc3cb4709809e655a4ba5a716086c8bc5bbbbccdb (diff)
xen/gndev: Xen backend support for paged out grant targets V4.
Since Xen-4.2, hvm domains may have portions of their memory paged out. When a foreign domain (such as dom0) attempts to map these frames, the map will initially fail. The hypervisor returns a suitable errno, and kicks an asynchronous page-in operation carried out by a helper. The foreign domain is expected to retry the mapping operation until it eventually succeeds. The foreign domain is not put to sleep because itself could be the one running the pager assist (typical scenario for dom0). This patch adds support for this mechanism for backend drivers using grant mapping and copying operations. Specifically, this covers the blkback and gntdev drivers (which map foreign grants), and the netback driver (which copies foreign grants). * Add a retry method for grants that fail with GNTST_eagain (i.e. because the target foreign frame is paged out). * Insert hooks with appropriate wrappers in the aforementioned drivers. The retry loop is only invoked if the grant operation status is GNTST_eagain. It guarantees to leave a new status code different from GNTST_eagain. Any other status code results in identical code execution as before. The retry loop performs 256 attempts with increasing time intervals through a 32 second period. It uses msleep to yield while waiting for the next retry. V2 after feedback from David Vrabel: * Explicit MAX_DELAY instead of wrap-around delay into zero * Abstract GNTST_eagain check into core grant table code for netback module. V3 after feedback from Ian Campbell: * Add placeholder in array of grant table error descriptions for unrelated error code we jump over. * Eliminate single map and retry macro in favor of a generic batch flavor. * Some renaming. * Bury most implementation in grant_table.c, cleaner interface. V4 rebased on top of sync of Xen grant table interface headers. Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> [v5: Fixed whitespace issues] Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/net/xen-netback')
-rw-r--r--drivers/net/xen-netback/netback.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 682633bfe00f..05593d882023 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -635,9 +635,7 @@ static void xen_netbk_rx_action(struct xen_netbk *netbk)
635 return; 635 return;
636 636
637 BUG_ON(npo.copy_prod > ARRAY_SIZE(netbk->grant_copy_op)); 637 BUG_ON(npo.copy_prod > ARRAY_SIZE(netbk->grant_copy_op));
638 ret = HYPERVISOR_grant_table_op(GNTTABOP_copy, &netbk->grant_copy_op, 638 gnttab_batch_copy(netbk->grant_copy_op, npo.copy_prod);
639 npo.copy_prod);
640 BUG_ON(ret != 0);
641 639
642 while ((skb = __skb_dequeue(&rxq)) != NULL) { 640 while ((skb = __skb_dequeue(&rxq)) != NULL) {
643 sco = (struct skb_cb_overlay *)skb->cb; 641 sco = (struct skb_cb_overlay *)skb->cb;
@@ -1460,18 +1458,15 @@ static void xen_netbk_tx_submit(struct xen_netbk *netbk)
1460static void xen_netbk_tx_action(struct xen_netbk *netbk) 1458static void xen_netbk_tx_action(struct xen_netbk *netbk)
1461{ 1459{
1462 unsigned nr_gops; 1460 unsigned nr_gops;
1463 int ret;
1464 1461
1465 nr_gops = xen_netbk_tx_build_gops(netbk); 1462 nr_gops = xen_netbk_tx_build_gops(netbk);
1466 1463
1467 if (nr_gops == 0) 1464 if (nr_gops == 0)
1468 return; 1465 return;
1469 ret = HYPERVISOR_grant_table_op(GNTTABOP_copy,
1470 netbk->tx_copy_ops, nr_gops);
1471 BUG_ON(ret);
1472 1466
1473 xen_netbk_tx_submit(netbk); 1467 gnttab_batch_copy(netbk->tx_copy_ops, nr_gops);
1474 1468
1469 xen_netbk_tx_submit(netbk);
1475} 1470}
1476 1471
1477static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx) 1472static void xen_netbk_idx_release(struct xen_netbk *netbk, u16 pending_idx)