DPDK  20.05.0
rte_security.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017,2019 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_memory.h>
31 #include <rte_mempool.h>
32 
39 };
40 
47 };
48 
55 };
56 
67  void *device;
69  const struct rte_security_ops *ops;
71  uint16_t sess_cnt;
73 };
74 
84  union {
85  struct {
86  struct in_addr src_ip;
88  struct in_addr dst_ip;
90  uint8_t dscp;
92  uint8_t df;
94  uint8_t ttl;
96  } ipv4;
98  struct {
99  struct in6_addr src_addr;
101  struct in6_addr dst_addr;
103  uint8_t dscp;
105  uint32_t flabel;
107  uint8_t hlimit;
109  } ipv6;
111  };
112 };
113 
123  uint32_t esn : 1;
124 
131  uint32_t udp_encap : 1;
132 
140  uint32_t copy_dscp : 1;
141 
148  uint32_t copy_flabel : 1;
149 
156  uint32_t copy_df : 1;
157 
165  uint32_t dec_ttl : 1;
166 
174  uint32_t ecn : 1;
175 
182  uint32_t stats : 1;
183 };
184 
191 };
192 
199  uint32_t spi;
201  uint32_t salt;
213  uint64_t esn_soft_limit;
215  uint32_t replay_win_sz;
219 };
220 
226  int dummy;
227 };
228 
235 };
236 
241 };
242 
255 };
256 
263  int8_t bearer;
267  uint8_t en_ordering;
282  uint32_t hfn;
284  uint32_t hfn_threshold;
293  uint32_t hfn_ovrd;
294 };
295 
318 };
319 
328 };
329 
339  union {
340  struct rte_security_ipsec_xform ipsec;
341  struct rte_security_macsec_xform macsec;
342  struct rte_security_pdcp_xform pdcp;
343  };
347  void *userdata;
349 };
350 
351 struct rte_security_session {
352  void *sess_private_data;
354  uint64_t opaque_data;
356 };
357 
368 struct rte_security_session *
370  struct rte_security_session_conf *conf,
371  struct rte_mempool *mp);
372 
383 __rte_experimental
384 int
386  struct rte_security_session *sess,
387  struct rte_security_session_conf *conf);
388 
398 unsigned int
400 
415 int
417  struct rte_security_session *sess);
418 
432 int
434  struct rte_security_session *sess,
435  struct rte_mbuf *mb, void *params);
436 
454 __rte_experimental
455 void *
456 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
457 
464 static inline int
466  struct rte_security_session *sess)
467 {
468  sym_op->sec_session = sess;
469 
470  return 0;
471 }
472 
473 static inline void *
474 get_sec_session_private_data(const struct rte_security_session *sess)
475 {
476  return sess->sess_private_data;
477 }
478 
479 static inline void
480 set_sec_session_private_data(struct rte_security_session *sess,
481  void *private_data)
482 {
483  sess->sess_private_data = private_data;
484 }
485 
495 static inline int
497  struct rte_security_session *sess)
498 {
500  return -EINVAL;
501 
503 
504  return __rte_security_attach_session(op->sym, sess);
505 }
506 
507 struct rte_security_macsec_stats {
508  uint64_t reserved;
509 };
510 
511 struct rte_security_ipsec_stats {
512  uint64_t ipackets;
513  uint64_t opackets;
514  uint64_t ibytes;
515  uint64_t obytes;
516  uint64_t ierrors;
517  uint64_t oerrors;
518  uint64_t reserved1;
519  uint64_t reserved2;
520 };
521 
522 struct rte_security_pdcp_stats {
523  uint64_t reserved;
524 };
525 
526 struct rte_security_stats {
527  enum rte_security_session_protocol protocol;
531  union {
532  struct rte_security_macsec_stats macsec;
533  struct rte_security_ipsec_stats ipsec;
534  struct rte_security_pdcp_stats pdcp;
535  };
536 };
537 
551 __rte_experimental
552 int
554  struct rte_security_session *sess,
555  struct rte_security_stats *stats);
556 
566  union {
567  struct {
580  } ipsec;
582  struct {
583  /* To be Filled */
584  int dummy;
585  } macsec;
587  struct {
590  uint32_t capa_flags;
592  } pdcp;
594  };
595 
599  uint32_t ol_flags;
601 };
602 
608 #define RTE_SECURITY_PDCP_ORDERING_CAP 0x00000001
609 
614 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP 0x00000002
615 
616 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
617 
620 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
621 
626 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
627 
639  enum rte_security_session_protocol protocol;
640 
642  union {
643  struct {
645  enum rte_security_ipsec_sa_mode mode;
646  enum rte_security_ipsec_sa_direction direction;
647  } ipsec;
648  struct {
649  enum rte_security_pdcp_domain domain;
650  uint32_t capa_flags;
651  } pdcp;
652  };
653 };
654 
664 const struct rte_security_capability *
666 
678 const struct rte_security_capability *
680  struct rte_security_capability_idx *idx);
681 
682 #ifdef __cplusplus
683 }
684 #endif
685 
686 #endif /* _RTE_SECURITY_H_ */
rte_security_pdcp_sn_size
Definition: rte_security.h:244
rte_security_ipsec_sa_protocol
Definition: rte_security.h:42
static int rte_security_attach_session(struct rte_crypto_op *op, struct rte_security_session *sess)
Definition: rte_security.h:496
rte_security_session_action_type
Definition: rte_security.h:299
rte_security_pdcp_direction
Definition: rte_security.h:238
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:205
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
struct rte_security_ipsec_tunnel_param tunnel
Definition: rte_security.h:211
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:203
struct rte_security_capability::@287::@291 pdcp
const struct rte_security_capability * rte_security_capabilities_get(struct rte_security_ctx *instance)
enum rte_security_session_action_type action
Definition: rte_security.h:561
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:345
rte_security_ipsec_sa_mode
Definition: rte_security.h:34
enum rte_security_pdcp_domain domain
Definition: rte_security.h:588
uint16_t sess_cnt
Definition: rte_security.h:71
static int __rte_security_attach_session(struct rte_crypto_sym_op *sym_op, struct rte_security_session *sess)
Definition: rte_security.h:465
enum rte_security_pdcp_sn_size sn_size
Definition: rte_security.h:278
enum rte_security_pdcp_direction pkt_dir
Definition: rte_security.h:276
rte_security_ipsec_sa_direction
Definition: rte_security.h:186
rte_security_ipsec_tunnel_type
Definition: rte_security.h:50
__rte_experimental int rte_security_session_stats_get(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_security_stats *stats)
__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)
enum rte_security_session_protocol protocol
Definition: rte_security.h:336
enum rte_security_session_action_type action_type
Definition: rte_security.h:334
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:574
struct rte_security_ipsec_tunnel_param::@279::@282 ipv6
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:207
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:572
struct rte_security_ipsec_tunnel_param::@279::@281 ipv4
struct rte_security_capability::@287::@290 macsec
struct rte_security_capability::@287::@289 ipsec
#define RTE_STD_C11
Definition: rte_common.h:40
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:568
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:570
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:596
enum rte_security_pdcp_domain domain
Definition: rte_security.h:274
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:209
enum rte_security_ipsec_tunnel_type type
Definition: rte_security.h:81
uint8_t sess_type
Definition: rte_crypto.h:94
rte_security_session_protocol
Definition: rte_security.h:321
rte_security_pdcp_domain
Definition: rte_security.h:232
struct rte_security_session * rte_security_session_create(struct rte_security_ctx *instance, struct rte_security_session_conf *conf, struct rte_mempool *mp)
enum rte_security_session_protocol protocol
Definition: rte_security.h:563
const struct rte_security_ops * ops
Definition: rte_security.h:69
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118