DPDK 25.03.0-rc0
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#include <string.h>
18
19#include <rte_compat.h>
20#include <rte_mbuf.h>
21#include <rte_memory.h>
22#include <rte_mempool.h>
23#include <rte_common.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
36 void *base;
40 uint32_t len;
42 uint32_t tot_len;
43};
44
53 uint32_t num;
54};
55
62 void *va;
63 rte_iova_t iova;
64};
65
73 uint32_t num;
82
83 __extension__
84 union {
89 };
90
96 int32_t *status;
97};
98
104 uint64_t raw;
105 struct {
106 struct {
107 uint16_t head;
108 uint16_t tail;
109 } auth, cipher;
110 } ofs;
111};
112
184
192
194extern const char *
196
212 struct {
213 const uint8_t *data;
214 uint16_t length;
215 } key;
247 struct {
248 uint16_t offset;
274 uint16_t length;
289 } iv;
291 uint32_t dataunit_len;
302};
303
385 RTE_CRYPTO_AUTH_SM3_HMAC,
387};
388
394
396extern const char *
398
412 struct {
413 const uint8_t *data;
414 uint16_t length;
415 } key;
423 struct {
424 uint16_t offset;
440 uint16_t length;
458 } iv;
470};
471
472
488
496
498extern const char *
500
501struct rte_crypto_aead_xform {
507 struct {
508 const uint8_t *data;
509 uint16_t length;
510 } key;
511
512 struct {
513 uint16_t offset;
533 uint16_t length;
549 } iv;
551 uint16_t digest_length;
552
553 uint16_t aad_length;
559};
560
568
578/* Structure rte_crypto_sym_xform 8< */
583 ;
584 union {
589 struct rte_crypto_aead_xform aead;
591 };
592};
593/* >8 End of structure rte_crypto_sym_xform. */
594
625/* Structure rte_crypto_sym_op 8< */
627 struct rte_mbuf *m_src;
628 struct rte_mbuf *m_dst;
630 union {
631 void *session;
635 };
636
637 union {
638 struct {
639 struct {
640 uint32_t offset;
645 uint32_t length;
651 struct {
652 uint8_t *data;
675 struct {
676 uint8_t *data;
698 } aad;
700 } aead;
701
702 struct {
703 struct {
704 struct {
705 uint32_t offset;
721 uint32_t length;
740 } cipher;
741
742 struct {
743 struct {
744 uint32_t offset;
770 uint32_t length;
794 } data;
797 struct {
798 uint8_t *data;
872 } auth;
873 };
874 };
875};
876/* >8 End of structure rte_crypto_sym_op. */
877
878
884static inline void
886{
887 memset(op, 0, sizeof(*op));
888}
889
890
901static inline struct rte_crypto_sym_xform *
903 void *priv_data, uint8_t nb_xforms)
904{
905 struct rte_crypto_sym_xform *xform;
906
907 sym_op->xform = xform = (struct rte_crypto_sym_xform *)priv_data;
908
909 do {
911 xform = xform->next = --nb_xforms > 0 ? xform + 1 : NULL;
912 } while (xform);
913
914 return sym_op->xform;
915}
916
917
924static inline int
926{
927 sym_op->session = sess;
928
929 return 0;
930}
931
950__rte_experimental
951static inline int
952rte_crypto_mbuf_to_vec(const struct rte_mbuf *mb, uint32_t ofs, uint32_t len,
953 struct rte_crypto_vec vec[], uint32_t num)
954{
955 uint32_t i;
956 struct rte_mbuf *nseg;
957 uint32_t left;
958 uint32_t seglen;
959
960 /* assuming that requested data starts in the first segment */
961 RTE_ASSERT(mb->data_len > ofs);
962
963 if (mb->nb_segs > num)
964 return -mb->nb_segs;
965
966 vec[0].base = rte_pktmbuf_mtod_offset(mb, void *, ofs);
967 vec[0].iova = rte_pktmbuf_iova_offset(mb, ofs);
968 vec[0].tot_len = mb->buf_len - rte_pktmbuf_headroom(mb) - ofs;
969
970 /* whole data lies in the first segment */
971 seglen = mb->data_len - ofs;
972 if (len <= seglen) {
973 vec[0].len = len;
974 return 1;
975 }
976
977 /* data spread across segments */
978 vec[0].len = seglen;
979 left = len - seglen;
980 for (i = 1, nseg = mb->next; nseg != NULL; nseg = nseg->next, i++) {
981
982 vec[i].base = rte_pktmbuf_mtod(nseg, void *);
983 vec[i].iova = rte_pktmbuf_iova(nseg);
984 vec[i].tot_len = mb->buf_len - rte_pktmbuf_headroom(mb) - ofs;
985
986 seglen = nseg->data_len;
987 if (left <= seglen) {
988 /* whole requested data is completed */
989 vec[i].len = left;
990 left = 0;
991 i++;
992 break;
993 }
994
995 /* use whole segment */
996 vec[i].len = seglen;
997 left -= seglen;
998 }
999
1000 RTE_ASSERT(left == 0);
1001 return i;
1002}
1003
1004
1005#ifdef __cplusplus
1006}
1007#endif
1008
1009#endif /* _RTE_CRYPTO_SYM_H_ */
uint64_t rte_iova_t
Definition: rte_common.h:658
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_SHAKE_256
@ RTE_CRYPTO_AUTH_SHAKE_128
@ 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_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_SM4_OFB
@ RTE_CRYPTO_CIPHER_SNOW3G_UEA2
@ RTE_CRYPTO_CIPHER_SM4_CBC
@ RTE_CRYPTO_CIPHER_SM4_XTS
@ RTE_CRYPTO_CIPHER_SM4_CFB
@ 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
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[]
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:1516
#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::@103 key
const uint8_t * data
enum rte_crypto_auth_operation op
struct rte_crypto_auth_xform::@104 iv
enum rte_crypto_cipher_algorithm algo
struct rte_crypto_cipher_xform::@102 iv
struct rte_crypto_cipher_xform::@101 key
enum rte_crypto_cipher_operation op
struct rte_crypto_vec * vec
struct rte_crypto_sym_op::@111::@113::@117 digest
struct rte_mbuf * m_dst
struct rte_crypto_sym_op::@111::@113::@116 data
struct rte_crypto_sym_op::@111::@113::@118 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