From patchwork Wed Jul 20 06:59:25 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: 1658354 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=ZoPyMcpJ; dkim-atps=neutral Authentication-Results: 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-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Lnmpn4lq8z9sFr for ; Wed, 20 Jul 2022 17:02:08 +1000 (AEST) Received: from localhost ([::1]:52536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oE3ie-0000IB-8L for incoming@patchwork.ozlabs.org; Wed, 20 Jul 2022 03:02:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33372) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oE3gd-0000HT-5Y for qemu-devel@nongnu.org; Wed, 20 Jul 2022 02:59:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:20994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oE3gb-0006Ci-2o for qemu-devel@nongnu.org; Wed, 20 Jul 2022 02:59:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658300396; 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; bh=PlVDVkJta6omSPb0x3dTfDeaCxRBXLCjfwSb4mOqoOQ=; b=ZoPyMcpJsYmQeTXITFM6kmbgdWt/PCaQSKFXNgm+8pEltRpBpi4vNUa6S4DIZzQZyuTBcZ epf/35YRbScAXZSFe+UkG/2TtpG9ZhqqgklonJYn0/0k0BXttecOaoM0PiTijK0Ucpw2i3 DFQsxsJolvW5XXLEg8y7LQR1F2oTSss= 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-145-FecGdgoiOrKCpBlT69acIQ-1; Wed, 20 Jul 2022 02:59:52 -0400 X-MC-Unique: FecGdgoiOrKCpBlT69acIQ-1 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 0846B1C05148; Wed, 20 Jul 2022 06:59:52 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id B1FC890A11; Wed, 20 Jul 2022 06:59:48 +0000 (UTC) From: =?utf-8?q?Eugenio_P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Stefano Garzarella , Liuxiangdong , Cornelia Huck , Laurent Vivier , Eli Cohen , Harpreet Singh Anand , Cindy Lu , Eric Blake , Zhu Lingshan , Jason Wang , Gautam Dawar , Parav Pandit , "Michael S. Tsirkin" , Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini , "Gonglei (Arei)" Subject: [PATCH v6 00/21] vdpa net devices Rx filter change notification with Shadow VQ Date: Wed, 20 Jul 2022 08:59:25 +0200 Message-Id: <20220720065946.3122611-1-eperezma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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" Control virtqueue is used by networking device for accepting various commands from the driver. It's a must to support advanced configurations. Rx filtering event is issues by qemu when device's MAC address changed once and the previous one has not been queried by external agents. Shadow VirtQueue (SVQ) already makes possible tracking the state of virtqueues, effectively intercepting them so qemu can track what regions of memory are dirty because device action and needs migration. However, this does not solve networking device state seen by the driver because CVQ messages, like changes on MAC addresses from the driver. This series uses SVQ infrastructure to intercept networking control messages used by the device. This way, qemu is able to update VirtIONet device model and react to them. In particular, this series enables rx filter change notification. This is a prerequisite to achieve net vdpa device with CVQ live migration. It's a stripped down version of [1], with error paths checked and no migration enabled. First ten patches reorder and clean code base so its easier to apply later ones. No functional change should be noticed from these changes. Patches from 11 to 15 enable SVQ API to make other parts of qemu to interact with it. In particular, they will be used by vhost-vdpa net to handle CVQ messages. Patches 16 to 18 enable the update of the virtio-net device model for each CVQ message acknowledged by the device. Last patches enable x-svq parameter, forbidding device migration since it is not restored in the destination's vdpa device yet. This will be added in later series, using this work. They could conflict trivially with series [2]. Comments are welcome. v6: - Add vhost-vdpa-stub.c in case qemu is compiled with no virtio-net support v5: - Add a volatile access modifier to force compiler to emit the read instruction - Fix use of undefined variable v4: - Add a timeout to vhost_svq_poll to not hold BQL forever v3: - Replace SVQElement with SVQDescState v2: - (Comments from series [1]). - Active poll for CVQ answer instead of relay on async used callback - Do not offer a new buffer to device but reuse qemu's - Use vhost_svq_add instead of not needed vhost_svq_inject - Delete used and detach callbacks, not needed anymore - Embed members of SVQElement in VirtQueueElement - Reuse the same buffers for all CVQ commands [1] https://patchwork.kernel.org/project/qemu-devel/cover/20220706184008.1649478-1-eperezma@redhat.com/ [2] https://lists.nongnu.org/archive/html/qemu-devel/2022-07/msg02984.html Eugenio PĂ©rez (21): vhost: move descriptor translation to vhost_svq_vring_write_descs virtio-net: Expose MAC_TABLE_ENTRIES virtio-net: Expose ctrl virtqueue logic vdpa: Avoid compiler to squash reads to used idx vhost: Reorder vhost_svq_kick vhost: Move vhost_svq_kick call to vhost_svq_add vhost: Check for queue full at vhost_svq_add vhost: Decouple vhost_svq_add from VirtQueueElement vhost: Add SVQDescState vhost: Track number of descs in SVQDescState vhost: add vhost_svq_push_elem vhost: Expose vhost_svq_add vhost: add vhost_svq_poll vhost: Add svq avail_handler callback vdpa: Export vhost_vdpa_dma_map and unmap calls vhost-net-vdpa: add stubs for when no virtio-net device is present vdpa: manual forward CVQ buffers vdpa: Buffer CVQ support on shadow virtqueue vdpa: Extract get features part from vhost_vdpa_get_max_queue_pairs vdpa: Add device migration blocker vdpa: Add x-svq to NetdevVhostVDPAOptions qapi/net.json | 9 +- hw/virtio/vhost-shadow-virtqueue.h | 52 ++++- include/hw/virtio/vhost-vdpa.h | 8 + include/hw/virtio/virtio-net.h | 7 + hw/net/virtio-net.c | 85 ++++--- hw/virtio/vhost-shadow-virtqueue.c | 210 ++++++++++++----- hw/virtio/vhost-vdpa.c | 26 ++- net/vhost-vdpa-stub.c | 21 ++ net/vhost-vdpa.c | 357 +++++++++++++++++++++++++++-- net/meson.build | 3 +- 10 files changed, 658 insertions(+), 120 deletions(-) create mode 100644 net/vhost-vdpa-stub.c