New upstream version 18.02
[deb_dpdk.git] / drivers / crypto / zuc / rte_zuc_pmd_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef _RTE_ZUC_PMD_PRIVATE_H_
6 #define _RTE_ZUC_PMD_PRIVATE_H_
7
8 #include <sso_zuc.h>
9
10 #define CRYPTODEV_NAME_ZUC_PMD          crypto_zuc
11 /**< KASUMI PMD device name */
12
13 #define ZUC_LOG_ERR(fmt, args...) \
14         RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
15                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \
16                         __func__, __LINE__, ## args)
17
18 #ifdef RTE_LIBRTE_ZUC_DEBUG
19 #define ZUC_LOG_INFO(fmt, args...) \
20         RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
21                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \
22                         __func__, __LINE__, ## args)
23
24 #define ZUC_LOG_DBG(fmt, args...) \
25         RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
26                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD), \
27                         __func__, __LINE__, ## args)
28 #else
29 #define ZUC_LOG_INFO(fmt, args...)
30 #define ZUC_LOG_DBG(fmt, args...)
31 #endif
32
33 #define ZUC_IV_KEY_LENGTH 16
34 #define ZUC_DIGEST_LENGTH 4
35
36 /** private data structure for each virtual ZUC device */
37 struct zuc_private {
38         unsigned max_nb_queue_pairs;
39         /**< Max number of queue pairs supported by device */
40         unsigned max_nb_sessions;
41         /**< Max number of sessions supported by device */
42 };
43
44 /** ZUC buffer queue pair */
45 struct zuc_qp {
46         uint16_t id;
47         /**< Queue Pair Identifier */
48         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
49         /**< Unique Queue Pair Name */
50         struct rte_ring *processed_ops;
51         /**< Ring for placing processed ops */
52         struct rte_mempool *sess_mp;
53         /**< Session Mempool */
54         struct rte_cryptodev_stats qp_stats;
55         /**< Queue pair statistics */
56         uint8_t temp_digest[ZUC_DIGEST_LENGTH];
57         /**< Buffer used to store the digest generated
58          * by the driver when verifying a digest provided
59          * by the user (using authentication verify operation)
60          */
61 } __rte_cache_aligned;
62
63 enum zuc_operation {
64         ZUC_OP_ONLY_CIPHER,
65         ZUC_OP_ONLY_AUTH,
66         ZUC_OP_CIPHER_AUTH,
67         ZUC_OP_AUTH_CIPHER,
68         ZUC_OP_NOT_SUPPORTED
69 };
70
71 /** ZUC private session structure */
72 struct zuc_session {
73         enum zuc_operation op;
74         enum rte_crypto_auth_operation auth_op;
75         uint8_t pKey_cipher[ZUC_IV_KEY_LENGTH];
76         uint8_t pKey_hash[ZUC_IV_KEY_LENGTH];
77         uint16_t cipher_iv_offset;
78         uint16_t auth_iv_offset;
79 } __rte_cache_aligned;
80
81
82 extern int
83 zuc_set_session_parameters(struct zuc_session *sess,
84                 const struct rte_crypto_sym_xform *xform);
85
86
87 /** device specific operations function pointer structure */
88 extern struct rte_cryptodev_ops *rte_zuc_pmd_ops;
89
90
91
92 #endif /* _RTE_ZUC_PMD_PRIVATE_H_ */