[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for 8.0 v8 06/12] vdpa: extract vhost_vdpa_svq_allocate_iova_
From: |
Jason Wang |
Subject: |
Re: [PATCH for 8.0 v8 06/12] vdpa: extract vhost_vdpa_svq_allocate_iova_tree |
Date: |
Wed, 30 Nov 2022 14:43:14 +0800 |
On Thu, Nov 24, 2022 at 11:52 PM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> It can be allocated either if all virtqueues must be shadowed or if
> vdpa-net detects it can shadow only cvq.
>
> Extract in its own function so we can reuse it.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
> net/vhost-vdpa.c | 29 +++++++++++++++++------------
> 1 file changed, 17 insertions(+), 12 deletions(-)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 88e0eec5fa..9ee3bc4cd3 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -240,6 +240,22 @@ static NetClientInfo net_vhost_vdpa_info = {
> .check_peer_type = vhost_vdpa_check_peer_type,
> };
>
> +static int vhost_vdpa_get_iova_range(int fd,
> + struct vhost_vdpa_iova_range
> *iova_range)
> +{
> + int ret = ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range);
> +
> + return ret < 0 ? -errno : 0;
> +}
I don't get why this needs to be moved to net specific code.
Thanks
> +
> +static VhostIOVATree *vhost_vdpa_svq_allocate_iova_tree(int vdpa_device_fd)
> +{
> + struct vhost_vdpa_iova_range iova_range;
> +
> + vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
> + return vhost_iova_tree_new(iova_range.first, iova_range.last);
> +}
> +
> static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr)
> {
> VhostIOVATree *tree = v->iova_tree;
> @@ -587,14 +603,6 @@ static NetClientState
> *net_vhost_vdpa_init(NetClientState *peer,
> return nc;
> }
>
> -static int vhost_vdpa_get_iova_range(int fd,
> - struct vhost_vdpa_iova_range
> *iova_range)
> -{
> - int ret = ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range);
> -
> - return ret < 0 ? -errno : 0;
> -}
> -
> static int vhost_vdpa_get_features(int fd, uint64_t *features, Error **errp)
> {
> int ret = ioctl(fd, VHOST_GET_FEATURES, features);
> @@ -690,14 +698,11 @@ int net_init_vhost_vdpa(const Netdev *netdev, const
> char *name,
> }
>
> if (opts->x_svq) {
> - struct vhost_vdpa_iova_range iova_range;
> -
> if (!vhost_vdpa_net_valid_svq_features(features, errp)) {
> goto err_svq;
> }
>
> - vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range);
> - iova_tree = vhost_iova_tree_new(iova_range.first, iova_range.last);
> + iova_tree = vhost_vdpa_svq_allocate_iova_tree(vdpa_device_fd);
> }
>
> ncs = g_malloc0(sizeof(*ncs) * queue_pairs);
> --
> 2.31.1
>
- [PATCH for 8.0 v8 00/12] ASID support in vhost-vdpa net, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 01/12] vdpa: use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 02/12] vhost: set SVQ device call handler at SVQ start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 03/12] vhost: allocate SVQ device file descriptors at device start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 04/12] vhost: move iova_tree set to vhost_svq_start, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 05/12] vdpa: add vhost_vdpa_net_valid_svq_features, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 06/12] vdpa: extract vhost_vdpa_svq_allocate_iova_tree, Eugenio Pérez, 2022/11/24
- Re: [PATCH for 8.0 v8 06/12] vdpa: extract vhost_vdpa_svq_allocate_iova_tree,
Jason Wang <=
- [PATCH for 8.0 v8 08/12] vdpa: allocate SVQ array unconditionally, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 07/12] vdpa: move SVQ vring features check to net/, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 10/12] vdpa: store x-svq parameter in VhostVDPAState, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 09/12] vdpa: add asid parameter to vhost_vdpa_dma_map/unmap, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 11/12] vdpa: add shadow_data to vhost_vdpa, Eugenio Pérez, 2022/11/24
- [PATCH for 8.0 v8 12/12] vdpa: always start CVQ in SVQ mode if possible, Eugenio Pérez, 2022/11/24