test mbuf attach
[dpdk.git] / lib / librte_vhost / rte_vhost_crypto.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017-2018 Intel Corporation
3  */
4
5 #ifndef _VHOST_CRYPTO_H_
6 #define _VHOST_CRYPTO_H_
7
8 #define VHOST_CRYPTO_MBUF_POOL_SIZE             (8192)
9 #define VHOST_CRYPTO_MAX_BURST_SIZE             (64)
10 #define VHOST_CRYPTO_SESSION_MAP_ENTRIES        (1024) /**< Max nb sessions */
11 /** max nb virtual queues in a burst for finalizing*/
12 #define VIRTIO_CRYPTO_MAX_NUM_BURST_VQS         (64)
13
14 enum rte_vhost_crypto_zero_copy {
15         RTE_VHOST_CRYPTO_ZERO_COPY_DISABLE = 0,
16         RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE = 1,
17         RTE_VHOST_CRYPTO_MAX_ZERO_COPY_OPTIONS
18 };
19
20 /**
21  *  Create Vhost-crypto instance
22  *
23  * @param vid
24  *  The identifier of the vhost device.
25  * @param cryptodev_id
26  *  The identifier of DPDK Cryptodev, the same cryptodev_id can be assigned to
27  *  multiple Vhost-crypto devices.
28  * @param sess_pool
29  *  The pointer to the created cryptodev session pool.
30  * @param sess_priv_pool
31  *  The pointer to the created cryptodev session private data mempool.
32  * @param socket_id
33  *  NUMA Socket ID to allocate resources on. *
34  * @return
35  *  0 if the Vhost Crypto Instance is created successfully.
36  *  Negative integer if otherwise
37  */
38 __rte_experimental
39 int
40 rte_vhost_crypto_create(int vid, uint8_t cryptodev_id,
41                 struct rte_mempool *sess_pool,
42                 struct rte_mempool *sess_priv_pool,
43                 int socket_id);
44
45 /**
46  *  Free the Vhost-crypto instance
47  *
48  * @param vid
49  *  The identifier of the vhost device.
50  * @return
51  *  0 if the Vhost Crypto Instance is created successfully.
52  *  Negative integer if otherwise.
53  */
54 __rte_experimental
55 int
56 rte_vhost_crypto_free(int vid);
57
58 /**
59  *  Enable or disable zero copy feature
60  *
61  * @param vid
62  *  The identifier of the vhost device.
63  * @param option
64  *  Flag of zero copy feature.
65  * @return
66  *  0 if completed successfully.
67  *  Negative integer if otherwise.
68  */
69 __rte_experimental
70 int
71 rte_vhost_crypto_set_zero_copy(int vid, enum rte_vhost_crypto_zero_copy option);
72
73 /**
74  * Fetch a number of vring descriptors from virt-queue and translate to DPDK
75  * crypto operations. After this function is executed, the user can enqueue
76  * the processed ops to the target cryptodev.
77  *
78  * @param vid
79  *  The identifier of the vhost device.
80  * @param qid
81  *  Virtio queue index.
82  * @param ops
83  *  The address of an array of pointers to *rte_crypto_op* structures that must
84  *  be large enough to store *nb_ops* pointers in it.
85  * @param nb_ops
86  *  The maximum number of operations to be fetched and translated.
87  * @return
88  *  The number of fetched and processed vhost crypto request operations.
89  */
90 __rte_experimental
91 uint16_t
92 rte_vhost_crypto_fetch_requests(int vid, uint32_t qid,
93                 struct rte_crypto_op **ops, uint16_t nb_ops);
94 /**
95  * Finalize the dequeued crypto ops. After the translated crypto ops are
96  * dequeued from the cryptodev, this function shall be called to write the
97  * processed data back to the vring descriptor (if no-copy is turned off).
98  *
99  * @param ops
100  *  The address of an array of *rte_crypto_op* structure that was dequeued
101  *  from cryptodev.
102  * @param nb_ops
103  *  The number of operations contained in the array.
104  * @callfds
105  *  The callfd number(s) contained in this burst, this shall be an array with
106  *  no less than VIRTIO_CRYPTO_MAX_NUM_BURST_VQS elements.
107  * @nb_callfds
108  *  The number of call_fd numbers exist in the callfds.
109  * @return
110  *  The number of ops processed.
111  */
112 __rte_experimental
113 uint16_t
114 rte_vhost_crypto_finalize_requests(struct rte_crypto_op **ops,
115                 uint16_t nb_ops, int *callfds, uint16_t *nb_callfds);
116
117 #endif /**< _VHOST_CRYPTO_H_ */