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