|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [RFC PATCH V3 12/16] netback: multi-page ring support
>>> On 30.01.12 at 15:45, Wei Liu <wei.liu2@xxxxxxxxxx> wrote:
> -int xenvif_map_frontend_rings(struct xenvif *vif,
> - grant_ref_t tx_ring_ref,
> - grant_ref_t rx_ring_ref)
> +int xenvif_map_frontend_rings(struct xen_comms *comms,
> + int domid,
> + unsigned long ring_ref[],
> + unsigned int ring_ref_count)
> {
> - void *addr;
> - struct xen_netif_tx_sring *txs;
> - struct xen_netif_rx_sring *rxs;
> -
> - int err = -ENOMEM;
> + struct gnttab_map_grant_ref op[NETBK_MAX_RING_PAGES];
> + unsigned int i;
> + int err = 0;
>
> - err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
> - tx_ring_ref, &addr);
Any reason why you don't just extend this function (in a prerequisite
patch) rather than open coding a common utility function (twice) here,
so that other backends (blkback!) can benefit later as well.
Jan
> - if (err)
> - goto err;
> + comms->ring_area = alloc_vm_area(PAGE_SIZE * ring_ref_count, NULL);
> + if (comms->ring_area == NULL)
> + return -ENOMEM;
>
> - txs = (struct xen_netif_tx_sring *)addr;
> - BACK_RING_INIT(&vif->tx, txs, PAGE_SIZE);
> + for (i = 0; i < ring_ref_count; i++) {
> + unsigned long addr = (unsigned long)comms->ring_area->addr +
> + (i * PAGE_SIZE);
> + gnttab_set_map_op(&op[i], addr, GNTMAP_host_map,
> + ring_ref[i], domid);
> + }
>
> - err = xenbus_map_ring_valloc(xenvif_to_xenbus_device(vif),
> - rx_ring_ref, &addr);
> - if (err)
> - goto err;
> + if (HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
> + &op, ring_ref_count))
> + BUG();
>
> - rxs = (struct xen_netif_rx_sring *)addr;
> - BACK_RING_INIT(&vif->rx, rxs, PAGE_SIZE);
> + comms->nr_handles = ring_ref_count;
>
> - vif->rx_req_cons_peek = 0;
> + for (i = 0; i < ring_ref_count; i++) {
> + if (op[i].status != 0) {
> + err = op[i].status;
> + comms->shmem_handle[i] = INVALID_GRANT_HANDLE;
> + continue;
> + }
> + comms->shmem_handle[i] = op[i].handle;
> + }
>
> - return 0;
> + if (err != 0)
> + xenvif_unmap_frontend_rings(comms);
>
> -err:
> - xenvif_unmap_frontend_rings(vif);
> return err;
> }
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |