New upstream version 18.02
[deb_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 #define GCM_LOG_ERR(fmt, args...) \
14         RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
15                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), \
16                         __func__, __LINE__, ## args)
17
18 #ifdef RTE_LIBRTE_AESNI_MB_DEBUG
19 #define GCM_LOG_INFO(fmt, args...) \
20         RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
21                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), \
22                         __func__, __LINE__, ## args)
23
24 #define GCM_LOG_DBG(fmt, args...) \
25         RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
26                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), \
27                         __func__, __LINE__, ## args)
28 #else
29 #define GCM_LOG_INFO(fmt, args...)
30 #define GCM_LOG_DBG(fmt, args...)
31 #endif
32
33 /* Maximum length for digest */
34 #define DIGEST_LENGTH_MAX 16
35
36 /** private data structure for each virtual AESNI GCM device */
37 struct aesni_gcm_private {
38         enum aesni_gcm_vector_mode vector_mode;
39         /**< Vector mode */
40         unsigned max_nb_queue_pairs;
41         /**< Max number of queue pairs supported by device */
42         unsigned max_nb_sessions;
43         /**< Max number of sessions supported by device */
44 };
45
46 struct aesni_gcm_qp {
47         const struct aesni_gcm_ops *ops;
48         /**< Architecture dependent function pointer table of the gcm APIs */
49         struct rte_ring *processed_pkts;
50         /**< Ring for placing process packets */
51         struct gcm_context_data gdata_ctx; /* (16 * 5) + 8 = 88 B */
52         /**< GCM parameters */
53         struct rte_cryptodev_stats qp_stats; /* 8 * 4 = 32 B */
54         /**< Queue pair statistics */
55         struct rte_mempool *sess_mp;
56         /**< Session Mempool */
57         uint16_t id;
58         /**< Queue Pair Identifier */
59         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
60         /**< Unique Queue Pair Name */
61         uint8_t temp_digest[DIGEST_LENGTH_MAX];
62         /**< Buffer used to store the digest generated
63          * by the driver when verifying a digest provided
64          * by the user (using authentication verify operation)
65          */
66 } __rte_cache_aligned;
67
68
69 enum aesni_gcm_operation {
70         AESNI_GCM_OP_AUTHENTICATED_ENCRYPTION,
71         AESNI_GCM_OP_AUTHENTICATED_DECRYPTION,
72         AESNI_GMAC_OP_GENERATE,
73         AESNI_GMAC_OP_VERIFY
74 };
75
76 /** AESNI GCM private session structure */
77 struct aesni_gcm_session {
78         struct {
79                 uint16_t length;
80                 uint16_t offset;
81         } iv;
82         /**< IV parameters */
83         uint16_t aad_length;
84         /**< AAD length */
85         uint16_t digest_length;
86         /**< Digest length */
87         enum aesni_gcm_operation op;
88         /**< GCM operation type */
89         enum aesni_gcm_key key;
90         /**< GCM key type */
91         struct gcm_key_data gdata_key;
92         /**< GCM parameters */
93 };
94
95
96 /**
97  * Setup GCM session parameters
98  * @param       sess    aesni gcm session structure
99  * @param       xform   crypto transform chain
100  *
101  * @return
102  * - On success returns 0
103  * - On failure returns error code < 0
104  */
105 extern int
106 aesni_gcm_set_session_parameters(const struct aesni_gcm_ops *ops,
107                 struct aesni_gcm_session *sess,
108                 const struct rte_crypto_sym_xform *xform);
109
110
111 /**
112  * Device specific operations function pointer structure */
113 extern struct rte_cryptodev_ops *rte_aesni_gcm_pmd_ops;
114
115
116 #endif /* _RTE_AESNI_GCM_PMD_PRIVATE_H_ */