From nobody Tue Feb 10 02:28:08 2026 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=fail(p=none dis=none) header.from=bytedance.com ARC-Seal: i=1; a=rsa-sha256; t=1674119631; cv=none; d=zohomail.com; s=zohoarc; b=Loiha1pSp+z7iyS0DMqmJ5Ft+iClowPBQojSD5iZ6nGsXjs8Pf8lPYtoQ1tGyCvsLW0qEZpUT77q75Rp17DCSr0uH4jemgUTYRJaJzdN2f1LfkAiuXtWwzakvbqCADgLuXQvGUO1Yi1a57ABtXTIsqxU1mLOJO/jaJrhyeBKiwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674119631; 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=hjFn9a0xpaAGk/jIa/89xQyXjHLDxYzq+jbq8vof9l4=; b=V/1VOda+ASHQqdTnVMt10ULYnXeWw+deaVY7iEVIZwSRlv867kY+tMnjwa6XJloHGsteblDgsOQZx4tsQKgtcf8yXM7jSW5dVco96vMdP4Fz8GPHgghH+pw/Mr7V3pV+eMMJMw37dlkgrKlBqbzpq0fkW+E8A3Q5llffPPrlTz4= 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=fail 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 167411963140878.45317304356593; Thu, 19 Jan 2023 01:13:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIP8E-00062R-6p; Thu, 19 Jan 2023 02:14:42 -0500 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 1pIP8A-00060t-I0 for qemu-devel@nongnu.org; Thu, 19 Jan 2023 02:14:39 -0500 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIP87-0002FN-8N for qemu-devel@nongnu.org; Thu, 19 Jan 2023 02:14:37 -0500 Received: by mail-pj1-x102d.google.com with SMTP id x2-20020a17090a46c200b002295ca9855aso4981294pjg.2 for ; Wed, 18 Jan 2023 23:14:30 -0800 (PST) Received: from always-pc.bytedance.net ([61.213.176.6]) by smtp.gmail.com with ESMTPSA id e4-20020a170902ef4400b0016d72804664sm24266631plx.205.2023.01.18.23.14.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 23:14:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hjFn9a0xpaAGk/jIa/89xQyXjHLDxYzq+jbq8vof9l4=; b=WVBrMCyL/g9wFXNBxFcIUibS2E0ZDh9f2ho9x8uLQ8BmOBML6CrgFiRzlNqvvwvkYd OX2nDZpvYaTHtI9cvhu881fSx5NXySvP7t0n7a/wviPH+AWKv5DWuJZs0JS92kdIAQEM wGjKWPr1VC+sKlHvm8yf41xNcE5sbjTeDqmfcftLm2bma0P62Zu2mQ+uatn0v6FeHBMN fmozXIux1jyHBvmkkNhwK8l8LtXVnYkGhEOT9BneJE9rbZBNPZb3bEP+v26AEHisllv8 +TypGEkyzaHQZx05YgM6HbjHXqQ6ceUpfQ3QokgtTVUIAr+afetd1/gfPPQR6PPic6Ce g2uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hjFn9a0xpaAGk/jIa/89xQyXjHLDxYzq+jbq8vof9l4=; b=IWLmUO8gYTTkg0Q94ibycUhgJ38rTegr6ArVovHwlt/Pa3RQcoees74fpjP3udYIf6 GxklT7CTrFGpr2AGIotKll+V4JV3YlHgEU2cVSNAOKRttm1p1BNcgbuwK2OEdedAbDBY /7uXzQIzIi/Q2FS494YbqJJcMDgDCtaoFy0tjEARHQYaGl0NiEgtfQQkc6E7qO8ARfKE 6MMSIZidPFlfWxTssjfwHXSMjbhX/VPauP9rRO5/Hz6ko2rrB7oK3dM2fcHO7yrQMBTG phEtYaVRyJdCEGyAMVZn/pIY8IQcvNTmv+G3DD3EZmSfBrK2S23ZZHtyM6/fUgfsu5Ef 8KNQ== X-Gm-Message-State: AFqh2kpTAXSHQ39txmc4jyZhnjuNaSOuAJCeVY1j8PVYmXtme9QLP//k vslOj/BeaEOCxQyJE7RsKRZI2w== X-Google-Smtp-Source: AMrXdXvmSFn11BBAd5dncVHcoNW1aiCriUa4TdCySSfaPB+ebW03m4jFKPfTxJBcS7RdUFMK+VHoEQ== X-Received: by 2002:a17:902:ebc9:b0:194:85da:16 with SMTP id p9-20020a170902ebc900b0019485da0016mr11143552plg.13.1674112469716; Wed, 18 Jan 2023 23:14:29 -0800 (PST) From: zhenwei pi To: arei.gonglei@huawei.com, mst@redhat.com, dgilbert@redhat.com, pbonzini@redhat.com, berrange@redhat.com Cc: armbru@redhat.com, qemu-devel@nongnu.org, zhenwei pi Subject: [PATCH v3 01/12] cryptodev: Introduce cryptodev.json Date: Thu, 19 Jan 2023 15:14:08 +0800 Message-Id: <20230119071419.3585771-2-pizhenwei@bytedance.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230119071419.3585771-1-pizhenwei@bytedance.com> References: <20230119071419.3585771-1-pizhenwei@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::102d; envelope-from=pizhenwei@bytedance.com; helo=mail-pj1-x102d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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 @bytedance-com.20210112.gappssmtp.com) X-ZM-MESSAGEID: 1674119633742100001 Introduce QCryptodevBackendType in cryptodev.json, also apply this to related codes. Then we can drop 'enum CryptoDevBackendOptionsType'. Note that `CRYPTODEV_BACKEND_TYPE_NONE` is *NOT* used by anywhere, so drop it(no 'none' enum in QCryptodevBackendType). Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: zhenwei pi --- MAINTAINERS | 1 + backends/cryptodev-builtin.c | 2 +- backends/cryptodev-lkcf.c | 2 +- backends/cryptodev-vhost-user.c | 4 ++-- backends/cryptodev-vhost.c | 4 ++-- include/sysemu/cryptodev.h | 11 ++--------- qapi/cryptodev.json | 20 ++++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + 9 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 qapi/cryptodev.json diff --git a/MAINTAINERS b/MAINTAINERS index 0fe50d01e3..5ec5aebadb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2861,6 +2861,7 @@ M: Gonglei S: Maintained F: include/sysemu/cryptodev*.h F: backends/cryptodev*.c +F: qapi/cryptodev.json =20 Python library M: John Snow diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index cda6ca3b71..8c7c10847d 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -76,7 +76,7 @@ static void cryptodev_builtin_init( "cryptodev-builtin", NULL); cc->info_str =3D g_strdup_printf("cryptodev-builtin0"); cc->queue_index =3D 0; - cc->type =3D CRYPTODEV_BACKEND_TYPE_BUILTIN; + cc->type =3D QCRYPTODEV_BACKEND_TYPE_BUILTIN; backend->conf.peers.ccs[0] =3D cc; =20 backend->conf.crypto_services =3D diff --git a/backends/cryptodev-lkcf.c b/backends/cryptodev-lkcf.c index 133bd706a4..91e02c0df9 100644 --- a/backends/cryptodev-lkcf.c +++ b/backends/cryptodev-lkcf.c @@ -226,7 +226,7 @@ static void cryptodev_lkcf_init(CryptoDevBackend *backe= nd, Error **errp) cc =3D cryptodev_backend_new_client("cryptodev-lkcf", NULL); cc->info_str =3D g_strdup_printf("cryptodev-lkcf0"); cc->queue_index =3D 0; - cc->type =3D CRYPTODEV_BACKEND_TYPE_LKCF; + cc->type =3D QCRYPTODEV_BACKEND_TYPE_LKCF; backend->conf.peers.ccs[0] =3D cc; =20 backend->conf.crypto_services =3D diff --git a/backends/cryptodev-vhost-user.c b/backends/cryptodev-vhost-use= r.c index ab3028e045..c165a1b1d6 100644 --- a/backends/cryptodev-vhost-user.c +++ b/backends/cryptodev-vhost-user.c @@ -67,7 +67,7 @@ cryptodev_vhost_user_get_vhost( { CryptoDevBackendVhostUser *s =3D CRYPTODEV_BACKEND_VHOST_USER(b); - assert(cc->type =3D=3D CRYPTODEV_BACKEND_TYPE_VHOST_USER); + assert(cc->type =3D=3D QCRYPTODEV_BACKEND_TYPE_VHOST_USER); assert(queue < MAX_CRYPTO_QUEUE_NUM); =20 return s->vhost_crypto[queue]; @@ -203,7 +203,7 @@ static void cryptodev_vhost_user_init( cc->info_str =3D g_strdup_printf("cryptodev-vhost-user%zu to %s ", i, chr->label); cc->queue_index =3D i; - cc->type =3D CRYPTODEV_BACKEND_TYPE_VHOST_USER; + cc->type =3D QCRYPTODEV_BACKEND_TYPE_VHOST_USER; =20 backend->conf.peers.ccs[i] =3D cc; =20 diff --git a/backends/cryptodev-vhost.c b/backends/cryptodev-vhost.c index 572f87b3be..a2b5a2cb3b 100644 --- a/backends/cryptodev-vhost.c +++ b/backends/cryptodev-vhost.c @@ -128,7 +128,7 @@ cryptodev_get_vhost(CryptoDevBackendClient *cc, =20 switch (cc->type) { #if defined(CONFIG_VHOST_USER) && defined(CONFIG_LINUX) - case CRYPTODEV_BACKEND_TYPE_VHOST_USER: + case QCRYPTODEV_BACKEND_TYPE_VHOST_USER: vhost_crypto =3D cryptodev_vhost_user_get_vhost(cc, b, queue); break; #endif @@ -196,7 +196,7 @@ int cryptodev_vhost_start(VirtIODevice *dev, int total_= queues) * because vhost user doesn't interrupt masking/unmasking * properly. */ - if (cc->type =3D=3D CRYPTODEV_BACKEND_TYPE_VHOST_USER) { + if (cc->type =3D=3D QCRYPTODEV_BACKEND_TYPE_VHOST_USER) { dev->use_guest_notifier_mask =3D false; } } diff --git a/include/sysemu/cryptodev.h b/include/sysemu/cryptodev.h index cf9b3f07fe..8d2adda974 100644 --- a/include/sysemu/cryptodev.h +++ b/include/sysemu/cryptodev.h @@ -25,6 +25,7 @@ =20 #include "qemu/queue.h" #include "qom/object.h" +#include "qapi/qapi-types-cryptodev.h" =20 /** * CryptoDevBackend: @@ -215,16 +216,8 @@ struct CryptoDevBackendClass { void *opaque); }; =20 -typedef enum CryptoDevBackendOptionsType { - CRYPTODEV_BACKEND_TYPE_NONE =3D 0, - CRYPTODEV_BACKEND_TYPE_BUILTIN =3D 1, - CRYPTODEV_BACKEND_TYPE_VHOST_USER =3D 2, - CRYPTODEV_BACKEND_TYPE_LKCF =3D 3, - CRYPTODEV_BACKEND_TYPE__MAX, -} CryptoDevBackendOptionsType; - struct CryptoDevBackendClient { - CryptoDevBackendOptionsType type; + QCryptodevBackendType type; char *model; char *name; char *info_str; diff --git a/qapi/cryptodev.json b/qapi/cryptodev.json new file mode 100644 index 0000000000..b65edbe183 --- /dev/null +++ b/qapi/cryptodev.json @@ -0,0 +1,20 @@ +# -*- Mode: Python -*- +# vim: filetype=3Dpython +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +## +# @QCryptodevBackendType: +# +# The crypto device backend type +# +# @builtin: the QEMU builtin support +# @vhost-user: vhost-user +# @lkcf: Linux kernel cryptographic framework +# +# Since: 8.0 +## +{ 'enum': 'QCryptodevBackendType', + 'prefix': 'QCRYPTODEV_BACKEND_TYPE', + 'data': ['builtin', 'vhost-user', 'lkcf']} diff --git a/qapi/meson.build b/qapi/meson.build index fbdb442fdf..1c37ae7491 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -56,6 +56,7 @@ if have_system qapi_all_modules +=3D [ 'acpi', 'audio', + 'cryptodev', 'qdev', 'pci', 'rdma', diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index f000b90744..1e923945db 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -95,3 +95,4 @@ { 'include': 'pci.json' } { 'include': 'stats.json' } { 'include': 'virtio.json' } +{ 'include': 'cryptodev.json' } --=20 2.34.1