mirror of
https://github.com/qemu/qemu.git
synced 2024-12-16 16:53:28 +08:00
0dda001b3a
There is no "version 2" of the "Lesser" General Public License. It is either "GPL version 2.0" or "Lesser GPL version 2.1". This patch replaces all occurrences of "Lesser GPL version 2" with "Lesser GPL version 2.1" in comment section. Signed-off-by: Chetan Pant <chetan4windows@gmail.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20201014133722.14041-1-chetan4windows@gmail.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
154 lines
4.1 KiB
C
154 lines
4.1 KiB
C
/*
|
|
* QEMU Crypto Device Common Vhost Implement
|
|
*
|
|
* Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
|
|
*
|
|
* Authors:
|
|
* Gonglei <arei.gonglei@huawei.com>
|
|
* Jay Zhou <jianjay.zhou@huawei.com>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
#ifndef CRYPTODEV_VHOST_H
|
|
#define CRYPTODEV_VHOST_H
|
|
|
|
#include "hw/virtio/vhost.h"
|
|
#include "hw/virtio/vhost-backend.h"
|
|
#include "chardev/char.h"
|
|
|
|
#include "sysemu/cryptodev.h"
|
|
|
|
|
|
typedef struct CryptoDevBackendVhostOptions {
|
|
VhostBackendType backend_type;
|
|
void *opaque;
|
|
int total_queues;
|
|
CryptoDevBackendClient *cc;
|
|
} CryptoDevBackendVhostOptions;
|
|
|
|
typedef struct CryptoDevBackendVhost {
|
|
struct vhost_dev dev;
|
|
struct vhost_virtqueue vqs[1];
|
|
int backend;
|
|
CryptoDevBackendClient *cc;
|
|
} CryptoDevBackendVhost;
|
|
|
|
/**
|
|
* cryptodev_vhost_get_max_queues:
|
|
* @crypto: the cryptodev backend common vhost object
|
|
*
|
|
* Get the maximum queue number of @crypto.
|
|
*
|
|
*
|
|
* Returns: the maximum queue number
|
|
*/
|
|
uint64_t
|
|
cryptodev_vhost_get_max_queues(
|
|
CryptoDevBackendVhost *crypto);
|
|
|
|
|
|
/**
|
|
* cryptodev_vhost_init:
|
|
* @options: the common vhost object's option
|
|
*
|
|
* Creates a new cryptodev backend common vhost object
|
|
*
|
|
** The returned object must be released with
|
|
* cryptodev_vhost_cleanup() when no
|
|
* longer required
|
|
*
|
|
* Returns: the cryptodev backend common vhost object
|
|
*/
|
|
struct CryptoDevBackendVhost *
|
|
cryptodev_vhost_init(
|
|
CryptoDevBackendVhostOptions *options);
|
|
|
|
/**
|
|
* cryptodev_vhost_cleanup:
|
|
* @crypto: the cryptodev backend common vhost object
|
|
*
|
|
* Clean the resouce associated with @crypto that realizaed
|
|
* by cryptodev_vhost_init()
|
|
*
|
|
*/
|
|
void cryptodev_vhost_cleanup(
|
|
CryptoDevBackendVhost *crypto);
|
|
|
|
/**
|
|
* cryptodev_get_vhost:
|
|
* @cc: the client object for each queue
|
|
* @b: the cryptodev backend common vhost object
|
|
* @queue: the cryptodev backend queue index
|
|
*
|
|
* Gets a new cryptodev backend common vhost object based on
|
|
* @b and @queue
|
|
*
|
|
* Returns: the cryptodev backend common vhost object
|
|
*/
|
|
CryptoDevBackendVhost *
|
|
cryptodev_get_vhost(CryptoDevBackendClient *cc,
|
|
CryptoDevBackend *b,
|
|
uint16_t queue);
|
|
/**
|
|
* cryptodev_vhost_start:
|
|
* @dev: the virtio crypto object
|
|
* @total_queues: the total count of queue
|
|
*
|
|
* Starts the vhost crypto logic
|
|
*
|
|
* Returns: 0 for success, negative for errors
|
|
*/
|
|
int cryptodev_vhost_start(VirtIODevice *dev, int total_queues);
|
|
|
|
/**
|
|
* cryptodev_vhost_stop:
|
|
* @dev: the virtio crypto object
|
|
* @total_queues: the total count of queue
|
|
*
|
|
* Stops the vhost crypto logic
|
|
*
|
|
*/
|
|
void cryptodev_vhost_stop(VirtIODevice *dev, int total_queues);
|
|
|
|
/**
|
|
* cryptodev_vhost_virtqueue_mask:
|
|
* @dev: the virtio crypto object
|
|
* @queue: the cryptodev backend queue index
|
|
* @idx: the virtqueue index
|
|
* @mask: mask or not (true or false)
|
|
*
|
|
* Mask/unmask events for @idx virtqueue on @dev device
|
|
*
|
|
*/
|
|
void cryptodev_vhost_virtqueue_mask(VirtIODevice *dev,
|
|
int queue,
|
|
int idx, bool mask);
|
|
|
|
/**
|
|
* cryptodev_vhost_virtqueue_pending:
|
|
* @dev: the virtio crypto object
|
|
* @queue: the cryptodev backend queue index
|
|
* @idx: the virtqueue index
|
|
*
|
|
* Test and clear event pending status for @idx virtqueue on @dev device.
|
|
* Should be called after unmask to avoid losing events.
|
|
*
|
|
* Returns: true for success, false for errors
|
|
*/
|
|
bool cryptodev_vhost_virtqueue_pending(VirtIODevice *dev,
|
|
int queue, int idx);
|
|
|
|
#endif /* CRYPTODEV_VHOST_H */
|