DPDK  19.11.10
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 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 
314 };
315 
324 };
325 
335  union {
336  struct rte_security_ipsec_xform ipsec;
337  struct rte_security_macsec_xform macsec;
338  struct rte_security_pdcp_xform pdcp;
339  };
343  void *userdata;
345 };
346 
347 struct rte_security_session {
348  void *sess_private_data;
350  uint64_t opaque_data;
352 };
353 
364 struct rte_security_session *
366  struct rte_security_session_conf *conf,
367  struct rte_mempool *mp);
368 
379 __rte_experimental
380 int
382  struct rte_security_session *sess,
383  struct rte_security_session_conf *conf);
384 
394 unsigned int
396 
411 int
413  struct rte_security_session *sess);
414 
428 int
430  struct rte_security_session *sess,
431  struct rte_mbuf *mb, void *params);
432 
450 __rte_experimental
451 void *
452 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
453 
460 static inline int
462  struct rte_security_session *sess)
463 {
464  sym_op->sec_session = sess;
465 
466  return 0;
467 }
468 
469 static inline void *
470 get_sec_session_private_data(const struct rte_security_session *sess)
471 {
472  return sess->sess_private_data;
473 }
474 
475 static inline void
476 set_sec_session_private_data(struct rte_security_session *sess,
477  void *private_data)
478 {
479  sess->sess_private_data = private_data;
480 }
481 
491 static inline int
493  struct rte_security_session *sess)
494 {
496  return -EINVAL;
497 
499 
500  return __rte_security_attach_session(op->sym, sess);
501 }
502 
503 struct rte_security_macsec_stats {
504  uint64_t reserved;
505 };
506 
507 struct rte_security_ipsec_stats {
508  uint64_t ipackets;
509  uint64_t opackets;
510  uint64_t ibytes;
511  uint64_t obytes;
512  uint64_t ierrors;
513  uint64_t oerrors;
514  uint64_t reserved1;
515  uint64_t reserved2;
516 };
517 
518 struct rte_security_pdcp_stats {
519  uint64_t reserved;
520 };
521 
522 struct rte_security_stats {
523  enum rte_security_session_protocol protocol;
527  union {
528  struct rte_security_macsec_stats macsec;
529  struct rte_security_ipsec_stats ipsec;
530  struct rte_security_pdcp_stats pdcp;
531  };
532 };
533 
547 __rte_experimental
548 int
550  struct rte_security_session *sess,
551  struct rte_security_stats *stats);
552 
562  union {
563  struct {
576  } ipsec;
578  struct {
579  /* To be Filled */
580  int dummy;
581  } macsec;
583  struct {
586  uint32_t capa_flags;
588  } pdcp;
590  };
591 
595  uint32_t ol_flags;
597 };
598 
604 #define RTE_SECURITY_PDCP_ORDERING_CAP 0x00000001
605 
610 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP 0x00000002
611 
612 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
613 
616 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
617 
622 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
623 
635  enum rte_security_session_protocol protocol;
636 
638  union {
639  struct {
641  enum rte_security_ipsec_sa_mode mode;
642  enum rte_security_ipsec_sa_direction direction;
643  } ipsec;
644  struct {
645  enum rte_security_pdcp_domain domain;
646  uint32_t capa_flags;
647  } pdcp;
648  };
649 };
650 
660 const struct rte_security_capability *
662 
674 const struct rte_security_capability *
676  struct rte_security_capability_idx *idx);
677 
678 #ifdef __cplusplus
679 }
680 #endif
681 
682 #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:492
rte_security_session_action_type
Definition: rte_security.h:299
rte_security_pdcp_direction
Definition: rte_security.h:238
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:341
rte_security_ipsec_sa_mode
Definition: rte_security.h:34
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:461
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)
#define RTE_STD_C11
Definition: rte_common.h:40
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:592
uint8_t sess_type
Definition: rte_crypto.h:94
rte_security_session_protocol
Definition: rte_security.h:317
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)
const struct rte_security_ops * ops
Definition: rte_security.h:69
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118