From nobody Mon Apr 29 14:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679601352; cv=none; d=zohomail.com; s=zohoarc; b=gCx3pGa61GnDzr8uBPBa3NPcCzEFeNTzIML22JyxxnpMev8kZvFAE1GGxG23m4SBlfMqI7lg+GgwB+tCHzDU6JOEQDALHVmhaoU7IR2RErlbzDF5lt260a3wVysCPyaSE4cHq+4hITj+CEnIMXFQA9++kwxxPeY3g1yvPDAIbzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679601352; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X3nK4ZpQgMUN43K3mekqrzfFLQ5w2ZvOSOOq3BPDe50=; b=GpjY5HS2Ybthlnd9z4Y5ygYkqIpYEQJtEtu1YM5ql/ynKRCzVk++2hCRdTdGGN1bM2eghUg02OOF9FucOHU+QDHYWrgojIWFYgGf2f8SrT2bud48KCrku/Yipzd4ZwTELvM82KKugY7Kuz95vD519OVun5vxVI8dbDdy0gBtNY0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679601352339301.59678133416014; Thu, 23 Mar 2023 12:55:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfR0x-0003Ep-1o; Thu, 23 Mar 2023 15:54:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0s-0003Ck-Kp for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0r-0007Pu-5Q for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:18 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-TpeLOVanOJiWhUF-o3R-yg-1; Thu, 23 Mar 2023 15:54:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2220C3C0ED6E; Thu, 23 Mar 2023 19:54:12 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7579744002; Thu, 23 Mar 2023 19:54:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679601256; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3nK4ZpQgMUN43K3mekqrzfFLQ5w2ZvOSOOq3BPDe50=; b=LTzl28V+M02foCxCveTeB9wzcgYV4TaU/hIGEc2PxzZWRajCEZllYNHFALI352EiIMk4j9 ChJ7b9/k4xIud4RDLDYa211qHmxFFK9oL+duCnDCbNsBaJ18gcRQf9kfhYV3uaCJ2SNQCs 1NDpAHTTaTOwcDFg5KvLadcCZRPqznw= X-MC-Unique: TpeLOVanOJiWhUF-o3R-yg-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Gautam Dawar , Jason Wang , alvaro.karsz@solid-run.com, "Gonglei (Arei)" , Lei Yang , si-wei.liu@oracle.com, Eli Cohen , Shannon Nelson , Laurent Vivier , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Zhu Lingshan , Cindy Lu , longpeng2@huawei.com, Harpreet Singh Anand Subject: [PATCH for 8.1 v2 1/6] vdpa: Remove status in reset tracing Date: Thu, 23 Mar 2023 20:53:59 +0100 Message-Id: <20230323195404.1247326-2-eperezma@redhat.com> In-Reply-To: <20230323195404.1247326-1-eperezma@redhat.com> References: <20230323195404.1247326-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679601352909100001 It is always 0 and it is not useful to route call through file descriptor. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Reviewed-by: Stefano Garzarella --- hw/virtio/vhost-vdpa.c | 2 +- hw/virtio/trace-events | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index bc6bad23d5..bbabea18f3 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -716,7 +716,7 @@ static int vhost_vdpa_reset_device(struct vhost_dev *de= v) uint8_t status =3D 0; =20 ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); - trace_vhost_vdpa_reset_device(dev, status); + trace_vhost_vdpa_reset_device(dev); v->suspended =3D false; return ret; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 8f8d05cf9b..6265231683 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -44,7 +44,7 @@ vhost_vdpa_set_mem_table(void *dev, uint32_t nregions, ui= nt32_t padding) "dev: % vhost_vdpa_dump_regions(void *dev, int i, uint64_t guest_phys_addr, uint64= _t memory_size, uint64_t userspace_addr, uint64_t flags_padding) "dev: %p %= d: guest_phys_addr: 0x%"PRIx64" memory_size: 0x%"PRIx64" userspace_addr: 0x= %"PRIx64" flags_padding: 0x%"PRIx64 vhost_vdpa_set_features(void *dev, uint64_t features) "dev: %p features: 0= x%"PRIx64 vhost_vdpa_get_device_id(void *dev, uint32_t device_id) "dev: %p device_id= %"PRIu32 -vhost_vdpa_reset_device(void *dev, uint8_t status) "dev: %p status: 0x%"PR= Ix8 +vhost_vdpa_reset_device(void *dev) "dev: %p" vhost_vdpa_get_vq_index(void *dev, int idx, int vq_idx) "dev: %p idx: %d v= q idx: %d" vhost_vdpa_set_vring_ready(void *dev) "dev: %p" vhost_vdpa_dump_config(void *dev, const char *line) "dev: %p %s" --=20 2.31.1 From nobody Mon Apr 29 14:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679601298; cv=none; d=zohomail.com; s=zohoarc; b=COkxh+WykBBUKHYcobD2fSBDhD5dW0AlQ+Lf1cCA7qz2e1qVtE6hj8bZT28sjV8bOMhizSYBaV1B75it3UZn9Gt+nQUQ+iQ0kDYef0ENyz0LrzbmXUbb0QycbpDnH/kqwhukFku/uo0eEOKZUflMudnO4uZDyJj1+1sJ++c9Ag4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679601298; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FzJsVnjSMdfsj8dkwdHKPdYDhmMC1ol2rRVEN/DKVvU=; b=RkFSEOGgH1OLu2JbyyZabZQadNsS/qu5JjxMFLiKBFschUFPYwhr5KqAQP35sf7iWy7HGsqlPiVfVEN28LYLrEY1sU6Sh27dZN+5dEQpDBUiy1b2CW4xRtj3uU8SKTCfVt9yBbFSYYE9IHXgjJni5XX+6pmrDFSRxQ9e8kwVgWE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679601298715695.9161359154699; Thu, 23 Mar 2023 12:54:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfR0z-0003FK-7H; Thu, 23 Mar 2023 15:54:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0x-0003F3-LR for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0w-0007QS-26 for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-326-4SjEaly9M5iUJ9pVbyCnFQ-1; Thu, 23 Mar 2023 15:54:15 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0B7B5380670A; Thu, 23 Mar 2023 19:54:15 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6045251FF; Thu, 23 Mar 2023 19:54:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679601258; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FzJsVnjSMdfsj8dkwdHKPdYDhmMC1ol2rRVEN/DKVvU=; b=LVFYT8IwmzhNqBgrEtLCPyUTgacOY0QLsjuTQMfiibTekO1xHSZ8c/PRVnU+8WBJiUw5zm ayZUa1XseT6Awydhfk5ki1dZnLqJeIE88zydzrFDM5NrQGNc0gNj+cB+qURMLpiA9bye+S PhNCb1rd3yVLZY8RsbqrWRTqzhqsuFU= X-MC-Unique: 4SjEaly9M5iUJ9pVbyCnFQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Gautam Dawar , Jason Wang , alvaro.karsz@solid-run.com, "Gonglei (Arei)" , Lei Yang , si-wei.liu@oracle.com, Eli Cohen , Shannon Nelson , Laurent Vivier , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Zhu Lingshan , Cindy Lu , longpeng2@huawei.com, Harpreet Singh Anand Subject: [PATCH for 8.1 v2 2/6] vdpa: add vhost_vdpa_reset_status_fd Date: Thu, 23 Mar 2023 20:54:00 +0100 Message-Id: <20230323195404.1247326-3-eperezma@redhat.com> In-Reply-To: <20230323195404.1247326-1-eperezma@redhat.com> References: <20230323195404.1247326-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679601301023100001 This allows to reset a vhost-vdpa device from external subsystems like vhost-net, since it does not have any struct vhost_dev by the time we need to use it. It is used in subsequent patches to negotiate features and probe for CVQ ASID isolation. Signed-off-by: Eugenio P=C3=A9rez Reviewed-by: Stefano Garzarella --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 58 +++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index c278a2a8de..28de7da91e 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -54,6 +54,7 @@ typedef struct vhost_vdpa { VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX]; } VhostVDPA; =20 +void vhost_vdpa_reset_status_fd(int fd); int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_r= ange); =20 int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index bbabea18f3..7a2053b8d9 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -335,38 +335,45 @@ static const MemoryListener vhost_vdpa_memory_listene= r =3D { .region_del =3D vhost_vdpa_listener_region_del, }; =20 -static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int reques= t, - void *arg) +static int vhost_vdpa_dev_fd(const struct vhost_dev *dev) { struct vhost_vdpa *v =3D dev->opaque; - int fd =3D v->device_fd; - int ret; =20 assert(dev->vhost_ops->backend_type =3D=3D VHOST_BACKEND_TYPE_VDPA); + return v->device_fd; +} + +static int vhost_vdpa_call_fd(int fd, unsigned long int request, void *arg) +{ + int ret =3D ioctl(fd, request, arg); =20 - ret =3D ioctl(fd, request, arg); return ret < 0 ? -errno : ret; } =20 -static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) +static int vhost_vdpa_call(struct vhost_dev *dev, unsigned long int reques= t, + void *arg) +{ + return vhost_vdpa_call_fd(vhost_vdpa_dev_fd(dev), request, arg); +} + +static int vhost_vdpa_add_status_fd(int fd, uint8_t status) { uint8_t s; int ret; =20 - trace_vhost_vdpa_add_status(dev, status); - ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s); + ret =3D vhost_vdpa_call_fd(fd, VHOST_VDPA_GET_STATUS, &s); if (ret < 0) { return ret; } =20 s |=3D status; =20 - ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &s); + ret =3D vhost_vdpa_call_fd(fd, VHOST_VDPA_SET_STATUS, &s); if (ret < 0) { return ret; } =20 - ret =3D vhost_vdpa_call(dev, VHOST_VDPA_GET_STATUS, &s); + ret =3D vhost_vdpa_call_fd(fd, VHOST_VDPA_GET_STATUS, &s); if (ret < 0) { return ret; } @@ -378,6 +385,12 @@ static int vhost_vdpa_add_status(struct vhost_dev *dev= , uint8_t status) return 0; } =20 +static int vhost_vdpa_add_status(struct vhost_dev *dev, uint8_t status) +{ + trace_vhost_vdpa_add_status(dev, status); + return vhost_vdpa_add_status_fd(vhost_vdpa_dev_fd(dev), status); +} + int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_r= ange) { int ret =3D ioctl(fd, VHOST_VDPA_GET_IOVA_RANGE, iova_range); @@ -709,16 +722,20 @@ static int vhost_vdpa_get_device_id(struct vhost_dev = *dev, return ret; } =20 +static int vhost_vdpa_reset_device_fd(int fd) +{ + uint8_t status =3D 0; + + return vhost_vdpa_call_fd(fd, VHOST_VDPA_SET_STATUS, &status); +} + static int vhost_vdpa_reset_device(struct vhost_dev *dev) { struct vhost_vdpa *v =3D dev->opaque; - int ret; - uint8_t status =3D 0; =20 - ret =3D vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status); - trace_vhost_vdpa_reset_device(dev); v->suspended =3D false; - return ret; + trace_vhost_vdpa_reset_device(dev); + return vhost_vdpa_reset_device_fd(vhost_vdpa_dev_fd(dev)); } =20 static int vhost_vdpa_get_vq_index(struct vhost_dev *dev, int idx) @@ -1170,6 +1187,13 @@ static int vhost_vdpa_dev_start(struct vhost_dev *de= v, bool started) return 0; } =20 +void vhost_vdpa_reset_status_fd(int fd) +{ + vhost_vdpa_reset_device_fd(fd); + vhost_vdpa_add_status_fd(fd, VIRTIO_CONFIG_S_ACKNOWLEDGE | + VIRTIO_CONFIG_S_DRIVER); +} + static void vhost_vdpa_reset_status(struct vhost_dev *dev) { struct vhost_vdpa *v =3D dev->opaque; @@ -1178,9 +1202,7 @@ static void vhost_vdpa_reset_status(struct vhost_dev = *dev) return; } =20 - vhost_vdpa_reset_device(dev); - vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE | - VIRTIO_CONFIG_S_DRIVER); + vhost_vdpa_reset_status_fd(vhost_vdpa_dev_fd(dev)); memory_listener_unregister(&v->listener); } =20 --=20 2.31.1 From nobody Mon Apr 29 14:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679601310; cv=none; d=zohomail.com; s=zohoarc; b=bnNIyX1Kc2hcLtDjOiD7prVCzFDCZ1MMz+qpT8gGsCqYfndPIMoad+LkVlkvuaVq4TxxFAwoYZxrhazbesolPH+gD2pYgOc893CvHq1VyLUTr0dKul1XidPexQV5n/mS30+6hDHLpeFtFP61t4EwpPLr8gkOQzUskmQZZJmc5DQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679601310; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1QPEuUIaDFfvXGLzy8Z6cRCOywp812xcHdq+YYtOmGU=; b=AWuh/+NZsuzvOpruIFIKfmsunJ8ewBZUDYqSREF2EPGow3VPzOaClIBSu24PjiSWMBBWMiXp1rr0V5uRMinWO7J9UeRwB6PLQ2Bd/qOML2EDr5JyUoeeE7uI0HLsodNz26lXpN42Am57ixzXYyPblMOQ6dFxYH6RXLD86UTV+2k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679601310627952.3319240250997; Thu, 23 Mar 2023 12:55:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfR10-0003G3-R4; Thu, 23 Mar 2023 15:54:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0z-0003FL-2n for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0x-0007Qu-JS for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:24 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-634-qYP1kOAKOJejeatUMnitpQ-1; Thu, 23 Mar 2023 15:54:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E915A884EC3; Thu, 23 Mar 2023 19:54:17 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49B1451FF; Thu, 23 Mar 2023 19:54:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679601263; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1QPEuUIaDFfvXGLzy8Z6cRCOywp812xcHdq+YYtOmGU=; b=KDIGIg8vDEbrIi4XBjaEQPYEMSxgBfA3bu/ZTyrMUYT9rQ2EFOg2N19CnSSic6172LSxEO CQIgL1hyxlmsk2I2mwm15yde3bxM+aW5E4PrFE8GxMSibNtEAAi/80gh4rQuAuhzNuFXtj YkKnfZB/gOO9878cfkaJ3oNXL6FtoZ4= X-MC-Unique: qYP1kOAKOJejeatUMnitpQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Gautam Dawar , Jason Wang , alvaro.karsz@solid-run.com, "Gonglei (Arei)" , Lei Yang , si-wei.liu@oracle.com, Eli Cohen , Shannon Nelson , Laurent Vivier , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Zhu Lingshan , Cindy Lu , longpeng2@huawei.com, Harpreet Singh Anand Subject: [PATCH for 8.1 v2 3/6] vdpa: add vhost_vdpa_set_dev_features_fd Date: Thu, 23 Mar 2023 20:54:01 +0100 Message-Id: <20230323195404.1247326-4-eperezma@redhat.com> In-Reply-To: <20230323195404.1247326-1-eperezma@redhat.com> References: <20230323195404.1247326-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679601312713100003 This allows to set the features of a vhost-vdpa device from external subsystems like vhost-net. It is used in subsequent patches to negotiate features and probe for CVQ ASID isolation. Reviewed-by: Stefano Garzarella Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang --- include/hw/virtio/vhost-vdpa.h | 1 + hw/virtio/vhost-vdpa.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 28de7da91e..a9cb6f3a32 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -55,6 +55,7 @@ typedef struct vhost_vdpa { } VhostVDPA; =20 void vhost_vdpa_reset_status_fd(int fd); +int vhost_vdpa_set_dev_features_fd(int fd, uint64_t features); int vhost_vdpa_get_iova_range(int fd, struct vhost_vdpa_iova_range *iova_r= ange); =20 int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 7a2053b8d9..acd5be46a9 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -651,11 +651,22 @@ static int vhost_vdpa_set_mem_table(struct vhost_dev = *dev, return 0; } =20 +int vhost_vdpa_set_dev_features_fd(int fd, uint64_t features) +{ + int ret; + + ret =3D vhost_vdpa_call_fd(fd, VHOST_SET_FEATURES, &features); + if (ret) { + return ret; + } + + return vhost_vdpa_add_status_fd(fd, VIRTIO_CONFIG_S_FEATURES_OK); +} + static int vhost_vdpa_set_features(struct vhost_dev *dev, uint64_t features) { struct vhost_vdpa *v =3D dev->opaque; - int ret; =20 if (!vhost_vdpa_first_dev(dev)) { return 0; @@ -678,12 +689,7 @@ static int vhost_vdpa_set_features(struct vhost_dev *d= ev, } =20 trace_vhost_vdpa_set_features(dev, features); - ret =3D vhost_vdpa_call(dev, VHOST_SET_FEATURES, &features); - if (ret) { - return ret; - } - - return vhost_vdpa_add_status(dev, VIRTIO_CONFIG_S_FEATURES_OK); + return vhost_vdpa_set_dev_features_fd(vhost_vdpa_dev_fd(dev), features= ); } =20 static int vhost_vdpa_set_backend_cap(struct vhost_dev *dev) --=20 2.31.1 From nobody Mon Apr 29 14:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679601317; cv=none; d=zohomail.com; s=zohoarc; b=XgypHrkrkfhvr+VPGX0q0NdIC5z8nk65kCTSU3NGmCheoeAr8WFRZRioXjg3Mk4+J8vyLH+k1E/p9+wHa/zFctPrZTAHThiaqLqcNJOhFjfqk80elLaNY0fDiw6fQ0kUDiwH8A37fEQcNMAKxIVAy8Y5ixZ1EZyBOvpOj5dm40U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679601317; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FJ/a51ubUh29zjleAZFiNilZ6DElrWQ6ax23K4vEkh4=; b=Nn9m5rVr/UjiFrRlx2nuSCm7CefInCSBjL0lOvrwtzvQBlYbJL9R+k5RFuWnGR8IuHOqWNMK1knjiiKfcwy8z8v8GT5e+tOrnajEqfa59cGpX/ye39PoAu/JqCH7b3zUd68mA21GECTsVTqU5UQ1T7OIhvMfli8UaswRfjJe6t8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679601317725214.30601133101504; Thu, 23 Mar 2023 12:55:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfR12-0003GT-Re; Thu, 23 Mar 2023 15:54:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR11-0003GJ-3G for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR0z-0007RK-Jv for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:26 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-125-atdARaRgMjiLEmCh82KuMQ-1; Thu, 23 Mar 2023 15:54:21 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5AC93C0ED70; Thu, 23 Mar 2023 19:54:20 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 323DD44002; Thu, 23 Mar 2023 19:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679601265; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FJ/a51ubUh29zjleAZFiNilZ6DElrWQ6ax23K4vEkh4=; b=P/bE5D5xawf1vLhKMqrqgBZKg8uCIDZX5oWIy0z2y57nLT70HSGqRedjCTRPdfYQ1yt0VA KaSj6VQNnxVzazyVdrpu2uHqHP7Bl0zalRjvqpVBylf5nwZw9YmuNY3NeB1LPNDHLgSTvH oH63LvXOsyBo0RUQQrGB5uQpOgl7MXs= X-MC-Unique: atdARaRgMjiLEmCh82KuMQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Gautam Dawar , Jason Wang , alvaro.karsz@solid-run.com, "Gonglei (Arei)" , Lei Yang , si-wei.liu@oracle.com, Eli Cohen , Shannon Nelson , Laurent Vivier , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Zhu Lingshan , Cindy Lu , longpeng2@huawei.com, Harpreet Singh Anand Subject: [PATCH for 8.1 v2 4/6] vdpa: return errno in vhost_vdpa_get_vring_group error Date: Thu, 23 Mar 2023 20:54:02 +0100 Message-Id: <20230323195404.1247326-5-eperezma@redhat.com> In-Reply-To: <20230323195404.1247326-1-eperezma@redhat.com> References: <20230323195404.1247326-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679601318904100001 We need to tell in the caller, as some errors are expected in a normal workflow. In particular, parent drivers in recent kernels with VHOST_BACKEND_F_IOTLB_ASID may not support vring groups. In that case, -ENOTSUP is returned. This is the case of vp_vdpa in Linux 6.2. Next patches in this series will use that information to know if it must abort or not. Also, next patches return properly an errp instead of printing with error_report. Signed-off-by: Eugenio P=C3=A9rez Acked-by: Jason Wang Reviewed-by: Stefano Garzarella --- net/vhost-vdpa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 99904a0da7..4397c0d4b3 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -361,6 +361,14 @@ static NetClientInfo net_vhost_vdpa_info =3D { .check_peer_type =3D vhost_vdpa_check_peer_type, }; =20 +/** + * Get vring virtqueue group + * + * @device_fd vdpa device fd + * @vq_index Virtqueue index + * + * Return -errno in case of error, or vq group if success. + */ static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index) { struct vhost_vring_state state =3D { @@ -369,6 +377,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd= , unsigned vq_index) int r =3D ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, &state); =20 if (unlikely(r < 0)) { + r =3D -errno; error_report("Cannot get VQ %u group: %s", vq_index, g_strerror(errno)); return r; --=20 2.31.1 From nobody Mon Apr 29 14:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679601338; cv=none; d=zohomail.com; s=zohoarc; b=dhb1A68wAe7KLLOxKohH9qPen+jtejKPifcYaDb5982AKfLDTaZYaPkCc25C87L7RKkO1AV0tFQTOVf3QBE7jr/lj9xKLmVbq1dxgBZSzladatj6Wjr5qeO3lcOohairTnSElYYDXGErzLux1VSz/boIEBwlVFbbhwv1nrc+L54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679601338; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S1d0H+kTzSqjjoQaUXsxGbhYuR/JutnAhjTKa0Z5NaY=; b=HIKbSRZYuu8zOhHt6k+IR0x/sn80qxz8frlvDVLAQ1zOslE/QlHycX5dhllZwjlshw1cpwa8HrzEs3tMSxkJS7LNL2E6BkRlXOeUjBrv2EAd7Za420o6hfbUs6aQRubJgoNStvKh8gLIuSwyTi0cJxDc37Pm5sHUHQWJjKdokFU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679601338060117.95129572520011; Thu, 23 Mar 2023 12:55:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfR15-0003H1-HL; Thu, 23 Mar 2023 15:54:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR14-0003Gq-GP for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR12-0007Rd-Jq for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-546-7rsNOGJrMK6tfRN7I5WJtQ-1; Thu, 23 Mar 2023 15:54:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C5852802D1A; Thu, 23 Mar 2023 19:54:23 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F5B851FF; Thu, 23 Mar 2023 19:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679601268; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S1d0H+kTzSqjjoQaUXsxGbhYuR/JutnAhjTKa0Z5NaY=; b=AjtGuymvTbf7wr/MuBRkrcCYw6tibRC/EdJ2p9wTyKc8I6vet5U3gWPKzBehbCuYev9Amz gJFjcdD/JkA9/YUhIMwNoXFwURce85MjgmSXi/iBxPPZpKdN3wh5DYpraXFtj9bY6NmsUx Ezu+Kp0/qHKBnlIpzXpdnt4GQiA/bmI= X-MC-Unique: 7rsNOGJrMK6tfRN7I5WJtQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Gautam Dawar , Jason Wang , alvaro.karsz@solid-run.com, "Gonglei (Arei)" , Lei Yang , si-wei.liu@oracle.com, Eli Cohen , Shannon Nelson , Laurent Vivier , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Zhu Lingshan , Cindy Lu , longpeng2@huawei.com, Harpreet Singh Anand Subject: [PATCH for 8.1 v2 5/6] vdpa: move CVQ isolation check to net_init_vhost_vdpa Date: Thu, 23 Mar 2023 20:54:03 +0100 Message-Id: <20230323195404.1247326-6-eperezma@redhat.com> In-Reply-To: <20230323195404.1247326-1-eperezma@redhat.com> References: <20230323195404.1247326-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679601338876100001 Evaluating it at start time instead of initialization time may make the guest capable of dynamically adding or removing migration blockers. Also, moving to initialization reduces the number of ioctls in the migration, reducing failure possibilities. As a drawback we need to check for CVQ isolation twice: one time with no MQ negotiated and another one acking it, as long as the device supports it. This is because Vring ASID / group management is based on vq indexes, but we don't know the index of CVQ before negotiating MQ. Signed-off-by: Eugenio P=C3=A9rez --- v2: Take out the reset of the device from vhost_vdpa_cvq_is_isolated --- net/vhost-vdpa.c | 194 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 151 insertions(+), 43 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 4397c0d4b3..db2c9afcb3 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -43,6 +43,13 @@ typedef struct VhostVDPAState { =20 /* The device always have SVQ enabled */ bool always_svq; + + /* The device can isolate CVQ in its own ASID if MQ is negotiated */ + bool cvq_isolated_mq; + + /* The device can isolate CVQ in its own ASID if MQ is not negotiated = */ + bool cvq_isolated; + bool started; } VhostVDPAState; =20 @@ -361,15 +368,8 @@ static NetClientInfo net_vhost_vdpa_info =3D { .check_peer_type =3D vhost_vdpa_check_peer_type, }; =20 -/** - * Get vring virtqueue group - * - * @device_fd vdpa device fd - * @vq_index Virtqueue index - * - * Return -errno in case of error, or vq group if success. - */ -static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index) +static int64_t vhost_vdpa_get_vring_group(int device_fd, unsigned vq_index, + Error **errp) { struct vhost_vring_state state =3D { .index =3D vq_index, @@ -378,8 +378,7 @@ static int64_t vhost_vdpa_get_vring_group(int device_fd= , unsigned vq_index) =20 if (unlikely(r < 0)) { r =3D -errno; - error_report("Cannot get VQ %u group: %s", vq_index, - g_strerror(errno)); + error_setg_errno(errp, errno, "Cannot get VQ %u group", vq_index); return r; } =20 @@ -479,9 +478,9 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) { VhostVDPAState *s, *s0; struct vhost_vdpa *v; - uint64_t backend_features; int64_t cvq_group; - int cvq_index, r; + int r; + Error *err =3D NULL; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 @@ -501,42 +500,29 @@ static int vhost_vdpa_net_cvq_start(NetClientState *n= c) /* * If we early return in these cases SVQ will not be enabled. The migr= ation * will be blocked as long as vhost-vdpa backends will not offer _F_LO= G. - * - * Calling VHOST_GET_BACKEND_FEATURES as they are not available in v->= dev - * yet. */ - r =3D ioctl(v->device_fd, VHOST_GET_BACKEND_FEATURES, &backend_feature= s); - if (unlikely(r < 0)) { - error_report("Cannot get vdpa backend_features: %s(%d)", - g_strerror(errno), errno); - return -1; - } - if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID)) || - !vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { + if (!vhost_vdpa_net_valid_svq_features(v->dev->features, NULL)) { return 0; } =20 - /* - * Check if all the virtqueues of the virtio device are in a different= vq - * than the last vq. VQ group of last group passed in cvq_group. - */ - cvq_index =3D v->dev->vq_index_end - 1; - cvq_group =3D vhost_vdpa_get_vring_group(v->device_fd, cvq_index); - if (unlikely(cvq_group < 0)) { - return cvq_group; - } - for (int i =3D 0; i < cvq_index; ++i) { - int64_t group =3D vhost_vdpa_get_vring_group(v->device_fd, i); - - if (unlikely(group < 0)) { - return group; + if (v->dev->features & BIT_ULL(VIRTIO_NET_F_MQ)) { + if (!s->cvq_isolated_mq) { + return 0; } - - if (group =3D=3D cvq_group) { + } else { + if (!s->cvq_isolated) { return 0; } } =20 + cvq_group =3D vhost_vdpa_get_vring_group(v->device_fd, + v->dev->vq_index_end - 1, + &err); + if (unlikely(cvq_group < 0)) { + error_report_err(err); + return cvq_group; + } + r =3D vhost_vdpa_set_address_space_id(v, cvq_group, VHOST_VDPA_NET_CVQ= _ASID); if (unlikely(r < 0)) { return r; @@ -798,6 +784,116 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_s= vq_ops =3D { .avail_handler =3D vhost_vdpa_net_handle_ctrl_avail, }; =20 +/** + * Probe the device to check control virtqueue is isolated. + * + * @device_fd vhost-vdpa file descriptor + * @features features to negotiate + * @cvq_index Control vq index + * + * Returns -1 in case of error, 0 if false and 1 if true + */ +static int vhost_vdpa_cvq_is_isolated(int device_fd, uint64_t features, + unsigned cvq_index, Error **errp) +{ + int64_t cvq_group; + int r; + + r =3D vhost_vdpa_set_dev_features_fd(device_fd, features); + if (unlikely(r < 0)) { + error_setg_errno(errp, -r, "Cannot set device features"); + return r; + } + + cvq_group =3D vhost_vdpa_get_vring_group(device_fd, cvq_index, errp); + if (unlikely(cvq_group < 0)) { + return cvq_group; + } + + for (int i =3D 0; i < cvq_index; ++i) { + int64_t group =3D vhost_vdpa_get_vring_group(device_fd, i, errp); + + if (unlikely(group < 0)) { + return group; + } + + if (group =3D=3D (int64_t)cvq_group) { + return 0; + } + } + + return 1; +} + +/** + * Probe if CVQ is isolated when the device is MQ and when it is not MQ + * + * @device_fd The vdpa device fd + * @features Features offered by the device. + * @cvq_index The control vq index if mq is negotiated. Ignored + * otherwise. + * @cvq_isolated It'll be set to true if cvq is isolated if mq is not + * negotiated. + * @cvq_isolated_mq It'll be set to true if cvq is isolated if mq is + * negotiated. + * + * Returns -1 in case of failure + */ +static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features, + int cvq_index, bool *cvq_isolate= d, + bool *cvq_isolated_mq, Error **e= rrp) +{ + uint64_t backend_features; + int r; + + ERRP_GUARD(); + + *cvq_isolated =3D false; + *cvq_isolated_mq =3D false; + r =3D ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features); + if (unlikely(r < 0)) { + error_setg_errno(errp, errno, "Cannot get vdpa backend_features"); + return r; + } + + if (!(backend_features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID))) { + return 0; + } + + r =3D vhost_vdpa_cvq_is_isolated(device_fd, + features & ~BIT_ULL(VIRTIO_NET_F_MQ), 2, + errp); + if (unlikely(r < 0)) { + if (r =3D=3D -ENOTSUP) { + /* + * The kernel report VHOST_BACKEND_F_IOTLB_ASID if the vdpa + * frontend support ASID but the parent driver does not. The = CVQ + * cannot be isolated in this case. + */ + error_free(*errp); + *errp =3D NULL; + return 0; + } + + return r; + } + + *cvq_isolated =3D r =3D=3D 1; + vhost_vdpa_reset_status_fd(device_fd); + if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) { + return 0; + } + + r =3D vhost_vdpa_cvq_is_isolated(device_fd, features, cvq_index * 2, e= rrp); + if (unlikely(r < 0)) { + return r; + } + + *cvq_isolated_mq =3D r =3D=3D 1; + vhost_vdpa_reset_status_fd(device_fd); + return 0; +} + static NetClientState *net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name, @@ -807,16 +903,26 @@ static NetClientState *net_vhost_vdpa_init(NetClientS= tate *peer, bool is_datapath, bool svq, struct vhost_vdpa_iova_range iova_r= ange, - uint64_t features) + uint64_t features, + Error **errp) { NetClientState *nc =3D NULL; VhostVDPAState *s; int ret =3D 0; assert(name); + bool cvq_isolated, cvq_isolated_mq; + if (is_datapath) { nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, name); } else { + ret =3D vhost_vdpa_probe_cvq_isolation(vdpa_device_fd, features, + queue_pair_index, &cvq_isolat= ed, + &cvq_isolated_mq, errp); + if (unlikely(ret)) { + return NULL; + } + nc =3D qemu_new_net_control_client(&net_vhost_vdpa_cvq_info, peer, device, name); } @@ -843,6 +949,8 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, =20 s->vhost_vdpa.shadow_vq_ops =3D &vhost_vdpa_net_svq_ops; s->vhost_vdpa.shadow_vq_ops_opaque =3D s; + s->cvq_isolated =3D cvq_isolated; + s->cvq_isolated_mq =3D cvq_isolated_mq; =20 /* * TODO: We cannot migrate devices with CVQ as there is no way to = set @@ -971,7 +1079,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 2, true, opts->x_s= vq, - iova_range, features); + iova_range, features, errp); if (!ncs[i]) goto err; } @@ -979,7 +1087,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, vdpa_device_fd, i, 1, false, - opts->x_svq, iova_range, features); + opts->x_svq, iova_range, features, errp); if (!nc) goto err; } --=20 2.31.1 From nobody Mon Apr 29 14:01:46 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679601352; cv=none; d=zohomail.com; s=zohoarc; b=kQviQcmGgJWPJ/UxuYgPUzGv/WekZ6UD0orToymI0LfYR7z0i3NEaiojJHsJBPA/kcEQ0kQYTchfpSIE9D0YKs8xktGr7/i5aX9BM1McJqTVC4fz9cf6hnu3XqWSXgtCS0Kx3Dqwkq/M9+Hr1nyRcrnmszXGEN9ADBRu3jmddbM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679601352; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=np2EKvRi2WJXUCP9UYg5mok3CE+biqSLgMQXjuNG6dQ=; b=GlTg+/OC4qR9lrZA3p2WbpKX5aY0CQ7riJuQEBmay8bXGQsV3HnQ0Pib6d4o6zz5+dkvudVDcAJv034bN8+3lmvzN2p+bpQG1iHrreD1Af8gq07hpGuc5m01Y+ApJ6WZeD2NBM8h12OZn9o6QIJjB8Eaoiy+0PEIFSSGJQAWtgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1679601352352370.8474504444504; Thu, 23 Mar 2023 12:55:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfR1A-0003ID-CI; Thu, 23 Mar 2023 15:54:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR17-0003HX-R6 for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfR16-0007SF-27 for qemu-devel@nongnu.org; Thu, 23 Mar 2023 15:54:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-345-5PXJLPKCPSKMKckgL49F5w-1; Thu, 23 Mar 2023 15:54:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E6EDF101A550; Thu, 23 Mar 2023 19:54:26 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F59051FF; Thu, 23 Mar 2023 19:54:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679601271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=np2EKvRi2WJXUCP9UYg5mok3CE+biqSLgMQXjuNG6dQ=; b=JsWjClHOdFwPzUnOlnjOC0FLgVZCOhWbwdojGrlfeXoCmf4BuCLr/0+4YSOO7VgQuYRvcK Sc91ml1mI1aWiQaEiamlcm3CEtRjvojCdUoI9UpK96aDylwqhuRfLJPY8fKOGDapIznAlF IoaX9mqj9VKsHPyaZk1ywIOANSgPimk= X-MC-Unique: 5PXJLPKCPSKMKckgL49F5w-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Liuxiangdong , Gautam Dawar , Jason Wang , alvaro.karsz@solid-run.com, "Gonglei (Arei)" , Lei Yang , si-wei.liu@oracle.com, Eli Cohen , Shannon Nelson , Laurent Vivier , "Michael S. Tsirkin" , Stefano Garzarella , Parav Pandit , Zhu Lingshan , Cindy Lu , longpeng2@huawei.com, Harpreet Singh Anand Subject: [PATCH for 8.1 v2 6/6] vdpa: Cache cvq group in VhostVDPAState Date: Thu, 23 Mar 2023 20:54:04 +0100 Message-Id: <20230323195404.1247326-7-eperezma@redhat.com> In-Reply-To: <20230323195404.1247326-1-eperezma@redhat.com> References: <20230323195404.1247326-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679601352917100002 Continue the move of code that interacts with the device from control virtqueue start to control virtqueue init. As with previous patches, it reduces the number of ioctls in the migration, reducing failure possibilities. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index db2c9afcb3..6a60e8cc2b 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -41,6 +41,12 @@ typedef struct VhostVDPAState { void *cvq_cmd_out_buffer; virtio_net_ctrl_ack *status; =20 + /* CVQ group if cvq_isolated_mq */ + uint32_t cvq_group_mq; + + /* CVQ group if cvq_isolated */ + uint32_t cvq_group; + /* The device always have SVQ enabled */ bool always_svq; =20 @@ -480,7 +486,6 @@ static int vhost_vdpa_net_cvq_start(NetClientState *nc) struct vhost_vdpa *v; int64_t cvq_group; int r; - Error *err =3D NULL; =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 @@ -509,18 +514,14 @@ static int vhost_vdpa_net_cvq_start(NetClientState *n= c) if (!s->cvq_isolated_mq) { return 0; } + + cvq_group =3D s->cvq_group_mq; } else { if (!s->cvq_isolated) { return 0; } - } =20 - cvq_group =3D vhost_vdpa_get_vring_group(v->device_fd, - v->dev->vq_index_end - 1, - &err); - if (unlikely(cvq_group < 0)) { - error_report_err(err); - return cvq_group; + cvq_group =3D s->cvq_group; } =20 r =3D vhost_vdpa_set_address_space_id(v, cvq_group, VHOST_VDPA_NET_CVQ= _ASID); @@ -790,11 +791,13 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_s= vq_ops =3D { * @device_fd vhost-vdpa file descriptor * @features features to negotiate * @cvq_index Control vq index + * @pcvq_group: Returns CVQ group if cvq is isolated. * * Returns -1 in case of error, 0 if false and 1 if true */ static int vhost_vdpa_cvq_is_isolated(int device_fd, uint64_t features, - unsigned cvq_index, Error **errp) + unsigned cvq_index, uint32_t *pcvq_g= roup, + Error **errp) { int64_t cvq_group; int r; @@ -810,6 +813,7 @@ static int vhost_vdpa_cvq_is_isolated(int device_fd, ui= nt64_t features, return cvq_group; } =20 + *pcvq_group =3D (uint32_t)cvq_group; for (int i =3D 0; i < cvq_index; ++i) { int64_t group =3D vhost_vdpa_get_vring_group(device_fd, i, errp); =20 @@ -836,12 +840,15 @@ static int vhost_vdpa_cvq_is_isolated(int device_fd, = uint64_t features, * negotiated. * @cvq_isolated_mq It'll be set to true if cvq is isolated if mq is * negotiated. + * @cvq_group CVQ group if MQ is not negotiated. + * @cvq_group_mq CVQ group if MQ is negotiated. * * Returns -1 in case of failure */ static int vhost_vdpa_probe_cvq_isolation(int device_fd, uint64_t features, int cvq_index, bool *cvq_isolate= d, - bool *cvq_isolated_mq, Error **e= rrp) + bool *cvq_isolated_mq, uint32_t = *cvq_group, + uint32_t *cvq_group_mq, Error **= errp) { uint64_t backend_features; int r; @@ -850,6 +857,8 @@ static int vhost_vdpa_probe_cvq_isolation(int device_fd= , uint64_t features, =20 *cvq_isolated =3D false; *cvq_isolated_mq =3D false; + *cvq_group =3D 0; + *cvq_group_mq =3D 0; r =3D ioctl(device_fd, VHOST_GET_BACKEND_FEATURES, &backend_features); if (unlikely(r < 0)) { error_setg_errno(errp, errno, "Cannot get vdpa backend_features"); @@ -862,7 +871,7 @@ static int vhost_vdpa_probe_cvq_isolation(int device_fd= , uint64_t features, =20 r =3D vhost_vdpa_cvq_is_isolated(device_fd, features & ~BIT_ULL(VIRTIO_NET_F_MQ), 2, - errp); + cvq_group, errp); if (unlikely(r < 0)) { if (r =3D=3D -ENOTSUP) { /* @@ -884,7 +893,8 @@ static int vhost_vdpa_probe_cvq_isolation(int device_fd= , uint64_t features, return 0; } =20 - r =3D vhost_vdpa_cvq_is_isolated(device_fd, features, cvq_index * 2, e= rrp); + r =3D vhost_vdpa_cvq_is_isolated(device_fd, features, cvq_index * 2, + cvq_group_mq, errp); if (unlikely(r < 0)) { return r; } @@ -911,6 +921,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, int ret =3D 0; assert(name); bool cvq_isolated, cvq_isolated_mq; + uint32_t cvq_group, cvq_group_mq; =20 if (is_datapath) { nc =3D qemu_new_net_client(&net_vhost_vdpa_info, peer, device, @@ -918,7 +929,8 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, } else { ret =3D vhost_vdpa_probe_cvq_isolation(vdpa_device_fd, features, queue_pair_index, &cvq_isolat= ed, - &cvq_isolated_mq, errp); + &cvq_isolated_mq, &cvq_group, + &cvq_group_mq, errp); if (unlikely(ret)) { return NULL; } @@ -951,6 +963,8 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, s->vhost_vdpa.shadow_vq_ops_opaque =3D s; s->cvq_isolated =3D cvq_isolated; s->cvq_isolated_mq =3D cvq_isolated_mq; + s->cvq_group =3D cvq_group; + s->cvq_group_mq =3D cvq_group_mq; =20 /* * TODO: We cannot migrate devices with CVQ as there is no way to = set --=20 2.31.1