DPDK  21.08.0
rte_security.h
Go to the documentation of this file.
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 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include <sys/types.h>
21 
22 #include <netinet/in.h>
23 #include <netinet/ip.h>
24 #include <netinet/ip6.h>
25 
26 #include <rte_compat.h>
27 #include <rte_common.h>
28 #include <rte_crypto.h>
29 #include <rte_mbuf.h>
30 #include <rte_mbuf_dyn.h>
31 #include <rte_memory.h>
32 #include <rte_mempool.h>
33 
40 };
41 
48 };
49 
56 };
57 
68  void *device;
70  const struct rte_security_ops *ops;
72  uint16_t sess_cnt;
74 };
75 
85  union {
86  struct {
87  struct in_addr src_ip;
89  struct in_addr dst_ip;
91  uint8_t dscp;
93  uint8_t df;
95  uint8_t ttl;
97  } ipv4;
99  struct {
100  struct in6_addr src_addr;
102  struct in6_addr dst_addr;
104  uint8_t dscp;
106  uint32_t flabel;
108  uint8_t hlimit;
110  } ipv6;
112  };
113 };
114 
124  uint32_t esn : 1;
125 
132  uint32_t udp_encap : 1;
133 
141  uint32_t copy_dscp : 1;
142 
149  uint32_t copy_flabel : 1;
150 
157  uint32_t copy_df : 1;
158 
166  uint32_t dec_ttl : 1;
167 
175  uint32_t ecn : 1;
176 
183  uint32_t stats : 1;
184 };
185 
192 };
193 
200  uint32_t spi;
202  uint32_t salt;
214  uint64_t esn_soft_limit;
216  uint32_t replay_win_sz;
220 };
221 
227  int dummy;
228 };
229 
236 };
237 
242 };
243 
256 };
257 
264  int8_t bearer;
268  uint8_t en_ordering;
283  uint32_t hfn;
285  uint32_t hfn_threshold;
294  uint8_t hfn_ovrd;
300  uint8_t sdap_enabled;
302  uint16_t reserved;
303 };
304 
315 };
316 
325 };
326 
349 };
350 
361 };
362 
372  union {
373  struct rte_security_ipsec_xform ipsec;
374  struct rte_security_macsec_xform macsec;
375  struct rte_security_pdcp_xform pdcp;
376  struct rte_security_docsis_xform docsis;
377  };
381  void *userdata;
383 };
384 
385 struct rte_security_session {
386  void *sess_private_data;
388  uint64_t opaque_data;
390 };
391 
403 struct rte_security_session *
405  struct rte_security_session_conf *conf,
406  struct rte_mempool *mp,
407  struct rte_mempool *priv_mp);
408 
419 __rte_experimental
420 int
422  struct rte_security_session *sess,
423  struct rte_security_session_conf *conf);
424 
434 unsigned int
436 
451 int
453  struct rte_security_session *sess);
454 
456 typedef uint64_t rte_security_dynfield_t;
459 
473 __rte_experimental
474 static inline rte_security_dynfield_t *
476 {
477  return RTE_MBUF_DYNFIELD(mbuf,
478  rte_security_dynfield_offset,
479  rte_security_dynfield_t *);
480 }
481 
490 __rte_experimental
491 static inline bool rte_security_dynfield_is_registered(void)
492 {
493  return rte_security_dynfield_offset >= 0;
494 }
495 
509 int
511  struct rte_security_session *sess,
512  struct rte_mbuf *mb, void *params);
513 
531 __rte_experimental
532 void *
533 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
534 
541 static inline int
543  struct rte_security_session *sess)
544 {
545  sym_op->sec_session = sess;
546 
547  return 0;
548 }
549 
550 static inline void *
551 get_sec_session_private_data(const struct rte_security_session *sess)
552 {
553  return sess->sess_private_data;
554 }
555 
556 static inline void
557 set_sec_session_private_data(struct rte_security_session *sess,
558  void *private_data)
559 {
560  sess->sess_private_data = private_data;
561 }
562 
572 static inline int
574  struct rte_security_session *sess)
575 {
577  return -EINVAL;
578 
580 
581  return __rte_security_attach_session(op->sym, sess);
582 }
583 
584 struct rte_security_macsec_stats {
585  uint64_t reserved;
586 };
587 
588 struct rte_security_ipsec_stats {
589  uint64_t ipackets;
590  uint64_t opackets;
591  uint64_t ibytes;
592  uint64_t obytes;
593  uint64_t ierrors;
594  uint64_t oerrors;
595  uint64_t reserved1;
596  uint64_t reserved2;
597 };
598 
599 struct rte_security_pdcp_stats {
600  uint64_t reserved;
601 };
602 
603 struct rte_security_docsis_stats {
604  uint64_t reserved;
605 };
606 
607 struct rte_security_stats {
608  enum rte_security_session_protocol protocol;
612  union {
613  struct rte_security_macsec_stats macsec;
614  struct rte_security_ipsec_stats ipsec;
615  struct rte_security_pdcp_stats pdcp;
616  struct rte_security_docsis_stats docsis;
617  };
618 };
619 
633 __rte_experimental
634 int
636  struct rte_security_session *sess,
637  struct rte_security_stats *stats);
638 
648  union {
649  struct {
662  } ipsec;
664  struct {
665  /* To be Filled */
666  int dummy;
667  } macsec;
669  struct {
672  uint32_t capa_flags;
674  } pdcp;
676  struct {
679  } docsis;
681  };
682 
686  uint32_t ol_flags;
688 };
689 
695 #define RTE_SECURITY_PDCP_ORDERING_CAP 0x00000001
696 
701 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP 0x00000002
702 
703 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
704 
707 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
708 
713 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
714 
726  enum rte_security_session_protocol protocol;
727 
729  union {
730  struct {
732  enum rte_security_ipsec_sa_mode mode;
733  enum rte_security_ipsec_sa_direction direction;
734  } ipsec;
735  struct {
736  enum rte_security_pdcp_domain domain;
737  uint32_t capa_flags;
738  } pdcp;
739  struct {
740  enum rte_security_docsis_direction direction;
741  } docsis;
742  };
743 };
744 
754 const struct rte_security_capability *
756 
768 const struct rte_security_capability *
770  struct rte_security_capability_idx *idx);
771 
772 #ifdef __cplusplus
773 }
774 #endif
775 
776 #endif /* _RTE_SECURITY_H_ */
rte_security_pdcp_sn_size
Definition: rte_security.h:245
rte_security_ipsec_sa_protocol
Definition: rte_security.h:43
static int rte_security_attach_session(struct rte_crypto_op *op, struct rte_security_session *sess)
Definition: rte_security.h:573
rte_security_session_action_type
Definition: rte_security.h:330
rte_security_pdcp_direction
Definition: rte_security.h:239
int rte_security_session_destroy(struct rte_security_ctx *instance, struct rte_security_session *sess)
int rte_security_set_pkt_metadata(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_mbuf *mb, void *params)
struct rte_security_session * sec_session
const struct rte_security_capability * rte_security_capabilities_get(struct rte_security_ctx *instance)
unsigned int rte_security_session_get_size(struct rte_security_ctx *instance)
uint8_t type
Definition: rte_crypto.h:84
struct rte_crypto_sym_xform * crypto_xform
Definition: rte_security.h:379
static __rte_experimental rte_security_dynfield_t * rte_security_dynfield(struct rte_mbuf *mbuf)
Definition: rte_security.h:475
rte_security_ipsec_sa_mode
Definition: rte_security.h:35
uint16_t sess_cnt
Definition: rte_security.h:72
struct rte_security_session * rte_security_session_create(struct rte_security_ctx *instance, struct rte_security_session_conf *conf, struct rte_mempool *mp, struct rte_mempool *priv_mp)
static int __rte_security_attach_session(struct rte_crypto_sym_op *sym_op, struct rte_security_session *sess)
Definition: rte_security.h:542
int rte_security_dynfield_offset
rte_security_ipsec_sa_direction
Definition: rte_security.h:187
rte_security_ipsec_tunnel_type
Definition: rte_security.h:51
__rte_experimental int rte_security_session_stats_get(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_security_stats *stats)
#define RTE_MBUF_DYNFIELD(m, offset, type)
Definition: rte_mbuf_dyn.h:235
__rte_experimental void * rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md)
#define unlikely(x)
__rte_experimental int rte_security_session_update(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_security_session_conf *conf)
#define RTE_STD_C11
Definition: rte_common.h:42
static __rte_experimental bool rte_security_dynfield_is_registered(void)
Definition: rte_security.h:491
rte_security_docsis_direction
Definition: rte_security.h:306
uint64_t rte_security_dynfield_t
Definition: rte_security.h:456
const struct rte_security_capability * rte_security_capability_get(struct rte_security_ctx *instance, struct rte_security_capability_idx *idx)
const struct rte_cryptodev_capabilities * crypto_capabilities
Definition: rte_security.h:683
uint8_t sess_type
Definition: rte_crypto.h:94
rte_security_session_protocol
Definition: rte_security.h:352
rte_security_pdcp_domain
Definition: rte_security.h:233
const struct rte_security_ops * ops
Definition: rte_security.h:70
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118