xref: /dpdk/lib/security/rte_security.h (revision c56185fc183fc0532d2f03aaf04bbf0989ea91a5)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017,2019-2020 NXP
3  * Copyright(c) 2017-2020 Intel Corporation.
4  */
5 
6 #ifndef _RTE_SECURITY_H_
7 #define _RTE_SECURITY_H_
8 
9 /**
10  * @file rte_security.h
11  *
12  * RTE Security Common Definitions
13  */
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include <sys/types.h>
20 
21 #include <rte_compat.h>
22 #include <rte_common.h>
23 #include <rte_crypto.h>
24 #include <rte_ip.h>
25 #include <rte_mbuf_dyn.h>
26 
27 /** IPSec protocol mode */
28 enum rte_security_ipsec_sa_mode {
29 	RTE_SECURITY_IPSEC_SA_MODE_TRANSPORT = 1,
30 	/**< IPSec Transport mode */
31 	RTE_SECURITY_IPSEC_SA_MODE_TUNNEL,
32 	/**< IPSec Tunnel mode */
33 };
34 
35 /** IPSec Protocol */
36 enum rte_security_ipsec_sa_protocol {
37 	RTE_SECURITY_IPSEC_SA_PROTO_AH = 1,
38 	/**< AH protocol */
39 	RTE_SECURITY_IPSEC_SA_PROTO_ESP,
40 	/**< ESP protocol */
41 };
42 
43 /** IPSEC tunnel type */
44 enum rte_security_ipsec_tunnel_type {
45 	RTE_SECURITY_IPSEC_TUNNEL_IPV4 = 1,
46 	/**< Outer header is IPv4 */
47 	RTE_SECURITY_IPSEC_TUNNEL_IPV6,
48 	/**< Outer header is IPv6 */
49 };
50 
51 /**
52  * IPSEC tunnel header verification mode
53  *
54  * Controls how outer IP header is verified in inbound.
55  */
56 #define RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR     0x1
57 #define RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR 0x2
58 
59 /**
60  * Security context for crypto/eth devices
61  *
62  * Security instance for each driver to register security operations.
63  * The application can get the security context from the crypto/eth device id
64  * using the APIs rte_cryptodev_get_sec_ctx()/rte_eth_dev_get_sec_ctx()
65  * This structure is used to identify the device(crypto/eth) for which the
66  * security operations need to be performed.
67  */
68 struct rte_security_ctx {
69 	void *device;
70 	/**< Crypto/ethernet device attached */
71 	const struct rte_security_ops *ops;
72 	/**< Pointer to security ops for the device */
73 	uint16_t sess_cnt;
74 	/**< Number of sessions attached to this context */
75 	uint16_t macsec_sc_cnt;
76 	/**< Number of MACsec SC attached to this context */
77 	uint16_t macsec_sa_cnt;
78 	/**< Number of MACsec SA attached to this context */
79 	uint32_t flags;
80 	/**< Flags for security context */
81 };
82 
83 #define RTE_SEC_CTX_F_FAST_SET_MDATA 0x00000001
84 /**< Driver uses fast metadata update without using driver specific callback.
85  * For fast mdata, mbuf dynamic field would be registered by driver
86  * via rte_security_dynfield_register().
87  */
88 
89 /**
90  * IPSEC tunnel parameters
91  *
92  * These parameters are used to build outbound tunnel headers.
93  */
94 struct rte_security_ipsec_tunnel_param {
95 	enum rte_security_ipsec_tunnel_type type;
96 	/**< Tunnel type: IPv4 or IPv6 */
97 	union {
98 		struct {
99 			struct in_addr src_ip;
100 			/**< IPv4 source address */
101 			struct in_addr dst_ip;
102 			/**< IPv4 destination address */
103 			uint8_t dscp;
104 			/**< IPv4 Differentiated Services Code Point */
105 			uint8_t df;
106 			/**< IPv4 Don't Fragment bit */
107 			uint8_t ttl;
108 			/**< IPv4 Time To Live */
109 		} ipv4;
110 		/**< IPv4 header parameters */
111 		struct {
112 			struct in6_addr src_addr;
113 			/**< IPv6 source address */
114 			struct in6_addr dst_addr;
115 			/**< IPv6 destination address */
116 			uint8_t dscp;
117 			/**< IPv6 Differentiated Services Code Point */
118 			uint32_t flabel;
119 			/**< IPv6 flow label */
120 			uint8_t hlimit;
121 			/**< IPv6 hop limit */
122 		} ipv6;
123 		/**< IPv6 header parameters */
124 	};
125 };
126 
127 struct rte_security_ipsec_udp_param {
128 	uint16_t sport;
129 	uint16_t dport;
130 };
131 
132 /**
133  * IPsec Security Association option flags
134  */
135 struct rte_security_ipsec_sa_options {
136 	/** Extended Sequence Numbers (ESN)
137 	 *
138 	 * * 1: Use extended (64 bit) sequence numbers
139 	 * * 0: Use normal sequence numbers
140 	 */
141 	uint32_t esn : 1;
142 
143 	/** UDP encapsulation
144 	 *
145 	 * * 1: Do UDP encapsulation/decapsulation so that IPSEC packets can
146 	 *      traverse through NAT boxes.
147 	 * * 0: No UDP encapsulation
148 	 */
149 	uint32_t udp_encap : 1;
150 
151 	/** Copy DSCP bits
152 	 *
153 	 * * 1: Copy IPv4 or IPv6 DSCP bits from inner IP header to
154 	 *      the outer IP header in encapsulation, and vice versa in
155 	 *      decapsulation.
156 	 * * 0: Do not change DSCP field.
157 	 */
158 	uint32_t copy_dscp : 1;
159 
160 	/** Copy IPv6 Flow Label
161 	 *
162 	 * * 1: Copy IPv6 flow label from inner IPv6 header to the
163 	 *      outer IPv6 header.
164 	 * * 0: Outer header is not modified.
165 	 */
166 	uint32_t copy_flabel : 1;
167 
168 	/** Copy IPv4 Don't Fragment bit
169 	 *
170 	 * * 1: Copy the DF bit from the inner IPv4 header to the outer
171 	 *      IPv4 header.
172 	 * * 0: Outer header is not modified.
173 	 */
174 	uint32_t copy_df : 1;
175 
176 	/** Decrement inner packet Time To Live (TTL) field
177 	 *
178 	 * * 1: In tunnel mode, decrement inner packet IPv4 TTL or
179 	 *      IPv6 Hop Limit after tunnel decapsulation, or before tunnel
180 	 *      encapsulation.
181 	 * * 0: Inner packet is not modified.
182 	 */
183 	uint32_t dec_ttl : 1;
184 
185 	/** Explicit Congestion Notification (ECN)
186 	 *
187 	 * * 1: In tunnel mode, enable outer header ECN Field copied from
188 	 *      inner header in tunnel encapsulation, or inner header ECN
189 	 *      field construction in decapsulation.
190 	 * * 0: Inner/outer header are not modified.
191 	 */
192 	uint32_t ecn : 1;
193 
194 	/** Security statistics
195 	 *
196 	 * * 1: Enable per session security statistics collection for
197 	 *      this SA, if supported by the driver.
198 	 * * 0: Disable per session security statistics collection for this SA.
199 	 */
200 	uint32_t stats : 1;
201 
202 	/** Disable IV generation in PMD
203 	 *
204 	 * * 1: Disable IV generation in PMD. When disabled, IV provided in
205 	 *      rte_crypto_op will be used by the PMD.
206 	 *
207 	 * * 0: Enable IV generation in PMD. When enabled, PMD generated random
208 	 *      value would be used and application is not required to provide
209 	 *      IV.
210 	 *
211 	 * Note: For inline cases, IV generation would always need to be handled
212 	 * by the PMD.
213 	 */
214 	uint32_t iv_gen_disable : 1;
215 
216 	/** Verify tunnel header in inbound
217 	 * * ``RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR``: Verify destination
218 	 *   IP address.
219 	 *
220 	 * * ``RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR``: Verify both
221 	 *   source and destination IP addresses.
222 	 */
223 	uint32_t tunnel_hdr_verify : 2;
224 
225 	/** Verify UDP encapsulation ports in inbound
226 	 *
227 	 * * 1: Match UDP source and destination ports
228 	 * * 0: Do not match UDP ports
229 	 */
230 	uint32_t udp_ports_verify : 1;
231 
232 	/** Compute/verify inner packet IPv4 header checksum in tunnel mode
233 	 *
234 	 * * 1: For outbound, compute inner packet IPv4 header checksum
235 	 *      before tunnel encapsulation and for inbound, verify after
236 	 *      tunnel decapsulation.
237 	 * * 0: Inner packet IP header checksum is not computed/verified.
238 	 *
239 	 * The checksum verification status would be set in mbuf using
240 	 * RTE_MBUF_F_RX_IP_CKSUM_xxx flags.
241 	 *
242 	 * Inner IP checksum computation can also be enabled(per operation)
243 	 * by setting the flag RTE_MBUF_F_TX_IP_CKSUM in mbuf.
244 	 */
245 	uint32_t ip_csum_enable : 1;
246 
247 	/** Compute/verify inner packet L4 checksum in tunnel mode
248 	 *
249 	 * * 1: For outbound, compute inner packet L4 checksum before
250 	 *      tunnel encapsulation and for inbound, verify after
251 	 *      tunnel decapsulation.
252 	 * * 0: Inner packet L4 checksum is not computed/verified.
253 	 *
254 	 * The checksum verification status would be set in mbuf using
255 	 * RTE_MBUF_F_RX_L4_CKSUM_xxx flags.
256 	 *
257 	 * Inner L4 checksum computation can also be enabled(per operation)
258 	 * by setting the flags RTE_MBUF_F_TX_TCP_CKSUM or RTE_MBUF_F_TX_SCTP_CKSUM or
259 	 * RTE_MBUF_F_TX_UDP_CKSUM or RTE_MBUF_F_TX_L4_MASK in mbuf.
260 	 */
261 	uint32_t l4_csum_enable : 1;
262 
263 	/** Enable IP reassembly on inline inbound packets.
264 	 *
265 	 * * 1: Enable driver to try reassembly of encrypted IP packets for
266 	 *      this SA, if supported by the driver. This feature will work
267 	 *      only if user has successfully set IP reassembly config params
268 	 *      using rte_eth_ip_reassembly_conf_set() for the inline Ethernet
269 	 *      device. PMD need to register mbuf dynamic fields using
270 	 *      rte_eth_ip_reassembly_dynfield_register() and security session
271 	 *      creation would fail if dynfield is not registered successfully.
272 	 * * 0: Disable IP reassembly of packets (default).
273 	 */
274 	uint32_t ip_reassembly_en : 1;
275 
276 	/** Reserved bit fields for future extension
277 	 *
278 	 * User should ensure reserved_opts is cleared as it may change in
279 	 * subsequent releases to support new options.
280 	 *
281 	 * Note: Reduce number of bits in reserved_opts for every new option.
282 	 */
283 	uint32_t reserved_opts : 17;
284 };
285 
286 /** IPSec security association direction */
287 enum rte_security_ipsec_sa_direction {
288 	RTE_SECURITY_IPSEC_SA_DIR_EGRESS,
289 	/**< Encrypt and generate digest */
290 	RTE_SECURITY_IPSEC_SA_DIR_INGRESS,
291 	/**< Verify digest and decrypt */
292 };
293 
294 /**
295  * Configure soft and hard lifetime of an IPsec SA
296  *
297  * Lifetime of an IPsec SA would specify the maximum number of packets or bytes
298  * that can be processed. IPsec operations would start failing once any hard
299  * limit is reached.
300  *
301  * Soft limits can be specified to generate notification when the SA is
302  * approaching hard limits for lifetime. For inline operations, reaching soft
303  * expiry limit would result in raising an eth event for the same. For lookaside
304  * operations, this would result in a warning returned in
305  * ``rte_crypto_op.aux_flags``.
306  */
307 struct rte_security_ipsec_lifetime {
308 	uint64_t packets_soft_limit;
309 	/**< Soft expiry limit in number of packets */
310 	uint64_t bytes_soft_limit;
311 	/**< Soft expiry limit in bytes */
312 	uint64_t packets_hard_limit;
313 	/**< Hard expiry limit in number of packets */
314 	uint64_t bytes_hard_limit;
315 	/**< Hard expiry limit in bytes */
316 };
317 
318 /**
319  * IPsec security association configuration data.
320  *
321  * This structure contains data required to create an IPsec SA security session.
322  */
323 struct rte_security_ipsec_xform {
324 	uint32_t spi;
325 	/**< SA security parameter index */
326 	uint32_t salt;
327 	/**< SA salt */
328 	struct rte_security_ipsec_sa_options options;
329 	/**< various SA options */
330 	enum rte_security_ipsec_sa_direction direction;
331 	/**< IPSec SA Direction - Egress/Ingress */
332 	enum rte_security_ipsec_sa_protocol proto;
333 	/**< IPsec SA Protocol - AH/ESP */
334 	enum rte_security_ipsec_sa_mode mode;
335 	/**< IPsec SA Mode - transport/tunnel */
336 	struct rte_security_ipsec_tunnel_param tunnel;
337 	/**< Tunnel parameters, NULL for transport mode */
338 	struct rte_security_ipsec_lifetime life;
339 	/**< IPsec SA lifetime */
340 	uint32_t replay_win_sz;
341 	/**< Anti replay window size to enable sequence replay attack handling.
342 	 * replay checking is disabled if the window size is 0.
343 	 */
344 	union {
345 		uint64_t value;
346 		struct {
347 			uint32_t low;
348 			uint32_t hi;
349 		};
350 	} esn;
351 	/**< Extended Sequence Number */
352 	struct rte_security_ipsec_udp_param udp;
353 	/**< UDP parameters, ignored when udp_encap option not specified */
354 };
355 
356 /**
357  * MACSec packet flow direction
358  */
359 enum rte_security_macsec_direction {
360 	/** Generate SecTag and encrypt/authenticate */
361 	RTE_SECURITY_MACSEC_DIR_TX,
362 	/** Remove SecTag and decrypt/verify */
363 	RTE_SECURITY_MACSEC_DIR_RX,
364 };
365 
366 /** Maximum number of association numbers for a secure channel. */
367 #define RTE_SECURITY_MACSEC_NUM_AN	4
368 /** Salt length for MACsec SA. */
369 #define RTE_SECURITY_MACSEC_SALT_LEN	12
370 
371 /**
372  * MACsec secure association (SA) configuration structure.
373  */
374 struct rte_security_macsec_sa {
375 	/** Direction of SA */
376 	enum rte_security_macsec_direction dir;
377 	/** MACsec SA key for AES-GCM 128/256 */
378 	struct {
379 		const uint8_t *data;	/**< pointer to key data */
380 		uint16_t length;	/**< key length in bytes */
381 	} key;
382 	/** 96-bit value distributed by key agreement protocol */
383 	uint8_t salt[RTE_SECURITY_MACSEC_SALT_LEN];
384 	/** Association number to be used */
385 	uint8_t an : 2;
386 	/** Short Secure Channel Identifier, to be used for XPN cases */
387 	uint32_t ssci;
388 	/** Extended packet number */
389 	uint32_t xpn;
390 	/** Packet number expected/ to be used for next packet of this SA */
391 	uint32_t next_pn;
392 };
393 
394 /**
395  * MACsec Secure Channel configuration parameters.
396  */
397 struct rte_security_macsec_sc {
398 	/** Direction of SC */
399 	enum rte_security_macsec_direction dir;
400 	/** Packet number threshold */
401 	uint64_t pn_threshold;
402 	union {
403 		struct {
404 			/** SAs for each association number */
405 			uint16_t sa_id[RTE_SECURITY_MACSEC_NUM_AN];
406 			/** flag to denote which all SAs are in use for each association number */
407 			uint8_t sa_in_use[RTE_SECURITY_MACSEC_NUM_AN];
408 			/** Channel is active */
409 			uint8_t active : 1;
410 			/** Extended packet number is enabled for SAs */
411 			uint8_t is_xpn : 1;
412 			/** Reserved bitfields for future */
413 			uint8_t reserved : 6;
414 		} sc_rx;
415 		struct {
416 			uint16_t sa_id; /**< SA ID to be used for encryption */
417 			uint16_t sa_id_rekey; /**< Rekeying SA ID to be used for encryption */
418 			uint64_t sci; /**< SCI value to be used if send_sci is set */
419 			uint8_t active : 1; /**< Channel is active */
420 			uint8_t re_key_en : 1; /**< Enable Rekeying */
421 			/** Extended packet number is enabled for SAs */
422 			uint8_t is_xpn : 1;
423 			/** Reserved bitfields for future */
424 			uint8_t reserved : 5;
425 		} sc_tx;
426 	};
427 };
428 
429 /**
430  * MACsec Supported Algorithm list as per IEEE Std 802.1AE.
431  */
432 enum rte_security_macsec_alg {
433 	RTE_SECURITY_MACSEC_ALG_GCM_128, /**< AES-GCM 128 bit block cipher */
434 	RTE_SECURITY_MACSEC_ALG_GCM_256, /**< AES-GCM 256 bit block cipher */
435 	RTE_SECURITY_MACSEC_ALG_GCM_XPN_128, /**< AES-GCM 128 bit block cipher with unique SSCI */
436 	RTE_SECURITY_MACSEC_ALG_GCM_XPN_256, /**< AES-GCM 256 bit block cipher with unique SSCI */
437 };
438 
439 /** Disable Validation of MACsec frame. */
440 #define RTE_SECURITY_MACSEC_VALIDATE_DISABLE	0
441 /** Validate MACsec frame but do not discard invalid frame. */
442 #define RTE_SECURITY_MACSEC_VALIDATE_NO_DISCARD	1
443 /** Validate MACsec frame and discart invalid frame. */
444 #define RTE_SECURITY_MACSEC_VALIDATE_STRICT	2
445 /** Do not perform any MACsec operation. */
446 #define RTE_SECURITY_MACSEC_VALIDATE_NO_OP	3
447 
448 /**
449  * MACsec security session configuration
450  */
451 struct rte_security_macsec_xform {
452 	/** Direction of flow/secure channel */
453 	enum rte_security_macsec_direction dir;
454 	/** MACsec algorithm to be used */
455 	enum rte_security_macsec_alg alg;
456 	/** Cipher offset from start of Ethernet header */
457 	uint8_t cipher_off;
458 	/**
459 	 * SCI to be used for RX flow identification or
460 	 * to set SCI in packet for TX when send_sci is set
461 	 */
462 	uint64_t sci;
463 	/** Receive/transmit secure channel ID created by *rte_security_macsec_sc_create* */
464 	uint16_t sc_id;
465 	union {
466 		struct {
467 			/** MTU for transmit frame (valid for inline processing) */
468 			uint16_t mtu;
469 			/**
470 			 * Offset to insert sectag from start of ethernet header or
471 			 * from a matching VLAN tag
472 			 */
473 			uint8_t sectag_off;
474 			/** Enable MACsec protection of frames */
475 			uint16_t protect_frames : 1;
476 			/**
477 			 * Sectag insertion mode
478 			 * If 1, Sectag is inserted at fixed sectag_off set above.
479 			 * If 0, Sectag is inserted at relative sectag_off from a matching
480 			 * VLAN tag set.
481 			 */
482 			uint16_t sectag_insert_mode : 1;
483 			/** ICV includes source and destination MAC addresses */
484 			uint16_t icv_include_da_sa : 1;
485 			/** Control port is enabled */
486 			uint16_t ctrl_port_enable : 1;
487 			/** Version of MACsec header. Should be 0 */
488 			uint16_t sectag_version : 1;
489 			/** Enable end station. SCI is not valid */
490 			uint16_t end_station : 1;
491 			/** Send SCI along with sectag */
492 			uint16_t send_sci : 1;
493 			/** enable secure channel support EPON - single copy broadcast */
494 			uint16_t scb : 1;
495 			/**
496 			 * Enable packet encryption and set RTE_MACSEC_TCI_C and
497 			 * RTE_MACSEC_TCI_E in sectag
498 			 */
499 			uint16_t encrypt : 1;
500 			/** Reserved bitfields for future */
501 			uint16_t reserved : 7;
502 		} tx_secy;
503 		struct {
504 			/** Replay Window size to be supported */
505 			uint32_t replay_win_sz;
506 			/** Set bits as per RTE_SECURITY_MACSEC_VALIDATE_* */
507 			uint16_t validate_frames : 2;
508 			/** ICV includes source and destination MAC addresses */
509 			uint16_t icv_include_da_sa : 1;
510 			/** Control port is enabled */
511 			uint16_t ctrl_port_enable : 1;
512 			/** Do not strip SecTAG after processing */
513 			uint16_t preserve_sectag : 1;
514 			/** Do not strip ICV from the packet after processing */
515 			uint16_t preserve_icv : 1;
516 			/** Enable anti-replay protection */
517 			uint16_t replay_protect : 1;
518 			/** Reserved bitfields for future */
519 			uint16_t reserved : 9;
520 		} rx_secy;
521 	};
522 };
523 
524 /**
525  * PDCP Mode of session
526  */
527 enum rte_security_pdcp_domain {
528 	RTE_SECURITY_PDCP_MODE_CONTROL,	/**< PDCP control plane */
529 	RTE_SECURITY_PDCP_MODE_DATA,	/**< PDCP data plane */
530 	RTE_SECURITY_PDCP_MODE_SHORT_MAC,	/**< PDCP short mac */
531 };
532 
533 /** PDCP Frame direction */
534 enum rte_security_pdcp_direction {
535 	RTE_SECURITY_PDCP_UPLINK,	/**< Uplink */
536 	RTE_SECURITY_PDCP_DOWNLINK,	/**< Downlink */
537 };
538 
539 /** PDCP Sequence Number Size selectors */
540 enum rte_security_pdcp_sn_size {
541 	/** PDCP_SN_SIZE_5: 5bit sequence number */
542 	RTE_SECURITY_PDCP_SN_SIZE_5 = 5,
543 	/** PDCP_SN_SIZE_7: 7bit sequence number */
544 	RTE_SECURITY_PDCP_SN_SIZE_7 = 7,
545 	/** PDCP_SN_SIZE_12: 12bit sequence number */
546 	RTE_SECURITY_PDCP_SN_SIZE_12 = 12,
547 	/** PDCP_SN_SIZE_15: 15bit sequence number */
548 	RTE_SECURITY_PDCP_SN_SIZE_15 = 15,
549 	/** PDCP_SN_SIZE_18: 18bit sequence number */
550 	RTE_SECURITY_PDCP_SN_SIZE_18 = 18
551 };
552 
553 /**
554  * PDCP security association configuration data.
555  *
556  * This structure contains data required to create a PDCP security session.
557  */
558 struct rte_security_pdcp_xform {
559 	int8_t bearer;	/**< PDCP bearer ID */
560 	/** Enable in order delivery, this field shall be set only if
561 	 * driver/HW is capable. See RTE_SECURITY_PDCP_ORDERING_CAP.
562 	 */
563 	uint8_t en_ordering;
564 	/** Notify driver/HW to detect and remove duplicate packets.
565 	 * This field should be set only when driver/hw is capable.
566 	 * See RTE_SECURITY_PDCP_DUP_DETECT_CAP.
567 	 */
568 	uint8_t remove_duplicates;
569 	/** PDCP mode of operation: Control or data */
570 	enum rte_security_pdcp_domain domain;
571 	/** PDCP Frame Direction 0:UL 1:DL */
572 	enum rte_security_pdcp_direction pkt_dir;
573 	/** Sequence number size, 5/7/12/15/18 */
574 	enum rte_security_pdcp_sn_size sn_size;
575 	/** Starting Hyper Frame Number to be used together with the SN
576 	 * from the PDCP frames
577 	 */
578 	uint32_t hfn;
579 	/** HFN Threshold for key renegotiation */
580 	uint32_t hfn_threshold;
581 	/** HFN can be given as a per packet value also.
582 	 * As we do not have IV in case of PDCP, and HFN is
583 	 * used to generate IV. IV field can be used to get the
584 	 * per packet HFN while enq/deq.
585 	 * If hfn_ovrd field is set, user is expected to set the
586 	 * per packet HFN in place of IV. PMDs will extract the HFN
587 	 * and perform operations accordingly.
588 	 */
589 	uint8_t hfn_ovrd;
590 	/** In case of 5G NR, a new protocol (SDAP) header may be set
591 	 * inside PDCP payload which should be authenticated but not
592 	 * encrypted. Hence, driver should be notified if SDAP is
593 	 * enabled or not, so that SDAP header is not encrypted.
594 	 */
595 	uint8_t sdap_enabled;
596 	/** Reserved for future */
597 	uint16_t reserved;
598 };
599 
600 /** DOCSIS direction */
601 enum rte_security_docsis_direction {
602 	RTE_SECURITY_DOCSIS_UPLINK,
603 	/**< Uplink
604 	 * - Decryption, followed by CRC Verification
605 	 */
606 	RTE_SECURITY_DOCSIS_DOWNLINK,
607 	/**< Downlink
608 	 * - CRC Generation, followed by Encryption
609 	 */
610 };
611 
612 /**
613  * DOCSIS security session configuration.
614  *
615  * This structure contains data required to create a DOCSIS security session.
616  */
617 struct rte_security_docsis_xform {
618 	enum rte_security_docsis_direction direction;
619 	/**< DOCSIS direction */
620 };
621 
622 /**
623  * Security session action type.
624  */
625 enum rte_security_session_action_type {
626 	RTE_SECURITY_ACTION_TYPE_NONE,
627 	/**< No security actions */
628 	RTE_SECURITY_ACTION_TYPE_INLINE_CRYPTO,
629 	/**< Crypto processing for security protocol is processed inline
630 	 * during transmission
631 	 */
632 	RTE_SECURITY_ACTION_TYPE_INLINE_PROTOCOL,
633 	/**< All security protocol processing is performed inline during
634 	 * transmission
635 	 */
636 	RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
637 	/**< All security protocol processing including crypto is performed
638 	 * on a lookaside accelerator
639 	 */
640 	RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO
641 	/**< Similar to ACTION_TYPE_NONE but crypto processing for security
642 	 * protocol is processed synchronously by a CPU.
643 	 */
644 };
645 
646 /** Security session protocol definition */
647 enum rte_security_session_protocol {
648 	RTE_SECURITY_PROTOCOL_IPSEC = 1,
649 	/**< IPsec Protocol */
650 	RTE_SECURITY_PROTOCOL_MACSEC,
651 	/**< MACSec Protocol */
652 	RTE_SECURITY_PROTOCOL_PDCP,
653 	/**< PDCP Protocol */
654 	RTE_SECURITY_PROTOCOL_DOCSIS,
655 	/**< DOCSIS Protocol */
656 };
657 
658 /**
659  * Security session configuration
660  */
661 struct rte_security_session_conf {
662 	enum rte_security_session_action_type action_type;
663 	/**< Type of action to be performed on the session */
664 	enum rte_security_session_protocol protocol;
665 	/**< Security protocol to be configured */
666 	union {
667 		struct rte_security_ipsec_xform ipsec;
668 		struct rte_security_macsec_xform macsec;
669 		struct rte_security_pdcp_xform pdcp;
670 		struct rte_security_docsis_xform docsis;
671 	};
672 	/**< Configuration parameters for security session */
673 	struct rte_crypto_sym_xform *crypto_xform;
674 	/**< Security Session Crypto Transformations. NULL in case of MACsec. */
675 	void *userdata;
676 	/**< Application specific userdata to be saved with session */
677 };
678 
679 /**
680  * Create security session as specified by the session configuration
681  *
682  * @param   instance	security instance
683  * @param   conf	session configuration parameters
684  * @param   mp		mempool to allocate session objects from
685  * @return
686  *  - On success, pointer to session
687  *  - On failure, NULL
688  */
689 void *
690 rte_security_session_create(struct rte_security_ctx *instance,
691 			    struct rte_security_session_conf *conf,
692 			    struct rte_mempool *mp);
693 
694 /**
695  * Update security session as specified by the session configuration
696  *
697  * @param   instance	security instance
698  * @param   sess	session to update parameters
699  * @param   conf	update configuration parameters
700  * @return
701  *  - On success returns 0
702  *  - On failure returns a negative errno value.
703  */
704 __rte_experimental
705 int
706 rte_security_session_update(struct rte_security_ctx *instance,
707 			    void *sess,
708 			    struct rte_security_session_conf *conf);
709 
710 /**
711  * Get the size of the security session data for a device.
712  *
713  * @param   instance	security instance.
714  *
715  * @return
716  *   - Size of the private data, if successful
717  *   - 0 if device is invalid or does not support the operation.
718  */
719 unsigned int
720 rte_security_session_get_size(struct rte_security_ctx *instance);
721 
722 /**
723  * Free security session header and the session private data and
724  * return it to its original mempool.
725  *
726  * @param   instance	security instance
727  * @param   sess	security session to be freed
728  *
729  * @return
730  *  - 0 if successful.
731  *  - -EINVAL if session or context instance is NULL.
732  *  - -EBUSY if not all device private data has been freed.
733  *  - -ENOTSUP if destroying private data is not supported.
734  *  - other negative values in case of freeing private data errors.
735  */
736 int
737 rte_security_session_destroy(struct rte_security_ctx *instance, void *sess);
738 
739 /**
740  * @warning
741  * @b EXPERIMENTAL: this API may change without prior notice
742  *
743  * Create MACsec security channel (SC).
744  *
745  * @param   instance	security instance
746  * @param   conf	MACsec SC configuration params
747  * @return
748  *  - secure channel ID if successful.
749  *  - -EINVAL if configuration params are invalid of instance is NULL.
750  *  - -ENOTSUP if device does not support MACsec.
751  *  - -ENOMEM if PMD is not capable to create more SC.
752  *  - other negative value for other errors.
753  */
754 __rte_experimental
755 int
756 rte_security_macsec_sc_create(struct rte_security_ctx *instance,
757 			      struct rte_security_macsec_sc *conf);
758 
759 /**
760  * @warning
761  * @b EXPERIMENTAL: this API may change without prior notice
762  *
763  * Destroy MACsec security channel (SC).
764  *
765  * @param   instance	security instance
766  * @param   sc_id	SC ID to be destroyed
767  * @param   dir		direction of the SC
768  * @return
769  *  - 0 if successful.
770  *  - -EINVAL if sc_id is invalid or instance is NULL.
771  *  - -EBUSY if sc is being used by some session.
772  */
773 __rte_experimental
774 int
775 rte_security_macsec_sc_destroy(struct rte_security_ctx *instance, uint16_t sc_id,
776 			       enum rte_security_macsec_direction dir);
777 
778 /**
779  * @warning
780  * @b EXPERIMENTAL: this API may change without prior notice
781  *
782  * Create MACsec security association (SA).
783  *
784  * @param   instance	security instance
785  * @param   conf	MACsec SA configuration params
786  * @return
787  *  - positive SA ID if successful.
788  *  - -EINVAL if configuration params are invalid of instance is NULL.
789  *  - -ENOTSUP if device does not support MACsec.
790  *  - -ENOMEM if PMD is not capable to create more SAs.
791  *  - other negative value for other errors.
792  */
793 __rte_experimental
794 int
795 rte_security_macsec_sa_create(struct rte_security_ctx *instance,
796 			      struct rte_security_macsec_sa *conf);
797 
798 /**
799  * @warning
800  * @b EXPERIMENTAL: this API may change without prior notice
801  *
802  * Destroy MACsec security association (SA).
803  *
804  * @param   instance	security instance
805  * @param   sa_id	SA ID to be destroyed
806  * @param   dir		direction of the SA
807  * @return
808  *  - 0 if successful.
809  *  - -EINVAL if sa_id is invalid or instance is NULL.
810  *  - -EBUSY if sa is being used by some session.
811  */
812 __rte_experimental
813 int
814 rte_security_macsec_sa_destroy(struct rte_security_ctx *instance, uint16_t sa_id,
815 			       enum rte_security_macsec_direction dir);
816 
817 /** Device-specific metadata field type */
818 typedef uint64_t rte_security_dynfield_t;
819 /** Dynamic mbuf field for device-specific metadata */
820 extern int rte_security_dynfield_offset;
821 
822 /**
823  * @warning
824  * @b EXPERIMENTAL: this API may change without prior notice
825  *
826  * Get pointer to mbuf field for device-specific metadata.
827  *
828  * For performance reason, no check is done,
829  * the dynamic field may not be registered.
830  * @see rte_security_dynfield_is_registered
831  *
832  * @param	mbuf	packet to access
833  * @return pointer to mbuf field
834  */
835 __rte_experimental
836 static inline rte_security_dynfield_t *
837 rte_security_dynfield(struct rte_mbuf *mbuf)
838 {
839 	return RTE_MBUF_DYNFIELD(mbuf,
840 		rte_security_dynfield_offset,
841 		rte_security_dynfield_t *);
842 }
843 
844 /**
845  * @warning
846  * @b EXPERIMENTAL: this API may change without prior notice
847  *
848  * Check whether the dynamic field is registered.
849  *
850  * @return true if rte_security_dynfield_register() has been called.
851  */
852 __rte_experimental
853 static inline bool rte_security_dynfield_is_registered(void)
854 {
855 	return rte_security_dynfield_offset >= 0;
856 }
857 
858 #define RTE_SECURITY_SESS_OPAQUE_DATA_OFF	0
859 #define RTE_SECURITY_SESS_FAST_MDATA_OFF	1
860 /**
861  * Get opaque data from session handle
862  */
863 static inline uint64_t
864 rte_security_session_opaque_data_get(void *sess)
865 {
866 	return *((uint64_t *)sess + RTE_SECURITY_SESS_OPAQUE_DATA_OFF);
867 }
868 
869 /**
870  * Set opaque data in session handle
871  */
872 static inline void
873 rte_security_session_opaque_data_set(void *sess, uint64_t opaque)
874 {
875 	uint64_t *data;
876 	data = (((uint64_t *)sess) + RTE_SECURITY_SESS_OPAQUE_DATA_OFF);
877 	*data = opaque;
878 }
879 
880 /**
881  * Get fast mdata from session handle
882  */
883 static inline uint64_t
884 rte_security_session_fast_mdata_get(void *sess)
885 {
886 	return *((uint64_t *)sess + RTE_SECURITY_SESS_FAST_MDATA_OFF);
887 }
888 
889 /**
890  * Set fast mdata in session handle
891  */
892 static inline void
893 rte_security_session_fast_mdata_set(void *sess, uint64_t fdata)
894 {
895 	uint64_t *data;
896 	data = (((uint64_t *)sess) + RTE_SECURITY_SESS_FAST_MDATA_OFF);
897 	*data = fdata;
898 }
899 
900 /** Function to call PMD specific function pointer set_pkt_metadata() */
901 __rte_experimental
902 int __rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
903 				    void *sess,
904 				    struct rte_mbuf *m, void *params);
905 
906 /**
907  *  Updates the buffer with device-specific defined metadata
908  *
909  * @param	instance	security instance
910  * @param	sess		security session
911  * @param	mb		packet mbuf to set metadata on.
912  * @param	params		device-specific defined parameters
913  *				required for metadata
914  *
915  * @return
916  *  - On success, zero.
917  *  - On failure, a negative value.
918  */
919 static inline int
920 rte_security_set_pkt_metadata(struct rte_security_ctx *instance,
921 			      void *sess,
922 			      struct rte_mbuf *mb, void *params)
923 {
924 	/* Fast Path */
925 	if (instance->flags & RTE_SEC_CTX_F_FAST_SET_MDATA) {
926 		*rte_security_dynfield(mb) = (rte_security_dynfield_t)
927 			rte_security_session_fast_mdata_get(sess);
928 		return 0;
929 	}
930 
931 	/* Jump to PMD specific function pointer */
932 	return __rte_security_set_pkt_metadata(instance, sess, mb, params);
933 }
934 
935 /**
936  * Attach a session to a symmetric crypto operation
937  *
938  * @param	sym_op	crypto operation
939  * @param	sess	security session
940  */
941 static inline int
942 __rte_security_attach_session(struct rte_crypto_sym_op *sym_op, void *sess)
943 {
944 	sym_op->session = sess;
945 
946 	return 0;
947 }
948 
949 /**
950  * Attach a session to a crypto operation.
951  * This API is needed only in case of RTE_SECURITY_SESS_CRYPTO_PROTO_OFFLOAD
952  * For other rte_security_session_action_type, ol_flags in rte_mbuf may be
953  * defined to perform security operations.
954  *
955  * @param	op	crypto operation
956  * @param	sess	security session
957  */
958 static inline int
959 rte_security_attach_session(struct rte_crypto_op *op,
960 			    void *sess)
961 {
962 	if (unlikely(op->type != RTE_CRYPTO_OP_TYPE_SYMMETRIC))
963 		return -EINVAL;
964 
965 	op->sess_type =  RTE_CRYPTO_OP_SECURITY_SESSION;
966 
967 	return __rte_security_attach_session(op->sym, sess);
968 }
969 
970 struct rte_security_macsec_secy_stats {
971 	uint64_t ctl_pkt_bcast_cnt;
972 	uint64_t ctl_pkt_mcast_cnt;
973 	uint64_t ctl_pkt_ucast_cnt;
974 	uint64_t ctl_octet_cnt;
975 	uint64_t unctl_pkt_bcast_cnt;
976 	uint64_t unctl_pkt_mcast_cnt;
977 	uint64_t unctl_pkt_ucast_cnt;
978 	uint64_t unctl_octet_cnt;
979 	/* Valid only for Rx */
980 	uint64_t octet_decrypted_cnt;
981 	uint64_t octet_validated_cnt;
982 	uint64_t pkt_port_disabled_cnt;
983 	uint64_t pkt_badtag_cnt;
984 	uint64_t pkt_nosa_cnt;
985 	uint64_t pkt_nosaerror_cnt;
986 	uint64_t pkt_tagged_ctl_cnt;
987 	uint64_t pkt_untaged_cnt;
988 	uint64_t pkt_ctl_cnt;
989 	uint64_t pkt_notag_cnt;
990 	/* Valid only for Tx */
991 	uint64_t octet_encrypted_cnt;
992 	uint64_t octet_protected_cnt;
993 	uint64_t pkt_noactivesa_cnt;
994 	uint64_t pkt_toolong_cnt;
995 	uint64_t pkt_untagged_cnt;
996 };
997 
998 struct rte_security_macsec_sc_stats {
999 	/* Rx */
1000 	uint64_t hit_cnt;
1001 	uint64_t pkt_invalid_cnt;
1002 	uint64_t pkt_late_cnt;
1003 	uint64_t pkt_notvalid_cnt;
1004 	uint64_t pkt_unchecked_cnt;
1005 	uint64_t pkt_delay_cnt;
1006 	uint64_t pkt_ok_cnt;
1007 	uint64_t octet_decrypt_cnt;
1008 	uint64_t octet_validate_cnt;
1009 	/* Tx */
1010 	uint64_t pkt_encrypt_cnt;
1011 	uint64_t pkt_protected_cnt;
1012 	uint64_t octet_encrypt_cnt;
1013 	uint64_t octet_protected_cnt;
1014 };
1015 
1016 struct rte_security_macsec_sa_stats {
1017 	/* Rx */
1018 	uint64_t pkt_invalid_cnt;
1019 	uint64_t pkt_nosaerror_cnt;
1020 	uint64_t pkt_notvalid_cnt;
1021 	uint64_t pkt_ok_cnt;
1022 	uint64_t pkt_nosa_cnt;
1023 	/* Tx */
1024 	uint64_t pkt_encrypt_cnt;
1025 	uint64_t pkt_protected_cnt;
1026 };
1027 
1028 struct rte_security_ipsec_stats {
1029 	uint64_t ipackets;  /**< Successfully received IPsec packets. */
1030 	uint64_t opackets;  /**< Successfully transmitted IPsec packets.*/
1031 	uint64_t ibytes;    /**< Successfully received IPsec bytes. */
1032 	uint64_t obytes;    /**< Successfully transmitted IPsec bytes. */
1033 	uint64_t ierrors;   /**< IPsec packets receive/decrypt errors. */
1034 	uint64_t oerrors;   /**< IPsec packets transmit/encrypt errors. */
1035 	uint64_t reserved1; /**< Reserved for future use. */
1036 	uint64_t reserved2; /**< Reserved for future use. */
1037 };
1038 
1039 struct rte_security_pdcp_stats {
1040 	uint64_t reserved;
1041 };
1042 
1043 struct rte_security_docsis_stats {
1044 	uint64_t reserved;
1045 };
1046 
1047 struct rte_security_stats {
1048 	enum rte_security_session_protocol protocol;
1049 	/**< Security protocol to be configured */
1050 
1051 	union {
1052 		struct rte_security_macsec_secy_stats macsec;
1053 		struct rte_security_ipsec_stats ipsec;
1054 		struct rte_security_pdcp_stats pdcp;
1055 		struct rte_security_docsis_stats docsis;
1056 	};
1057 };
1058 
1059 /**
1060  * Get security session statistics
1061  *
1062  * @param	instance	security instance
1063  * @param	sess		security session
1064  * If security session is NULL then global (per security instance) statistics
1065  * will be retrieved, if supported. Global statistics collection is not
1066  * dependent on the per session statistics configuration.
1067  * @param	stats		statistics
1068  * @return
1069  *  - On success, return 0
1070  *  - On failure, a negative value
1071  */
1072 __rte_experimental
1073 int
1074 rte_security_session_stats_get(struct rte_security_ctx *instance,
1075 			       void *sess,
1076 			       struct rte_security_stats *stats);
1077 
1078 /**
1079  * @warning
1080  * @b EXPERIMENTAL: this API may change without prior notice
1081  *
1082  * Get MACsec SA statistics.
1083  *
1084  * @param	instance	security instance
1085  * @param	sa_id		SA ID for which stats are needed
1086  * @param	dir		direction of the SA
1087  * @param	stats		statistics
1088  * @return
1089  *  - On success, return 0.
1090  *  - On failure, a negative value.
1091  */
1092 __rte_experimental
1093 int
1094 rte_security_macsec_sa_stats_get(struct rte_security_ctx *instance,
1095 				 uint16_t sa_id, enum rte_security_macsec_direction dir,
1096 				 struct rte_security_macsec_sa_stats *stats);
1097 
1098 /**
1099  * @warning
1100  * @b EXPERIMENTAL: this API may change without prior notice
1101  *
1102  * Get MACsec SC statistics.
1103  *
1104  * @param	instance	security instance
1105  * @param	sc_id		SC ID for which stats are needed
1106  * @param	dir		direction of the SC
1107  * @param	stats		SC statistics
1108  * @return
1109  *  - On success, return 0.
1110  *  - On failure, a negative value.
1111  */
1112 __rte_experimental
1113 int
1114 rte_security_macsec_sc_stats_get(struct rte_security_ctx *instance,
1115 				 uint16_t sc_id, enum rte_security_macsec_direction dir,
1116 				 struct rte_security_macsec_sc_stats *stats);
1117 
1118 /**
1119  * Security capability definition
1120  */
1121 struct rte_security_capability {
1122 	enum rte_security_session_action_type action;
1123 	/**< Security action type*/
1124 	enum rte_security_session_protocol protocol;
1125 	/**< Security protocol */
1126 	union {
1127 		struct {
1128 			enum rte_security_ipsec_sa_protocol proto;
1129 			/**< IPsec SA protocol */
1130 			enum rte_security_ipsec_sa_mode mode;
1131 			/**< IPsec SA mode */
1132 			enum rte_security_ipsec_sa_direction direction;
1133 			/**< IPsec SA direction */
1134 			struct rte_security_ipsec_sa_options options;
1135 			/**< IPsec SA supported options */
1136 			uint32_t replay_win_sz_max;
1137 			/**< IPsec Anti Replay Window Size. A '0' value
1138 			 * indicates that Anti Replay is not supported.
1139 			 */
1140 		} ipsec;
1141 		/**< IPsec capability */
1142 		struct {
1143 			/** MTU supported for inline TX */
1144 			uint16_t mtu;
1145 			/** MACsec algorithm to be used */
1146 			enum rte_security_macsec_alg alg;
1147 			/** Maximum number of secure channels supported */
1148 			uint16_t max_nb_sc;
1149 			/** Maximum number of SAs supported */
1150 			uint16_t max_nb_sa;
1151 			/** Maximum number of SAs supported */
1152 			uint16_t max_nb_sess;
1153 			/** MACsec anti replay window size */
1154 			uint32_t replay_win_sz;
1155 			/** Support Sectag insertion at relative offset */
1156 			uint16_t relative_sectag_insert : 1;
1157 			/** Support Sectag insertion at fixed offset */
1158 			uint16_t fixed_sectag_insert : 1;
1159 			/** ICV includes source and destination MAC addresses */
1160 			uint16_t icv_include_da_sa : 1;
1161 			/** Control port traffic is supported */
1162 			uint16_t ctrl_port_enable : 1;
1163 			/** Do not strip SecTAG after processing */
1164 			uint16_t preserve_sectag : 1;
1165 			/** Do not strip ICV from the packet after processing */
1166 			uint16_t preserve_icv : 1;
1167 			/** Support frame validation as per RTE_SECURITY_MACSEC_VALIDATE_* */
1168 			uint16_t validate_frames : 1;
1169 			/** support re-keying on SA expiry */
1170 			uint16_t re_key : 1;
1171 			/** support anti replay */
1172 			uint16_t anti_replay : 1;
1173 			/** Reserved bitfields for future capabilities */
1174 			uint16_t reserved : 7;
1175 		} macsec;
1176 		/**< MACsec capability */
1177 		struct {
1178 			enum rte_security_pdcp_domain domain;
1179 			/**< PDCP mode of operation: Control or data */
1180 			uint32_t capa_flags;
1181 			/**< Capability flags, see RTE_SECURITY_PDCP_* */
1182 		} pdcp;
1183 		/**< PDCP capability */
1184 		struct {
1185 			enum rte_security_docsis_direction direction;
1186 			/**< DOCSIS direction */
1187 		} docsis;
1188 		/**< DOCSIS capability */
1189 	};
1190 
1191 	const struct rte_cryptodev_capabilities *crypto_capabilities;
1192 	/**< Corresponding crypto capabilities for security capability  */
1193 
1194 	uint32_t ol_flags;
1195 	/**< Device offload flags */
1196 };
1197 
1198 /** Underlying Hardware/driver which support PDCP may or may not support
1199  * packet ordering. Set RTE_SECURITY_PDCP_ORDERING_CAP if it support.
1200  * If it is not set, driver/HW assumes packets received are in order
1201  * and it will be application's responsibility to maintain ordering.
1202  */
1203 #define RTE_SECURITY_PDCP_ORDERING_CAP		0x00000001
1204 
1205 /** Underlying Hardware/driver which support PDCP may or may not detect
1206  * duplicate packet. Set RTE_SECURITY_PDCP_DUP_DETECT_CAP if it support.
1207  * If it is not set, driver/HW assumes there is no duplicate packet received.
1208  */
1209 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP	0x00000002
1210 
1211 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA	0x00000001
1212 /**< HW needs metadata update, see rte_security_set_pkt_metadata().
1213  */
1214 
1215 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD	0x00000002
1216 /**< HW constructs trailer of packets
1217  * Transmitted packets will have the trailer added to them
1218  * by hardware. The next protocol field will be based on
1219  * the mbuf->inner_esp_next_proto field.
1220  */
1221 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD	0x00010000
1222 /**< HW removes trailer of packets
1223  * Received packets have no trailer, the next protocol field
1224  * is supplied in the mbuf->inner_esp_next_proto field.
1225  * Inner packet is not modified.
1226  */
1227 
1228 /**
1229  * Security capability index used to query a security instance for a specific
1230  * security capability
1231  */
1232 struct rte_security_capability_idx {
1233 	enum rte_security_session_action_type action;
1234 	enum rte_security_session_protocol protocol;
1235 
1236 	union {
1237 		struct {
1238 			enum rte_security_ipsec_sa_protocol proto;
1239 			enum rte_security_ipsec_sa_mode mode;
1240 			enum rte_security_ipsec_sa_direction direction;
1241 		} ipsec;
1242 		struct {
1243 			enum rte_security_pdcp_domain domain;
1244 			uint32_t capa_flags;
1245 		} pdcp;
1246 		struct {
1247 			enum rte_security_docsis_direction direction;
1248 		} docsis;
1249 	};
1250 };
1251 
1252 /**
1253  *  Returns array of security instance capabilities
1254  *
1255  * @param	instance	Security instance.
1256  *
1257  * @return
1258  *   - Returns array of security capabilities.
1259  *   - Return NULL if no capabilities available.
1260  */
1261 const struct rte_security_capability *
1262 rte_security_capabilities_get(struct rte_security_ctx *instance);
1263 
1264 /**
1265  * Query if a specific capability is available on security instance
1266  *
1267  * @param	instance	security instance.
1268  * @param	idx		security capability index to match against
1269  *
1270  * @return
1271  *   - Returns pointer to security capability on match of capability
1272  *     index criteria.
1273  *   - Return NULL if the capability not matched on security instance.
1274  */
1275 const struct rte_security_capability *
1276 rte_security_capability_get(struct rte_security_ctx *instance,
1277 			    struct rte_security_capability_idx *idx);
1278 
1279 #ifdef __cplusplus
1280 }
1281 #endif
1282 
1283 #endif /* _RTE_SECURITY_H_ */
1284