New upstream version 17.11-rc3
[deb_dpdk.git] / drivers / crypto / zuc / rte_zuc_pmd_private.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2016-2017 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
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
15  *       distribution.
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.
19  *
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.
31  */
32
33 #ifndef _RTE_ZUC_PMD_PRIVATE_H_
34 #define _RTE_ZUC_PMD_PRIVATE_H_
35
36 #include <sso_zuc.h>
37
38 #define CRYPTODEV_NAME_ZUC_PMD          crypto_zuc
39 /**< KASUMI PMD device name */
40
41 #define ZUC_LOG_ERR(fmt, args...) \
42         RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
43                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \
44                         __func__, __LINE__, ## args)
45
46 #ifdef RTE_LIBRTE_ZUC_DEBUG
47 #define ZUC_LOG_INFO(fmt, args...) \
48         RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
49                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \
50                         __func__, __LINE__, ## args)
51
52 #define ZUC_LOG_DBG(fmt, args...) \
53         RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
54                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \
55                         __func__, __LINE__, ## args)
56 #else
57 #define ZUC_LOG_INFO(fmt, args...)
58 #define ZUC_LOG_DBG(fmt, args...)
59 #endif
60
61 #define ZUC_IV_KEY_LENGTH 16
62 #define ZUC_DIGEST_LENGTH 4
63
64 /** private data structure for each virtual ZUC device */
65 struct zuc_private {
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 */
70 };
71
72 /** ZUC buffer queue pair */
73 struct zuc_qp {
74         uint16_t id;
75         /**< Queue Pair Identifier */
76         char name[RTE_CRYPTODEV_NAME_LEN];
77         /**< Unique Queue Pair Name */
78         struct rte_ring *processed_ops;
79         /**< Ring for placing processed ops */
80         struct rte_mempool *sess_mp;
81         /**< Session Mempool */
82         struct rte_cryptodev_stats qp_stats;
83         /**< Queue pair statistics */
84         uint8_t temp_digest[ZUC_DIGEST_LENGTH];
85         /**< Buffer used to store the digest generated
86          * by the driver when verifying a digest provided
87          * by the user (using authentication verify operation)
88          */
89 } __rte_cache_aligned;
90
91 enum zuc_operation {
92         ZUC_OP_ONLY_CIPHER,
93         ZUC_OP_ONLY_AUTH,
94         ZUC_OP_CIPHER_AUTH,
95         ZUC_OP_AUTH_CIPHER,
96         ZUC_OP_NOT_SUPPORTED
97 };
98
99 /** ZUC private session structure */
100 struct zuc_session {
101         enum zuc_operation op;
102         enum rte_crypto_auth_operation auth_op;
103         uint8_t pKey_cipher[ZUC_IV_KEY_LENGTH];
104         uint8_t pKey_hash[ZUC_IV_KEY_LENGTH];
105         uint16_t cipher_iv_offset;
106         uint16_t auth_iv_offset;
107 } __rte_cache_aligned;
108
109
110 extern int
111 zuc_set_session_parameters(struct zuc_session *sess,
112                 const struct rte_crypto_sym_xform *xform);
113
114
115 /** device specific operations function pointer structure */
116 extern struct rte_cryptodev_ops *rte_zuc_pmd_ops;
117
118
119
120 #endif /* _RTE_ZUC_PMD_PRIVATE_H_ */