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
11 * @b EXPERIMENTAL: this API may change without prior notice
13 * RTE Security Common Definitions
21 #include "rte_security.h"
24 * Configure a security session on a device.
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
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.
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);
43 * Free driver private session data.
45 * @param dev Crypto/eth device pointer
46 * @param sess Security session structure
48 typedef int (*security_session_destroy_t)(void *device,
49 struct rte_security_session *sess);
52 * Update driver private session data.
54 * @param device Crypto/eth device pointer
55 * @param sess Pointer to Security private session structure
56 * @param conf Security session configuration
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.
63 typedef int (*security_session_update_t)(void *device,
64 struct rte_security_session *sess,
65 struct rte_security_session_conf *conf);
68 * Get the size of a security session
70 * @param device Crypto/eth device pointer
73 * - On success returns the size of the session structure for device
74 * - On failure returns 0
76 typedef unsigned int (*security_session_get_size)(void *device);
79 * Get stats from the PMD.
81 * @param device Crypto/eth device pointer
82 * @param sess Pointer to Security private session structure
83 * @param stats Security stats of the driver
86 * - Returns 0 if private session structure have been updated successfully.
87 * - Returns -EINVAL if session parameters are invalid.
89 typedef int (*security_session_stats_get_t)(void *device,
90 struct rte_security_session *sess,
91 struct rte_security_stats *stats);
94 * Update the mbuf with provided metadata.
96 * @param sess Security session structure
97 * @param mb Packet buffer
101 * - Returns 0 if metadata updated successfully.
102 * - Returns -ve value for errors.
104 typedef int (*security_set_pkt_metadata_t)(void *device,
105 struct rte_security_session *sess, struct rte_mbuf *m,
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.
113 * @param device Crypto/eth device pointer
115 * @param userdata Pointer to receive userdata
118 * - Returns 0 if userdata is retrieved successfully.
119 * - Returns -ve value for errors.
121 typedef int (*security_get_userdata_t)(void *device,
122 uint64_t md, void **userdata);
125 * Get security capabilities of the device.
127 * @param device crypto/eth device pointer
130 * - Returns rte_security_capability pointer on success.
131 * - Returns NULL on error.
133 typedef const struct rte_security_capability *(*security_capabilities_get_t)(
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. */
160 #endif /* _RTE_SECURITY_DRIVER_H_ */