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 device 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 device Crypto/eth device pointer
99 * @param sess Security session structure
100 * @param mb Packet buffer
101 * @param params Metadata
104 * - Returns 0 if metadata updated successfully.
105 * - Returns -ve value for errors.
107 typedef int (*security_set_pkt_metadata_t)(void *device,
108 struct rte_security_session *sess, struct rte_mbuf *mb,
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.
116 * @param device Crypto/eth device pointer
118 * @param userdata Pointer to receive userdata
121 * - Returns 0 if userdata is retrieved successfully.
122 * - Returns -ve value for errors.
124 typedef int (*security_get_userdata_t)(void *device,
125 uint64_t md, void **userdata);
128 * Get security capabilities of the device.
130 * @param device crypto/eth device pointer
133 * - Returns rte_security_capability pointer on success.
134 * - Returns NULL on error.
136 typedef const struct rte_security_capability *(*security_capabilities_get_t)(
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. */
163 #endif /* _RTE_SECURITY_DRIVER_H_ */