DPDK  18.02.2
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 };
226 
232  int dummy;
233 };
234 
253 };
254 
261 };
262 
272  union {
273  struct rte_security_ipsec_xform ipsec;
274  struct rte_security_macsec_xform macsec;
275  };
279  void *userdata;
281 };
282 
283 struct rte_security_session {
284  void *sess_private_data;
286 };
287 
298 struct rte_security_session * __rte_experimental
300  struct rte_security_session_conf *conf,
301  struct rte_mempool *mp);
302 
313 int __rte_experimental
315  struct rte_security_session *sess,
316  struct rte_security_session_conf *conf);
317 
327 unsigned int __rte_experimental
329 
342 int __rte_experimental
344  struct rte_security_session *sess);
345 
359 int __rte_experimental
361  struct rte_security_session *sess,
362  struct rte_mbuf *mb, void *params);
363 
379 void * __rte_experimental
380 rte_security_get_userdata(struct rte_security_ctx *instance, uint64_t md);
381 
388 static inline int __rte_experimental
390  struct rte_security_session *sess)
391 {
392  sym_op->sec_session = sess;
393 
394  return 0;
395 }
396 
397 static inline void * __rte_experimental
398 get_sec_session_private_data(const struct rte_security_session *sess)
399 {
400  return sess->sess_private_data;
401 }
402 
403 static inline void __rte_experimental
404 set_sec_session_private_data(struct rte_security_session *sess,
405  void *private_data)
406 {
407  sess->sess_private_data = private_data;
408 }
409 
419 static inline int __rte_experimental
421  struct rte_security_session *sess)
422 {
424  return -EINVAL;
425 
427 
428  return __rte_security_attach_session(op->sym, sess);
429 }
430 
431 struct rte_security_macsec_stats {
432  uint64_t reserved;
433 };
434 
435 struct rte_security_ipsec_stats {
436  uint64_t reserved;
437 
438 };
439 
440 struct rte_security_stats {
441  enum rte_security_session_protocol protocol;
445  union {
446  struct rte_security_macsec_stats macsec;
447  struct rte_security_ipsec_stats ipsec;
448  };
449 };
450 
461 int __rte_experimental
463  struct rte_security_session *sess,
464  struct rte_security_stats *stats);
465 
475  union {
476  struct {
485  } ipsec;
487  struct {
488  /* To be Filled */
489  int dummy;
490  } macsec;
492  };
493 
497  uint32_t ol_flags;
499 };
500 
501 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
502 
505 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
506 
511 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
512 
524  enum rte_security_session_protocol protocol;
525 
527  union {
528  struct {
530  enum rte_security_ipsec_sa_mode mode;
531  enum rte_security_ipsec_sa_direction direction;
532  } ipsec;
533  };
534 };
535 
545 const struct rte_security_capability * __rte_experimental
547 
559 const struct rte_security_capability * __rte_experimental
561  struct rte_security_capability_idx *idx);
562 
563 #ifdef __cplusplus
564 }
565 #endif
566 
567 #endif /* _RTE_SECURITY_H_ */