DPDK 22.11.0-rc2
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
18extern "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;
41 uint32_t tot_len;
42};
43
52 uint32_t num;
53};
54
61 void *va;
62 rte_iova_t iova;
63};
64
72 uint32_t num;
81
82 __extension__
83 union {
88 };
89
95 int32_t *status;
96};
97
103 uint64_t raw;
104 struct {
105 struct {
106 uint16_t head;
107 uint16_t tail;
108 } auth, cipher;
109 } ofs;
110};
111
177
179extern const char *
181
189
191extern const char *
193
209 struct {
210 const uint8_t *data;
211 uint16_t length;
212 } key;
244 struct {
245 uint16_t offset;
271 uint16_t length;
286 } iv;
288 uint32_t dataunit_len;
299};
300
378
380extern const char *
382
388
390extern const char *
392
406 struct {
407 const uint8_t *data;
408 uint16_t length;
409 } key;
417 struct {
418 uint16_t offset;
434 uint16_t length;
452 } iv;
464};
465
466
482
484extern const char *
486
494
496extern const char *
498
499struct rte_crypto_aead_xform {
505 struct {
506 const uint8_t *data;
507 uint16_t length;
508 } key;
509
510 struct {
511 uint16_t offset;
531 uint16_t length;
547 } iv;
549 uint16_t digest_length;
550
551 uint16_t aad_length;
557};
558
566
580 ;
582 union {
587 struct rte_crypto_aead_xform aead;
589 };
590};
591
623 struct rte_mbuf *m_src;
624 struct rte_mbuf *m_dst;
627 union {
628 void *session;
632 };
633
635 union {
636 struct {
637 struct {
638 uint32_t offset;
643 uint32_t length;
649 struct {
650 uint8_t *data;
673 struct {
674 uint8_t *data;
706 } aad;
708 } aead;
709
710 struct {
711 struct {
712 struct {
713 uint32_t offset;
729 uint32_t length;
747 } cipher;
748
749 struct {
750 struct {
751 uint32_t offset;
777 uint32_t length;
801 } data;
804 struct {
805 uint8_t *data;
879 } auth;
880 };
881 };
882};
883
884
890static inline void
892{
893 memset(op, 0, sizeof(*op));
894}
895
896
907static inline struct rte_crypto_sym_xform *
909 void *priv_data, uint8_t nb_xforms)
910{
911 struct rte_crypto_sym_xform *xform;
912
913 sym_op->xform = xform = (struct rte_crypto_sym_xform *)priv_data;
914
915 do {
917 xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL;
918 } while (xform);
919
920 return sym_op->xform;
921}
922
923
930static inline int
932{
933 sym_op->session = sess;
934
935 return 0;
936}
937
956__rte_experimental
957static inline int
958rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
959 struct rte_crypto_vec vec[], uint32_t num)
960{
961 uint32_t i;
962 struct rte_mbuf *nseg;
963 uint32_t left;
964 uint32_t seglen;
965
966 /* assuming that requested data starts in the first segment */
967 RTE_ASSERT(mb->data_len > ofs);
968
969 if (mb->nb_segs > num)
970 return -mb->nb_segs;
971
972 vec[0].base = rte_pktmbuf_mtod_offset(mb, void *, ofs);
973 vec[0].iova = rte_pktmbuf_iova_offset(mb, ofs);
974 vec[0].tot_len = mb->buf_len - rte_pktmbuf_headroom(mb) - ofs;
975
976 /* whole data lies in the first segment */
977 seglen = mb->data_len - ofs;
978 if (len <= seglen) {
979 vec[0].len = len;
980 return 1;
981 }
982
983 /* data spread across segments */
984 vec[0].len = seglen;
985 left = len - seglen;
986 for (i = 1, nseg = mb->next; nseg != NULL; nseg = nseg->next, i++) {
987
988 vec[i].base = rte_pktmbuf_mtod(nseg, void *);
989 vec[i].iova = rte_pktmbuf_iova(nseg);
990 vec[i].tot_len = mb->buf_len - rte_pktmbuf_headroom(mb) - ofs;
991
992 seglen = nseg->data_len;
993 if (left <= seglen) {
994 /* whole requested data is completed */
995 vec[i].len = left;
996 left = 0;
997 i++;
998 break;
999 }
1000
1001 /* use whole segment */
1002 vec[i].len = seglen;
1003 left -= seglen;
1004 }
1005
1006 RTE_ASSERT(left == 0);
1007 return i;
1008}
1009
1010
1011#ifdef __cplusplus
1012}
1013#endif
1014
1015#endif /* _RTE_CRYPTO_SYM_H_ */
uint64_t rte_iova_t
Definition: rte_common.h:458
#define RTE_STD_C11
Definition: rte_common.h:39
static void __rte_crypto_sym_op_reset(struct rte_crypto_sym_op *op)
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_SM3
@ 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_SM4_ECB
@ 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_SM4_CBC
@ RTE_CRYPTO_CIPHER_3DES_ECB
@ RTE_CRYPTO_CIPHER_ZUC_EEA3
@ RTE_CRYPTO_CIPHER_DES_DOCSISBPI
@ RTE_CRYPTO_CIPHER_NULL
@ RTE_CRYPTO_CIPHER_SM4_CTR
@ 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[]
static int __rte_crypto_sym_op_attach_sym_session(struct rte_crypto_sym_op *sym_op, void *sess)
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)
static uint16_t rte_pktmbuf_headroom(const struct rte_mbuf *m)
Definition: rte_mbuf.h:1511
#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::@76 key
const uint8_t * data
enum rte_crypto_auth_operation op
struct rte_crypto_auth_xform::@77 iv
struct rte_crypto_cipher_xform::@74 key
enum rte_crypto_cipher_algorithm algo
struct rte_crypto_cipher_xform::@75 iv
enum rte_crypto_cipher_operation op
struct rte_crypto_vec * vec
struct rte_crypto_sym_op::@84::@86::@89 data
struct rte_crypto_sym_op::@84::@86::@90 digest
struct rte_mbuf * m_dst
struct rte_crypto_sym_op::@84::@86::@91 aad
struct rte_crypto_sym_xform * xform
rte_iova_t phys_addr
struct rte_mbuf * m_src
struct rte_crypto_sgl * src_sgl
struct rte_crypto_sgl * dest_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
uint32_t tot_len
uint16_t nb_segs
uint16_t buf_len
struct rte_mbuf * next
uint16_t data_len