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