From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjjtl-0006DN-G8 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 05:21:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjjth-0003qL-66 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 05:21:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjjtg-0003qD-Uj for qemu-devel@nongnu.org; Tue, 13 Sep 2016 05:20:57 -0400 Date: Tue, 13 Sep 2016 10:20:50 +0100 From: "Daniel P. Berrange" Message-ID: <20160913092050.GD30949@redhat.com> Reply-To: "Daniel P. Berrange" References: <1473738741-220600-1-git-send-email-arei.gonglei@huawei.com> <1473738741-220600-3-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1473738741-220600-3-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v2 02/15] crypto: introduce crypto queue handler List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei Cc: qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org, peter.huangpeng@huawei.com, luonengjun@huawei.com, mst@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, weidong.huang@huawei.com, mike.caraman@nxp.com, agraf@suse.de, xin.zeng@intel.com, claudio.fontana@huawei.com, nmorey@kalray.eu, vincent.jardin@6wind.com On Tue, Sep 13, 2016 at 11:52:08AM +0800, Gonglei wrote: > crypto queue is a gallery used for executing crypto > operation, which supports both synchronization and > asynchronization. The thoughts stolen from net/queue.c > > Signed-off-by: Gonglei > --- > crypto/Makefile.objs | 1 + > crypto/crypto-queue.c | 206 ++++++++++++++++++++++++++++++++++++++++++ > crypto/crypto.c | 28 ++++++ > include/crypto/crypto-queue.h | 69 ++++++++++++++ > include/crypto/crypto.h | 12 +++ > 5 files changed, 316 insertions(+) > create mode 100644 crypto/crypto-queue.c > create mode 100644 include/crypto/crypto-queue.h > > diff --git a/include/crypto/crypto-queue.h b/include/crypto/crypto-queue.h > new file mode 100644 > index 0000000..6fba64d > --- /dev/null > +++ b/include/crypto/crypto-queue.h > @@ -0,0 +1,69 @@ > +/* > + * Copyright (c) 2003-2008 Fabrice Bellard > + * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD. > + * > + * Authors: > + * Gonglei > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ Again, wrong license header. > +#ifndef QEMU_CRYPTO_QUEUE_H > +#define QEMU_CRYPTO_QUEUE_H > + > +#include "qemu-common.h" > + > +typedef struct CryptoPacket CryptoPacket; > +typedef struct CryptoQueue CryptoQueue; > +typedef struct CryptoPacketBuf CryptoPacketBuf; > + > +typedef void (CryptoPacketSent) (CryptoClientState *, int); As previously, I'd expect naming of QCryptoCryptodevPacket QCryptoCryptodevPacketBuf QCryptoCryptodevQueue > + > + > +/* Returns: > + * >0 - success > + * 0 - queue packet for future redelivery > + * <0 - failure (discard packet) > + */ > +typedef int (CryptoQueueDeliverFunc)(CryptoClientState *sender, > + unsigned flags, > + void *header_opaque, > + void *opaque); > + > +CryptoQueue * > +qemu_new_crypto_queue(CryptoQueueDeliverFunc *deliver, void *opaque); > + > +void qemu_crypto_queue_cache(CryptoQueue *queue, > + unsigned flags, > + CryptoClientState *sender, > + void *opaque, > + CryptoPacketSent *sent_cb); > + > +void qemu_del_crypto_queue(CryptoQueue *queue); > + > +int qemu_crypto_queue_send(CryptoQueue *queue, > + unsigned flags, > + CryptoClientState *sender, > + void *opaque, > + CryptoPacketSent *sent_cb); > + > +void qemu_crypto_queue_purge(CryptoQueue *queue, CryptoClientState *from); > +bool qemu_crypto_queue_flush(CryptoQueue *queue); And naming of qcrypto_cryptodev_queue_purge qcrypto_cryptodev_queue_flush etc. Also missing docs for this file > +#endif /* QEMU_CRYPTO_QUEUE_H */ > diff --git a/include/crypto/crypto.h b/include/crypto/crypto.h > index f93f6f9..46b3b9e 100644 > --- a/include/crypto/crypto.h > +++ b/include/crypto/crypto.h > @@ -29,6 +29,8 @@ > > #include "qemu/queue.h" > #include "qapi-types.h" > +#include "crypto/crypto-queue.h" > + > > typedef void (CryptoPoll)(CryptoClientState *, bool); > typedef void (CryptoCleanup) (CryptoClientState *); > @@ -52,6 +54,8 @@ struct CryptoClientState { > char *model; > char *name; > char info_str[256]; > + CryptoQueue *incoming_queue; > + unsigned int queue_index; > CryptoClientDestructor *destructor; > }; > > @@ -62,5 +66,13 @@ CryptoClientState *new_crypto_client(CryptoClientInfo *info, > CryptoClientState *peer, > const char *model, > const char *name); > +int qemu_deliver_crypto_packet(CryptoClientState *sender, > + unsigned flags, > + void *header_opqaue, > + void *opaque); > +int qemu_send_crypto_packet_async(CryptoClientState *sender, > + unsigned flags, > + void *opaque, > + CryptoPacketSent *sent_cb); Missing docs for these API additions. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|