1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
4 #ifndef TEST_CRYPTODEV_H_
5 #define TEST_CRYPTODEV_H_
12 #define MAX_NUM_OPS_INFLIGHT (4096)
13 #define MIN_NUM_OPS_INFLIGHT (128)
14 #define DEFAULT_NUM_OPS_INFLIGHT (128)
16 #define MAX_NUM_QPS_PER_QAT_DEVICE (2)
17 #define DEFAULT_NUM_QPS_PER_QAT_DEVICE (2)
18 #define DEFAULT_BURST_SIZE (64)
19 #define DEFAULT_NUM_XFORMS (2)
20 #define NUM_MBUFS (8191)
21 #define MBUF_CACHE_SIZE (256)
22 #define MBUF_DATAPAYLOAD_SIZE (2048 + DIGEST_BYTE_LENGTH_SHA512)
23 #define MBUF_SIZE (sizeof(struct rte_mbuf) + \
24 RTE_PKTMBUF_HEADROOM + MBUF_DATAPAYLOAD_SIZE)
26 #define BYTE_LENGTH(x) (x/8)
27 /* HASH DIGEST LENGTHS */
28 #define DIGEST_BYTE_LENGTH_MD5 (BYTE_LENGTH(128))
29 #define DIGEST_BYTE_LENGTH_SHA1 (BYTE_LENGTH(160))
30 #define DIGEST_BYTE_LENGTH_SHA224 (BYTE_LENGTH(224))
31 #define DIGEST_BYTE_LENGTH_SHA256 (BYTE_LENGTH(256))
32 #define DIGEST_BYTE_LENGTH_SHA384 (BYTE_LENGTH(384))
33 #define DIGEST_BYTE_LENGTH_SHA512 (BYTE_LENGTH(512))
34 #define DIGEST_BYTE_LENGTH_AES_XCBC (BYTE_LENGTH(96))
35 #define DIGEST_BYTE_LENGTH_SNOW3G_UIA2 (BYTE_LENGTH(32))
36 #define DIGEST_BYTE_LENGTH_KASUMI_F9 (BYTE_LENGTH(32))
37 #define AES_XCBC_MAC_KEY_SZ (16)
38 #define DIGEST_BYTE_LENGTH_AES_GCM (BYTE_LENGTH(128))
40 #define TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 (12)
41 #define TRUNCATED_DIGEST_BYTE_LENGTH_SHA224 (16)
42 #define TRUNCATED_DIGEST_BYTE_LENGTH_SHA256 (16)
43 #define TRUNCATED_DIGEST_BYTE_LENGTH_SHA384 (24)
44 #define TRUNCATED_DIGEST_BYTE_LENGTH_SHA512 (32)
46 #define MAXIMUM_IV_LENGTH (16)
48 #define IV_OFFSET (sizeof(struct rte_crypto_op) + \
49 sizeof(struct rte_crypto_sym_op) + DEFAULT_NUM_XFORMS * \
50 sizeof(struct rte_crypto_sym_xform))
52 #define CRYPTODEV_NAME_NULL_PMD crypto_null
53 #define CRYPTODEV_NAME_AESNI_MB_PMD crypto_aesni_mb
54 #define CRYPTODEV_NAME_AESNI_GCM_PMD crypto_aesni_gcm
55 #define CRYPTODEV_NAME_OPENSSL_PMD crypto_openssl
56 #define CRYPTODEV_NAME_QAT_SYM_PMD crypto_qat
57 #define CRYPTODEV_NAME_QAT_ASYM_PMD crypto_qat_asym
58 #define CRYPTODEV_NAME_SNOW3G_PMD crypto_snow3g
59 #define CRYPTODEV_NAME_KASUMI_PMD crypto_kasumi
60 #define CRYPTODEV_NAME_ZUC_PMD crypto_zuc
61 #define CRYPTODEV_NAME_ARMV8_PMD crypto_armv8
62 #define CRYPTODEV_NAME_DPAA_SEC_PMD crypto_dpaa_sec
63 #define CRYPTODEV_NAME_DPAA2_SEC_PMD crypto_dpaa2_sec
64 #define CRYPTODEV_NAME_SCHEDULER_PMD crypto_scheduler
65 #define CRYPTODEV_NAME_MVSAM_PMD crypto_mvsam
66 #define CRYPTODEV_NAME_CCP_PMD crypto_ccp
67 #define CRYPTODEV_NAME_VIRTIO_PMD crypto_virtio
68 #define CRYPTODEV_NAME_OCTEONTX_SYM_PMD crypto_octeontx
69 #define CRYPTODEV_NAME_CAAM_JR_PMD crypto_caam_jr
72 * Write (spread) data from buffer to mbuf data
77 * Start offset in mbuf
79 * Number of bytes to copy
81 * Continuous source buffer
84 pktmbuf_write(struct rte_mbuf *mbuf, int offset, int len, const uint8_t *buffer)
91 for (m = mbuf; (m != NULL) && (offset > m->data_len); m = m->next)
92 offset -= m->data_len;
94 l = m->data_len - offset;
96 /* copy data from first segment */
97 dst = rte_pktmbuf_mtod_offset(m, char *, offset);
99 rte_memcpy(dst, buffer, len);
103 rte_memcpy(dst, buffer, l);
107 for (m = m->next; (m != NULL) && (n > 0); m = m->next) {
108 dst = rte_pktmbuf_mtod(m, char *);
111 rte_memcpy(dst, buffer, n);
114 rte_memcpy(dst, buffer, l);
120 static inline uint8_t *
121 pktmbuf_mtod_offset(struct rte_mbuf *mbuf, int offset) {
124 for (m = mbuf; (m != NULL) && (offset > m->data_len); m = m->next)
125 offset -= m->data_len;
128 printf("pktmbuf_mtod_offset: offset out of buffer\n");
131 return rte_pktmbuf_mtod_offset(m, uint8_t *, offset);
134 static inline rte_iova_t
135 pktmbuf_iova_offset(struct rte_mbuf *mbuf, int offset) {
138 for (m = mbuf; (m != NULL) && (offset > m->data_len); m = m->next)
139 offset -= m->data_len;
142 printf("pktmbuf_iova_offset: offset out of buffer\n");
145 return rte_pktmbuf_iova_offset(m, offset);
148 static inline struct rte_mbuf *
149 create_segmented_mbuf(struct rte_mempool *mbuf_pool, int pkt_len,
150 int nb_segs, uint8_t pattern) {
152 struct rte_mbuf *m = NULL, *mbuf = NULL;
159 printf("Packet size must be 1 or more (is %d)\n", pkt_len);
164 printf("Number of segments must be 1 or more (is %d)\n",
169 t_len = pkt_len >= nb_segs ? pkt_len / nb_segs : 1;
172 /* Create chained mbuf_src and fill it generated data */
173 for (i = 0; size > 0; i++) {
175 m = rte_pktmbuf_alloc(mbuf_pool);
180 printf("Cannot create segment for source mbuf");
184 /* Make sure if tailroom is zeroed */
185 memset(m->buf_addr, pattern, m->buf_len);
187 data_len = size > t_len ? t_len : size;
188 dst = (uint8_t *)rte_pktmbuf_append(m, data_len);
190 printf("Cannot append %d bytes to the mbuf\n",
196 rte_pktmbuf_chain(mbuf, m);
205 rte_pktmbuf_free(mbuf);
209 #endif /* TEST_CRYPTODEV_H_ */