test mbuf attach
[dpdk.git] / app / test / test_cryptodev_blockcipher.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef TEST_CRYPTODEV_BLOCKCIPHER_H_
6 #define TEST_CRYPTODEV_BLOCKCIPHER_H_
7
8 #ifndef BLOCKCIPHER_TEST_MSG_LEN
9 #define BLOCKCIPHER_TEST_MSG_LEN                256
10 #endif
11
12 #define BLOCKCIPHER_TEST_OP_ENCRYPT             0x01
13 #define BLOCKCIPHER_TEST_OP_DECRYPT             0x02
14 #define BLOCKCIPHER_TEST_OP_AUTH_GEN    0x04
15 #define BLOCKCIPHER_TEST_OP_AUTH_VERIFY 0x08
16
17 #define BLOCKCIPHER_TEST_FEATURE_OOP                    0x01
18 #define BLOCKCIPHER_TEST_FEATURE_SESSIONLESS    0x02
19 #define BLOCKCIPHER_TEST_FEATURE_STOPPER        0x04 /* stop upon failing */
20 #define BLOCKCIPHER_TEST_FEATURE_SG             0x08 /* Scatter Gather */
21
22 #define BLOCKCIPHER_TEST_OP_CIPHER      (BLOCKCIPHER_TEST_OP_ENCRYPT | \
23                                         BLOCKCIPHER_TEST_OP_DECRYPT)
24
25 #define BLOCKCIPHER_TEST_OP_AUTH        (BLOCKCIPHER_TEST_OP_AUTH_GEN | \
26                                         BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
27
28 #define BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN        (BLOCKCIPHER_TEST_OP_ENCRYPT | \
29                                         BLOCKCIPHER_TEST_OP_AUTH_GEN)
30
31 #define BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC     (BLOCKCIPHER_TEST_OP_DECRYPT | \
32                                         BLOCKCIPHER_TEST_OP_AUTH_VERIFY)
33
34 enum blockcipher_test_type {
35         BLKCIPHER_AES_CHAIN_TYPE,       /* use aes_chain_test_cases[] */
36         BLKCIPHER_AES_CIPHERONLY_TYPE,  /* use aes_cipheronly_test_cases[] */
37         BLKCIPHER_AES_DOCSIS_TYPE,      /* use aes_docsis_test_cases[] */
38         BLKCIPHER_3DES_CHAIN_TYPE,      /* use triple_des_chain_test_cases[] */
39         BLKCIPHER_3DES_CIPHERONLY_TYPE, /* triple_des_cipheronly_test_cases[] */
40         BLKCIPHER_AUTHONLY_TYPE,        /* use hash_test_cases[] */
41         BLKCIPHER_DES_CIPHERONLY_TYPE,  /* use des_cipheronly_test_cases[] */
42         BLKCIPHER_DES_DOCSIS_TYPE       /* use des_docsis_test_cases[] */
43 };
44
45 struct blockcipher_test_case {
46         const char *test_descr; /* test description */
47         const struct blockcipher_test_data *test_data;
48         uint8_t op_mask; /* operation mask */
49         uint8_t feature_mask;
50 };
51
52 struct blockcipher_test_data {
53         enum rte_crypto_cipher_algorithm crypto_algo;
54
55         struct {
56                 uint8_t data[64];
57                 unsigned int len;
58         } cipher_key;
59
60         struct {
61                 uint8_t data[64] __rte_aligned(16);
62                 unsigned int len;
63         } iv;
64
65         struct {
66                 const uint8_t *data;
67                 unsigned int len;
68         } plaintext;
69
70         struct {
71                 const uint8_t *data;
72                 unsigned int len;
73         } ciphertext;
74
75         enum rte_crypto_auth_algorithm auth_algo;
76
77         struct {
78                 uint8_t data[128];
79                 unsigned int len;
80         } auth_key;
81
82         struct {
83                 uint8_t data[128];
84                 unsigned int len;               /* for qat */
85                 unsigned int truncated_len;     /* for mb */
86         } digest;
87
88         unsigned int cipher_offset;
89         unsigned int auth_offset;
90 };
91
92 int
93 test_blockcipher_all_tests(struct rte_mempool *mbuf_pool,
94         struct rte_mempool *op_mpool,
95         struct rte_mempool *sess_mpool,
96         struct rte_mempool *sess_priv_mpool,
97         uint8_t dev_id,
98         enum blockcipher_test_type test_type);
99
100 #endif /* TEST_CRYPTODEV_BLOCKCIPHER_H_ */