1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2017 Intel Corporation.
6 #ifndef _RTE_SECURITY_DRIVER_H_
7 #define _RTE_SECURITY_DRIVER_H_
10 * @file rte_security_driver.h
12 * RTE Security Common Definitions
20 #include "rte_security.h"
23 * Configure a security session on a device.
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
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.
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);
42 * Free driver private session data.
44 * @param dev Crypto/eth device pointer
45 * @param sess Security session structure
47 typedef int (*security_session_destroy_t)(void *device,
48 struct rte_security_session *sess);
51 * Update driver private session data.
53 * @param device Crypto/eth device pointer
54 * @param sess Pointer to Security private session structure
55 * @param conf Security session configuration
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.
62 typedef int (*security_session_update_t)(void *device,
63 struct rte_security_session *sess,
64 struct rte_security_session_conf *conf);
67 * Get the size of a security session
69 * @param device Crypto/eth device pointer
72 * - On success returns the size of the session structure for device
73 * - On failure returns 0
75 typedef unsigned int (*security_session_get_size)(void *device);
78 * Get stats from the PMD.
80 * @param device Crypto/eth device pointer
81 * @param sess Pointer to Security private session structure
82 * @param stats Security stats of the driver
85 * - Returns 0 if private session structure have been updated successfully.
86 * - Returns -EINVAL if session parameters are invalid.
88 typedef int (*security_session_stats_get_t)(void *device,
89 struct rte_security_session *sess,
90 struct rte_security_stats *stats);
93 int rte_security_dynfield_register(void);
96 * Update the mbuf with provided metadata.
98 * @param sess Security session structure
99 * @param mb Packet buffer
103 * - Returns 0 if metadata updated successfully.
104 * - Returns -ve value for errors.
106 typedef int (*security_set_pkt_metadata_t)(void *device,
107 struct rte_security_session *sess, struct rte_mbuf *m,
111 * Get application specific userdata associated with the security session.
112 * Device specific metadata provided would be used to uniquely identify
113 * the security session being referred to.
115 * @param device Crypto/eth device pointer
117 * @param userdata Pointer to receive userdata
120 * - Returns 0 if userdata is retrieved successfully.
121 * - Returns -ve value for errors.
123 typedef int (*security_get_userdata_t)(void *device,
124 uint64_t md, void **userdata);
127 * Get security capabilities of the device.
129 * @param device crypto/eth device pointer
132 * - Returns rte_security_capability pointer on success.
133 * - Returns NULL on error.
135 typedef const struct rte_security_capability *(*security_capabilities_get_t)(
138 /** Security operations function pointer table */
139 struct rte_security_ops {
140 security_session_create_t session_create;
141 /**< Configure a security session. */
142 security_session_update_t session_update;
143 /**< Update a security session. */
144 security_session_get_size session_get_size;
145 /**< Return size of security session. */
146 security_session_stats_get_t session_stats_get;
147 /**< Get security session statistics. */
148 security_session_destroy_t session_destroy;
149 /**< Clear a security sessions private data. */
150 security_set_pkt_metadata_t set_pkt_metadata;
151 /**< Update mbuf metadata. */
152 security_get_userdata_t get_userdata;
153 /**< Get userdata associated with session which processed the packet. */
154 security_capabilities_get_t capabilities_get;
155 /**< Get security capabilities. */
162 #endif /* _RTE_SECURITY_DRIVER_H_ */