DPDK  20.11.7
rte_crypto_sym.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2020 Intel Corporation
3  */
4 
5 #ifndef _RTE_CRYPTO_SYM_H_
6 #define _RTE_CRYPTO_SYM_H_
7 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <string.h>
22 
23 #include <rte_mbuf.h>
24 #include <rte_memory.h>
25 #include <rte_mempool.h>
26 #include <rte_common.h>
27 
35  void *base;
39  uint32_t len;
40 };
41 
50  uint32_t num;
51 };
52 
59  void *va;
60  rte_iova_t iova;
61 };
62 
70  uint32_t num;
77 
78  __extension__
79  union {
84  };
85 
91  int32_t *status;
92 };
93 
99  uint64_t raw;
100  struct {
101  struct {
102  uint16_t head;
103  uint16_t tail;
104  } auth, cipher;
105  } ofs;
106 };
107 
165 };
166 
168 extern const char *
170 
177 };
178 
180 extern const char *
182 
198  struct {
199  const uint8_t *data;
200  uint16_t length;
201  } key;
225  struct {
226  uint16_t offset;
252  uint16_t length;
267  } iv;
268 };
269 
344 };
345 
347 extern const char *
349 
354 };
355 
357 extern const char *
359 
373  struct {
374  const uint8_t *data;
375  uint16_t length;
376  } key;
384  struct {
385  uint16_t offset;
401  uint16_t length;
419  } iv;
421  uint16_t digest_length;
431 };
432 
433 
448 };
449 
451 extern const char *
453 
460 };
461 
463 extern const char *
465 
466 struct rte_crypto_aead_xform {
469  enum rte_crypto_aead_algorithm algo;
472  struct {
473  const uint8_t *data;
474  uint16_t length;
475  } key;
476 
477  struct {
478  uint16_t offset;
498  uint16_t length;
514  } iv;
516  uint16_t digest_length;
517 
518  uint16_t aad_length;
524 };
525 
532 };
533 
547  ;
549  union {
554  struct rte_crypto_aead_xform aead;
556  };
557 };
558 
560 
592  struct rte_mbuf *m_src;
593  struct rte_mbuf *m_dst;
596  union {
601  struct rte_security_session *sec_session;
603  };
604 
606  union {
607  struct {
608  struct {
609  uint32_t offset;
614  uint32_t length;
619  } data;
620  struct {
621  uint8_t *data;
643  } digest;
644  struct {
645  uint8_t *data;
677  } aad;
679  } aead;
680 
681  struct {
682  struct {
683  struct {
684  uint32_t offset;
700  uint32_t length;
716  } data;
717  } cipher;
718 
719  struct {
720  struct {
721  uint32_t offset;
747  uint32_t length;
771  } data;
774  struct {
775  uint8_t *data;
848  } digest;
849  } auth;
850  };
851  };
852 };
853 
854 
860 static inline void
862 {
863  memset(op, 0, sizeof(*op));
864 }
865 
866 
877 static inline struct rte_crypto_sym_xform *
879  void *priv_data, uint8_t nb_xforms)
880 {
881  struct rte_crypto_sym_xform *xform;
882 
883  sym_op->xform = xform = (struct rte_crypto_sym_xform *)priv_data;
884 
885  do {
887  xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL;
888  } while (xform);
889 
890  return sym_op->xform;
891 }
892 
893 
900 static inline int
902  struct rte_cryptodev_sym_session *sess)
903 {
904  sym_op->session = sess;
905 
906  return 0;
907 }
908 
927 __rte_experimental
928 static inline int
929 rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
930  struct rte_crypto_vec vec[], uint32_t num)
931 {
932  uint32_t i;
933  struct rte_mbuf *nseg;
934  uint32_t left;
935  uint32_t seglen;
936 
937  /* assuming that requested data starts in the first segment */
938  RTE_ASSERT(mb->data_len > ofs);
939 
940  if (mb->nb_segs > num)
941  return -mb->nb_segs;
942 
943  vec[0].base = rte_pktmbuf_mtod_offset(mb, void *, ofs);
944  vec[0].iova = rte_pktmbuf_iova_offset(mb, ofs);
945 
946  /* whole data lies in the first segment */
947  seglen = mb->data_len - ofs;
948  if (len <= seglen) {
949  vec[0].len = len;
950  return 1;
951  }
952 
953  /* data spread across segments */
954  vec[0].len = seglen;
955  left = len - seglen;
956  for (i = 1, nseg = mb->next; nseg != NULL; nseg = nseg->next, i++) {
957 
958  vec[i].base = rte_pktmbuf_mtod(nseg, void *);
959  vec[i].iova = rte_pktmbuf_iova(nseg);
960 
961  seglen = nseg->data_len;
962  if (left <= seglen) {
963  /* whole requested data is completed */
964  vec[i].len = left;
965  left = 0;
966  i++;
967  break;
968  }
969 
970  /* use whole segment */
971  vec[i].len = seglen;
972  left -= seglen;
973  }
974 
975  RTE_ASSERT(left == 0);
976  return i;
977 }
978 
979 
980 #ifdef __cplusplus
981 }
982 #endif
983 
984 #endif /* _RTE_CRYPTO_SYM_H_ */
uint64_t rte_iova_t
Definition: rte_common.h:423
#define RTE_STD_C11
Definition: rte_common.h:40
static void __rte_crypto_sym_op_reset(struct rte_crypto_sym_op *op)
static int __rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op, struct rte_cryptodev_sym_session *sess)
rte_crypto_auth_algorithm
@ RTE_CRYPTO_AUTH_SHA512_HMAC
@ RTE_CRYPTO_AUTH_ZUC_EIA3
@ RTE_CRYPTO_AUTH_SHA3_224
@ RTE_CRYPTO_AUTH_AES_CBC_MAC
@ RTE_CRYPTO_AUTH_SHA224_HMAC
@ RTE_CRYPTO_AUTH_AES_XCBC_MAC
@ RTE_CRYPTO_AUTH_SHA3_224_HMAC
@ RTE_CRYPTO_AUTH_SNOW3G_UIA2
@ RTE_CRYPTO_AUTH_SHA1
@ RTE_CRYPTO_AUTH_SHA3_384_HMAC
@ RTE_CRYPTO_AUTH_SHA512
@ RTE_CRYPTO_AUTH_SHA384_HMAC
@ RTE_CRYPTO_AUTH_KASUMI_F9
@ RTE_CRYPTO_AUTH_MD5
@ RTE_CRYPTO_AUTH_MD5_HMAC
@ RTE_CRYPTO_AUTH_SHA384
@ RTE_CRYPTO_AUTH_SHA224
@ RTE_CRYPTO_AUTH_SHA3_512
@ RTE_CRYPTO_AUTH_AES_CMAC
@ RTE_CRYPTO_AUTH_SHA3_256_HMAC
@ RTE_CRYPTO_AUTH_SHA1_HMAC
@ RTE_CRYPTO_AUTH_NULL
@ RTE_CRYPTO_AUTH_SHA3_384
@ RTE_CRYPTO_AUTH_SHA3_256
@ RTE_CRYPTO_AUTH_SHA256
@ RTE_CRYPTO_AUTH_SHA256_HMAC
@ RTE_CRYPTO_AUTH_AES_GMAC
@ RTE_CRYPTO_AUTH_SHA3_512_HMAC
const char * rte_crypto_auth_algorithm_strings[]
const char * rte_crypto_cipher_operation_strings[]
rte_crypto_cipher_operation
@ RTE_CRYPTO_CIPHER_OP_DECRYPT
@ RTE_CRYPTO_CIPHER_OP_ENCRYPT
rte_crypto_sym_xform_type
@ RTE_CRYPTO_SYM_XFORM_NOT_SPECIFIED
@ RTE_CRYPTO_SYM_XFORM_AUTH
@ RTE_CRYPTO_SYM_XFORM_AEAD
@ RTE_CRYPTO_SYM_XFORM_CIPHER
rte_crypto_aead_algorithm
@ RTE_CRYPTO_AEAD_AES_CCM
@ RTE_CRYPTO_AEAD_AES_GCM
@ RTE_CRYPTO_AEAD_CHACHA20_POLY1305
rte_crypto_cipher_algorithm
@ RTE_CRYPTO_CIPHER_DES_CBC
@ RTE_CRYPTO_CIPHER_ARC4
@ RTE_CRYPTO_CIPHER_AES_XTS
@ RTE_CRYPTO_CIPHER_AES_CTR
@ RTE_CRYPTO_CIPHER_AES_DOCSISBPI
@ RTE_CRYPTO_CIPHER_SNOW3G_UEA2
@ RTE_CRYPTO_CIPHER_3DES_ECB
@ RTE_CRYPTO_CIPHER_ZUC_EEA3
@ RTE_CRYPTO_CIPHER_DES_DOCSISBPI
@ RTE_CRYPTO_CIPHER_NULL
@ RTE_CRYPTO_CIPHER_KASUMI_F8
@ RTE_CRYPTO_CIPHER_AES_CBC
@ RTE_CRYPTO_CIPHER_AES_F8
@ RTE_CRYPTO_CIPHER_3DES_CBC
@ RTE_CRYPTO_CIPHER_3DES_CTR
@ RTE_CRYPTO_CIPHER_AES_ECB
const char * rte_crypto_aead_operation_strings[]
rte_crypto_auth_operation
@ RTE_CRYPTO_AUTH_OP_VERIFY
@ RTE_CRYPTO_AUTH_OP_GENERATE
const char * rte_crypto_aead_algorithm_strings[]
rte_crypto_aead_operation
@ RTE_CRYPTO_AEAD_OP_DECRYPT
@ RTE_CRYPTO_AEAD_OP_ENCRYPT
const char * rte_crypto_auth_operation_strings[]
const char * rte_crypto_cipher_algorithm_strings[]
static struct rte_crypto_sym_xform * __rte_crypto_sym_op_sym_xforms_alloc(struct rte_crypto_sym_op *sym_op, void *priv_data, uint8_t nb_xforms)
static __rte_experimental int rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len, struct rte_crypto_vec vec[], uint32_t num)
#define rte_pktmbuf_iova_offset(m, o)
#define rte_pktmbuf_iova(m)
#define rte_pktmbuf_mtod(m, t)
#define rte_pktmbuf_mtod_offset(m, t, o)
enum rte_crypto_auth_algorithm algo
struct rte_crypto_auth_xform::@114 key
const uint8_t * data
enum rte_crypto_auth_operation op
struct rte_crypto_auth_xform::@115 iv
enum rte_crypto_cipher_algorithm algo
struct rte_crypto_cipher_xform::@112 key
enum rte_crypto_cipher_operation op
struct rte_crypto_cipher_xform::@113 iv
struct rte_crypto_vec * vec
struct rte_cryptodev_sym_session * session
struct rte_crypto_sym_op::@122::@124::@129 aad
struct rte_security_session * sec_session
struct rte_crypto_sym_op::@122::@124::@128 digest
struct rte_mbuf * m_dst
struct rte_crypto_sym_xform * xform
rte_iova_t phys_addr
struct rte_mbuf * m_src
struct rte_crypto_sym_op::@122::@124::@127 data
struct rte_crypto_sgl * sgl
struct rte_crypto_va_iova_ptr * iv
struct rte_crypto_va_iova_ptr * auth_iv
struct rte_crypto_va_iova_ptr * digest
struct rte_crypto_va_iova_ptr * aad
struct rte_crypto_auth_xform auth
enum rte_crypto_sym_xform_type type
struct rte_crypto_sym_xform * next
struct rte_crypto_cipher_xform cipher
struct rte_crypto_aead_xform aead
rte_iova_t iova
uint16_t nb_segs
struct rte_mbuf * next
uint16_t data_len