From patchwork Mon Sep 12 03:10:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Xu X-Patchwork-Id: 1676689 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=) 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 4MQs824Y6Xz1ypL for ; Mon, 12 Sep 2022 13:11:43 +1000 (AEST) Received: from localhost ([::1]:34120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXZrG-0006UP-Qo for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2022 23:11:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqk-0006Tt-Dg for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:06 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:46951) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqd-0007IO-SN for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:04 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R781e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046056; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0VPNJLNS_1662952250; Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VPNJLNS_1662952250) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 11:10:51 +0800 From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 1/6] net: virtio: rename vhost_set_vring_enable to vhost_set_dev_enable Date: Mon, 12 Sep 2022 11:10:44 +0800 Message-Id: <390f63067306a35c669a6d0cb5ad7ad242a3fcfe.1662949366.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.54; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-54.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" Previously, vhost_set_vring_enable will enable/disable all vrings in a device, which causes ambiguity. So we rename it to vhost_set_dev_enable. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- backends/cryptodev-vhost.c | 12 ++++++------ hw/net/vhost_net-stub.c | 2 +- hw/net/vhost_net.c | 8 ++++---- hw/net/virtio-net.c | 4 ++-- hw/virtio/vhost-user.c | 4 ++-- include/hw/virtio/vhost-backend.h | 6 +++--- include/net/vhost_net.h | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index bc13e466b4..b83e939760 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -147,9 +147,9 @@ cryptodev_vhost_set_vq_index(CryptoDevBackendVhost *crypto, } static int -vhost_set_vring_enable(CryptoDevBackendClient *cc, - CryptoDevBackend *b, - uint16_t queue, int enable) +vhost_set_dev_enable(CryptoDevBackendClient *cc, + CryptoDevBackend *b, + uint16_t queue, int enable) { CryptoDevBackendVhost *crypto = cryptodev_get_vhost(cc, b, queue); @@ -162,8 +162,8 @@ vhost_set_vring_enable(CryptoDevBackendClient *cc, } vhost_ops = crypto->dev.vhost_ops; - if (vhost_ops->vhost_set_vring_enable) { - return vhost_ops->vhost_set_vring_enable(&crypto->dev, enable); + if (vhost_ops->vhost_set_dev_enable) { + return vhost_ops->vhost_set_dev_enable(&crypto->dev, enable); } return 0; @@ -219,7 +219,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_queues) if (cc->vring_enable) { /* restore vring enable state */ - r = vhost_set_vring_enable(cc, b, i, cc->vring_enable); + r = vhost_set_dev_enable(cc, b, i, cc->vring_enable); if (r < 0) { goto err_start; diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c index 89d71cfb8e..ac5f217dc1 100644 --- a/hw/net/vhost_net-stub.c +++ b/hw/net/vhost_net-stub.c @@ -92,7 +92,7 @@ VHostNetState *get_vhost_net(NetClientState *nc) return 0; } -int vhost_set_vring_enable(NetClientState *nc, int enable) +int vhost_set_dev_enable(NetClientState *nc, int enable) { return 0; } diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 97cdf9280b..ea896ea75b 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -396,7 +396,7 @@ int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, if (peer->vring_enable) { /* restore vring enable state */ - r = vhost_set_vring_enable(peer, peer->vring_enable); + r = vhost_set_dev_enable(peer, peer->vring_enable); if (r < 0) { vhost_net_stop_one(get_vhost_net(peer), dev); @@ -508,15 +508,15 @@ VHostNetState *get_vhost_net(NetClientState *nc) return vhost_net; } -int vhost_set_vring_enable(NetClientState *nc, int enable) +int vhost_set_dev_enable(NetClientState *nc, int enable) { VHostNetState *net = get_vhost_net(nc); const VhostOps *vhost_ops = net->dev.vhost_ops; nc->vring_enable = enable; - if (vhost_ops && vhost_ops->vhost_set_vring_enable) { - return vhost_ops->vhost_set_vring_enable(&net->dev, enable); + if (vhost_ops && vhost_ops->vhost_set_dev_enable) { + return vhost_ops->vhost_set_dev_enable(&net->dev, enable); } return 0; diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7817206596..6ab796b399 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -696,7 +696,7 @@ static int peer_attach(VirtIONet *n, int index) } if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) { - vhost_set_vring_enable(nc->peer, 1); + vhost_set_dev_enable(nc->peer, 1); } if (nc->peer->info->type != NET_CLIENT_DRIVER_TAP) { @@ -719,7 +719,7 @@ static int peer_detach(VirtIONet *n, int index) } if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER) { - vhost_set_vring_enable(nc->peer, 0); + vhost_set_dev_enable(nc->peer, 0); } if (nc->peer->info->type != NET_CLIENT_DRIVER_TAP) { diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index bd24741be8..794519359b 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1198,7 +1198,7 @@ static int vhost_user_set_vring_base(struct vhost_dev *dev, return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring); } -static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable) +static int vhost_user_set_dev_enable(struct vhost_dev *dev, int enable) { int i; @@ -2627,7 +2627,7 @@ const VhostOps user_ops = { .vhost_set_owner = vhost_user_set_owner, .vhost_reset_device = vhost_user_reset_device, .vhost_get_vq_index = vhost_user_get_vq_index, - .vhost_set_vring_enable = vhost_user_set_vring_enable, + .vhost_set_dev_enable = vhost_user_set_dev_enable, .vhost_requires_shm_log = vhost_user_requires_shm_log, .vhost_migration_done = vhost_user_migration_done, .vhost_backend_can_merge = vhost_user_can_merge, diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index eab46d7f0b..b49432045f 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -81,8 +81,8 @@ typedef int (*vhost_set_backend_cap_op)(struct vhost_dev *dev); typedef int (*vhost_set_owner_op)(struct vhost_dev *dev); typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); -typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, - int enable); +typedef int (*vhost_set_dev_enable_op)(struct vhost_dev *dev, + int enable); typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); typedef int (*vhost_migration_done_op)(struct vhost_dev *dev, char *mac_addr); @@ -155,7 +155,7 @@ typedef struct VhostOps { vhost_set_owner_op vhost_set_owner; vhost_reset_device_op vhost_reset_device; vhost_get_vq_index_op vhost_get_vq_index; - vhost_set_vring_enable_op vhost_set_vring_enable; + vhost_set_dev_enable_op vhost_set_dev_enable; vhost_requires_shm_log_op vhost_requires_shm_log; vhost_migration_done_op vhost_migration_done; vhost_backend_can_merge_op vhost_backend_can_merge; diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index 40b9a40074..22a1fcd39e 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -42,7 +42,7 @@ void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev, int vhost_net_notify_migration_done(VHostNetState *net, char* mac_addr); VHostNetState *get_vhost_net(NetClientState *nc); -int vhost_set_vring_enable(NetClientState * nc, int enable); +int vhost_set_dev_enable(NetClientState *nc, int enable); uint64_t vhost_net_get_acked_features(VHostNetState *net); From patchwork Mon Sep 12 03:10:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Xu X-Patchwork-Id: 1676690 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=) 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 4MQs824CvZz1ynm for ; Mon, 12 Sep 2022 13:11:43 +1000 (AEST) Received: from localhost ([::1]:34122 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXZrI-0006VD-4z for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2022 23:11:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqk-0006Ts-Ig for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:06 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:48339) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqd-0007IP-Uc for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:04 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R111e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046056; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0VPNH8U2_1662952251; Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VPNH8U2_1662952251) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 11:10:52 +0800 From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 2/6] vhost-user: add op to enable or disable a single vring Date: Mon, 12 Sep 2022 11:10:45 +0800 Message-Id: <985e7facb121059d06631a9688e93d11e453795c.1662949366.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.132; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-132.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" There is only vhost_set_dev_enable op in VhostOps. Thus, we introduce the interface vhost_set_vring_enable to set the enable status for a single vring. Resetting a single vq will rely on this interface. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/virtio/vhost-user.c | 25 ++++++++++++++++++------- include/hw/virtio/vhost-backend.h | 3 +++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 794519359b..3f140d5085 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1198,6 +1198,22 @@ static int vhost_user_set_vring_base(struct vhost_dev *dev, return vhost_set_vring(dev, VHOST_USER_SET_VRING_BASE, ring); } +static int vhost_user_set_vring_enable(struct vhost_dev *dev, + int index, + int enable) +{ + if (index < dev->vq_index || index >= dev->vq_index + dev->nvqs) { + return -EINVAL; + } + + struct vhost_vring_state state = { + .index = index, + .num = enable, + }; + + return vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); +} + static int vhost_user_set_dev_enable(struct vhost_dev *dev, int enable) { int i; @@ -1207,13 +1223,7 @@ static int vhost_user_set_dev_enable(struct vhost_dev *dev, int enable) } for (i = 0; i < dev->nvqs; ++i) { - int ret; - struct vhost_vring_state state = { - .index = dev->vq_index + i, - .num = enable, - }; - - ret = vhost_set_vring(dev, VHOST_USER_SET_VRING_ENABLE, &state); + int ret = vhost_user_set_vring_enable(dev, dev->vq_index + i, enable); if (ret < 0) { /* * Restoring the previous state is likely infeasible, as well as @@ -2627,6 +2637,7 @@ const VhostOps user_ops = { .vhost_set_owner = vhost_user_set_owner, .vhost_reset_device = vhost_user_reset_device, .vhost_get_vq_index = vhost_user_get_vq_index, + .vhost_set_vring_enable = vhost_user_set_vring_enable, .vhost_set_dev_enable = vhost_user_set_dev_enable, .vhost_requires_shm_log = vhost_user_requires_shm_log, .vhost_migration_done = vhost_user_migration_done, diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h index b49432045f..dad7191bac 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -81,6 +81,8 @@ typedef int (*vhost_set_backend_cap_op)(struct vhost_dev *dev); typedef int (*vhost_set_owner_op)(struct vhost_dev *dev); typedef int (*vhost_reset_device_op)(struct vhost_dev *dev); typedef int (*vhost_get_vq_index_op)(struct vhost_dev *dev, int idx); +typedef int (*vhost_set_vring_enable_op)(struct vhost_dev *dev, + int index, int enable); typedef int (*vhost_set_dev_enable_op)(struct vhost_dev *dev, int enable); typedef bool (*vhost_requires_shm_log_op)(struct vhost_dev *dev); @@ -155,6 +157,7 @@ typedef struct VhostOps { vhost_set_owner_op vhost_set_owner; vhost_reset_device_op vhost_reset_device; vhost_get_vq_index_op vhost_get_vq_index; + vhost_set_vring_enable_op vhost_set_vring_enable; vhost_set_dev_enable_op vhost_set_dev_enable; vhost_requires_shm_log_op vhost_requires_shm_log; vhost_migration_done_op vhost_migration_done; From patchwork Mon Sep 12 03:10:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Xu X-Patchwork-Id: 1676694 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=) 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 4MQsCY4CN8z1ypL for ; Mon, 12 Sep 2022 13:14:49 +1000 (AEST) Received: from localhost ([::1]:48454 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXZuJ-0004Ap-Gr for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2022 23:14:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZql-0006Tr-QE for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:07 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:57816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqd-0007IM-Tk for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:04 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R211e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046051; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0VPNIbvR_1662952252; Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VPNIbvR_1662952252) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 11:10:53 +0800 From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 3/6] vhost-net: vhost-user: update vhost_net_virtqueue_reset() Date: Mon, 12 Sep 2022 11:10:46 +0800 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.54; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-54.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" Update vhost_net_virtqueue_reset() for vhost-user scenario. In order to reuse some functions, we process the idx for vhost-user scenario because vhost_get_vq_index behave differently for vhost-user. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index ea896ea75b..25e5665489 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -545,6 +545,9 @@ void vhost_net_virtqueue_reset(VirtIODevice *vdev, NetClientState *nc, assert(vhost_ops); idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index); + if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) { + idx -= net->dev.vq_index; + } if (net->nc->info->type == NET_CLIENT_DRIVER_TAP) { file.index = idx; From patchwork Mon Sep 12 03:10:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Xu X-Patchwork-Id: 1676695 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=) 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 4MQsGb0q9Cz1ync for ; Mon, 12 Sep 2022 13:17:25 +1000 (AEST) Received: from localhost ([::1]:52218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXZwj-0007Cz-Sn for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2022 23:17:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZql-0006Tv-QK for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:07 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:51976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqd-0007IR-Vp for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:05 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R261e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045168; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0VPNJLP1_1662952253; Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VPNJLP1_1662952253) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 11:10:54 +0800 From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 4/6] vhost-net: vhost-user: update vhost_net_virtqueue_restart() Date: Mon, 12 Sep 2022 11:10:47 +0800 Message-Id: <2f51b68283755fe268dd4ce30a8cae7b1488e903.1662949366.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.54; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-54.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" Update vhost_net_virtqueue_restart() for vhost-user scenario. In order to reuse some functions, we process the idx for vhost-user case. It is because vhost_get_vq_index behave differently in vhost-user. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo --- hw/net/vhost_net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 25e5665489..8b80942e7c 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -577,6 +577,9 @@ int vhost_net_virtqueue_restart(VirtIODevice *vdev, NetClientState *nc, assert(vhost_ops); idx = vhost_ops->vhost_get_vq_index(&net->dev, vq_index); + if (net->nc->info->type == NET_CLIENT_DRIVER_VHOST_USER) { + idx -= net->dev.vq_index; + } r = vhost_virtqueue_start(&net->dev, vdev, From patchwork Mon Sep 12 03:10:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Xu X-Patchwork-Id: 1676693 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=) 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 4MQsCY1TtXz1ynm for ; Mon, 12 Sep 2022 13:14:49 +1000 (AEST) Received: from localhost ([::1]:48456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXZuJ-0004B3-49 for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2022 23:14:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZql-0006Tw-QL for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:07 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:33636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqe-0007Ib-IB for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:05 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R211e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045168; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0VPNIbwO_1662952254; Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VPNIbwO_1662952254) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 11:10:55 +0800 From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 5/6] virtio-net: vhost-user: update queue_reset and queue_enable Date: Mon, 12 Sep 2022 11:10:48 +0800 Message-Id: <407c17b9a62bb7be06423b00a77b0fe301dc46de.1662949366.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.132; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-132.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" Update virtio_net_queue_reset() and virtio_net_queue_enable() for vhost-user scenario. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/net/virtio-net.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 6ab796b399..19a2132180 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -550,7 +550,8 @@ static void virtio_net_queue_reset(VirtIODevice *vdev, uint32_t queue_index) } if (get_vhost_net(nc->peer) && - nc->peer->info->type == NET_CLIENT_DRIVER_TAP) { + (nc->peer->info->type == NET_CLIENT_DRIVER_TAP || + nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER)) { vhost_net_virtqueue_reset(vdev, nc, queue_index); } @@ -568,7 +569,8 @@ static void virtio_net_queue_enable(VirtIODevice *vdev, uint32_t queue_index) } if (get_vhost_net(nc->peer) && - nc->peer->info->type == NET_CLIENT_DRIVER_TAP) { + (nc->peer->info->type == NET_CLIENT_DRIVER_TAP || + nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_USER)) { r = vhost_net_virtqueue_restart(vdev, nc, queue_index); if (r < 0) { error_report("unable to restart vhost net virtqueue: %d, " From patchwork Mon Sep 12 03:10:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Xu X-Patchwork-Id: 1676691 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=) 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 4MQs9q2kNRz1ypL for ; Mon, 12 Sep 2022 13:13:19 +1000 (AEST) Received: from localhost ([::1]:50588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oXZsq-0001MJ-Vt for incoming@patchwork.ozlabs.org; Sun, 11 Sep 2022 23:13:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqk-0006Tq-Ih for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:06 -0400 Received: from out30-54.freemail.mail.aliyun.com ([115.124.30.54]:34082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oXZqd-0007IZ-VV for qemu-devel@nongnu.org; Sun, 11 Sep 2022 23:11:04 -0400 X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R191e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018046050; MF=kangjie.xu@linux.alibaba.com; NM=1; PH=DS; RN=6; SR=0; TI=SMTPD_---0VPNH8Vs_1662952255; Received: from localhost(mailfrom:kangjie.xu@linux.alibaba.com fp:SMTPD_---0VPNH8Vs_1662952255) by smtp.aliyun-inc.com; Mon, 12 Sep 2022 11:10:56 +0800 From: Kangjie Xu To: qemu-devel@nongnu.org Cc: mst@redhat.com, jasowang@redhat.com, arei.gonglei@huawei.com, hengqi@linux.alibaba.com, xuanzhuo@linux.alibaba.com Subject: [PATCH v2 6/6] vhost: vhost-user: enable vq reset feature Date: Mon, 12 Sep 2022 11:10:49 +0800 Message-Id: <6349759c3ec0fae409f730dfce70240eb255b608.1662949366.git.kangjie.xu@linux.alibaba.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=115.124.30.54; envelope-from=kangjie.xu@linux.alibaba.com; helo=out30-54.freemail.mail.aliyun.com X-Spam_score_int: -98 X-Spam_score: -9.9 X-Spam_bar: --------- X-Spam_report: (-9.9 / 5.0 requ) BAYES_00=-1.9, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_SPF_WL=-7.5 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" Add virtqueue reset feature for vhost-user. Signed-off-by: Kangjie Xu Signed-off-by: Xuan Zhuo Acked-by: Jason Wang --- hw/net/vhost_net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 8b80942e7c..ad319faee8 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -74,6 +74,7 @@ static const int user_feature_bits[] = { VIRTIO_NET_F_MTU, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_RING_PACKED, + VIRTIO_F_RING_RESET, VIRTIO_NET_F_RSS, VIRTIO_NET_F_HASH_REPORT,