1d30ea906Sjfb8856606 /* SPDX-License-Identifier: BSD-3-Clause
2*2d9fd380Sjfb8856606  * Copyright 2017,2019-2020 NXP
3*2d9fd380Sjfb8856606  * Copyright(c) 2017-2020 Intel Corporation.
42bfe3f2eSlogwang  */
52bfe3f2eSlogwang 
62bfe3f2eSlogwang #ifndef _RTE_SECURITY_H_
72bfe3f2eSlogwang #define _RTE_SECURITY_H_
82bfe3f2eSlogwang 
92bfe3f2eSlogwang /**
102bfe3f2eSlogwang  * @file rte_security.h
112bfe3f2eSlogwang  *
122bfe3f2eSlogwang  * RTE Security Common Definitions
132bfe3f2eSlogwang  *
142bfe3f2eSlogwang  */
152bfe3f2eSlogwang 
162bfe3f2eSlogwang #ifdef __cplusplus
172bfe3f2eSlogwang extern "C" {
182bfe3f2eSlogwang #endif
192bfe3f2eSlogwang 
202bfe3f2eSlogwang #include <sys/types.h>
212bfe3f2eSlogwang 
222bfe3f2eSlogwang #include <netinet/in.h>
232bfe3f2eSlogwang #include <netinet/ip.h>
242bfe3f2eSlogwang #include <netinet/ip6.h>
252bfe3f2eSlogwang 
26d30ea906Sjfb8856606 #include <rte_compat.h>
272bfe3f2eSlogwang #include <rte_common.h>
282bfe3f2eSlogwang #include <rte_crypto.h>
292bfe3f2eSlogwang #include <rte_mbuf.h>
30*2d9fd380Sjfb8856606 #include <rte_mbuf_dyn.h>
312bfe3f2eSlogwang #include <rte_memory.h>
322bfe3f2eSlogwang #include <rte_mempool.h>
332bfe3f2eSlogwang 
342bfe3f2eSlogwang /** IPSec protocol mode */
352bfe3f2eSlogwang enum rte_security_ipsec_sa_mode {
362bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT = 1,
372bfe3f2eSlogwang 	/**< IPSec Transport mode */
382bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
392bfe3f2eSlogwang 	/**< IPSec Tunnel mode */
402bfe3f2eSlogwang };
412bfe3f2eSlogwang 
422bfe3f2eSlogwang /** IPSec Protocol */
432bfe3f2eSlogwang enum rte_security_ipsec_sa_protocol {
442bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_SA_PROTO_AH = 1,
452bfe3f2eSlogwang 	/**< AH protocol */
462bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_SA_PROTO_ESP,
472bfe3f2eSlogwang 	/**< ESP protocol */
482bfe3f2eSlogwang };
492bfe3f2eSlogwang 
502bfe3f2eSlogwang /** IPSEC tunnel type */
512bfe3f2eSlogwang enum rte_security_ipsec_tunnel_type {
522bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_TUNNEL_IPV4 = 1,
532bfe3f2eSlogwang 	/**< Outer header is IPv4 */
542bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_TUNNEL_IPV6,
552bfe3f2eSlogwang 	/**< Outer header is IPv6 */
562bfe3f2eSlogwang };
572bfe3f2eSlogwang 
582bfe3f2eSlogwang /**
592bfe3f2eSlogwang  * Security context for crypto/eth devices
602bfe3f2eSlogwang  *
612bfe3f2eSlogwang  * Security instance for each driver to register security operations.
622bfe3f2eSlogwang  * The application can get the security context from the crypto/eth device id
632bfe3f2eSlogwang  * using the APIs rte_cryptodev_get_sec_ctx()/rte_eth_dev_get_sec_ctx()
642bfe3f2eSlogwang  * This structure is used to identify the device(crypto/eth) for which the
652bfe3f2eSlogwang  * security operations need to be performed.
662bfe3f2eSlogwang  */
672bfe3f2eSlogwang struct rte_security_ctx {
682bfe3f2eSlogwang 	void *device;
692bfe3f2eSlogwang 	/**< Crypto/ethernet device attached */
702bfe3f2eSlogwang 	const struct rte_security_ops *ops;
712bfe3f2eSlogwang 	/**< Pointer to security ops for the device */
722bfe3f2eSlogwang 	uint16_t sess_cnt;
732bfe3f2eSlogwang 	/**< Number of sessions attached to this context */
742bfe3f2eSlogwang };
752bfe3f2eSlogwang 
762bfe3f2eSlogwang /**
772bfe3f2eSlogwang  * IPSEC tunnel parameters
782bfe3f2eSlogwang  *
792bfe3f2eSlogwang  * These parameters are used to build outbound tunnel headers.
802bfe3f2eSlogwang  */
812bfe3f2eSlogwang struct rte_security_ipsec_tunnel_param {
822bfe3f2eSlogwang 	enum rte_security_ipsec_tunnel_type type;
832bfe3f2eSlogwang 	/**< Tunnel type: IPv4 or IPv6 */
842bfe3f2eSlogwang 	RTE_STD_C11
852bfe3f2eSlogwang 	union {
862bfe3f2eSlogwang 		struct {
872bfe3f2eSlogwang 			struct in_addr src_ip;
882bfe3f2eSlogwang 			/**< IPv4 source address */
892bfe3f2eSlogwang 			struct in_addr dst_ip;
902bfe3f2eSlogwang 			/**< IPv4 destination address */
912bfe3f2eSlogwang 			uint8_t dscp;
922bfe3f2eSlogwang 			/**< IPv4 Differentiated Services Code Point */
932bfe3f2eSlogwang 			uint8_t df;
942bfe3f2eSlogwang 			/**< IPv4 Don't Fragment bit */
952bfe3f2eSlogwang 			uint8_t ttl;
962bfe3f2eSlogwang 			/**< IPv4 Time To Live */
972bfe3f2eSlogwang 		} ipv4;
982bfe3f2eSlogwang 		/**< IPv4 header parameters */
992bfe3f2eSlogwang 		struct {
1002bfe3f2eSlogwang 			struct in6_addr src_addr;
1012bfe3f2eSlogwang 			/**< IPv6 source address */
1022bfe3f2eSlogwang 			struct in6_addr dst_addr;
1032bfe3f2eSlogwang 			/**< IPv6 destination address */
1042bfe3f2eSlogwang 			uint8_t dscp;
1052bfe3f2eSlogwang 			/**< IPv6 Differentiated Services Code Point */
1062bfe3f2eSlogwang 			uint32_t flabel;
1072bfe3f2eSlogwang 			/**< IPv6 flow label */
1082bfe3f2eSlogwang 			uint8_t hlimit;
1092bfe3f2eSlogwang 			/**< IPv6 hop limit */
1102bfe3f2eSlogwang 		} ipv6;
1112bfe3f2eSlogwang 		/**< IPv6 header parameters */
1122bfe3f2eSlogwang 	};
1132bfe3f2eSlogwang };
1142bfe3f2eSlogwang 
1152bfe3f2eSlogwang /**
1162bfe3f2eSlogwang  * IPsec Security Association option flags
1172bfe3f2eSlogwang  */
1182bfe3f2eSlogwang struct rte_security_ipsec_sa_options {
1194418919fSjohnjiang 	/** Extended Sequence Numbers (ESN)
1202bfe3f2eSlogwang 	 *
1212bfe3f2eSlogwang 	 * * 1: Use extended (64 bit) sequence numbers
1222bfe3f2eSlogwang 	 * * 0: Use normal sequence numbers
1232bfe3f2eSlogwang 	 */
1242bfe3f2eSlogwang 	uint32_t esn : 1;
1252bfe3f2eSlogwang 
1264418919fSjohnjiang 	/** UDP encapsulation
1272bfe3f2eSlogwang 	 *
1282bfe3f2eSlogwang 	 * * 1: Do UDP encapsulation/decapsulation so that IPSEC packets can
1292bfe3f2eSlogwang 	 *      traverse through NAT boxes.
1302bfe3f2eSlogwang 	 * * 0: No UDP encapsulation
1312bfe3f2eSlogwang 	 */
1322bfe3f2eSlogwang 	uint32_t udp_encap : 1;
1332bfe3f2eSlogwang 
1344418919fSjohnjiang 	/** Copy DSCP bits
1352bfe3f2eSlogwang 	 *
1362bfe3f2eSlogwang 	 * * 1: Copy IPv4 or IPv6 DSCP bits from inner IP header to
1372bfe3f2eSlogwang 	 *      the outer IP header in encapsulation, and vice versa in
1382bfe3f2eSlogwang 	 *      decapsulation.
1392bfe3f2eSlogwang 	 * * 0: Do not change DSCP field.
1402bfe3f2eSlogwang 	 */
1412bfe3f2eSlogwang 	uint32_t copy_dscp : 1;
1422bfe3f2eSlogwang 
1434418919fSjohnjiang 	/** Copy IPv6 Flow Label
1442bfe3f2eSlogwang 	 *
1452bfe3f2eSlogwang 	 * * 1: Copy IPv6 flow label from inner IPv6 header to the
1462bfe3f2eSlogwang 	 *      outer IPv6 header.
1472bfe3f2eSlogwang 	 * * 0: Outer header is not modified.
1482bfe3f2eSlogwang 	 */
1492bfe3f2eSlogwang 	uint32_t copy_flabel : 1;
1502bfe3f2eSlogwang 
1514418919fSjohnjiang 	/** Copy IPv4 Don't Fragment bit
1522bfe3f2eSlogwang 	 *
1532bfe3f2eSlogwang 	 * * 1: Copy the DF bit from the inner IPv4 header to the outer
1542bfe3f2eSlogwang 	 *      IPv4 header.
1552bfe3f2eSlogwang 	 * * 0: Outer header is not modified.
1562bfe3f2eSlogwang 	 */
1572bfe3f2eSlogwang 	uint32_t copy_df : 1;
1582bfe3f2eSlogwang 
1594418919fSjohnjiang 	/** Decrement inner packet Time To Live (TTL) field
1602bfe3f2eSlogwang 	 *
1612bfe3f2eSlogwang 	 * * 1: In tunnel mode, decrement inner packet IPv4 TTL or
1622bfe3f2eSlogwang 	 *      IPv6 Hop Limit after tunnel decapsulation, or before tunnel
1632bfe3f2eSlogwang 	 *      encapsulation.
1642bfe3f2eSlogwang 	 * * 0: Inner packet is not modified.
1652bfe3f2eSlogwang 	 */
1662bfe3f2eSlogwang 	uint32_t dec_ttl : 1;
1674418919fSjohnjiang 
1684418919fSjohnjiang 	/** Explicit Congestion Notification (ECN)
1694418919fSjohnjiang 	 *
1704418919fSjohnjiang 	 * * 1: In tunnel mode, enable outer header ECN Field copied from
1714418919fSjohnjiang 	 *      inner header in tunnel encapsulation, or inner header ECN
1724418919fSjohnjiang 	 *      field construction in decapsulation.
1734418919fSjohnjiang 	 * * 0: Inner/outer header are not modified.
1744418919fSjohnjiang 	 */
1754418919fSjohnjiang 	uint32_t ecn : 1;
1764418919fSjohnjiang 
1774418919fSjohnjiang 	/** Security statistics
1784418919fSjohnjiang 	 *
1794418919fSjohnjiang 	 * * 1: Enable per session security statistics collection for
1804418919fSjohnjiang 	 *      this SA, if supported by the driver.
1814418919fSjohnjiang 	 * * 0: Disable per session security statistics collection for this SA.
1824418919fSjohnjiang 	 */
1834418919fSjohnjiang 	uint32_t stats : 1;
1842bfe3f2eSlogwang };
1852bfe3f2eSlogwang 
1862bfe3f2eSlogwang /** IPSec security association direction */
1872bfe3f2eSlogwang enum rte_security_ipsec_sa_direction {
1882bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
1892bfe3f2eSlogwang 	/**< Encrypt and generate digest */
1902bfe3f2eSlogwang 	RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
1912bfe3f2eSlogwang 	/**< Verify digest and decrypt */
1922bfe3f2eSlogwang };
1932bfe3f2eSlogwang 
1942bfe3f2eSlogwang /**
1952bfe3f2eSlogwang  * IPsec security association configuration data.
1962bfe3f2eSlogwang  *
1972bfe3f2eSlogwang  * This structure contains data required to create an IPsec SA security session.
1982bfe3f2eSlogwang  */
1992bfe3f2eSlogwang struct rte_security_ipsec_xform {
2002bfe3f2eSlogwang 	uint32_t spi;
2012bfe3f2eSlogwang 	/**< SA security parameter index */
2022bfe3f2eSlogwang 	uint32_t salt;
2032bfe3f2eSlogwang 	/**< SA salt */
2042bfe3f2eSlogwang 	struct rte_security_ipsec_sa_options options;
2052bfe3f2eSlogwang 	/**< various SA options */
2062bfe3f2eSlogwang 	enum rte_security_ipsec_sa_direction direction;
2072bfe3f2eSlogwang 	/**< IPSec SA Direction - Egress/Ingress */
2082bfe3f2eSlogwang 	enum rte_security_ipsec_sa_protocol proto;
2092bfe3f2eSlogwang 	/**< IPsec SA Protocol - AH/ESP */
2102bfe3f2eSlogwang 	enum rte_security_ipsec_sa_mode mode;
2112bfe3f2eSlogwang 	/**< IPsec SA Mode - transport/tunnel */
2122bfe3f2eSlogwang 	struct rte_security_ipsec_tunnel_param tunnel;
2132bfe3f2eSlogwang 	/**< Tunnel parameters, NULL for transport mode */
214d30ea906Sjfb8856606 	uint64_t esn_soft_limit;
215d30ea906Sjfb8856606 	/**< ESN for which the overflow event need to be raised */
2164418919fSjohnjiang 	uint32_t replay_win_sz;
2174418919fSjohnjiang 	/**< Anti replay window size to enable sequence replay attack handling.
2184418919fSjohnjiang 	 * replay checking is disabled if the window size is 0.
2194418919fSjohnjiang 	 */
2202bfe3f2eSlogwang };
2212bfe3f2eSlogwang 
2222bfe3f2eSlogwang /**
2232bfe3f2eSlogwang  * MACsec security session configuration
2242bfe3f2eSlogwang  */
2252bfe3f2eSlogwang struct rte_security_macsec_xform {
2262bfe3f2eSlogwang 	/** To be Filled */
2272bfe3f2eSlogwang 	int dummy;
2282bfe3f2eSlogwang };
2292bfe3f2eSlogwang 
2302bfe3f2eSlogwang /**
231d30ea906Sjfb8856606  * PDCP Mode of session
232d30ea906Sjfb8856606  */
233d30ea906Sjfb8856606 enum rte_security_pdcp_domain {
234d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_MODE_CONTROL,	/**< PDCP control plane */
235d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_MODE_DATA,	/**< PDCP data plane */
236d30ea906Sjfb8856606 };
237d30ea906Sjfb8856606 
238d30ea906Sjfb8856606 /** PDCP Frame direction */
239d30ea906Sjfb8856606 enum rte_security_pdcp_direction {
240d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_UPLINK,	/**< Uplink */
241d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_DOWNLINK,	/**< Downlink */
242d30ea906Sjfb8856606 };
243d30ea906Sjfb8856606 
244d30ea906Sjfb8856606 /** PDCP Sequence Number Size selectors */
245d30ea906Sjfb8856606 enum rte_security_pdcp_sn_size {
246d30ea906Sjfb8856606 	/** PDCP_SN_SIZE_5: 5bit sequence number */
247d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_SN_SIZE_5 = 5,
248d30ea906Sjfb8856606 	/** PDCP_SN_SIZE_7: 7bit sequence number */
249d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_SN_SIZE_7 = 7,
250d30ea906Sjfb8856606 	/** PDCP_SN_SIZE_12: 12bit sequence number */
251d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_SN_SIZE_12 = 12,
252d30ea906Sjfb8856606 	/** PDCP_SN_SIZE_15: 15bit sequence number */
253d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_SN_SIZE_15 = 15,
254d30ea906Sjfb8856606 	/** PDCP_SN_SIZE_18: 18bit sequence number */
255d30ea906Sjfb8856606 	RTE_SECURITY_PDCP_SN_SIZE_18 = 18
256d30ea906Sjfb8856606 };
257d30ea906Sjfb8856606 
258d30ea906Sjfb8856606 /**
259d30ea906Sjfb8856606  * PDCP security association configuration data.
260d30ea906Sjfb8856606  *
261d30ea906Sjfb8856606  * This structure contains data required to create a PDCP security session.
262d30ea906Sjfb8856606  */
263d30ea906Sjfb8856606 struct rte_security_pdcp_xform {
264d30ea906Sjfb8856606 	int8_t bearer;	/**< PDCP bearer ID */
265d30ea906Sjfb8856606 	/** Enable in order delivery, this field shall be set only if
266d30ea906Sjfb8856606 	 * driver/HW is capable. See RTE_SECURITY_PDCP_ORDERING_CAP.
267d30ea906Sjfb8856606 	 */
268d30ea906Sjfb8856606 	uint8_t en_ordering;
269d30ea906Sjfb8856606 	/** Notify driver/HW to detect and remove duplicate packets.
270d30ea906Sjfb8856606 	 * This field should be set only when driver/hw is capable.
271d30ea906Sjfb8856606 	 * See RTE_SECURITY_PDCP_DUP_DETECT_CAP.
272d30ea906Sjfb8856606 	 */
273d30ea906Sjfb8856606 	uint8_t remove_duplicates;
274d30ea906Sjfb8856606 	/** PDCP mode of operation: Control or data */
275d30ea906Sjfb8856606 	enum rte_security_pdcp_domain domain;
276d30ea906Sjfb8856606 	/** PDCP Frame Direction 0:UL 1:DL */
277d30ea906Sjfb8856606 	enum rte_security_pdcp_direction pkt_dir;
278d30ea906Sjfb8856606 	/** Sequence number size, 5/7/12/15/18 */
279d30ea906Sjfb8856606 	enum rte_security_pdcp_sn_size sn_size;
280d30ea906Sjfb8856606 	/** Starting Hyper Frame Number to be used together with the SN
281d30ea906Sjfb8856606 	 * from the PDCP frames
282d30ea906Sjfb8856606 	 */
283d30ea906Sjfb8856606 	uint32_t hfn;
284d30ea906Sjfb8856606 	/** HFN Threshold for key renegotiation */
285d30ea906Sjfb8856606 	uint32_t hfn_threshold;
2864418919fSjohnjiang 	/** HFN can be given as a per packet value also.
2874418919fSjohnjiang 	 * As we do not have IV in case of PDCP, and HFN is
2884418919fSjohnjiang 	 * used to generate IV. IV field can be used to get the
2894418919fSjohnjiang 	 * per packet HFN while enq/deq.
2904418919fSjohnjiang 	 * If hfn_ovrd field is set, user is expected to set the
2914418919fSjohnjiang 	 * per packet HFN in place of IV. PMDs will extract the HFN
2924418919fSjohnjiang 	 * and perform operations accordingly.
2934418919fSjohnjiang 	 */
294*2d9fd380Sjfb8856606 	uint8_t hfn_ovrd;
295*2d9fd380Sjfb8856606 	/** In case of 5G NR, a new protocol (SDAP) header may be set
296*2d9fd380Sjfb8856606 	 * inside PDCP payload which should be authenticated but not
297*2d9fd380Sjfb8856606 	 * encrypted. Hence, driver should be notified if SDAP is
298*2d9fd380Sjfb8856606 	 * enabled or not, so that SDAP header is not encrypted.
299*2d9fd380Sjfb8856606 	 */
300*2d9fd380Sjfb8856606 	uint8_t sdap_enabled;
301*2d9fd380Sjfb8856606 	/** Reserved for future */
302*2d9fd380Sjfb8856606 	uint16_t reserved;
303*2d9fd380Sjfb8856606 };
304*2d9fd380Sjfb8856606 
305*2d9fd380Sjfb8856606 /** DOCSIS direction */
306*2d9fd380Sjfb8856606 enum rte_security_docsis_direction {
307*2d9fd380Sjfb8856606 	RTE_SECURITY_DOCSIS_UPLINK,
308*2d9fd380Sjfb8856606 	/**< Uplink
309*2d9fd380Sjfb8856606 	 * - Decryption, followed by CRC Verification
310*2d9fd380Sjfb8856606 	 */
311*2d9fd380Sjfb8856606 	RTE_SECURITY_DOCSIS_DOWNLINK,
312*2d9fd380Sjfb8856606 	/**< Downlink
313*2d9fd380Sjfb8856606 	 * - CRC Generation, followed by Encryption
314*2d9fd380Sjfb8856606 	 */
315*2d9fd380Sjfb8856606 };
316*2d9fd380Sjfb8856606 
317*2d9fd380Sjfb8856606 /**
318*2d9fd380Sjfb8856606  * DOCSIS security session configuration.
319*2d9fd380Sjfb8856606  *
320*2d9fd380Sjfb8856606  * This structure contains data required to create a DOCSIS security session.
321*2d9fd380Sjfb8856606  */
322*2d9fd380Sjfb8856606 struct rte_security_docsis_xform {
323*2d9fd380Sjfb8856606 	enum rte_security_docsis_direction direction;
324*2d9fd380Sjfb8856606 	/**< DOCSIS direction */
325d30ea906Sjfb8856606 };
326d30ea906Sjfb8856606 
327d30ea906Sjfb8856606 /**
3282bfe3f2eSlogwang  * Security session action type.
3292bfe3f2eSlogwang  */
3302bfe3f2eSlogwang enum rte_security_session_action_type {
3312bfe3f2eSlogwang 	RTE_SECURITY_ACTION_TYPE_NONE,
3322bfe3f2eSlogwang 	/**< No security actions */
3332bfe3f2eSlogwang 	RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
3342bfe3f2eSlogwang 	/**< Crypto processing for security protocol is processed inline
3352bfe3f2eSlogwang 	 * during transmission
3362bfe3f2eSlogwang 	 */
3372bfe3f2eSlogwang 	RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL,
3382bfe3f2eSlogwang 	/**< All security protocol processing is performed inline during
3392bfe3f2eSlogwang 	 * transmission
3402bfe3f2eSlogwang 	 */
341*2d9fd380Sjfb8856606 	RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
3422bfe3f2eSlogwang 	/**< All security protocol processing including crypto is performed
3432bfe3f2eSlogwang 	 * on a lookaside accelerator
3442bfe3f2eSlogwang 	 */
345*2d9fd380Sjfb8856606 	RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO
346*2d9fd380Sjfb8856606 	/**< Similar to ACTION_TYPE_NONE but crypto processing for security
347*2d9fd380Sjfb8856606 	 * protocol is processed synchronously by a CPU.
348*2d9fd380Sjfb8856606 	 */
3492bfe3f2eSlogwang };
3502bfe3f2eSlogwang 
3512bfe3f2eSlogwang /** Security session protocol definition */
3522bfe3f2eSlogwang enum rte_security_session_protocol {
3532bfe3f2eSlogwang 	RTE_SECURITY_PROTOCOL_IPSEC = 1,
3542bfe3f2eSlogwang 	/**< IPsec Protocol */
3552bfe3f2eSlogwang 	RTE_SECURITY_PROTOCOL_MACSEC,
3562bfe3f2eSlogwang 	/**< MACSec Protocol */
357d30ea906Sjfb8856606 	RTE_SECURITY_PROTOCOL_PDCP,
358d30ea906Sjfb8856606 	/**< PDCP Protocol */
359*2d9fd380Sjfb8856606 	RTE_SECURITY_PROTOCOL_DOCSIS,
360*2d9fd380Sjfb8856606 	/**< DOCSIS Protocol */
3612bfe3f2eSlogwang };
3622bfe3f2eSlogwang 
3632bfe3f2eSlogwang /**
3642bfe3f2eSlogwang  * Security session configuration
3652bfe3f2eSlogwang  */
3662bfe3f2eSlogwang struct rte_security_session_conf {
3672bfe3f2eSlogwang 	enum rte_security_session_action_type action_type;
3682bfe3f2eSlogwang 	/**< Type of action to be performed on the session */
3692bfe3f2eSlogwang 	enum rte_security_session_protocol protocol;
3702bfe3f2eSlogwang 	/**< Security protocol to be configured */
3712bfe3f2eSlogwang 	RTE_STD_C11
3722bfe3f2eSlogwang 	union {
3732bfe3f2eSlogwang 		struct rte_security_ipsec_xform ipsec;
3742bfe3f2eSlogwang 		struct rte_security_macsec_xform macsec;
375d30ea906Sjfb8856606 		struct rte_security_pdcp_xform pdcp;
376*2d9fd380Sjfb8856606 		struct rte_security_docsis_xform docsis;
3772bfe3f2eSlogwang 	};
3782bfe3f2eSlogwang 	/**< Configuration parameters for security session */
3792bfe3f2eSlogwang 	struct rte_crypto_sym_xform *crypto_xform;
3802bfe3f2eSlogwang 	/**< Security Session Crypto Transformations */
381d30ea906Sjfb8856606 	void *userdata;
382d30ea906Sjfb8856606 	/**< Application specific userdata to be saved with session */
3832bfe3f2eSlogwang };
3842bfe3f2eSlogwang 
3852bfe3f2eSlogwang struct rte_security_session {
3862bfe3f2eSlogwang 	void *sess_private_data;
3872bfe3f2eSlogwang 	/**< Private session material */
3884418919fSjohnjiang 	uint64_t opaque_data;
3894418919fSjohnjiang 	/**< Opaque user defined data */
3902bfe3f2eSlogwang };
3912bfe3f2eSlogwang 
3922bfe3f2eSlogwang /**
3932bfe3f2eSlogwang  * Create security session as specified by the session configuration
3942bfe3f2eSlogwang  *
3952bfe3f2eSlogwang  * @param   instance	security instance
3962bfe3f2eSlogwang  * @param   conf	session configuration parameters
3972bfe3f2eSlogwang  * @param   mp		mempool to allocate session objects from
398*2d9fd380Sjfb8856606  * @param   priv_mp	mempool to allocate session private data objects from
3992bfe3f2eSlogwang  * @return
4002bfe3f2eSlogwang  *  - On success, pointer to session
4012bfe3f2eSlogwang  *  - On failure, NULL
4022bfe3f2eSlogwang  */
4032bfe3f2eSlogwang struct rte_security_session *
4042bfe3f2eSlogwang rte_security_session_create(struct rte_security_ctx *instance,
4052bfe3f2eSlogwang 			    struct rte_security_session_conf *conf,
406*2d9fd380Sjfb8856606 			    struct rte_mempool *mp,
407*2d9fd380Sjfb8856606 			    struct rte_mempool *priv_mp);
4082bfe3f2eSlogwang 
4092bfe3f2eSlogwang /**
4102bfe3f2eSlogwang  * Update security session as specified by the session configuration
4112bfe3f2eSlogwang  *
4122bfe3f2eSlogwang  * @param   instance	security instance
4132bfe3f2eSlogwang  * @param   sess	session to update parameters
4142bfe3f2eSlogwang  * @param   conf	update configuration parameters
4152bfe3f2eSlogwang  * @return
4162bfe3f2eSlogwang  *  - On success returns 0
4170c6bd470Sfengbojiang  *  - On failure returns a negative errno value.
4182bfe3f2eSlogwang  */
4194418919fSjohnjiang __rte_experimental
4204418919fSjohnjiang int
4212bfe3f2eSlogwang rte_security_session_update(struct rte_security_ctx *instance,
4222bfe3f2eSlogwang 			    struct rte_security_session *sess,
4232bfe3f2eSlogwang 			    struct rte_security_session_conf *conf);
4242bfe3f2eSlogwang 
4252bfe3f2eSlogwang /**
426d30ea906Sjfb8856606  * Get the size of the security session data for a device.
427d30ea906Sjfb8856606  *
428d30ea906Sjfb8856606  * @param   instance	security instance.
429d30ea906Sjfb8856606  *
430d30ea906Sjfb8856606  * @return
431d30ea906Sjfb8856606  *   - Size of the private data, if successful
432d30ea906Sjfb8856606  *   - 0 if device is invalid or does not support the operation.
433d30ea906Sjfb8856606  */
434d30ea906Sjfb8856606 unsigned int
435d30ea906Sjfb8856606 rte_security_session_get_size(struct rte_security_ctx *instance);
436d30ea906Sjfb8856606 
437d30ea906Sjfb8856606 /**
4382bfe3f2eSlogwang  * Free security session header and the session private data and
4392bfe3f2eSlogwang  * return it to its original mempool.
4402bfe3f2eSlogwang  *
4412bfe3f2eSlogwang  * @param   instance	security instance
4420c6bd470Sfengbojiang  * @param   sess	security session to be freed
4432bfe3f2eSlogwang  *
4442bfe3f2eSlogwang  * @return
4452bfe3f2eSlogwang  *  - 0 if successful.
4460c6bd470Sfengbojiang  *  - -EINVAL if session or context instance is NULL.
4472bfe3f2eSlogwang  *  - -EBUSY if not all device private data has been freed.
4480c6bd470Sfengbojiang  *  - -ENOTSUP if destroying private data is not supported.
4490c6bd470Sfengbojiang  *  - other negative values in case of freeing private data errors.
4502bfe3f2eSlogwang  */
4512bfe3f2eSlogwang int
4522bfe3f2eSlogwang rte_security_session_destroy(struct rte_security_ctx *instance,
4532bfe3f2eSlogwang 			     struct rte_security_session *sess);
4542bfe3f2eSlogwang 
455*2d9fd380Sjfb8856606 /** Device-specific metadata field type */
456*2d9fd380Sjfb8856606 typedef uint64_t rte_security_dynfield_t;
457*2d9fd380Sjfb8856606 /** Dynamic mbuf field for device-specific metadata */
458*2d9fd380Sjfb8856606 extern int rte_security_dynfield_offset;
459*2d9fd380Sjfb8856606 
460*2d9fd380Sjfb8856606 /**
461*2d9fd380Sjfb8856606  * @warning
462*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
463*2d9fd380Sjfb8856606  *
464*2d9fd380Sjfb8856606  * Get pointer to mbuf field for device-specific metadata.
465*2d9fd380Sjfb8856606  *
466*2d9fd380Sjfb8856606  * For performance reason, no check is done,
467*2d9fd380Sjfb8856606  * the dynamic field may not be registered.
468*2d9fd380Sjfb8856606  * @see rte_security_dynfield_is_registered
469*2d9fd380Sjfb8856606  *
470*2d9fd380Sjfb8856606  * @param	mbuf	packet to access
471*2d9fd380Sjfb8856606  * @return pointer to mbuf field
472*2d9fd380Sjfb8856606  */
473*2d9fd380Sjfb8856606 __rte_experimental
474*2d9fd380Sjfb8856606 static inline rte_security_dynfield_t *
rte_security_dynfield(struct rte_mbuf * mbuf)475*2d9fd380Sjfb8856606 rte_security_dynfield(struct rte_mbuf *mbuf)
476*2d9fd380Sjfb8856606 {
477*2d9fd380Sjfb8856606 	return RTE_MBUF_DYNFIELD(mbuf,
478*2d9fd380Sjfb8856606 		rte_security_dynfield_offset,
479*2d9fd380Sjfb8856606 		rte_security_dynfield_t *);
480*2d9fd380Sjfb8856606 }
481*2d9fd380Sjfb8856606 
482*2d9fd380Sjfb8856606 /**
483*2d9fd380Sjfb8856606  * @warning
484*2d9fd380Sjfb8856606  * @b EXPERIMENTAL: this API may change without prior notice
485*2d9fd380Sjfb8856606  *
486*2d9fd380Sjfb8856606  * Check whether the dynamic field is registered.
487*2d9fd380Sjfb8856606  *
488*2d9fd380Sjfb8856606  * @return true if rte_security_dynfield_register() has been called.
489*2d9fd380Sjfb8856606  */
490*2d9fd380Sjfb8856606 __rte_experimental
rte_security_dynfield_is_registered(void)491*2d9fd380Sjfb8856606 static inline bool rte_security_dynfield_is_registered(void)
492*2d9fd380Sjfb8856606 {
493*2d9fd380Sjfb8856606 	return rte_security_dynfield_offset >= 0;
494*2d9fd380Sjfb8856606 }
495*2d9fd380Sjfb8856606 
4962bfe3f2eSlogwang /**
4972bfe3f2eSlogwang  *  Updates the buffer with device-specific defined metadata
4982bfe3f2eSlogwang  *
4992bfe3f2eSlogwang  * @param	instance	security instance
5002bfe3f2eSlogwang  * @param	sess		security session
5012bfe3f2eSlogwang  * @param	mb		packet mbuf to set metadata on.
5022bfe3f2eSlogwang  * @param	params		device-specific defined parameters
5032bfe3f2eSlogwang  *				required for metadata
5042bfe3f2eSlogwang  *
5052bfe3f2eSlogwang  * @return
5062bfe3f2eSlogwang  *  - On success, zero.
5072bfe3f2eSlogwang  *  - On failure, a negative value.
5082bfe3f2eSlogwang  */
5092bfe3f2eSlogwang int
5102bfe3f2eSlogwang rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
5112bfe3f2eSlogwang 			      struct rte_security_session *sess,
5122bfe3f2eSlogwang 			      struct rte_mbuf *mb, void *params);
5132bfe3f2eSlogwang 
5142bfe3f2eSlogwang /**
515d30ea906Sjfb8856606  * Get userdata associated with the security session. Device specific metadata
516d30ea906Sjfb8856606  * provided would be used to uniquely identify the security session being
517d30ea906Sjfb8856606  * referred to. This userdata would be registered while creating the session,
518d30ea906Sjfb8856606  * and application can use this to identify the SA etc.
519d30ea906Sjfb8856606  *
520d30ea906Sjfb8856606  * Device specific metadata would be set in mbuf for inline processed inbound
521d30ea906Sjfb8856606  * packets. In addition, the same metadata would be set for IPsec events
522d30ea906Sjfb8856606  * reported by rte_eth_event framework.
523d30ea906Sjfb8856606  *
524d30ea906Sjfb8856606  * @param   instance	security instance
525d30ea906Sjfb8856606  * @param   md		device-specific metadata
526d30ea906Sjfb8856606  *
527d30ea906Sjfb8856606  * @return
528d30ea906Sjfb8856606  *  - On success, userdata
529d30ea906Sjfb8856606  *  - On failure, NULL
530d30ea906Sjfb8856606  */
5314418919fSjohnjiang __rte_experimental
5324418919fSjohnjiang void *
533d30ea906Sjfb8856606 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
534d30ea906Sjfb8856606 
535d30ea906Sjfb8856606 /**
5362bfe3f2eSlogwang  * Attach a session to a symmetric crypto operation
5372bfe3f2eSlogwang  *
5382bfe3f2eSlogwang  * @param	sym_op	crypto operation
5392bfe3f2eSlogwang  * @param	sess	security session
5402bfe3f2eSlogwang  */
5412bfe3f2eSlogwang static inline int
__rte_security_attach_session(struct rte_crypto_sym_op * sym_op,struct rte_security_session * sess)5422bfe3f2eSlogwang __rte_security_attach_session(struct rte_crypto_sym_op *sym_op,
5432bfe3f2eSlogwang 			      struct rte_security_session *sess)
5442bfe3f2eSlogwang {
5452bfe3f2eSlogwang 	sym_op->sec_session = sess;
5462bfe3f2eSlogwang 
5472bfe3f2eSlogwang 	return 0;
5482bfe3f2eSlogwang }
5492bfe3f2eSlogwang 
5502bfe3f2eSlogwang static inline void *
get_sec_session_private_data(const struct rte_security_session * sess)5512bfe3f2eSlogwang get_sec_session_private_data(const struct rte_security_session *sess)
5522bfe3f2eSlogwang {
5532bfe3f2eSlogwang 	return sess->sess_private_data;
5542bfe3f2eSlogwang }
5552bfe3f2eSlogwang 
5562bfe3f2eSlogwang static inline void
set_sec_session_private_data(struct rte_security_session * sess,void * private_data)5572bfe3f2eSlogwang set_sec_session_private_data(struct rte_security_session *sess,
5582bfe3f2eSlogwang 			     void *private_data)
5592bfe3f2eSlogwang {
5602bfe3f2eSlogwang 	sess->sess_private_data = private_data;
5612bfe3f2eSlogwang }
5622bfe3f2eSlogwang 
5632bfe3f2eSlogwang /**
5642bfe3f2eSlogwang  * Attach a session to a crypto operation.
5652bfe3f2eSlogwang  * This API is needed only in case of RTE_SECURITY_SESS_CRYPTO_PROTO_OFFLOAD
5662bfe3f2eSlogwang  * For other rte_security_session_action_type, ol_flags in rte_mbuf may be
5672bfe3f2eSlogwang  * defined to perform security operations.
5682bfe3f2eSlogwang  *
5692bfe3f2eSlogwang  * @param	op	crypto operation
5702bfe3f2eSlogwang  * @param	sess	security session
5712bfe3f2eSlogwang  */
5722bfe3f2eSlogwang static inline int
rte_security_attach_session(struct rte_crypto_op * op,struct rte_security_session * sess)5732bfe3f2eSlogwang rte_security_attach_session(struct rte_crypto_op *op,
5742bfe3f2eSlogwang 			    struct rte_security_session *sess)
5752bfe3f2eSlogwang {
5762bfe3f2eSlogwang 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC))
5772bfe3f2eSlogwang 		return -EINVAL;
5782bfe3f2eSlogwang 
5792bfe3f2eSlogwang 	op->sess_type =  RTE_CRYPTO_OP_SECURITY_SESSION;
5802bfe3f2eSlogwang 
5812bfe3f2eSlogwang 	return __rte_security_attach_session(op->sym, sess);
5822bfe3f2eSlogwang }
5832bfe3f2eSlogwang 
5842bfe3f2eSlogwang struct rte_security_macsec_stats {
5852bfe3f2eSlogwang 	uint64_t reserved;
5862bfe3f2eSlogwang };
5872bfe3f2eSlogwang 
5882bfe3f2eSlogwang struct rte_security_ipsec_stats {
5894418919fSjohnjiang 	uint64_t ipackets;  /**< Successfully received IPsec packets. */
5904418919fSjohnjiang 	uint64_t opackets;  /**< Successfully transmitted IPsec packets.*/
5914418919fSjohnjiang 	uint64_t ibytes;    /**< Successfully received IPsec bytes. */
5924418919fSjohnjiang 	uint64_t obytes;    /**< Successfully transmitted IPsec bytes. */
5934418919fSjohnjiang 	uint64_t ierrors;   /**< IPsec packets receive/decrypt errors. */
5944418919fSjohnjiang 	uint64_t oerrors;   /**< IPsec packets transmit/encrypt errors. */
5954418919fSjohnjiang 	uint64_t reserved1; /**< Reserved for future use. */
5964418919fSjohnjiang 	uint64_t reserved2; /**< Reserved for future use. */
5972bfe3f2eSlogwang };
5982bfe3f2eSlogwang 
599d30ea906Sjfb8856606 struct rte_security_pdcp_stats {
600d30ea906Sjfb8856606 	uint64_t reserved;
601d30ea906Sjfb8856606 };
602d30ea906Sjfb8856606 
603*2d9fd380Sjfb8856606 struct rte_security_docsis_stats {
604*2d9fd380Sjfb8856606 	uint64_t reserved;
605*2d9fd380Sjfb8856606 };
606*2d9fd380Sjfb8856606 
6072bfe3f2eSlogwang struct rte_security_stats {
6082bfe3f2eSlogwang 	enum rte_security_session_protocol protocol;
6092bfe3f2eSlogwang 	/**< Security protocol to be configured */
6102bfe3f2eSlogwang 
6112bfe3f2eSlogwang 	RTE_STD_C11
6122bfe3f2eSlogwang 	union {
6132bfe3f2eSlogwang 		struct rte_security_macsec_stats macsec;
6142bfe3f2eSlogwang 		struct rte_security_ipsec_stats ipsec;
615d30ea906Sjfb8856606 		struct rte_security_pdcp_stats pdcp;
616*2d9fd380Sjfb8856606 		struct rte_security_docsis_stats docsis;
6172bfe3f2eSlogwang 	};
6182bfe3f2eSlogwang };
6192bfe3f2eSlogwang 
6202bfe3f2eSlogwang /**
6212bfe3f2eSlogwang  * Get security session statistics
6222bfe3f2eSlogwang  *
6232bfe3f2eSlogwang  * @param	instance	security instance
6242bfe3f2eSlogwang  * @param	sess		security session
6254418919fSjohnjiang  * If security session is NULL then global (per security instance) statistics
6264418919fSjohnjiang  * will be retrieved, if supported. Global statistics collection is not
6274418919fSjohnjiang  * dependent on the per session statistics configuration.
6282bfe3f2eSlogwang  * @param	stats		statistics
6292bfe3f2eSlogwang  * @return
6304418919fSjohnjiang  *  - On success, return 0
6314418919fSjohnjiang  *  - On failure, a negative value
6322bfe3f2eSlogwang  */
6334418919fSjohnjiang __rte_experimental
6344418919fSjohnjiang int
6352bfe3f2eSlogwang rte_security_session_stats_get(struct rte_security_ctx *instance,
6362bfe3f2eSlogwang 			       struct rte_security_session *sess,
6372bfe3f2eSlogwang 			       struct rte_security_stats *stats);
6382bfe3f2eSlogwang 
6392bfe3f2eSlogwang /**
6402bfe3f2eSlogwang  * Security capability definition
6412bfe3f2eSlogwang  */
6422bfe3f2eSlogwang struct rte_security_capability {
6432bfe3f2eSlogwang 	enum rte_security_session_action_type action;
6442bfe3f2eSlogwang 	/**< Security action type*/
6452bfe3f2eSlogwang 	enum rte_security_session_protocol protocol;
6462bfe3f2eSlogwang 	/**< Security protocol */
6472bfe3f2eSlogwang 	RTE_STD_C11
6482bfe3f2eSlogwang 	union {
6492bfe3f2eSlogwang 		struct {
6502bfe3f2eSlogwang 			enum rte_security_ipsec_sa_protocol proto;
6512bfe3f2eSlogwang 			/**< IPsec SA protocol */
6522bfe3f2eSlogwang 			enum rte_security_ipsec_sa_mode mode;
6532bfe3f2eSlogwang 			/**< IPsec SA mode */
6542bfe3f2eSlogwang 			enum rte_security_ipsec_sa_direction direction;
6552bfe3f2eSlogwang 			/**< IPsec SA direction */
6562bfe3f2eSlogwang 			struct rte_security_ipsec_sa_options options;
6572bfe3f2eSlogwang 			/**< IPsec SA supported options */
6584418919fSjohnjiang 			uint32_t replay_win_sz_max;
6594418919fSjohnjiang 			/**< IPsec Anti Replay Window Size. A '0' value
6604418919fSjohnjiang 			 * indicates that Anti Replay is not supported.
6614418919fSjohnjiang 			 */
6622bfe3f2eSlogwang 		} ipsec;
6632bfe3f2eSlogwang 		/**< IPsec capability */
6642bfe3f2eSlogwang 		struct {
6652bfe3f2eSlogwang 			/* To be Filled */
6662bfe3f2eSlogwang 			int dummy;
6672bfe3f2eSlogwang 		} macsec;
6682bfe3f2eSlogwang 		/**< MACsec capability */
669d30ea906Sjfb8856606 		struct {
670d30ea906Sjfb8856606 			enum rte_security_pdcp_domain domain;
671d30ea906Sjfb8856606 			/**< PDCP mode of operation: Control or data */
672d30ea906Sjfb8856606 			uint32_t capa_flags;
6731646932aSjfb8856606 			/**< Capability flags, see RTE_SECURITY_PDCP_* */
674d30ea906Sjfb8856606 		} pdcp;
675d30ea906Sjfb8856606 		/**< PDCP capability */
676*2d9fd380Sjfb8856606 		struct {
677*2d9fd380Sjfb8856606 			enum rte_security_docsis_direction direction;
678*2d9fd380Sjfb8856606 			/**< DOCSIS direction */
679*2d9fd380Sjfb8856606 		} docsis;
680*2d9fd380Sjfb8856606 		/**< DOCSIS capability */
6812bfe3f2eSlogwang 	};
6822bfe3f2eSlogwang 
6832bfe3f2eSlogwang 	const struct rte_cryptodev_capabilities *crypto_capabilities;
6842bfe3f2eSlogwang 	/**< Corresponding crypto capabilities for security capability  */
6852bfe3f2eSlogwang 
6862bfe3f2eSlogwang 	uint32_t ol_flags;
6872bfe3f2eSlogwang 	/**< Device offload flags */
6882bfe3f2eSlogwang };
6892bfe3f2eSlogwang 
690d30ea906Sjfb8856606 /** Underlying Hardware/driver which support PDCP may or may not support
691d30ea906Sjfb8856606  * packet ordering. Set RTE_SECURITY_PDCP_ORDERING_CAP if it support.
692d30ea906Sjfb8856606  * If it is not set, driver/HW assumes packets received are in order
693d30ea906Sjfb8856606  * and it will be application's responsibility to maintain ordering.
694d30ea906Sjfb8856606  */
695d30ea906Sjfb8856606 #define RTE_SECURITY_PDCP_ORDERING_CAP		0x00000001
696d30ea906Sjfb8856606 
697d30ea906Sjfb8856606 /** Underlying Hardware/driver which support PDCP may or may not detect
698d30ea906Sjfb8856606  * duplicate packet. Set RTE_SECURITY_PDCP_DUP_DETECT_CAP if it support.
699d30ea906Sjfb8856606  * If it is not set, driver/HW assumes there is no duplicate packet received.
700d30ea906Sjfb8856606  */
701d30ea906Sjfb8856606 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP	0x00000002
702d30ea906Sjfb8856606 
7032bfe3f2eSlogwang #define RTE_SECURITY_TX_OLOAD_NEED_MDATA	0x00000001
7042bfe3f2eSlogwang /**< HW needs metadata update, see rte_security_set_pkt_metadata().
7052bfe3f2eSlogwang  */
7062bfe3f2eSlogwang 
7072bfe3f2eSlogwang #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD	0x00000002
7082bfe3f2eSlogwang /**< HW constructs trailer of packets
7092bfe3f2eSlogwang  * Transmitted packets will have the trailer added to them
7101646932aSjfb8856606  * by hardware. The next protocol field will be based on
7112bfe3f2eSlogwang  * the mbuf->inner_esp_next_proto field.
7122bfe3f2eSlogwang  */
7132bfe3f2eSlogwang #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD	0x00010000
7142bfe3f2eSlogwang /**< HW removes trailer of packets
7152bfe3f2eSlogwang  * Received packets have no trailer, the next protocol field
7162bfe3f2eSlogwang  * is supplied in the mbuf->inner_esp_next_proto field.
7172bfe3f2eSlogwang  * Inner packet is not modified.
7182bfe3f2eSlogwang  */
7192bfe3f2eSlogwang 
7202bfe3f2eSlogwang /**
7212bfe3f2eSlogwang  * Security capability index used to query a security instance for a specific
7222bfe3f2eSlogwang  * security capability
7232bfe3f2eSlogwang  */
7242bfe3f2eSlogwang struct rte_security_capability_idx {
7252bfe3f2eSlogwang 	enum rte_security_session_action_type action;
7262bfe3f2eSlogwang 	enum rte_security_session_protocol protocol;
7272bfe3f2eSlogwang 
7282bfe3f2eSlogwang 	RTE_STD_C11
7292bfe3f2eSlogwang 	union {
7302bfe3f2eSlogwang 		struct {
7312bfe3f2eSlogwang 			enum rte_security_ipsec_sa_protocol proto;
7322bfe3f2eSlogwang 			enum rte_security_ipsec_sa_mode mode;
7332bfe3f2eSlogwang 			enum rte_security_ipsec_sa_direction direction;
7342bfe3f2eSlogwang 		} ipsec;
735d30ea906Sjfb8856606 		struct {
736d30ea906Sjfb8856606 			enum rte_security_pdcp_domain domain;
737d30ea906Sjfb8856606 			uint32_t capa_flags;
738d30ea906Sjfb8856606 		} pdcp;
739*2d9fd380Sjfb8856606 		struct {
740*2d9fd380Sjfb8856606 			enum rte_security_docsis_direction direction;
741*2d9fd380Sjfb8856606 		} docsis;
7422bfe3f2eSlogwang 	};
7432bfe3f2eSlogwang };
7442bfe3f2eSlogwang 
7452bfe3f2eSlogwang /**
7462bfe3f2eSlogwang  *  Returns array of security instance capabilities
7472bfe3f2eSlogwang  *
7482bfe3f2eSlogwang  * @param	instance	Security instance.
7492bfe3f2eSlogwang  *
7502bfe3f2eSlogwang  * @return
7512bfe3f2eSlogwang  *   - Returns array of security capabilities.
7522bfe3f2eSlogwang  *   - Return NULL if no capabilities available.
7532bfe3f2eSlogwang  */
7542bfe3f2eSlogwang const struct rte_security_capability *
7552bfe3f2eSlogwang rte_security_capabilities_get(struct rte_security_ctx *instance);
7562bfe3f2eSlogwang 
7572bfe3f2eSlogwang /**
7582bfe3f2eSlogwang  * Query if a specific capability is available on security instance
7592bfe3f2eSlogwang  *
7602bfe3f2eSlogwang  * @param	instance	security instance.
7612bfe3f2eSlogwang  * @param	idx		security capability index to match against
7622bfe3f2eSlogwang  *
7632bfe3f2eSlogwang  * @return
7642bfe3f2eSlogwang  *   - Returns pointer to security capability on match of capability
7652bfe3f2eSlogwang  *     index criteria.
7662bfe3f2eSlogwang  *   - Return NULL if the capability not matched on security instance.
7672bfe3f2eSlogwang  */
7682bfe3f2eSlogwang const struct rte_security_capability *
7692bfe3f2eSlogwang rte_security_capability_get(struct rte_security_ctx *instance,
7702bfe3f2eSlogwang 			    struct rte_security_capability_idx *idx);
7712bfe3f2eSlogwang 
7722bfe3f2eSlogwang #ifdef __cplusplus
7732bfe3f2eSlogwang }
7742bfe3f2eSlogwang #endif
7752bfe3f2eSlogwang 
7762bfe3f2eSlogwang #endif /* _RTE_SECURITY_H_ */
777