DPDK  20.11.10
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 
330 /* Enumeration of rte_security_session_action_type 8<*/
350 };
351 /* >8 End enumeration of rte_security_session_action_type. */
352 
354 /* Enumeration of rte_security_session_protocol 8<*/
364 };
365 /* >8 End enumeration of rte_security_session_protocol. */
366 
370 /* Structure rte_security_session_conf 8< */
377  union {
378  struct rte_security_ipsec_xform ipsec;
379  struct rte_security_macsec_xform macsec;
380  struct rte_security_pdcp_xform pdcp;
381  struct rte_security_docsis_xform docsis;
382  };
386  void *userdata;
388 };
389 /* >8 End of structure rte_security_session_conf. */
390 
391 struct rte_security_session {
392  void *sess_private_data;
394  uint64_t opaque_data;
396 };
397 
409 struct rte_security_session *
411  struct rte_security_session_conf *conf,
412  struct rte_mempool *mp,
413  struct rte_mempool *priv_mp);
414 
425 __rte_experimental
426 int
428  struct rte_security_session *sess,
429  struct rte_security_session_conf *conf);
430 
440 unsigned int
442 
457 int
459  struct rte_security_session *sess);
460 
462 typedef uint64_t rte_security_dynfield_t;
465 
479 __rte_experimental
480 static inline rte_security_dynfield_t *
482 {
483  return RTE_MBUF_DYNFIELD(mbuf,
484  rte_security_dynfield_offset,
485  rte_security_dynfield_t *);
486 }
487 
496 __rte_experimental
497 static inline bool rte_security_dynfield_is_registered(void)
498 {
499  return rte_security_dynfield_offset >= 0;
500 }
501 
515 int
517  struct rte_security_session *sess,
518  struct rte_mbuf *mb, void *params);
519 
537 __rte_experimental
538 void *
539 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
540 
547 static inline int
549  struct rte_security_session *sess)
550 {
551  sym_op->sec_session = sess;
552 
553  return 0;
554 }
555 
556 static inline void *
557 get_sec_session_private_data(const struct rte_security_session *sess)
558 {
559  return sess->sess_private_data;
560 }
561 
562 static inline void
563 set_sec_session_private_data(struct rte_security_session *sess,
564  void *private_data)
565 {
566  sess->sess_private_data = private_data;
567 }
568 
578 static inline int
580  struct rte_security_session *sess)
581 {
583  return -EINVAL;
584 
586 
587  return __rte_security_attach_session(op->sym, sess);
588 }
589 
590 struct rte_security_macsec_stats {
591  uint64_t reserved;
592 };
593 
594 struct rte_security_ipsec_stats {
595  uint64_t ipackets;
596  uint64_t opackets;
597  uint64_t ibytes;
598  uint64_t obytes;
599  uint64_t ierrors;
600  uint64_t oerrors;
601  uint64_t reserved1;
602  uint64_t reserved2;
603 };
604 
605 struct rte_security_pdcp_stats {
606  uint64_t reserved;
607 };
608 
609 struct rte_security_docsis_stats {
610  uint64_t reserved;
611 };
612 
613 struct rte_security_stats {
614  enum rte_security_session_protocol protocol;
618  union {
619  struct rte_security_macsec_stats macsec;
620  struct rte_security_ipsec_stats ipsec;
621  struct rte_security_pdcp_stats pdcp;
622  struct rte_security_docsis_stats docsis;
623  };
624 };
625 
639 __rte_experimental
640 int
642  struct rte_security_session *sess,
643  struct rte_security_stats *stats);
644 
654  union {
655  struct {
668  } ipsec;
670  struct {
671  /* To be Filled */
672  int dummy;
673  } macsec;
675  struct {
678  uint32_t capa_flags;
680  } pdcp;
682  struct {
685  } docsis;
687  };
688 
692  uint32_t ol_flags;
694 };
695 
701 #define RTE_SECURITY_PDCP_ORDERING_CAP 0x00000001
702 
707 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP 0x00000002
708 
709 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
710 
713 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
714 
719 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
720 
732  enum rte_security_session_protocol protocol;
733 
735  union {
736  struct {
738  enum rte_security_ipsec_sa_mode mode;
739  enum rte_security_ipsec_sa_direction direction;
740  } ipsec;
741  struct {
742  enum rte_security_pdcp_domain domain;
743  uint32_t capa_flags;
744  } pdcp;
745  struct {
746  enum rte_security_docsis_direction direction;
747  } docsis;
748  };
749 };
750 
760 const struct rte_security_capability *
762 
774 const struct rte_security_capability *
776  struct rte_security_capability_idx *idx);
777 
778 #ifdef __cplusplus
779 }
780 #endif
781 
782 #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:579
rte_security_session_action_type
Definition: rte_security.h:331
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:384
static __rte_experimental rte_security_dynfield_t * rte_security_dynfield(struct rte_mbuf *mbuf)
Definition: rte_security.h:481
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:548
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:40
static __rte_experimental bool rte_security_dynfield_is_registered(void)
Definition: rte_security.h:497
rte_security_docsis_direction
Definition: rte_security.h:306
uint64_t rte_security_dynfield_t
Definition: rte_security.h:462
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:689
uint8_t sess_type
Definition: rte_crypto.h:94
rte_security_session_protocol
Definition: rte_security.h:355
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:125