DPDK  20.08.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 
306 };
307 
316 };
317 
340 };
341 
352 };
353 
363  union {
364  struct rte_security_ipsec_xform ipsec;
365  struct rte_security_macsec_xform macsec;
366  struct rte_security_pdcp_xform pdcp;
367  struct rte_security_docsis_xform docsis;
368  };
372  void *userdata;
374 };
375 
376 struct rte_security_session {
377  void *sess_private_data;
379  uint64_t opaque_data;
381 };
382 
393 struct rte_security_session *
395  struct rte_security_session_conf *conf,
396  struct rte_mempool *mp);
397 
408 __rte_experimental
409 int
411  struct rte_security_session *sess,
412  struct rte_security_session_conf *conf);
413 
423 unsigned int
425 
440 int
442  struct rte_security_session *sess);
443 
457 int
459  struct rte_security_session *sess,
460  struct rte_mbuf *mb, void *params);
461 
479 __rte_experimental
480 void *
481 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
482 
489 static inline int
491  struct rte_security_session *sess)
492 {
493  sym_op->sec_session = sess;
494 
495  return 0;
496 }
497 
498 static inline void *
499 get_sec_session_private_data(const struct rte_security_session *sess)
500 {
501  return sess->sess_private_data;
502 }
503 
504 static inline void
505 set_sec_session_private_data(struct rte_security_session *sess,
506  void *private_data)
507 {
508  sess->sess_private_data = private_data;
509 }
510 
520 static inline int
522  struct rte_security_session *sess)
523 {
525  return -EINVAL;
526 
528 
529  return __rte_security_attach_session(op->sym, sess);
530 }
531 
532 struct rte_security_macsec_stats {
533  uint64_t reserved;
534 };
535 
536 struct rte_security_ipsec_stats {
537  uint64_t ipackets;
538  uint64_t opackets;
539  uint64_t ibytes;
540  uint64_t obytes;
541  uint64_t ierrors;
542  uint64_t oerrors;
543  uint64_t reserved1;
544  uint64_t reserved2;
545 };
546 
547 struct rte_security_pdcp_stats {
548  uint64_t reserved;
549 };
550 
551 struct rte_security_docsis_stats {
552  uint64_t reserved;
553 };
554 
555 struct rte_security_stats {
556  enum rte_security_session_protocol protocol;
560  union {
561  struct rte_security_macsec_stats macsec;
562  struct rte_security_ipsec_stats ipsec;
563  struct rte_security_pdcp_stats pdcp;
564  struct rte_security_docsis_stats docsis;
565  };
566 };
567 
581 __rte_experimental
582 int
584  struct rte_security_session *sess,
585  struct rte_security_stats *stats);
586 
596  union {
597  struct {
610  } ipsec;
612  struct {
613  /* To be Filled */
614  int dummy;
615  } macsec;
617  struct {
620  uint32_t capa_flags;
622  } pdcp;
624  struct {
627  } docsis;
629  };
630 
634  uint32_t ol_flags;
636 };
637 
643 #define RTE_SECURITY_PDCP_ORDERING_CAP 0x00000001
644 
649 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP 0x00000002
650 
651 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
652 
655 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
656 
661 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
662 
674  enum rte_security_session_protocol protocol;
675 
677  union {
678  struct {
680  enum rte_security_ipsec_sa_mode mode;
681  enum rte_security_ipsec_sa_direction direction;
682  } ipsec;
683  struct {
684  enum rte_security_pdcp_domain domain;
685  uint32_t capa_flags;
686  } pdcp;
687  struct {
688  enum rte_security_docsis_direction direction;
689  } docsis;
690  };
691 };
692 
702 const struct rte_security_capability *
704 
716 const struct rte_security_capability *
718  struct rte_security_capability_idx *idx);
719 
720 #ifdef __cplusplus
721 }
722 #endif
723 
724 #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:521
rte_security_session_action_type
Definition: rte_security.h:321
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
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:591
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:370
rte_security_ipsec_sa_mode
Definition: rte_security.h:34
enum rte_security_pdcp_domain domain
Definition: rte_security.h:618
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:490
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:360
enum rte_security_session_action_type action_type
Definition: rte_security.h:358
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:604
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:207
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:602
struct rte_security_capability::@305::@308 macsec
struct rte_security_capability::@305::@309 pdcp
#define RTE_STD_C11
Definition: rte_common.h:40
struct rte_security_capability::@305::@310 docsis
struct rte_security_ipsec_tunnel_param::@297::@299 ipv4
enum rte_security_docsis_direction direction
Definition: rte_security.h:314
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:598
rte_security_docsis_direction
Definition: rte_security.h:297
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:600
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:631
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:343
rte_security_pdcp_domain
Definition: rte_security.h:232
struct rte_security_capability::@305::@307 ipsec
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:593
const struct rte_security_ops * ops
Definition: rte_security.h:69
struct rte_security_ipsec_tunnel_param::@297::@300 ipv6
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118