1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2018 HUAWEI TECHNOLOGIES CO., LTD.
3  */
4 
5 #ifndef _VIRTIO_CRYPTODEV_H_
6 #define _VIRTIO_CRYPTODEV_H_
7 
8 #include "virtio_crypto.h"
9 #include "virtio_pci.h"
10 #include "virtio_ring.h"
11 
12 /* Features desired/implemented by this driver. */
13 #define VIRTIO_CRYPTO_PMD_GUEST_FEATURES (1ULL << VIRTIO_F_VERSION_1)
14 
15 #define CRYPTODEV_NAME_VIRTIO_PMD crypto_virtio
16 
17 #define NUM_ENTRY_VIRTIO_CRYPTO_OP 7
18 
19 #define VIRTIO_CRYPTO_MAX_IV_SIZE 16
20 
21 extern uint8_t cryptodev_virtio_driver_id;
22 
23 enum virtio_crypto_cmd_id {
24 	VIRTIO_CRYPTO_CMD_CIPHER = 0,
25 	VIRTIO_CRYPTO_CMD_AUTH = 1,
26 	VIRTIO_CRYPTO_CMD_CIPHER_HASH = 2,
27 	VIRTIO_CRYPTO_CMD_HASH_CIPHER = 3
28 };
29 
30 struct virtio_crypto_op_cookie {
31 	struct virtio_crypto_op_data_req data_req;
32 	struct virtio_crypto_inhdr inhdr;
33 	struct vring_desc desc[NUM_ENTRY_VIRTIO_CRYPTO_OP];
34 	uint8_t iv[VIRTIO_CRYPTO_MAX_IV_SIZE];
35 };
36 
37 /*
38  * Control queue function prototype
39  */
40 void virtio_crypto_ctrlq_start(struct rte_cryptodev *dev);
41 
42 /*
43  * Data queue function prototype
44  */
45 void virtio_crypto_dataq_start(struct rte_cryptodev *dev);
46 
47 int virtio_crypto_queue_setup(struct rte_cryptodev *dev,
48 		int queue_type,
49 		uint16_t vtpci_queue_idx,
50 		uint16_t nb_desc,
51 		int socket_id,
52 		struct virtqueue **pvq);
53 
54 void virtio_crypto_queue_release(struct virtqueue *vq);
55 
56 uint16_t virtio_crypto_pkt_tx_burst(void *tx_queue,
57 		struct rte_crypto_op **tx_pkts,
58 		uint16_t nb_pkts);
59 
60 uint16_t virtio_crypto_pkt_rx_burst(void *tx_queue,
61 		struct rte_crypto_op **tx_pkts,
62 		uint16_t nb_pkts);
63 
64 #endif /* _VIRTIO_CRYPTODEV_H_ */
65