Skip to content

Commit

Permalink
xenbus_client: Extend interface to support multi-page ring
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wei Liu authored and David Vrabel committed Apr 15, 2015
1 parent 278edfc commit ccc9d90
Show file tree
Hide file tree
Showing 11 changed files with 324 additions and 125 deletions.
5 changes: 3 additions & 2 deletions drivers/block/xen-blkback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
return ERR_PTR(-ENOMEM);
}

static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
static int xen_blkif_map(struct xen_blkif *blkif, grant_ref_t gref,
unsigned int evtchn)
{
int err;
Expand All @@ -202,7 +202,8 @@ static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
if (blkif->irq)
return 0;

err = xenbus_map_ring_valloc(blkif->be->dev, shared_page, &blkif->blk_ring);
err = xenbus_map_ring_valloc(blkif->be->dev, &gref, 1,
&blkif->blk_ring);
if (err < 0)
return err;

Expand Down
5 changes: 3 additions & 2 deletions drivers/block/xen-blkfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,7 @@ static int setup_blkring(struct xenbus_device *dev,
struct blkfront_info *info)
{
struct blkif_sring *sring;
grant_ref_t gref;
int err;

info->ring_ref = GRANT_INVALID_REF;
Expand All @@ -1257,13 +1258,13 @@ static int setup_blkring(struct xenbus_device *dev,
SHARED_RING_INIT(sring);
FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);

err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
err = xenbus_grant_ring(dev, info->ring.sring, 1, &gref);
if (err < 0) {
free_page((unsigned long)sring);
info->ring.sring = NULL;
goto fail;
}
info->ring_ref = err;
info->ring_ref = gref;

err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err)
Expand Down
5 changes: 3 additions & 2 deletions drivers/char/tpm/xen-tpmfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,19 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
struct xenbus_transaction xbt;
const char *message = NULL;
int rv;
grant_ref_t gref;

priv->shr = (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO);
if (!priv->shr) {
xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring");
return -ENOMEM;
}

rv = xenbus_grant_ring(dev, virt_to_mfn(priv->shr));
rv = xenbus_grant_ring(dev, &priv->shr, 1, &gref);
if (rv < 0)
return rv;

priv->ring_ref = rv;
priv->ring_ref = gref;

rv = xenbus_alloc_evtchn(dev, &priv->evtchn);
if (rv)
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/xen-netback/netback.c
Original file line number Diff line number Diff line change
Expand Up @@ -1781,15 +1781,15 @@ int xenvif_map_frontend_rings(struct xenvif_queue *queue,
int err = -ENOMEM;

err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif),
tx_ring_ref, &addr);
&tx_ring_ref, 1, &addr);
if (err)
goto err;

txs = (struct xen_netif_tx_sring *)addr;
BACK_RING_INIT(&queue->tx, txs, PAGE_SIZE);

err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif),
rx_ring_ref, &addr);
&rx_ring_ref, 1, &addr);
if (err)
goto err;

Expand Down
9 changes: 5 additions & 4 deletions drivers/net/xen-netfront.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@ static int setup_netfront(struct xenbus_device *dev,
{
struct xen_netif_tx_sring *txs;
struct xen_netif_rx_sring *rxs;
grant_ref_t gref;
int err;

queue->tx_ring_ref = GRANT_INVALID_REF;
Expand All @@ -1502,10 +1503,10 @@ static int setup_netfront(struct xenbus_device *dev,
SHARED_RING_INIT(txs);
FRONT_RING_INIT(&queue->tx, txs, PAGE_SIZE);

err = xenbus_grant_ring(dev, virt_to_mfn(txs));
err = xenbus_grant_ring(dev, txs, 1, &gref);
if (err < 0)
goto grant_tx_ring_fail;
queue->tx_ring_ref = err;
queue->tx_ring_ref = gref;

rxs = (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIGH);
if (!rxs) {
Expand All @@ -1516,10 +1517,10 @@ static int setup_netfront(struct xenbus_device *dev,
SHARED_RING_INIT(rxs);
FRONT_RING_INIT(&queue->rx, rxs, PAGE_SIZE);

err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
err = xenbus_grant_ring(dev, rxs, 1, &gref);
if (err < 0)
goto grant_rx_ring_fail;
queue->rx_ring_ref = err;
queue->rx_ring_ref = gref;

if (feature_split_evtchn)
err = setup_netfront_split(queue);
Expand Down
5 changes: 3 additions & 2 deletions drivers/pci/xen-pcifront.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,12 +777,13 @@ static int pcifront_publish_info(struct pcifront_device *pdev)
{
int err = 0;
struct xenbus_transaction trans;
grant_ref_t gref;

err = xenbus_grant_ring(pdev->xdev, virt_to_mfn(pdev->sh_info));
err = xenbus_grant_ring(pdev->xdev, pdev->sh_info, 1, &gref);
if (err < 0)
goto out;

pdev->gnt_ref = err;
pdev->gnt_ref = gref;

err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
if (err)
Expand Down
5 changes: 3 additions & 2 deletions drivers/scsi/xen-scsifront.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
{
struct xenbus_device *dev = info->dev;
struct vscsiif_sring *sring;
grant_ref_t gref;
int err = -ENOMEM;

/***** Frontend to Backend ring start *****/
Expand All @@ -726,14 +727,14 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
SHARED_RING_INIT(sring);
FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);

err = xenbus_grant_ring(dev, virt_to_mfn(sring));
err = xenbus_grant_ring(dev, sring, 1, &gref);
if (err < 0) {
free_page((unsigned long)sring);
xenbus_dev_fatal(dev, err,
"fail to grant shared ring (Front to Back)");
return err;
}
info->ring_ref = err;
info->ring_ref = gref;

err = xenbus_alloc_evtchn(dev, &info->evtchn);
if (err) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/xen/xen-pciback/xenbus.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref,
"Attaching to frontend resources - gnt_ref=%d evtchn=%d\n",
gnt_ref, remote_evtchn);

err = xenbus_map_ring_valloc(pdev->xdev, gnt_ref, &vaddr);
err = xenbus_map_ring_valloc(pdev->xdev, &gnt_ref, 1, &vaddr);
if (err < 0) {
xenbus_dev_fatal(pdev->xdev, err,
"Error mapping other domain page in ours.");
Expand Down
2 changes: 1 addition & 1 deletion drivers/xen/xen-scsiback.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ static int scsiback_init_sring(struct vscsibk_info *info, grant_ref_t ring_ref,
if (info->irq)
return -1;

err = xenbus_map_ring_valloc(info->dev, ring_ref, &area);
err = xenbus_map_ring_valloc(info->dev, &ring_ref, 1, &area);
if (err)
return err;

Expand Down
Loading

0 comments on commit ccc9d90

Please sign in to comment.