From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: David Vrabel <david.vrabel@citrix.com>, davem@davemloft.net
Cc: xen-devel@lists.xensource.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, "David S . Miller" <davem@davemloft.net>
Subject: Re: [PATCH 3/4] net: xen-netback: use API provided by xenbus module to map rings
Date: Thu, 20 Oct 2011 17:00:53 -0400 [thread overview]
Message-ID: <20111020210053.GA19558@phenom.dumpdata.com> (raw)
In-Reply-To: <1319107519-2253-4-git-send-email-david.vrabel@citrix.com>
On Thu, Oct 20, 2011 at 11:45:18AM +0100, David Vrabel wrote:
> The xenbus module provides xenbus_map_ring_valloc() and
> xenbus_map_ring_vfree(). Use these to map the Tx and Rx ring pages
> granted by the frontend.
>
> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Dave, this is a standalone patch and can be applied independently of
> the rest of the series.
.. or Dave, if you would like I can carry these patches.
>
> drivers/net/xen-netback/common.h | 11 ++---
> drivers/net/xen-netback/netback.c | 80 ++++++++-----------------------------
> 2 files changed, 22 insertions(+), 69 deletions(-)
>
> diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
> index 161f207..94b79c3 100644
> --- a/drivers/net/xen-netback/common.h
> +++ b/drivers/net/xen-netback/common.h
> @@ -58,10 +58,6 @@ struct xenvif {
> u8 fe_dev_addr[6];
>
> /* Physical parameters of the comms window. */
> - grant_handle_t tx_shmem_handle;
> - grant_ref_t tx_shmem_ref;
> - grant_handle_t rx_shmem_handle;
> - grant_ref_t rx_shmem_ref;
> unsigned int irq;
>
> /* List of frontends to notify after a batch of frames sent. */
> @@ -70,8 +66,6 @@ struct xenvif {
> /* The shared rings and indexes. */
> struct xen_netif_tx_back_ring tx;
> struct xen_netif_rx_back_ring rx;
> - struct vm_struct *tx_comms_area;
> - struct vm_struct *rx_comms_area;
>
> /* Frontend feature information. */
> u8 can_sg:1;
> @@ -106,6 +100,11 @@ struct xenvif {
> wait_queue_head_t waiting_to_free;
> };
>
> +static inline struct xenbus_device *xenvif_to_xenbus_device(struct xenvif *vif)
> +{
> + return to_xenbus_device(vif->dev->dev.parent);
> +}
> +
> #define XEN_NETIF_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, PAGE_SIZE)
> #define XEN_NETIF_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, PAGE_SIZE)
>
> diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
> index fd00f25..3af2924 100644
> --- a/drivers/net/xen-netback/netback.c
> +++ b/drivers/net/xen-netback/netback.c
> @@ -1577,88 +1577,42 @@ static int xen_netbk_kthread(void *data)
>
> void xen_netbk_unmap_frontend_rings(struct xenvif *vif)
> {
> - struct gnttab_unmap_grant_ref op;
> -
> - if (vif->tx.sring) {
> - gnttab_set_unmap_op(&op, (unsigned long)vif->tx_comms_area->addr,
> - GNTMAP_host_map, vif->tx_shmem_handle);
> -
> - if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
> - BUG();
> - }
> -
> - if (vif->rx.sring) {
> - gnttab_set_unmap_op(&op, (unsigned long)vif->rx_comms_area->addr,
> - GNTMAP_host_map, vif->rx_shmem_handle);
> -
> - if (HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, &op, 1))
> - BUG();
> - }
> - if (vif->rx_comms_area)
> - free_vm_area(vif->rx_comms_area);
> - if (vif->tx_comms_area)
> - free_vm_area(vif->tx_comms_area);
> + if (vif->tx.sring)
> + xenbus_unmap_ring_vfree(xenvif_to_xenbus_device(vif),
> + vif->tx.sring);
> + if (vif->rx.sring)
> + xenbus_unmap_ring_vfree(xenvif_to_xenbus_device(vif),
> + vif->rx.sring);
> }
>
> int xen_netbk_map_frontend_rings(struct xenvif *vif,
> grant_ref_t tx_ring_ref,
> grant_ref_t rx_ring_ref)
> {
> - struct gnttab_map_grant_ref op;
> + void *addr;
> struct xen_netif_tx_sring *txs;
> struct xen_netif_rx_sring *rxs;
>
> int err = -ENOMEM;
>
> - vif->tx_comms_area = alloc_vm_area(PAGE_SIZE);
> - if (vif->tx_comms_area == NULL)
> + err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
> + tx_ring_ref, &addr);
> + if (err)
> goto err;
>
> - vif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
> - if (vif->rx_comms_area == NULL)
> - goto err;
> -
> - gnttab_set_map_op(&op, (unsigned long)vif->tx_comms_area->addr,
> - GNTMAP_host_map, tx_ring_ref, vif->domid);
> -
> - if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
> - BUG();
> -
> - if (op.status) {
> - netdev_warn(vif->dev,
> - "failed to map tx ring. err=%d status=%d\n",
> - err, op.status);
> - err = op.status;
> - goto err;
> - }
> -
> - vif->tx_shmem_ref = tx_ring_ref;
> - vif->tx_shmem_handle = op.handle;
> -
> - txs = (struct xen_netif_tx_sring *)vif->tx_comms_area->addr;
> + txs = (struct xen_netif_tx_sring *)addr;
> BACK_RING_INIT(&vif->tx, txs, PAGE_SIZE);
>
> - gnttab_set_map_op(&op, (unsigned long)vif->rx_comms_area->addr,
> - GNTMAP_host_map, rx_ring_ref, vif->domid);
> -
> - if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, &op, 1))
> - BUG();
> -
> - if (op.status) {
> - netdev_warn(vif->dev,
> - "failed to map rx ring. err=%d status=%d\n",
> - err, op.status);
> - err = op.status;
> + err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
> + rx_ring_ref, &addr);
> + if (err)
> goto err;
> - }
> -
> - vif->rx_shmem_ref = rx_ring_ref;
> - vif->rx_shmem_handle = op.handle;
> - vif->rx_req_cons_peek = 0;
>
> - rxs = (struct xen_netif_rx_sring *)vif->rx_comms_area->addr;
> + rxs = (struct xen_netif_rx_sring *)addr;
> BACK_RING_INIT(&vif->rx, rxs, PAGE_SIZE);
>
> + vif->rx_req_cons_peek = 0;
> +
> return 0;
>
> err:
> --
> 1.7.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2011-10-24 13:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-20 10:45 [PATCH 0/4] xen: map foreign pages for shared rings by updating the PTEs directly David Vrabel
2011-10-20 10:45 ` [PATCH 1/4] xen: use generic functions instead of xen_{alloc,free}_vm_area() David Vrabel
2011-10-20 23:45 ` Konrad Rzeszutek Wilk
2011-10-20 10:45 ` [PATCH 2/4] block: xen-blkback: use API provided by xenbus module to map rings David Vrabel
2011-10-26 13:47 ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-10-26 13:55 ` Jens Axboe
2011-10-20 10:45 ` [PATCH 3/4] net: xen-netback: " David Vrabel
2011-10-20 21:00 ` Konrad Rzeszutek Wilk [this message]
2011-10-20 10:45 ` [PATCH 4/4] xen: map foreign pages for shared rings by updating the PTEs directly David Vrabel
2011-10-20 23:44 ` [PATCH 0/4] " Konrad Rzeszutek Wilk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111020210053.GA19558@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=davem@davemloft.net \
--cc=david.vrabel@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).