DPDK  18.05.1
rte_security.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright 2017 NXP.
5  * Copyright(c) 2017 Intel Corporation. All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of NXP nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #ifndef _RTE_SECURITY_H_
35 #define _RTE_SECURITY_H_
36 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #include <sys/types.h>
50 
51 #include <netinet/in.h>
52 #include <netinet/ip.h>
53 #include <netinet/ip6.h>
54 
55 #include <rte_compat.h>
56 #include <rte_common.h>
57 #include <rte_crypto.h>
58 #include <rte_mbuf.h>
59 #include <rte_memory.h>
60 #include <rte_mempool.h>
61 
68 };
69 
76 };
77 
84 };
85 
96  void *device;
98  const struct rte_security_ops *ops;
100  uint16_t sess_cnt;
102 };
103 
113  union {
114  struct {
115  struct in_addr src_ip;
117  struct in_addr dst_ip;
119  uint8_t dscp;
121  uint8_t df;
123  uint8_t ttl;
125  } ipv4;
127  struct {
128  struct in6_addr src_addr;
130  struct in6_addr dst_addr;
132  uint8_t dscp;
134  uint32_t flabel;
136  uint8_t hlimit;
138  } ipv6;
140  };
141 };
142 
152  uint32_t esn : 1;
153 
160  uint32_t udp_encap : 1;
161 
169  uint32_t copy_dscp : 1;
170 
177  uint32_t copy_flabel : 1;
178 
185  uint32_t copy_df : 1;
186 
194  uint32_t dec_ttl : 1;
195 };
196 
203 };
204 
211  uint32_t spi;
213  uint32_t salt;
225  uint64_t esn_soft_limit;
227 };
228 
234  int dummy;
235 };
236 
255 };
256 
263 };
264 
274  union {
275  struct rte_security_ipsec_xform ipsec;
276  struct rte_security_macsec_xform macsec;
277  };
281  void *userdata;
283 };
284 
285 struct rte_security_session {
286  void *sess_private_data;
288 };
289 
300 struct rte_security_session * __rte_experimental
302  struct rte_security_session_conf *conf,
303  struct rte_mempool *mp);
304 
315 int __rte_experimental
317  struct rte_security_session *sess,
318  struct rte_security_session_conf *conf);
319 
329 unsigned int __rte_experimental
331 
344 int __rte_experimental
346  struct rte_security_session *sess);
347 
361 int __rte_experimental
363  struct rte_security_session *sess,
364  struct rte_mbuf *mb, void *params);
365 
383 void * __rte_experimental
384 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
385 
392 static inline int __rte_experimental
394  struct rte_security_session *sess)
395 {
396  sym_op->sec_session = sess;
397 
398  return 0;
399 }
400 
401 static inline void * __rte_experimental
402 get_sec_session_private_data(const struct rte_security_session *sess)
403 {
404  return sess->sess_private_data;
405 }
406 
407 static inline void __rte_experimental
408 set_sec_session_private_data(struct rte_security_session *sess,
409  void *private_data)
410 {
411  sess->sess_private_data = private_data;
412 }
413 
423 static inline int __rte_experimental
425  struct rte_security_session *sess)
426 {
428  return -EINVAL;
429 
431 
432  return __rte_security_attach_session(op->sym, sess);
433 }
434 
435 struct rte_security_macsec_stats {
436  uint64_t reserved;
437 };
438 
439 struct rte_security_ipsec_stats {
440  uint64_t reserved;
441 
442 };
443 
444 struct rte_security_stats {
445  enum rte_security_session_protocol protocol;
449  union {
450  struct rte_security_macsec_stats macsec;
451  struct rte_security_ipsec_stats ipsec;
452  };
453 };
454 
465 int __rte_experimental
467  struct rte_security_session *sess,
468  struct rte_security_stats *stats);
469 
479  union {
480  struct {
489  } ipsec;
491  struct {
492  /* To be Filled */
493  int dummy;
494  } macsec;
496  };
497 
501  uint32_t ol_flags;
503 };
504 
505 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
506 
509 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
510 
515 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
516 
528  enum rte_security_session_protocol protocol;
529 
531  union {
532  struct {
534  enum rte_security_ipsec_sa_mode mode;
535  enum rte_security_ipsec_sa_direction direction;
536  } ipsec;
537  };
538 };
539 
549 const struct rte_security_capability * __rte_experimental
551 
563 const struct rte_security_capability * __rte_experimental
565  struct rte_security_capability_idx *idx);
566 
567 #ifdef __cplusplus
568 }
569 #endif
570 
571 #endif /* _RTE_SECURITY_H_ */