From patchwork Wed Aug 24 18:35:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 1669941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=aV4cxl6w; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MCZbF1WCNz1ygV for ; Thu, 25 Aug 2022 04:37:43 +1000 (AEST) Received: from localhost ([::1]:56482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQvFz-0007dg-OQ for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2022 14:37:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEj-0007aj-EG for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:45929) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEV-0005Ri-C4 for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366164; 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=MFiLWeiVsGEscClQ/MvCKfr/QZjXWkuihIbsMAiGk+o=; b=aV4cxl6wB3b+Iqqj2fdBy8vjwj3nX6vPudViqUjGDKWjndGlawJ6ZObt8vc0AdjZ6wvEFM Z+1/EOU55LCl6ic70aDyEPJLP+5iHTMCpTKQfebW9yp064i4UNFIMBePeYs2OY8gay9Mi0 aExRbpamydhjyL0be1mI6bCSauOGQVs= 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-652-Y_Scn3pLM82iW5zgEw-6Ng-1; Wed, 24 Aug 2022 14:36:00 -0400 X-MC-Unique: Y_Scn3pLM82iW5zgEw-6Ng-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CF8793C0CD5D; Wed, 24 Aug 2022 18:35:59 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50BC72166B26; Wed, 24 Aug 2022 18:35:57 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Stefano Garzarella , "Michael S. Tsirkin" , Liuxiangdong , Stefan Hajnoczi , Laurent Vivier , Cornelia Huck , Gautam Dawar , Jason Wang , Harpreet Singh Anand , "Gonglei (Arei)" , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Eli Cohen Subject: [PATCH v2 1/6] vdpa: Make VhostVDPAState cvq_cmd_out_buffer control ack type Date: Wed, 24 Aug 2022 20:35:46 +0200 Message-Id: <20220824183551.197052-2-eperezma@redhat.com> In-Reply-To: <20220824183551.197052-1-eperezma@redhat.com> References: <20220824183551.197052-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This allows to simplify the code. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 6ce68fcd3f..468e460ac2 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -35,7 +35,9 @@ typedef struct VhostVDPAState { VHostNetState *vhost_net; /* Control commands shadow buffers */ - void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer; + void *cvq_cmd_out_buffer; + virtio_net_ctrl_ack *cvq_cmd_in_buffer; + bool started; } VhostVDPAState; @@ -396,7 +398,7 @@ static int vhost_vdpa_net_load(NetClientState *nc) return dev_written; } - return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) != VIRTIO_NET_OK; + return *s->cvq_cmd_in_buffer != VIRTIO_NET_OK; } return 0; @@ -491,8 +493,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, goto out; } - memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status)); - if (status != VIRTIO_NET_OK) { + if (*s->cvq_cmd_in_buffer != VIRTIO_NET_OK) { return VIRTIO_NET_ERR; } From patchwork Wed Aug 24 18:35:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 1669943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=gOggw3BS; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MCZbm5j8Zz1ygV for ; Thu, 25 Aug 2022 04:38:12 +1000 (AEST) Received: from localhost ([::1]:46788 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQvGU-0000AZ-M2 for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2022 14:38:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEZ-0007a2-Jk for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:36169) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEV-0005Ru-C3 for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366166; 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=naaRwhcnqZscdMw6fcVC2/f7vDSLifPy1NzGabm4hQk=; b=gOggw3BS2KzUx00diqim7H/gjXB8GRGzCzbsGfW28A3Po/TwHfX+/bGeWz6tDZ1S/q45/P qb1QmhVVjd1H6PZ3A1cdSo659FANZMKe9HPppeXkZrojKYomCXrTvHoiRGhObokNhJDl66 iG60/wn21pTl4dQcc06S3/FklgJ+Fn8= 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-156-Q3NFcxfXPWqQEUubYJy4Yg-1; Wed, 24 Aug 2022 14:36:03 -0400 X-MC-Unique: Q3NFcxfXPWqQEUubYJy4Yg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0BAE293248E; Wed, 24 Aug 2022 18:36:02 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C95B2166B29; Wed, 24 Aug 2022 18:35:59 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Stefano Garzarella , "Michael S. Tsirkin" , Liuxiangdong , Stefan Hajnoczi , Laurent Vivier , Cornelia Huck , Gautam Dawar , Jason Wang , Harpreet Singh Anand , "Gonglei (Arei)" , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Eli Cohen Subject: [PATCH v2 2/6] vdpa: extract vhost_vdpa_net_load_mac from vhost_vdpa_net_load Date: Wed, 24 Aug 2022 20:35:47 +0200 Message-Id: <20220824183551.197052-3-eperezma@redhat.com> In-Reply-To: <20220824183551.197052-1-eperezma@redhat.com> References: <20220824183551.197052-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Since there may be many commands we need to issue to load the NIC state, let's split them in individual functions Signed-off-by: Eugenio Pérez --- v2: Add vhost_vdpa_net_load_cmd helper --- net/vhost-vdpa.c | 54 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 468e460ac2..c89e2262d9 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -365,35 +365,31 @@ static ssize_t vhost_vdpa_net_cvq_add(VhostVDPAState *s, size_t out_len, return vhost_svq_poll(svq); } -static int vhost_vdpa_net_load(NetClientState *nc) +static ssize_t vhost_vdpa_net_load_cmd(VhostVDPAState *s, + const struct virtio_net_ctrl_hdr *ctrl, + const void *data, size_t data_size) { - VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); - const struct vhost_vdpa *v = &s->vhost_vdpa; - const VirtIONet *n; - uint64_t features; + assert(data_size < vhost_vdpa_net_cvq_cmd_page_len() - sizeof(*ctrl)); - assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); + memcpy(s->cvq_cmd_out_buffer, ctrl, sizeof(*ctrl)); + memcpy(s->cvq_cmd_out_buffer + sizeof(ctrl), data, data_size); - if (!v->shadow_vqs_enabled) { - return 0; - } + return vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + data_size, + sizeof(virtio_net_ctrl_ack)); +} - n = VIRTIO_NET(v->dev->vdev); - features = n->parent_obj.guest_features; +static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) +{ + uint64_t features = n->parent_obj.guest_features; if (features & BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR)) { const struct virtio_net_ctrl_hdr ctrl = { .class = VIRTIO_NET_CTRL_MAC, .cmd = VIRTIO_NET_CTRL_MAC_ADDR_SET, }; - char *cursor = s->cvq_cmd_out_buffer; ssize_t dev_written; - memcpy(cursor, &ctrl, sizeof(ctrl)); - cursor += sizeof(ctrl); - memcpy(cursor, n->mac, sizeof(n->mac)); - - dev_written = vhost_vdpa_net_cvq_add(s, sizeof(ctrl) + sizeof(n->mac), - sizeof(virtio_net_ctrl_ack)); + dev_written = vhost_vdpa_net_load_cmd(s, &ctrl, n->mac, + sizeof(n->mac)); if (unlikely(dev_written < 0)) { return dev_written; } @@ -404,6 +400,28 @@ static int vhost_vdpa_net_load(NetClientState *nc) return 0; } +static int vhost_vdpa_net_load(NetClientState *nc) +{ + VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v = &s->vhost_vdpa; + const VirtIONet *n; + int r; + + assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA); + + if (!v->shadow_vqs_enabled) { + return 0; + } + + n = VIRTIO_NET(v->dev->vdev); + r = vhost_vdpa_net_load_mac(s, n); + if (unlikely(r < 0)) { + return r; + } + + return 0; +} + static NetClientInfo net_vhost_vdpa_cvq_info = { .type = NET_CLIENT_DRIVER_VHOST_VDPA, .size = sizeof(VhostVDPAState), From patchwork Wed Aug 24 18:35:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 1669945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=eAXJIpXn; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MCZgg6914z1ygF for ; Thu, 25 Aug 2022 04:41:35 +1000 (AEST) Received: from localhost ([::1]:54042 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQvJl-0003nL-A5 for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2022 14:41:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEj-0007al-Ul for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEa-0005Sq-BH for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366171; 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=FWGv15i6933p5S0UQDcSLRpXSTNPnB/6M20ffMC4s6Q=; b=eAXJIpXnUp4JZHkr7H9ZgEDGhueXws9BlVRK3YcSNaydc+eBk9fF2O8/ZpcKPC2siWXo0M rd5J2FFIVRscguz6XixP6ykvaphdbLmm+eEdIzWUqhC2X8R+JEij+xO9JGhlaFiH9nsJ9w 20Y4TMb2g1ZvgfZAQj34zK3jr0PZ7+w= 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-120-xzGiJooUMUm47J-QCDSJxQ-1; Wed, 24 Aug 2022 14:36:05 -0400 X-MC-Unique: xzGiJooUMUm47J-QCDSJxQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 66134101AA6A; Wed, 24 Aug 2022 18:36:05 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id E13672166B26; Wed, 24 Aug 2022 18:36:02 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Stefano Garzarella , "Michael S. Tsirkin" , Liuxiangdong , Stefan Hajnoczi , Laurent Vivier , Cornelia Huck , Gautam Dawar , Jason Wang , Harpreet Singh Anand , "Gonglei (Arei)" , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Eli Cohen Subject: [PATCH v2 3/6] vdpa: Add vhost_vdpa_net_load_mq Date: Wed, 24 Aug 2022 20:35:48 +0200 Message-Id: <20220824183551.197052-4-eperezma@redhat.com> In-Reply-To: <20220824183551.197052-1-eperezma@redhat.com> References: <20220824183551.197052-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Same way as with the MAC, restore the expected number of queues at device's start. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index c89e2262d9..77c85f4ddd 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -400,6 +400,30 @@ static int vhost_vdpa_net_load_mac(VhostVDPAState *s, const VirtIONet *n) return 0; } +static int vhost_vdpa_net_load_mq(VhostVDPAState *s, + const VirtIONet *n) +{ + const struct virtio_net_ctrl_hdr ctrl = { + .class = VIRTIO_NET_CTRL_MQ, + .cmd = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET, + }; + struct virtio_net_ctrl_mq mq; + uint64_t features = n->parent_obj.guest_features; + ssize_t dev_written; + + if (!(features & BIT_ULL(VIRTIO_NET_F_MQ))) { + return 0; + } + + mq.virtqueue_pairs = cpu_to_le16(n->curr_queue_pairs); + dev_written = vhost_vdpa_net_load_cmd(s, &ctrl, &mq, sizeof(mq)); + if (unlikely(dev_written < 0)) { + return dev_written; + } + + return *s->cvq_cmd_in_buffer != VIRTIO_NET_OK; +} + static int vhost_vdpa_net_load(NetClientState *nc) { VhostVDPAState *s = DO_UPCAST(VhostVDPAState, nc, nc); @@ -418,6 +442,10 @@ static int vhost_vdpa_net_load(NetClientState *nc) if (unlikely(r < 0)) { return r; } + r = vhost_vdpa_net_load_mq(s, n); + if (unlikely(r)) { + return r; + } return 0; } From patchwork Wed Aug 24 18:35:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 1669946 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=JtCDAMog; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MCZhL11V4z1ygF for ; Thu, 25 Aug 2022 04:42:10 +1000 (AEST) Received: from localhost ([::1]:47948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQvKJ-0004K1-P8 for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2022 14:42:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49810) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEm-0007b1-PU for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29775) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEe-0005Sv-MW for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366171; 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=3skSELz/ftK6DYd0+fbYwIww+EVUIoVg4WOCXikX4qs=; b=JtCDAMogTUghtVws/2f39//rh2PZugyDbqYb8208NmM2hKRuUYsucLeIZG4OGTyzeEKo13 c+kWoGbGWzCuqxTqRwgLgnWP9hNa3NdNE3xWRg1OxBpALLrEtuen17o3/gMPVTLabmH4pv RDki09Y7+2jsN2JPo9WmQtL9VDJH2h8= 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-342-kiY6ccF5M5OlDOGr88jOUA-1; Wed, 24 Aug 2022 14:36:08 -0400 X-MC-Unique: kiY6ccF5M5OlDOGr88jOUA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 30B9C101E9B2; Wed, 24 Aug 2022 18:36:08 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id A85D92166B26; Wed, 24 Aug 2022 18:36:05 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Stefano Garzarella , "Michael S. Tsirkin" , Liuxiangdong , Stefan Hajnoczi , Laurent Vivier , Cornelia Huck , Gautam Dawar , Jason Wang , Harpreet Singh Anand , "Gonglei (Arei)" , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Eli Cohen Subject: [PATCH v2 4/6] vdpa: validate MQ CVQ commands Date: Wed, 24 Aug 2022 20:35:49 +0200 Message-Id: <20220824183551.197052-5-eperezma@redhat.com> In-Reply-To: <20220824183551.197052-1-eperezma@redhat.com> References: <20220824183551.197052-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" So we are sure we can update the device model properly before sending to the device. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 77c85f4ddd..b070c029e7 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -488,6 +488,15 @@ static bool vhost_vdpa_net_cvq_validate_cmd(const void *out_buf, size_t len) __func__, ctrl.cmd); }; break; + case VIRTIO_NET_CTRL_MQ: + switch (ctrl.cmd) { + case VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET: + return true; + default: + qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid mq cmd %u\n", + __func__, ctrl.cmd); + }; + break; default: qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid control class %u\n", __func__, ctrl.class); From patchwork Wed Aug 24 18:35:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 1669949 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=adxO8Z6n; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MCZlc6hSRz1ygF for ; Thu, 25 Aug 2022 04:44:59 +1000 (AEST) Received: from localhost ([::1]:40038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQvN2-0008T0-06 for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2022 14:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEu-0007gf-3e for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEq-0005V9-S8 for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366187; 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=xoutYqkapS/nIMsepScl0jd/aod9k3GRqbKF46hCZW0=; b=adxO8Z6nZLm+2jLz4sEe4Z6olIlTNnTXJdgqT85m3zWyPd50h2km/8OS626ZBzyzp3t3zj AjBpJF+74uV+L67ckE967GREIvO926MX6qaVpK2o2aBlgb3PQMeMCgxAxCoJiRYJF97iN1 QXS8vNlUyzpSD1wyK/PYlBHD5eZnOd4= 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-260-tP36kRF9MYqdDDUpy_rabQ-1; Wed, 24 Aug 2022 14:36:11 -0400 X-MC-Unique: tP36kRF9MYqdDDUpy_rabQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EDE17101A56C; Wed, 24 Aug 2022 18:36:10 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70F032166B26; Wed, 24 Aug 2022 18:36:08 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Stefano Garzarella , "Michael S. Tsirkin" , Liuxiangdong , Stefan Hajnoczi , Laurent Vivier , Cornelia Huck , Gautam Dawar , Jason Wang , Harpreet Singh Anand , "Gonglei (Arei)" , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Eli Cohen Subject: [PATCH v2 5/6] virtio-net: Update virtio-net curr_queue_pairs in vdpa backends Date: Wed, 24 Aug 2022 20:35:50 +0200 Message-Id: <20220824183551.197052-6-eperezma@redhat.com> In-Reply-To: <20220824183551.197052-1-eperezma@redhat.com> References: <20220824183551.197052-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It was returned as error before. Instead of it, simply update the corresponding field so qemu can send it in the migration data. Signed-off-by: Eugenio Pérez --- hw/net/virtio-net.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index dd0d056fde..63a8332cd0 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1412,19 +1412,14 @@ static int virtio_net_handle_mq(VirtIONet *n, uint8_t cmd, return VIRTIO_NET_ERR; } - /* Avoid changing the number of queue_pairs for vdpa device in - * userspace handler. A future fix is needed to handle the mq - * change in userspace handler with vhost-vdpa. Let's disable - * the mq handling from userspace for now and only allow get - * done through the kernel. Ripples may be seen when falling - * back to userspace, but without doing it qemu process would - * crash on a recursive entry to virtio_net_set_status(). - */ + n->curr_queue_pairs = queue_pairs; if (nc->peer && nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) { - return VIRTIO_NET_ERR; + /* + * Avoid updating the backend for a vdpa device: We're only interested + * in updating the device model queues. + */ + return VIRTIO_NET_OK; } - - n->curr_queue_pairs = queue_pairs; /* stop the backend before changing the number of queue_pairs to avoid handling a * disabled queue */ virtio_net_set_status(vdev, vdev->status); From patchwork Wed Aug 24 18:35:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eugenio Perez Martin X-Patchwork-Id: 1669944 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=QdT4Gz+d; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MCZgT3cw5z1ygF for ; Thu, 25 Aug 2022 04:41:25 +1000 (AEST) Received: from localhost ([::1]:53826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oQvJa-0003gh-UE for incoming@patchwork.ozlabs.org; Wed, 24 Aug 2022 14:41:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEr-0007br-3g for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48489) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oQvEh-0005T6-EW for qemu-devel@nongnu.org; Wed, 24 Aug 2022 14:36:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661366177; 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=vldHrZkwaODePCqH6svGbEAIaESOGjjCriCn35ZnDlQ=; b=QdT4Gz+dYLuExbrAxnay4m3kOhiqzVy0yQuECb/gcY8SbvyINWxwyLCY06V/lZKKb2tO9v sUgtIvLN9oqBeErv7yijlYm8WplmyF0k+Aj6nCmywfFmgbqK4jg53Cgn3yGe+ODhI/oiWj R6iCkgU7FA/5u+W7k+KqgGL8Pi+WvoY= 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-512-4P1C38u1NsqK4b0hjo-KHA-1; Wed, 24 Aug 2022 14:36:14 -0400 X-MC-Unique: 4P1C38u1NsqK4b0hjo-KHA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE7CD3C0E227; Wed, 24 Aug 2022 18:36:13 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.193.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CA322166B26; Wed, 24 Aug 2022 18:36:11 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Cindy Lu , Stefano Garzarella , "Michael S. Tsirkin" , Liuxiangdong , Stefan Hajnoczi , Laurent Vivier , Cornelia Huck , Gautam Dawar , Jason Wang , Harpreet Singh Anand , "Gonglei (Arei)" , Parav Pandit , Paolo Bonzini , Zhu Lingshan , Eli Cohen Subject: [PATCH v2 6/6] vdpa: Allow MQ feture in SVQ Date: Wed, 24 Aug 2022 20:35:51 +0200 Message-Id: <20220824183551.197052-7-eperezma@redhat.com> In-Reply-To: <20220824183551.197052-1-eperezma@redhat.com> References: <20220824183551.197052-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Finally enable SVQ with MQ feature. Signed-off-by: Eugenio Pérez --- net/vhost-vdpa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index b070c029e7..0376151b60 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -94,6 +94,7 @@ static const uint64_t vdpa_svq_device_features = BIT_ULL(VIRTIO_NET_F_MRG_RXBUF) | BIT_ULL(VIRTIO_NET_F_STATUS) | BIT_ULL(VIRTIO_NET_F_CTRL_VQ) | + BIT_ULL(VIRTIO_NET_F_MQ) | BIT_ULL(VIRTIO_F_ANY_LAYOUT) | BIT_ULL(VIRTIO_NET_F_CTRL_MAC_ADDR) | BIT_ULL(VIRTIO_NET_F_RSC_EXT) |