lib: remove librte_ prefix from directory names
[dpdk.git] / lib / security / rte_security_driver.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017 NXP.
3  * Copyright(c) 2017 Intel Corporation.
4  */
5
6 #ifndef _RTE_SECURITY_DRIVER_H_
7 #define _RTE_SECURITY_DRIVER_H_
8
9 /**
10  * @file rte_security_driver.h
11  *
12  * RTE Security Common Definitions
13  *
14  */
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #include "rte_security.h"
21
22 /**
23  * Configure a security session on a device.
24  *
25  * @param       device          Crypto/eth device pointer
26  * @param       conf            Security session configuration
27  * @param       sess            Pointer to Security private session structure
28  * @param       mp              Mempool where the private session is allocated
29  *
30  * @return
31  *  - Returns 0 if private session structure have been created successfully.
32  *  - Returns -EINVAL if input parameters are invalid.
33  *  - Returns -ENOTSUP if crypto device does not support the crypto transform.
34  *  - Returns -ENOMEM if the private session could not be allocated.
35  */
36 typedef int (*security_session_create_t)(void *device,
37                 struct rte_security_session_conf *conf,
38                 struct rte_security_session *sess,
39                 struct rte_mempool *mp);
40
41 /**
42  * Free driver private session data.
43  *
44  * @param       device          Crypto/eth device pointer
45  * @param       sess            Security session structure
46  */
47 typedef int (*security_session_destroy_t)(void *device,
48                 struct rte_security_session *sess);
49
50 /**
51  * Update driver private session data.
52  *
53  * @param       device          Crypto/eth device pointer
54  * @param       sess            Pointer to Security private session structure
55  * @param       conf            Security session configuration
56  *
57  * @return
58  *  - Returns 0 if private session structure have been updated successfully.
59  *  - Returns -EINVAL if input parameters are invalid.
60  *  - Returns -ENOTSUP if crypto device does not support the crypto transform.
61  */
62 typedef int (*security_session_update_t)(void *device,
63                 struct rte_security_session *sess,
64                 struct rte_security_session_conf *conf);
65
66 /**
67  * Get the size of a security session
68  *
69  * @param       device          Crypto/eth device pointer
70  *
71  * @return
72  *  - On success returns the size of the session structure for device
73  *  - On failure returns 0
74  */
75 typedef unsigned int (*security_session_get_size)(void *device);
76
77 /**
78  * Get stats from the PMD.
79  *
80  * @param       device          Crypto/eth device pointer
81  * @param       sess            Pointer to Security private session structure
82  * @param       stats           Security stats of the driver
83  *
84  * @return
85  *  - Returns 0 if private session structure have been updated successfully.
86  *  - Returns -EINVAL if session parameters are invalid.
87  */
88 typedef int (*security_session_stats_get_t)(void *device,
89                 struct rte_security_session *sess,
90                 struct rte_security_stats *stats);
91
92 __rte_experimental
93 int rte_security_dynfield_register(void);
94
95 /**
96  * Update the mbuf with provided metadata.
97  *
98  * @param       device          Crypto/eth device pointer
99  * @param       sess            Security session structure
100  * @param       mb              Packet buffer
101  * @param       params          Metadata
102  *
103  * @return
104  *  - Returns 0 if metadata updated successfully.
105  *  - Returns -ve value for errors.
106  */
107 typedef int (*security_set_pkt_metadata_t)(void *device,
108                 struct rte_security_session *sess, struct rte_mbuf *mb,
109                 void *params);
110
111 /**
112  * Get application specific userdata associated with the security session.
113  * Device specific metadata provided would be used to uniquely identify
114  * the security session being referred to.
115  *
116  * @param       device          Crypto/eth device pointer
117  * @param       md              Metadata
118  * @param       userdata        Pointer to receive userdata
119  *
120  * @return
121  *  - Returns 0 if userdata is retrieved successfully.
122  *  - Returns -ve value for errors.
123  */
124 typedef int (*security_get_userdata_t)(void *device,
125                 uint64_t md, void **userdata);
126
127 /**
128  * Get security capabilities of the device.
129  *
130  * @param       device          crypto/eth device pointer
131  *
132  * @return
133  *  - Returns rte_security_capability pointer on success.
134  *  - Returns NULL on error.
135  */
136 typedef const struct rte_security_capability *(*security_capabilities_get_t)(
137                 void *device);
138
139 /** Security operations function pointer table */
140 struct rte_security_ops {
141         security_session_create_t session_create;
142         /**< Configure a security session. */
143         security_session_update_t session_update;
144         /**< Update a security session. */
145         security_session_get_size session_get_size;
146         /**< Return size of security session. */
147         security_session_stats_get_t session_stats_get;
148         /**< Get security session statistics. */
149         security_session_destroy_t session_destroy;
150         /**< Clear a security sessions private data. */
151         security_set_pkt_metadata_t set_pkt_metadata;
152         /**< Update mbuf metadata. */
153         security_get_userdata_t get_userdata;
154         /**< Get userdata associated with session which processed the packet. */
155         security_capabilities_get_t capabilities_get;
156         /**< Get security capabilities. */
157 };
158
159 #ifdef __cplusplus
160 }
161 #endif
162
163 #endif /* _RTE_SECURITY_DRIVER_H_ */