DPDK  17.11.10
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_common.h>
56 #include <rte_crypto.h>
57 #include <rte_mbuf.h>
58 #include <rte_memory.h>
59 #include <rte_mempool.h>
60 
67 };
68 
75 };
76 
83 };
84 
95  void *device;
97  const struct rte_security_ops *ops;
99  uint16_t sess_cnt;
101 };
102 
112  union {
113  struct {
114  struct in_addr src_ip;
116  struct in_addr dst_ip;
118  uint8_t dscp;
120  uint8_t df;
122  uint8_t ttl;
124  } ipv4;
126  struct {
127  struct in6_addr src_addr;
129  struct in6_addr dst_addr;
131  uint8_t dscp;
133  uint32_t flabel;
135  uint8_t hlimit;
137  } ipv6;
139  };
140 };
141 
151  uint32_t esn : 1;
152 
159  uint32_t udp_encap : 1;
160 
168  uint32_t copy_dscp : 1;
169 
176  uint32_t copy_flabel : 1;
177 
184  uint32_t copy_df : 1;
185 
193  uint32_t dec_ttl : 1;
194 };
195 
202 };
203 
210  uint32_t spi;
212  uint32_t salt;
224 };
225 
231  int dummy;
232 };
233 
252 };
253 
260 };
261 
271  union {
272  struct rte_security_ipsec_xform ipsec;
273  struct rte_security_macsec_xform macsec;
274  };
278 };
279 
280 struct rte_security_session {
281  void *sess_private_data;
283 };
284 
295 struct rte_security_session *
297  struct rte_security_session_conf *conf,
298  struct rte_mempool *mp);
299 
310 int
312  struct rte_security_session *sess,
313  struct rte_security_session_conf *conf);
314 
327 int
329  struct rte_security_session *sess);
330 
344 int
346  struct rte_security_session *sess,
347  struct rte_mbuf *mb, void *params);
348 
355 static inline int
357  struct rte_security_session *sess)
358 {
359  sym_op->sec_session = sess;
360 
361  return 0;
362 }
363 
364 static inline void *
365 get_sec_session_private_data(const struct rte_security_session *sess)
366 {
367  return sess->sess_private_data;
368 }
369 
370 static inline void
371 set_sec_session_private_data(struct rte_security_session *sess,
372  void *private_data)
373 {
374  sess->sess_private_data = private_data;
375 }
376 
386 static inline int
388  struct rte_security_session *sess)
389 {
391  return -EINVAL;
392 
394 
395  return __rte_security_attach_session(op->sym, sess);
396 }
397 
398 struct rte_security_macsec_stats {
399  uint64_t reserved;
400 };
401 
402 struct rte_security_ipsec_stats {
403  uint64_t reserved;
404 
405 };
406 
407 struct rte_security_stats {
408  enum rte_security_session_protocol protocol;
412  union {
413  struct rte_security_macsec_stats macsec;
414  struct rte_security_ipsec_stats ipsec;
415  };
416 };
417 
428 int
430  struct rte_security_session *sess,
431  struct rte_security_stats *stats);
432 
442  union {
443  struct {
452  } ipsec;
454  struct {
455  /* To be Filled */
456  int dummy;
457  } macsec;
459  };
460 
464  uint32_t ol_flags;
466 };
467 
468 #define RTE_SECURITY_TX_OLOAD_NEED_MDATA 0x00000001
469 
472 #define RTE_SECURITY_TX_HW_TRAILER_OFFLOAD 0x00000002
473 
478 #define RTE_SECURITY_RX_HW_TRAILER_OFFLOAD 0x00010000
479 
491  enum rte_security_session_protocol protocol;
492 
494  union {
495  struct {
497  enum rte_security_ipsec_sa_mode mode;
498  enum rte_security_ipsec_sa_direction direction;
499  } ipsec;
500  };
501 };
502 
512 const struct rte_security_capability *
514 
526 const struct rte_security_capability *
528  struct rte_security_capability_idx *idx);
529 
530 #ifdef __cplusplus
531 }
532 #endif
533 
534 #endif /* _RTE_SECURITY_H_ */
rte_security_ipsec_sa_protocol
Definition: rte_security.h:70
static int rte_security_attach_session(struct rte_crypto_op *op, struct rte_security_session *sess)
Definition: rte_security.h:387
rte_security_session_action_type
Definition: rte_security.h:237
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:216
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:222
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:214
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:437
uint8_t type
Definition: rte_crypto.h:104
struct rte_crypto_sym_xform * crypto_xform
Definition: rte_security.h:276
int rte_security_session_update(struct rte_security_ctx *instance, struct rte_security_session *sess, struct rte_security_session_conf *conf)
rte_security_ipsec_sa_mode
Definition: rte_security.h:62
struct rte_security_capability::@153::@156 macsec
uint16_t sess_cnt
Definition: rte_security.h:99
static int __rte_security_attach_session(struct rte_crypto_sym_op *sym_op, struct rte_security_session *sess)
Definition: rte_security.h:356
rte_security_ipsec_sa_direction
Definition: rte_security.h:197
rte_security_ipsec_tunnel_type
Definition: rte_security.h:78
struct rte_security_ipsec_tunnel_param::@145::@147 ipv4
#define unlikely(x)
enum rte_security_session_protocol protocol
Definition: rte_security.h:268
enum rte_security_session_action_type action_type
Definition: rte_security.h:266
struct rte_security_ipsec_tunnel_param::@145::@148 ipv6
struct rte_security_ipsec_sa_options options
Definition: rte_security.h:450
enum rte_security_ipsec_sa_protocol proto
Definition: rte_security.h:218
enum rte_security_ipsec_sa_direction direction
Definition: rte_security.h:448
#define RTE_STD_C11
Definition: rte_common.h:66
int 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:444
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:446
struct rte_security_capability::@153::@155 ipsec
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:461
enum rte_security_ipsec_sa_mode mode
Definition: rte_security.h:220
enum rte_security_ipsec_tunnel_type type
Definition: rte_security.h:109
uint8_t sess_type
Definition: rte_crypto.h:113
rte_security_session_protocol
Definition: rte_security.h:255
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:439
const struct rte_security_ops * ops
Definition: rte_security.h:97
struct rte_crypto_sym_op sym[0]
Definition: rte_crypto.h:126