From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CB638C43217 for ; Wed, 9 Feb 2022 12:29:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 84AD74154E; Wed, 9 Feb 2022 12:29:20 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id REv0c22dxzwn; Wed, 9 Feb 2022 12:29:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTPS id BE0B8415E2; Wed, 9 Feb 2022 12:29:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8D3C3C0011; Wed, 9 Feb 2022 12:29:17 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 932C9C0077 for ; Wed, 9 Feb 2022 12:29:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7A04540488 for ; Wed, 9 Feb 2022 12:29:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kOQrcmXdnvi7 for ; Wed, 9 Feb 2022 12:29:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by smtp2.osuosl.org (Postfix) with ESMTPS id 70BE2404B7 for ; Wed, 9 Feb 2022 12:29:12 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R101e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e04357; MF=xuanzhuo@linux.alibaba.com; NM=1; PH=DS; RN=4; SR=0; TI=SMTPD_---0V4.8o04_1644409748; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0V4.8o04_1644409748) by smtp.aliyun-inc.com(127.0.0.1); Wed, 09 Feb 2022 20:29:09 +0800 From: Xuan Zhuo To: linux-kernel@vger.kernel.org Subject: [PATCH v4 09/14] virtio: queue_reset: struct virtio_config_ops add callbacks for queue_reset Date: Wed, 9 Feb 2022 20:28:56 +0800 Message-Id: <20220209122901.51790-10-xuanzhuo@linux.alibaba.com> X-Mailer: git-send-email 2.31.0 In-Reply-To: <20220209122901.51790-1-xuanzhuo@linux.alibaba.com> References: <20220209122901.51790-1-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 Cc: virtualization@lists.linux-foundation.org, "Michael S. Tsirkin" X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" Performing reset on a queue is divided into four steps: 1. reset_vq: reset one vq 2. recycle the buffer from vq by virtqueue_detach_unused_buf() 3. release the ring of the vq by vring_release_virtqueue() 4. enable_reset_vq: re-enable the reset queue So add two callbacks reset_vq, enable_reset_vq to struct virtio_config_ops. Signed-off-by: Xuan Zhuo --- include/linux/virtio_config.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 4d107ad31149..0d01a64f2576 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -74,6 +74,17 @@ struct virtio_shm_region { * @set_vq_affinity: set the affinity for a virtqueue (optional). * @get_vq_affinity: get the affinity for a virtqueue (optional). * @get_shm_region: get a shared memory region based on the index. + * @reset_vq: reset a queue individually + * vq: the virtqueue + * Returns 0 on success or error status + * After successfully calling this, be sure to call + * virtqueue_detach_unused_buf() to recycle the buffer in the ring, and + * then call vring_release_virtqueue() to release the vq ring. + * @enable_reset_vq: enable a reset queue + * vq: the virtqueue + * ring_num: specify ring num for the vq to be re-enabled. 0 means use the + * default value. MUST be a power of 2. + * Returns 0 on success or error status */ typedef void vq_callback_t(struct virtqueue *); struct virtio_config_ops { @@ -100,6 +111,8 @@ struct virtio_config_ops { int index); bool (*get_shm_region)(struct virtio_device *vdev, struct virtio_shm_region *region, u8 id); + int (*reset_vq)(struct virtqueue *vq); + int (*enable_reset_vq)(struct virtqueue *vq, u16 ring_num); }; /* If driver didn't advertise the feature, it will never appear. */ -- 2.31.0 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization