You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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>
This commit is contained in:
@@ -193,7 +193,7 @@ fail:
|
||||
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;
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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)
|
||||
|
||||
@@ -193,6 +193,7 @@ 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) {
|
||||
@@ -200,11 +201,11 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
|
||||
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)
|
||||
|
||||
@@ -1781,7 +1781,7 @@ 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;
|
||||
|
||||
@@ -1789,7 +1789,7 @@ int xenvif_map_frontend_rings(struct xenvif_queue *queue,
|
||||
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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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) {
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 *****/
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
+286
-101
File diff suppressed because it is too large
Load Diff
+14
-6
@@ -46,6 +46,10 @@
|
||||
#include <xen/interface/io/xenbus.h>
|
||||
#include <xen/interface/io/xs_wire.h>
|
||||
|
||||
#define XENBUS_MAX_RING_PAGE_ORDER 4
|
||||
#define XENBUS_MAX_RING_PAGES (1U << XENBUS_MAX_RING_PAGE_ORDER)
|
||||
#define INVALID_GRANT_HANDLE (~0U)
|
||||
|
||||
/* Register callback to watch this node. */
|
||||
struct xenbus_watch
|
||||
{
|
||||
@@ -199,15 +203,19 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch,
|
||||
const char *pathfmt, ...);
|
||||
|
||||
int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state);
|
||||
int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn);
|
||||
int xenbus_map_ring_valloc(struct xenbus_device *dev,
|
||||
int gnt_ref, void **vaddr);
|
||||
int xenbus_map_ring(struct xenbus_device *dev, int gnt_ref,
|
||||
grant_handle_t *handle, void *vaddr);
|
||||
int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
|
||||
unsigned int nr_pages, grant_ref_t *grefs);
|
||||
int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_refs,
|
||||
unsigned int nr_grefs, void **vaddr);
|
||||
int xenbus_map_ring(struct xenbus_device *dev,
|
||||
grant_ref_t *gnt_refs, unsigned int nr_grefs,
|
||||
grant_handle_t *handles, unsigned long *vaddrs,
|
||||
bool *leaked);
|
||||
|
||||
int xenbus_unmap_ring_vfree(struct xenbus_device *dev, void *vaddr);
|
||||
int xenbus_unmap_ring(struct xenbus_device *dev,
|
||||
grant_handle_t handle, void *vaddr);
|
||||
grant_handle_t *handles, unsigned int nr_handles,
|
||||
unsigned long *vaddrs);
|
||||
|
||||
int xenbus_alloc_evtchn(struct xenbus_device *dev, int *port);
|
||||
int xenbus_free_evtchn(struct xenbus_device *dev, int port);
|
||||
|
||||
Reference in New Issue
Block a user