4 * Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef _RTE_AESNI_GCM_PMD_PRIVATE_H_
34 #define _RTE_AESNI_GCM_PMD_PRIVATE_H_
36 #include "aesni_gcm_ops.h"
38 #define CRYPTODEV_NAME_AESNI_GCM_PMD crypto_aesni_gcm
39 /**< AES-NI GCM PMD device name */
41 #define GCM_LOG_ERR(fmt, args...) \
42 RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
43 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), \
44 __func__, __LINE__, ## args)
46 #ifdef RTE_LIBRTE_AESNI_MB_DEBUG
47 #define GCM_LOG_INFO(fmt, args...) \
48 RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
49 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), \
50 __func__, __LINE__, ## args)
52 #define GCM_LOG_DBG(fmt, args...) \
53 RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
54 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), \
55 __func__, __LINE__, ## args)
57 #define GCM_LOG_INFO(fmt, args...)
58 #define GCM_LOG_DBG(fmt, args...)
62 /** private data structure for each virtual AESNI GCM device */
63 struct aesni_gcm_private {
64 enum aesni_gcm_vector_mode vector_mode;
66 unsigned max_nb_queue_pairs;
67 /**< Max number of queue pairs supported by device */
68 unsigned max_nb_sessions;
69 /**< Max number of sessions supported by device */
73 const struct aesni_gcm_ops *ops;
74 /**< Architecture dependent function pointer table of the gcm APIs */
75 struct rte_ring *processed_pkts;
76 /**< Ring for placing process packets */
77 struct gcm_context_data gdata_ctx; /* (16 * 5) + 8 = 88 B */
78 /**< GCM parameters */
79 struct rte_cryptodev_stats qp_stats; /* 8 * 4 = 32 B */
80 /**< Queue pair statistics */
81 struct rte_mempool *sess_mp;
82 /**< Session Mempool */
84 /**< Queue Pair Identifier */
85 char name[RTE_CRYPTODEV_NAME_LEN];
86 /**< Unique Queue Pair Name */
87 } __rte_cache_aligned;
90 enum aesni_gcm_operation {
91 AESNI_GCM_OP_AUTHENTICATED_ENCRYPTION,
92 AESNI_GCM_OP_AUTHENTICATED_DECRYPTION,
93 AESNI_GMAC_OP_GENERATE,
97 /** AESNI GCM private session structure */
98 struct aesni_gcm_session {
103 /**< IV parameters */
106 uint16_t digest_length;
107 /**< Digest length */
108 enum aesni_gcm_operation op;
109 /**< GCM operation type */
110 enum aesni_gcm_key key;
112 struct gcm_key_data gdata_key;
113 /**< GCM parameters */
118 * Setup GCM session parameters
119 * @param sess aesni gcm session structure
120 * @param xform crypto transform chain
123 * - On success returns 0
124 * - On failure returns error code < 0
127 aesni_gcm_set_session_parameters(const struct aesni_gcm_ops *ops,
128 struct aesni_gcm_session *sess,
129 const struct rte_crypto_sym_xform *xform);
133 * Device specific operations function pointer structure */
134 extern struct rte_cryptodev_ops *rte_aesni_gcm_pmd_ops;
137 #endif /* _RTE_AESNI_GCM_PMD_PRIVATE_H_ */