Skip to content

Commit ccc9d90

Browse files
Wei LiuDavid Vrabel
authored andcommitted
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>
1 parent 278edfc commit ccc9d90

File tree

11 files changed

+324
-125
lines changed

11 files changed

+324
-125
lines changed

drivers/block/xen-blkback/xenbus.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
193193
return ERR_PTR(-ENOMEM);
194194
}
195195

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,
197197
unsigned int evtchn)
198198
{
199199
int err;
@@ -202,7 +202,8 @@ static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
202202
if (blkif->irq)
203203
return 0;
204204

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);
206207
if (err < 0)
207208
return err;
208209

drivers/block/xen-blkfront.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,7 @@ static int setup_blkring(struct xenbus_device *dev,
12451245
struct blkfront_info *info)
12461246
{
12471247
struct blkif_sring *sring;
1248+
grant_ref_t gref;
12481249
int err;
12491250

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

1260-
err = xenbus_grant_ring(dev, virt_to_mfn(info->ring.sring));
1261+
err = xenbus_grant_ring(dev, info->ring.sring, 1, &gref);
12611262
if (err < 0) {
12621263
free_page((unsigned long)sring);
12631264
info->ring.sring = NULL;
12641265
goto fail;
12651266
}
1266-
info->ring_ref = err;
1267+
info->ring_ref = gref;
12671268

12681269
err = xenbus_alloc_evtchn(dev, &info->evtchn);
12691270
if (err)

drivers/char/tpm/xen-tpmfront.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,19 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
193193
struct xenbus_transaction xbt;
194194
const char *message = NULL;
195195
int rv;
196+
grant_ref_t gref;
196197

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

203-
rv = xenbus_grant_ring(dev, virt_to_mfn(priv->shr));
204+
rv = xenbus_grant_ring(dev, &priv->shr, 1, &gref);
204205
if (rv < 0)
205206
return rv;
206207

207-
priv->ring_ref = rv;
208+
priv->ring_ref = gref;
208209

209210
rv = xenbus_alloc_evtchn(dev, &priv->evtchn);
210211
if (rv)

drivers/net/xen-netback/netback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,15 +1781,15 @@ int xenvif_map_frontend_rings(struct xenvif_queue *queue,
17811781
int err = -ENOMEM;
17821782

17831783
err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif),
1784-
tx_ring_ref, &addr);
1784+
&tx_ring_ref, 1, &addr);
17851785
if (err)
17861786
goto err;
17871787

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

17911791
err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(queue->vif),
1792-
rx_ring_ref, &addr);
1792+
&rx_ring_ref, 1, &addr);
17931793
if (err)
17941794
goto err;
17951795

drivers/net/xen-netfront.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ static int setup_netfront(struct xenbus_device *dev,
14861486
{
14871487
struct xen_netif_tx_sring *txs;
14881488
struct xen_netif_rx_sring *rxs;
1489+
grant_ref_t gref;
14891490
int err;
14901491

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

1505-
err = xenbus_grant_ring(dev, virt_to_mfn(txs));
1506+
err = xenbus_grant_ring(dev, txs, 1, &gref);
15061507
if (err < 0)
15071508
goto grant_tx_ring_fail;
1508-
queue->tx_ring_ref = err;
1509+
queue->tx_ring_ref = gref;
15091510

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

1519-
err = xenbus_grant_ring(dev, virt_to_mfn(rxs));
1520+
err = xenbus_grant_ring(dev, rxs, 1, &gref);
15201521
if (err < 0)
15211522
goto grant_rx_ring_fail;
1522-
queue->rx_ring_ref = err;
1523+
queue->rx_ring_ref = gref;
15231524

15241525
if (feature_split_evtchn)
15251526
err = setup_netfront_split(queue);

drivers/pci/xen-pcifront.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,13 @@ static int pcifront_publish_info(struct pcifront_device *pdev)
777777
{
778778
int err = 0;
779779
struct xenbus_transaction trans;
780+
grant_ref_t gref;
780781

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);
782783
if (err < 0)
783784
goto out;
784785

785-
pdev->gnt_ref = err;
786+
pdev->gnt_ref = gref;
786787

787788
err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
788789
if (err)

drivers/scsi/xen-scsifront.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
714714
{
715715
struct xenbus_device *dev = info->dev;
716716
struct vscsiif_sring *sring;
717+
grant_ref_t gref;
717718
int err = -ENOMEM;
718719

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

729-
err = xenbus_grant_ring(dev, virt_to_mfn(sring));
730+
err = xenbus_grant_ring(dev, sring, 1, &gref);
730731
if (err < 0) {
731732
free_page((unsigned long)sring);
732733
xenbus_dev_fatal(dev, err,
733734
"fail to grant shared ring (Front to Back)");
734735
return err;
735736
}
736-
info->ring_ref = err;
737+
info->ring_ref = gref;
737738

738739
err = xenbus_alloc_evtchn(dev, &info->evtchn);
739740
if (err) {

drivers/xen/xen-pciback/xenbus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int xen_pcibk_do_attach(struct xen_pcibk_device *pdev, int gnt_ref,
113113
"Attaching to frontend resources - gnt_ref=%d evtchn=%d\n",
114114
gnt_ref, remote_evtchn);
115115

116-
err = xenbus_map_ring_valloc(pdev->xdev, gnt_ref, &vaddr);
116+
err = xenbus_map_ring_valloc(pdev->xdev, &gnt_ref, 1, &vaddr);
117117
if (err < 0) {
118118
xenbus_dev_fatal(pdev->xdev, err,
119119
"Error mapping other domain page in ours.");

drivers/xen/xen-scsiback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ static int scsiback_init_sring(struct vscsibk_info *info, grant_ref_t ring_ref,
809809
if (info->irq)
810810
return -1;
811811

812-
err = xenbus_map_ring_valloc(info->dev, ring_ref, &area);
812+
err = xenbus_map_ring_valloc(info->dev, &ring_ref, 1, &area);
813813
if (err)
814814
return err;
815815

0 commit comments

Comments
 (0)