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 * Start vhost crypto driver 25 * 26 * @param path 27 * The vhost-user socket file path 28 * @return 29 * 0 on success, -1 on failure 30 */ 31 __rte_experimental 32 int 33 rte_vhost_crypto_driver_start(const char *path); 34 35 /** 36 * Create Vhost-crypto instance 37 * 38 * @param vid 39 * The identifier of the vhost device. 40 * @param cryptodev_id 41 * The identifier of DPDK Cryptodev, the same cryptodev_id can be assigned to 42 * multiple Vhost-crypto devices. 43 * @param sess_pool 44 * The pointer to the created cryptodev session pool. 45 * @param sess_priv_pool 46 * The pointer to the created cryptodev session private data mempool. 47 * @param socket_id 48 * NUMA Socket ID to allocate resources on. * 49 * @return 50 * 0 if the Vhost Crypto Instance is created successfully. 51 * Negative integer if otherwise 52 */ 53 __rte_experimental 54 int 55 rte_vhost_crypto_create(int vid, uint8_t cryptodev_id, 56 struct rte_mempool *sess_pool, 57 struct rte_mempool *sess_priv_pool, 58 int socket_id); 59 60 /** 61 * Free the Vhost-crypto instance 62 * 63 * @param vid 64 * The identifier of the vhost device. 65 * @return 66 * 0 if the Vhost Crypto Instance is created successfully. 67 * Negative integer if otherwise. 68 */ 69 __rte_experimental 70 int 71 rte_vhost_crypto_free(int vid); 72 73 /** 74 * Enable or disable zero copy feature 75 * 76 * @param vid 77 * The identifier of the vhost device. 78 * @param option 79 * Flag of zero copy feature. 80 * @return 81 * 0 if completed successfully. 82 * Negative integer if otherwise. 83 */ 84 __rte_experimental 85 int 86 rte_vhost_crypto_set_zero_copy(int vid, enum rte_vhost_crypto_zero_copy option); 87 88 /** 89 * Fetch a number of vring descriptors from virt-queue and translate to DPDK 90 * crypto operations. After this function is executed, the user can enqueue 91 * the processed ops to the target cryptodev. 92 * 93 * @param vid 94 * The identifier of the vhost device. 95 * @param qid 96 * Virtio queue index. 97 * @param ops 98 * The address of an array of pointers to *rte_crypto_op* structures that must 99 * be large enough to store *nb_ops* pointers in it. 100 * @param nb_ops 101 * The maximum number of operations to be fetched and translated. 102 * @return 103 * The number of fetched and processed vhost crypto request operations. 104 */ 105 __rte_experimental 106 uint16_t 107 rte_vhost_crypto_fetch_requests(int vid, uint32_t qid, 108 struct rte_crypto_op **ops, uint16_t nb_ops); 109 /** 110 * Finalize the dequeued crypto ops. After the translated crypto ops are 111 * dequeued from the cryptodev, this function shall be called to write the 112 * processed data back to the vring descriptor (if no-copy is turned off). 113 * 114 * @param ops 115 * The address of an array of *rte_crypto_op* structure that was dequeued 116 * from cryptodev. 117 * @param nb_ops 118 * The number of operations contained in the array. 119 * @callfds 120 * The callfd number(s) contained in this burst, this shall be an array with 121 * no less than VIRTIO_CRYPTO_MAX_NUM_BURST_VQS elements. 122 * @nb_callfds 123 * The number of call_fd numbers exist in the callfds. 124 * @return 125 * The number of ops processed. 126 */ 127 __rte_experimental 128 uint16_t 129 rte_vhost_crypto_finalize_requests(struct rte_crypto_op **ops, 130 uint16_t nb_ops, int *callfds, uint16_t *nb_callfds); 131 132 #endif /**< _VHOST_CRYPTO_H_ */ 133