DPDK  18.11.11
rte_security.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright 2017 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 };
167 
174 };
175 
182  uint32_t spi;
184  uint32_t salt;
196  uint64_t esn_soft_limit;
198 };
199 
205  int dummy;
206 };
207 
214 };
215 
220 };
221 
234 };
235 
242  int8_t bearer;
246  uint8_t en_ordering;
261  uint32_t hfn;
263  uint32_t hfn_threshold;
264 };
265 
284 };
285 
294 };
295 
305  union {
306  struct rte_security_ipsec_xform ipsec;
307  struct rte_security_macsec_xform macsec;
308  struct rte_security_pdcp_xform pdcp;
309  };
313  void *userdata;
315 };
316 
317 struct rte_security_session {
318  void *sess_private_data;
320 };
321 
332 struct rte_security_session *
334  struct rte_security_session_conf *conf,
335  struct rte_mempool *mp);
336 
347 int __rte_experimental
349  struct rte_security_session *sess,
350  struct rte_security_session_conf *conf);
351 
361 unsigned int
363 
378 int
380  struct rte_security_session *sess);
381 
395 int
397  struct rte_security_session *sess,
398  struct rte_mbuf *mb, void *params);
399 
417 void * __rte_experimental
418 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
419 
426 static inline int
428  struct rte_security_session *sess)
429 {
430  sym_op->sec_session = sess;
431 
432  return 0;
433 }
434 
435 static inline void *
436 get_sec_session_private_data(const struct rte_security_session *sess)
437 {
438  return sess->sess_private_data;
439 }
440 
441 static inline void
442 set_sec_session_private_data(struct rte_security_session *sess,
443  void *private_data)
444 {
445  sess->sess_private_data = private_data;
446 }
447 
457 static inline int
459  struct rte_security_session *sess)
460 {
462  return -EINVAL;
463 
465 
466  return __rte_security_attach_session(op->sym, sess);
467 }
468 
469 struct rte_security_macsec_stats {
470  uint64_t reserved;
471 };
472 
473 struct rte_security_ipsec_stats {
474  uint64_t reserved;
475 
476 };
477 
478 struct rte_security_pdcp_stats {
479  uint64_t reserved;
480 };
481 
482 struct rte_security_stats {
483  enum rte_security_session_protocol protocol;
487  union {
488  struct rte_security_macsec_stats macsec;
489  struct rte_security_ipsec_stats ipsec;
490  struct rte_security_pdcp_stats pdcp;
491  };
492 };
493 
504 int __rte_experimental
506  struct rte_security_session *sess,
507  struct rte_security_stats *stats);
508 
518  union {
519  struct {
528  } ipsec;
530  struct {
531  /* To be Filled */
532  int dummy;
533  } macsec;
535  struct {
538  uint32_t capa_flags;
540  } pdcp;
542  };
543 
547  uint32_t ol_flags;
549 };
550 
556 #define RTE_SECURITY_PDCP_ORDERING_CAP 0x00000001
557 
562 #define RTE_SECURITY_PDCP_DUP_DETECT_CAP 0x00000002
563 
564 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
565 
568 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
569 
574 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
575 
587  enum rte_security_session_protocol protocol;
588 
590  union {
591  struct {
593  enum rte_security_ipsec_sa_mode mode;
594  enum rte_security_ipsec_sa_direction direction;
595  } ipsec;
596  struct {
597  enum rte_security_pdcp_domain domain;
598  uint32_t capa_flags;
599  } pdcp;
600  };
601 };
602 
612 const struct rte_security_capability *
614 
626 const struct rte_security_capability *
628  struct rte_security_capability_idx *idx);
629 
630 #ifdef __cplusplus
631 }
632 #endif
633 
634 #endif /* _RTE_SECURITY_H_ */
rte_security_pdcp_sn_size
Definition: rte_security.h:223
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:458
rte_security_session_action_type
Definition: rte_security.h:269
rte_security_pdcp_direction
Definition: rte_security.h:217
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:188
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:194
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:186
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:513
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:311
rte_security_ipsec_sa_mode
Definition: rte_security.h:34
enum rte_security_pdcp_domain domain
Definition: rte_security.h:536
struct rte_security_ipsec_tunnel_param::@226::@229 ipv6
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:427
enum rte_security_pdcp_sn_size sn_size
Definition: rte_security.h:257
enum rte_security_pdcp_direction pkt_dir
Definition: rte_security.h:255
int __rte_experimental rte_security_session_update(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_security_session_conf *conf)
rte_security_ipsec_sa_direction
Definition: rte_security.h:169
rte_security_ipsec_tunnel_type
Definition: rte_security.h:50
void *__rte_experimental rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md)
struct rte_security_ipsec_tunnel_param::@226::@228 ipv4
#define unlikely(x)
enum rte_security_session_protocol protocol
Definition: rte_security.h:302
enum rte_security_session_action_type action_type
Definition: rte_security.h:300
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:526
int __rte_experimental rte_security_session_stats_get(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_security_stats *stats)
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:190
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:524
struct rte_security_capability::@234::@236 ipsec
#define RTE_STD_C11
Definition: rte_common.h:37
struct rte_security_capability::@234::@238 pdcp
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:520
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:522
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:544
enum rte_security_pdcp_domain domain
Definition: rte_security.h:253
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:192
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:287
rte_security_pdcp_domain
Definition: rte_security.h:211
struct rte_security_capability::@234::@237 macsec
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:515
const struct rte_security_ops * ops
Definition: rte_security.h:69
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:118