crypto/aesni_gcm: add dynamic logging
[dpdk.git] / drivers / crypto / aesni_gcm / aesni_gcm_pmd_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef _RTE_AESNI_GCM_PMD_PRIVATE_H_
6 #define _RTE_AESNI_GCM_PMD_PRIVATE_H_
7
8 #include "aesni_gcm_ops.h"
9
10 #define CRYPTODEV_NAME_AESNI_GCM_PMD    crypto_aesni_gcm
11 /**< AES-NI GCM PMD device name */
12
13 /** AES-NI GCM PMD  LOGTYPE DRIVER */
14 int aesni_gcm_logtype_driver;
15 #define AESNI_GCM_LOG(level, fmt, ...) \
16         rte_log(RTE_LOG_ ## level, aesni_gcm_logtype_driver,    \
17                         "%s() line %u: "fmt "\n", __func__, __LINE__,   \
18                                         ## __VA_ARGS__)
19
20 /* Maximum length for digest */
21 #define DIGEST_LENGTH_MAX 16
22
23 /** private data structure for each virtual AESNI GCM device */
24 struct aesni_gcm_private {
25         enum aesni_gcm_vector_mode vector_mode;
26         /**< Vector mode */
27         unsigned max_nb_queue_pairs;
28         /**< Max number of queue pairs supported by device */
29         unsigned max_nb_sessions;
30         /**< Max number of sessions supported by device */
31 };
32
33 struct aesni_gcm_qp {
34         const struct aesni_gcm_ops *ops;
35         /**< Architecture dependent function pointer table of the gcm APIs */
36         struct rte_ring *processed_pkts;
37         /**< Ring for placing process packets */
38         struct gcm_context_data gdata_ctx; /* (16 * 5) + 8 = 88 B */
39         /**< GCM parameters */
40         struct rte_cryptodev_stats qp_stats; /* 8 * 4 = 32 B */
41         /**< Queue pair statistics */
42         struct rte_mempool *sess_mp;
43         /**< Session Mempool */
44         uint16_t id;
45         /**< Queue Pair Identifier */
46         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
47         /**< Unique Queue Pair Name */
48         uint8_t temp_digest[DIGEST_LENGTH_MAX];
49         /**< Buffer used to store the digest generated
50          * by the driver when verifying a digest provided
51          * by the user (using authentication verify operation)
52          */
53 } __rte_cache_aligned;
54
55
56 enum aesni_gcm_operation {
57         AESNI_GCM_OP_AUTHENTICATED_ENCRYPTION,
58         AESNI_GCM_OP_AUTHENTICATED_DECRYPTION,
59         AESNI_GMAC_OP_GENERATE,
60         AESNI_GMAC_OP_VERIFY
61 };
62
63 /** AESNI GCM private session structure */
64 struct aesni_gcm_session {
65         struct {
66                 uint16_t length;
67                 uint16_t offset;
68         } iv;
69         /**< IV parameters */
70         uint16_t aad_length;
71         /**< AAD length */
72         uint16_t digest_length;
73         /**< Digest length */
74         enum aesni_gcm_operation op;
75         /**< GCM operation type */
76         enum aesni_gcm_key key;
77         /**< GCM key type */
78         struct gcm_key_data gdata_key;
79         /**< GCM parameters */
80 };
81
82
83 /**
84  * Setup GCM session parameters
85  * @param       sess    aesni gcm session structure
86  * @param       xform   crypto transform chain
87  *
88  * @return
89  * - On success returns 0
90  * - On failure returns error code < 0
91  */
92 extern int
93 aesni_gcm_set_session_parameters(const struct aesni_gcm_ops *ops,
94                 struct aesni_gcm_session *sess,
95                 const struct rte_crypto_sym_xform *xform);
96
97
98 /**
99  * Device specific operations function pointer structure */
100 extern struct rte_cryptodev_ops *rte_aesni_gcm_pmd_ops;
101
102
103 #endif /* _RTE_AESNI_GCM_PMD_PRIVATE_H_ */