diff options
| author | Wei Liu <wei.liu2@citrix.com> | 2015-04-03 02:44:59 -0400 |
|---|---|---|
| committer | David Vrabel <david.vrabel@citrix.com> | 2015-04-15 05:56:47 -0400 |
| commit | ccc9d90a9a8b5c4ad7e9708ec41f75ff9e98d61d (patch) | |
| tree | 2a147c10a289a3f4283d6008708297f07df052a6 | |
| parent | 278edfc07875779a69277f6c5773ec9318a994ee (diff) | |
xenbus_client: Extend interface to support multi-page ring
Originally Xen PV drivers only use single-page ring to pass along
information. This might limit the throughput between frontend and
backend.
The patch extends Xenbus driver to support multi-page ring, which in
general should improve throughput if ring is the bottleneck. Changes to
various frontend / backend to adapt to the new interface are also
included.
Affected Xen drivers:
* blkfront/back
* netfront/back
* pcifront/back
* scsifront/back
* vtpmfront
The interface is documented, as before, in xenbus_client.c.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Bob Liu <bob.liu@oracle.com>
Cc: Konrad Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
| -rw-r--r-- | drivers/block/xen-blkback/xenbus.c | 5 | ||||
| -rw-r--r-- | drivers/block/xen-blkfront.c | 5 | ||||
| -rw-r--r-- | drivers/char/tpm/xen-tpmfront.c | 5 | ||||
| -rw-r--r-- | drivers/net/xen-netback/netback.c | 4 | ||||
| -rw-r--r-- | drivers/net/xen-netfront.c | 9 | ||||
| -rw-r--r-- | drivers/pci/xen-pcifront.c | 5 | ||||
| -rw-r--r-- | drivers/scsi/xen-scsifront.c | 5 | ||||
| -rw-r--r-- | drivers/xen/xen-pciback/xenbus.c | 2 | ||||
| -rw-r--r-- | drivers/xen/xen-scsiback.c | 2 | ||||
| -rw-r--r-- | drivers/xen/xenbus/xenbus_client.c | 387 | ||||
| -rw-r--r-- | include/xen/xenbus.h | 20 |
11 files changed, 324 insertions, 125 deletions
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index e3afe97280b1..ff3025922c14 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c | |||
| @@ -193,7 +193,7 @@ fail: | |||
| 193 | return ERR_PTR(-ENOMEM); | 193 | return ERR_PTR(-ENOMEM); |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page, | 196 | static int xen_blkif_map(struct xen_blkif *blkif, grant_ref_t gref, |
| 197 | unsigned int evtchn) | 197 | unsigned int evtchn) |
| 198 | { | 198 | { |
| 199 | int err; | 199 | int err; |
| @@ -202,7 +202,8 @@ static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page, | |||
| 202 | if (blkif->irq) | 202 | if (blkif->irq) |
| 203 | return 0; | 203 | return 0; |
| 204 | 204 | ||
| 205 | err = xenbus_map_ring_valloc(blkif->be->dev, shared_page, &blkif->blk_ring); | 205 | err = xenbus_map_ring_valloc(blkif->be->dev, &gref, 1, |
| 206 | &blkif->blk_ring); | ||
| 206 | if (err < 0) | 207 | if (err < 0) |
| 207 | return err; | 208 | return err; |
| 208 | 209 | ||
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 37779e4c4585..2c61cf8c6f61 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
| @@ -1245,6 +1245,7 @@ static int setup_blkring(struct xenbus_device *dev, | |||
| 1245 | struct blkfront_info *info) | 1245 | struct blkfront_info *info) |
| 1246 | { | 1246 | { |
| 1247 | struct blkif_sring *sring; | 1247 | struct blkif_sring *sring; |
| 1248 | grant_ref_t gref; | ||
| 1248 | int err; | 1249 | int err; |
| 1249 | 1250 | ||
| 1250 | info->ring_ref = GRANT_INVALID_REF; | 1251 | info->ring_ref = GRANT_INVALID_REF; |
| @@ -1257,13 +1258,13 @@ static int setup_blkring(struct xenbus_device *dev, | |||
| 1257 | SHARED_RING_INIT(sring); | 1258 | SHARED_RING_INIT(sring); |
| 1258 | FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); | 1259 | FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); |
| 1259 | 1260 | ||
| 1260 | err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring)); | 1261 | err = xenbus_grant_ring(dev, info->ring.sring, 1, &gref); |
| 1261 | if (err < 0) { | 1262 | if (err < 0) { |
| 1262 | free_page((unsigned long)sring); | 1263 | free_page((unsigned long)sring); |
| 1263 | info->ring.sring = NULL; | 1264 | info->ring.sring = NULL; |
| 1264 | goto fail; | 1265 | goto fail; |
| 1265 | } | 1266 | } |
| 1266 | info->ring_ref = err; | 1267 | info->ring_ref = gref; |
| 1267 | 1268 | ||
| 1268 | err = xenbus_alloc_evtchn(dev, &info->evtchn); | 1269 | err = xenbus_alloc_evtchn(dev, &info->evtchn); |
| 1269 | if (err) | 1270 | if (err) |
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index c3b4f5a5ac10..3111f2778079 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c | |||
| @@ -193,6 +193,7 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv) | |||
| 193 | struct xenbus_transaction xbt; | 193 | struct xenbus_transaction xbt; |
| 194 | const char *message = NULL; | 194 | const char *message = NULL; |
| 195 | int rv; | 195 | int rv; |
| 196 | grant_ref_t gref; | ||
| 196 | 197 | ||
| 197 | priv->shr = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO); | 198 | priv->shr = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO); |
| 198 | if (!priv->shr) { | 199 | if (!priv->shr) { |
| @@ -200,11 +201,11 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv) | |||
| 200 | return -ENOMEM; | 201 | return -ENOMEM; |
| 201 | } | 202 | } |
| 202 | 203 | ||
| 203 | rv = xenbus_grant_ring(dev, virt_to_mfn(priv->shr)); | 204 | rv = xenbus_grant_ring(dev, &priv->shr, 1, &gref); |
| 204 | if (rv < 0) | 205 | if (rv < 0) |
| 205 | return rv; | 206 | return rv; |
| 206 | 207 | ||
| 207 | priv->ring_ref = rv; | 208 | priv->ring_ref = gref; |
| 208 | 209 | ||
| 209 | rv = xenbus_alloc_evtchn(dev, &priv->evtchn); | 210 | rv = xenbus_alloc_evtchn(dev, &priv->evtchn); |
| 210 | if (rv) | 211 | if (rv) |
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index cab9f5257f57..99a49479843d 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
| @@ -1781,7 +1781,7 @@ int xenvif_map_frontend_rings(struct xenvif_queue *queue, | |||
| 1781 | int err = -ENOMEM; | 1781 | int err = -ENOMEM; |
| 1782 | 1782 | ||
| 1783 | err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif), | 1783 | err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif), |
| 1784 | tx_ring_ref, &addr); | 1784 | &tx_ring_ref, 1, &addr); |
| 1785 | if (err) | 1785 | if (err) |
| 1786 | goto err; | 1786 | goto err; |
| 1787 | 1787 | ||
| @@ -1789,7 +1789,7 @@ int xenvif_map_frontend_rings(struct xenvif_queue *queue, | |||
| 1789 | BACK_RING_INIT(&queue->tx, txs, PAGE_SIZE); | 1789 | BACK_RING_INIT(&queue->tx, txs, PAGE_SIZE); |
| 1790 | 1790 | ||
| 1791 | err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif), | 1791 | err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif), |
| 1792 | rx_ring_ref, &addr); | 1792 | &rx_ring_ref, 1, &addr); |
| 1793 | if (err) | 1793 | if (err) |
| 1794 | goto err; | 1794 | goto err; |
| 1795 | 1795 | ||
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index e9b960f0ff32..13f5e7ff4bb5 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
| @@ -1486,6 +1486,7 @@ static int setup_netfront(struct xenbus_device *dev, | |||
| 1486 | { | 1486 | { |
| 1487 | struct xen_netif_tx_sring *txs; | 1487 | struct xen_netif_tx_sring *txs; |
| 1488 | struct xen_netif_rx_sring *rxs; | 1488 | struct xen_netif_rx_sring *rxs; |
| 1489 | grant_ref_t gref; | ||
| 1489 | int err; | 1490 | int err; |
| 1490 | 1491 | ||
| 1491 | queue->tx_ring_ref = GRANT_INVALID_REF; | 1492 | queue->tx_ring_ref = GRANT_INVALID_REF; |
| @@ -1502,10 +1503,10 @@ static int setup_netfront(struct xenbus_device *dev, | |||
| 1502 | SHARED_RING_INIT(txs); | 1503 | SHARED_RING_INIT(txs); |
| 1503 | FRONT_RING_INIT(&queue->tx, txs, PAGE_SIZE); | 1504 | FRONT_RING_INIT(&queue->tx, txs, PAGE_SIZE); |
| 1504 | 1505 | ||
| 1505 | err = xenbus_grant_ring(dev, virt_to_mfn(txs)); | 1506 | err = xenbus_grant_ring(dev, txs, 1, &gref); |
| 1506 | if (err < 0) | 1507 | if (err < 0) |
| 1507 | goto grant_tx_ring_fail; | 1508 | goto grant_tx_ring_fail; |
| 1508 | queue->tx_ring_ref = err; | 1509 | queue->tx_ring_ref = gref; |
| 1509 | 1510 | ||
| 1510 | rxs = (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIGH); | 1511 | rxs = (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIGH); |
| 1511 | if (!rxs) { | 1512 | if (!rxs) { |
| @@ -1516,10 +1517,10 @@ static int setup_netfront(struct xenbus_device *dev, | |||
| 1516 | SHARED_RING_INIT(rxs); | 1517 | SHARED_RING_INIT(rxs); |
| 1517 | FRONT_RING_INIT(&queue->rx, rxs, PAGE_SIZE); | 1518 | FRONT_RING_INIT(&queue->rx, rxs, PAGE_SIZE); |
| 1518 | 1519 | ||
| 1519 | err = xenbus_grant_ring(dev, virt_to_mfn(rxs)); | 1520 | err = xenbus_grant_ring(dev, rxs, 1, &gref); |
| 1520 | if (err < 0) | 1521 | if (err < 0) |
| 1521 | goto grant_rx_ring_fail; | 1522 | goto grant_rx_ring_fail; |
| 1522 | queue->rx_ring_ref = err; | 1523 | queue->rx_ring_ref = gref; |
| 1523 | 1524 | ||
| 1524 | if (feature_split_evtchn) | 1525 | if (feature_split_evtchn) |
| 1525 | err = setup_netfront_split(queue); | 1526 | err = setup_netfront_split(queue); |
diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index b1ffebec9b9e..7cfd2db02deb 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c | |||
| @@ -777,12 +777,13 @@ static int pcifront_publish_info(struct pcifront_device *pdev) | |||
| 777 | { | 777 | { |
| 778 | int err = 0; | 778 | int err = 0; |
| 779 | struct xenbus_transaction trans; | 779 | struct xenbus_transaction trans; |
| 780 | grant_ref_t gref; | ||
| 780 | 781 | ||
| 781 | err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info)); | 782 | err = xenbus_grant_ring(pdev->xdev, pdev->sh_info, 1, &gref); |
| 782 | if | ||
