1*2bfe3f2eSlogwang /*- 2*2bfe3f2eSlogwang * BSD LICENSE 3*2bfe3f2eSlogwang * 4*2bfe3f2eSlogwang * Copyright(c) 2017 Intel Corporation. All rights reserved. 5*2bfe3f2eSlogwang * Copyright 2017 NXP. 6*2bfe3f2eSlogwang * 7*2bfe3f2eSlogwang * Redistribution and use in source and binary forms, with or without 8*2bfe3f2eSlogwang * modification, are permitted provided that the following conditions 9*2bfe3f2eSlogwang * are met: 10*2bfe3f2eSlogwang * 11*2bfe3f2eSlogwang * * Redistributions of source code must retain the above copyright 12*2bfe3f2eSlogwang * notice, this list of conditions and the following disclaimer. 13*2bfe3f2eSlogwang * * Redistributions in binary form must reproduce the above copyright 14*2bfe3f2eSlogwang * notice, this list of conditions and the following disclaimer in 15*2bfe3f2eSlogwang * the documentation and/or other materials provided with the 16*2bfe3f2eSlogwang * distribution. 17*2bfe3f2eSlogwang * * Neither the name of Intel Corporation nor the names of its 18*2bfe3f2eSlogwang * contributors may be used to endorse or promote products derived 19*2bfe3f2eSlogwang * from this software without specific prior written permission. 20*2bfe3f2eSlogwang * 21*2bfe3f2eSlogwang * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22*2bfe3f2eSlogwang * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23*2bfe3f2eSlogwang * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24*2bfe3f2eSlogwang * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25*2bfe3f2eSlogwang * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26*2bfe3f2eSlogwang * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27*2bfe3f2eSlogwang * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28*2bfe3f2eSlogwang * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29*2bfe3f2eSlogwang * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30*2bfe3f2eSlogwang * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31*2bfe3f2eSlogwang * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32*2bfe3f2eSlogwang */ 33*2bfe3f2eSlogwang 34*2bfe3f2eSlogwang #ifndef _RTE_SECURITY_DRIVER_H_ 35*2bfe3f2eSlogwang #define _RTE_SECURITY_DRIVER_H_ 36*2bfe3f2eSlogwang 37*2bfe3f2eSlogwang /** 38*2bfe3f2eSlogwang * @file rte_security_driver.h 39*2bfe3f2eSlogwang * @b EXPERIMENTAL: this API may change without prior notice 40*2bfe3f2eSlogwang * 41*2bfe3f2eSlogwang * RTE Security Common Definitions 42*2bfe3f2eSlogwang * 43*2bfe3f2eSlogwang */ 44*2bfe3f2eSlogwang 45*2bfe3f2eSlogwang #ifdef __cplusplus 46*2bfe3f2eSlogwang extern "C" { 47*2bfe3f2eSlogwang #endif 48*2bfe3f2eSlogwang 49*2bfe3f2eSlogwang #include "rte_security.h" 50*2bfe3f2eSlogwang 51*2bfe3f2eSlogwang /** 52*2bfe3f2eSlogwang * Configure a security session on a device. 53*2bfe3f2eSlogwang * 54*2bfe3f2eSlogwang * @param device Crypto/eth device pointer 55*2bfe3f2eSlogwang * @param conf Security session configuration 56*2bfe3f2eSlogwang * @param sess Pointer to Security private session structure 57*2bfe3f2eSlogwang * @param mp Mempool where the private session is allocated 58*2bfe3f2eSlogwang * 59*2bfe3f2eSlogwang * @return 60*2bfe3f2eSlogwang * - Returns 0 if private session structure have been created successfully. 61*2bfe3f2eSlogwang * - Returns -EINVAL if input parameters are invalid. 62*2bfe3f2eSlogwang * - Returns -ENOTSUP if crypto device does not support the crypto transform. 63*2bfe3f2eSlogwang * - Returns -ENOMEM if the private session could not be allocated. 64*2bfe3f2eSlogwang */ 65*2bfe3f2eSlogwang typedef int (*security_session_create_t)(void *device, 66*2bfe3f2eSlogwang struct rte_security_session_conf *conf, 67*2bfe3f2eSlogwang struct rte_security_session *sess, 68*2bfe3f2eSlogwang struct rte_mempool *mp); 69*2bfe3f2eSlogwang 70*2bfe3f2eSlogwang /** 71*2bfe3f2eSlogwang * Free driver private session data. 72*2bfe3f2eSlogwang * 73*2bfe3f2eSlogwang * @param dev Crypto/eth device pointer 74*2bfe3f2eSlogwang * @param sess Security session structure 75*2bfe3f2eSlogwang */ 76*2bfe3f2eSlogwang typedef int (*security_session_destroy_t)(void *device, 77*2bfe3f2eSlogwang struct rte_security_session *sess); 78*2bfe3f2eSlogwang 79*2bfe3f2eSlogwang /** 80*2bfe3f2eSlogwang * Update driver private session data. 81*2bfe3f2eSlogwang * 82*2bfe3f2eSlogwang * @param device Crypto/eth device pointer 83*2bfe3f2eSlogwang * @param sess Pointer to Security private session structure 84*2bfe3f2eSlogwang * @param conf Security session configuration 85*2bfe3f2eSlogwang * 86*2bfe3f2eSlogwang * @return 87*2bfe3f2eSlogwang * - Returns 0 if private session structure have been updated successfully. 88*2bfe3f2eSlogwang * - Returns -EINVAL if input parameters are invalid. 89*2bfe3f2eSlogwang * - Returns -ENOTSUP if crypto device does not support the crypto transform. 90*2bfe3f2eSlogwang */ 91*2bfe3f2eSlogwang typedef int (*security_session_update_t)(void *device, 92*2bfe3f2eSlogwang struct rte_security_session *sess, 93*2bfe3f2eSlogwang struct rte_security_session_conf *conf); 94*2bfe3f2eSlogwang /** 95*2bfe3f2eSlogwang * Get stats from the PMD. 96*2bfe3f2eSlogwang * 97*2bfe3f2eSlogwang * @param device Crypto/eth device pointer 98*2bfe3f2eSlogwang * @param sess Pointer to Security private session structure 99*2bfe3f2eSlogwang * @param stats Security stats of the driver 100*2bfe3f2eSlogwang * 101*2bfe3f2eSlogwang * @return 102*2bfe3f2eSlogwang * - Returns 0 if private session structure have been updated successfully. 103*2bfe3f2eSlogwang * - Returns -EINVAL if session parameters are invalid. 104*2bfe3f2eSlogwang */ 105*2bfe3f2eSlogwang typedef int (*security_session_stats_get_t)(void *device, 106*2bfe3f2eSlogwang struct rte_security_session *sess, 107*2bfe3f2eSlogwang struct rte_security_stats *stats); 108*2bfe3f2eSlogwang 109*2bfe3f2eSlogwang /** 110*2bfe3f2eSlogwang * Update the mbuf with provided metadata. 111*2bfe3f2eSlogwang * 112*2bfe3f2eSlogwang * @param sess Security session structure 113*2bfe3f2eSlogwang * @param mb Packet buffer 114*2bfe3f2eSlogwang * @param mt Metadata 115*2bfe3f2eSlogwang * 116*2bfe3f2eSlogwang * @return 117*2bfe3f2eSlogwang * - Returns 0 if metadata updated successfully. 118*2bfe3f2eSlogwang * - Returns -ve value for errors. 119*2bfe3f2eSlogwang */ 120*2bfe3f2eSlogwang typedef int (*security_set_pkt_metadata_t)(void *device, 121*2bfe3f2eSlogwang struct rte_security_session *sess, struct rte_mbuf *m, 122*2bfe3f2eSlogwang void *params); 123*2bfe3f2eSlogwang 124*2bfe3f2eSlogwang /** 125*2bfe3f2eSlogwang * Get security capabilities of the device. 126*2bfe3f2eSlogwang * 127*2bfe3f2eSlogwang * @param device crypto/eth device pointer 128*2bfe3f2eSlogwang * 129*2bfe3f2eSlogwang * @return 130*2bfe3f2eSlogwang * - Returns rte_security_capability pointer on success. 131*2bfe3f2eSlogwang * - Returns NULL on error. 132*2bfe3f2eSlogwang */ 133*2bfe3f2eSlogwang typedef const struct rte_security_capability *(*security_capabilities_get_t)( 134*2bfe3f2eSlogwang void *device); 135*2bfe3f2eSlogwang 136*2bfe3f2eSlogwang /** Security operations function pointer table */ 137*2bfe3f2eSlogwang struct rte_security_ops { 138*2bfe3f2eSlogwang security_session_create_t session_create; 139*2bfe3f2eSlogwang /**< Configure a security session. */ 140*2bfe3f2eSlogwang security_session_update_t session_update; 141*2bfe3f2eSlogwang /**< Update a security session. */ 142*2bfe3f2eSlogwang security_session_stats_get_t session_stats_get; 143*2bfe3f2eSlogwang /**< Get security session statistics. */ 144*2bfe3f2eSlogwang security_session_destroy_t session_destroy; 145*2bfe3f2eSlogwang /**< Clear a security sessions private data. */ 146*2bfe3f2eSlogwang security_set_pkt_metadata_t set_pkt_metadata; 147*2bfe3f2eSlogwang /**< Update mbuf metadata. */ 148*2bfe3f2eSlogwang security_capabilities_get_t capabilities_get; 149*2bfe3f2eSlogwang /**< Get security capabilities. */ 150*2bfe3f2eSlogwang }; 151*2bfe3f2eSlogwang 152*2bfe3f2eSlogwang #ifdef __cplusplus 153*2bfe3f2eSlogwang } 154*2bfe3f2eSlogwang #endif 155*2bfe3f2eSlogwang 156*2bfe3f2eSlogwang #endif /* _RTE_SECURITY_DRIVER_H_ */ 157