2bb9a228c1fc6f590cfb2f577cefdbb43d46dd8d
[dpdk.git] / lib / cryptodev / rte_cryptodev_core.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef _RTE_CRYPTODEV_CORE_H_
6 #define _RTE_CRYPTODEV_CORE_H_
7
8 /**
9  * @file
10  *
11  * RTE Crypto Device internal header.
12  *
13  * This header contains internal data types. But they are still part of the
14  * public API because they are used by inline functions in the published API.
15  *
16  * Applications should not use these directly.
17  *
18  */
19
20 typedef uint16_t (*dequeue_pkt_burst_t)(void *qp,
21                 struct rte_crypto_op **ops,     uint16_t nb_ops);
22 /**< Dequeue processed packets from queue pair of a device. */
23
24 typedef uint16_t (*enqueue_pkt_burst_t)(void *qp,
25                 struct rte_crypto_op **ops,     uint16_t nb_ops);
26 /**< Enqueue packets for processing on queue pair of a device. */
27
28 /**
29  * @internal
30  * Structure used to hold opaque pointers to internal ethdev Rx/Tx
31  * queues data.
32  * The main purpose to expose these pointers at all - allow compiler
33  * to fetch this data for fast-path cryptodev inline functions in advance.
34  */
35 struct rte_cryptodev_qpdata {
36         /** points to array of internal queue pair data pointers. */
37         void **data;
38         /** points to array of enqueue callback data pointers */
39         struct rte_cryptodev_cb_rcu *enq_cb;
40         /** points to array of dequeue callback data pointers */
41         struct rte_cryptodev_cb_rcu *deq_cb;
42 };
43
44 struct rte_crypto_fp_ops {
45         /** PMD enqueue burst function. */
46         enqueue_pkt_burst_t enqueue_burst;
47         /** PMD dequeue burst function. */
48         dequeue_pkt_burst_t dequeue_burst;
49         /** Internal queue pair data pointers. */
50         struct rte_cryptodev_qpdata qp;
51         /** Reserved for future ops. */
52         uintptr_t reserved[3];
53 } __rte_cache_aligned;
54
55 extern struct rte_crypto_fp_ops rte_crypto_fp_ops[RTE_CRYPTO_MAX_DEVS];
56
57 /**
58  * @internal
59  * The data part, with no function pointers, associated with each device.
60  *
61  * This structure is safe to place in shared memory to be common among
62  * different processes in a multi-process configuration.
63  */
64 struct rte_cryptodev_data {
65         uint8_t dev_id;
66         /**< Device ID for this instance */
67         uint8_t socket_id;
68         /**< Socket ID where memory is allocated */
69         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
70         /**< Unique identifier name */
71
72         __extension__
73         uint8_t dev_started : 1;
74         /**< Device state: STARTED(1)/STOPPED(0) */
75
76         struct rte_mempool *session_pool;
77         /**< Session memory pool */
78         void **queue_pairs;
79         /**< Array of pointers to queue pairs. */
80         uint16_t nb_queue_pairs;
81         /**< Number of device queue pairs. */
82
83         void *dev_private;
84         /**< PMD-specific private data */
85 } __rte_cache_aligned;
86
87
88 /** @internal The data structure associated with each crypto device. */
89 struct rte_cryptodev {
90         dequeue_pkt_burst_t dequeue_burst;
91         /**< Pointer to PMD receive function. */
92         enqueue_pkt_burst_t enqueue_burst;
93         /**< Pointer to PMD transmit function. */
94
95         struct rte_cryptodev_data *data;
96         /**< Pointer to device data */
97         struct rte_cryptodev_ops *dev_ops;
98         /**< Functions exported by PMD */
99         uint64_t feature_flags;
100         /**< Feature flags exposes HW/SW features for the given device */
101         struct rte_device *device;
102         /**< Backing device */
103
104         uint8_t driver_id;
105         /**< Crypto driver identifier*/
106
107         struct rte_cryptodev_cb_list link_intr_cbs;
108         /**< User application callback for interrupts if present */
109
110         void *security_ctx;
111         /**< Context for security ops */
112
113         __extension__
114         uint8_t attached : 1;
115         /**< Flag indicating the device is attached */
116
117         struct rte_cryptodev_cb_rcu *enq_cbs;
118         /**< User application callback for pre enqueue processing */
119
120         struct rte_cryptodev_cb_rcu *deq_cbs;
121         /**< User application callback for post dequeue processing */
122 } __rte_cache_aligned;
123
124 /**
125  * The pool of rte_cryptodev structures.
126  */
127 extern struct rte_cryptodev *rte_cryptodevs;
128
129 #endif /* _RTE_CRYPTODEV_CORE_H_ */