DPDK  19.02.0
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  uint64_t opaque_data;
322 };
323 
334 struct rte_security_session *
336  struct rte_security_session_conf *conf,
337  struct rte_mempool *mp);
338 
349 int __rte_experimental
351  struct rte_security_session *sess,
352  struct rte_security_session_conf *conf);
353 
363 unsigned int
365 
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_ */