New upstream version 18.02
[deb_dpdk.git] / drivers / crypto / kasumi / rte_kasumi_pmd_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef _RTE_KASUMI_PMD_PRIVATE_H_
6 #define _RTE_KASUMI_PMD_PRIVATE_H_
7
8 #include <sso_kasumi.h>
9
10 #define CRYPTODEV_NAME_KASUMI_PMD       crypto_kasumi
11 /**< KASUMI PMD device name */
12
13 #define KASUMI_LOG_ERR(fmt, args...) \
14         RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
15                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), \
16                         __func__, __LINE__, ## args)
17
18 #ifdef RTE_LIBRTE_KASUMI_DEBUG
19 #define KASUMI_LOG_INFO(fmt, args...) \
20         RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
21                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), \
22                         __func__, __LINE__, ## args)
23
24 #define KASUMI_LOG_DBG(fmt, args...) \
25         RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
26                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), \
27                         __func__, __LINE__, ## args)
28 #else
29 #define KASUMI_LOG_INFO(fmt, args...)
30 #define KASUMI_LOG_DBG(fmt, args...)
31 #endif
32
33 #define KASUMI_DIGEST_LENGTH 4
34
35 /** private data structure for each virtual KASUMI device */
36 struct kasumi_private {
37         unsigned max_nb_queue_pairs;
38         /**< Max number of queue pairs supported by device */
39         unsigned max_nb_sessions;
40         /**< Max number of sessions supported by device */
41 };
42
43 /** KASUMI buffer queue pair */
44 struct kasumi_qp {
45         uint16_t id;
46         /**< Queue Pair Identifier */
47         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
48         /**< Unique Queue Pair Name */
49         struct rte_ring *processed_ops;
50         /**< Ring for placing processed ops */
51         struct rte_mempool *sess_mp;
52         /**< Session Mempool */
53         struct rte_cryptodev_stats qp_stats;
54         /**< Queue pair statistics */
55         uint8_t temp_digest[KASUMI_DIGEST_LENGTH];
56         /**< Buffer used to store the digest generated
57          * by the driver when verifying a digest provided
58          * by the user (using authentication verify operation)
59          */
60 } __rte_cache_aligned;
61
62 enum kasumi_operation {
63         KASUMI_OP_ONLY_CIPHER,
64         KASUMI_OP_ONLY_AUTH,
65         KASUMI_OP_CIPHER_AUTH,
66         KASUMI_OP_AUTH_CIPHER,
67         KASUMI_OP_NOT_SUPPORTED
68 };
69
70 /** KASUMI private session structure */
71 struct kasumi_session {
72         /* Keys have to be 16-byte aligned */
73         sso_kasumi_key_sched_t pKeySched_cipher;
74         sso_kasumi_key_sched_t pKeySched_hash;
75         enum kasumi_operation op;
76         enum rte_crypto_auth_operation auth_op;
77         uint16_t cipher_iv_offset;
78 } __rte_cache_aligned;
79
80
81 int
82 kasumi_set_session_parameters(struct kasumi_session *sess,
83                 const struct rte_crypto_sym_xform *xform);
84
85
86 /** device specific operations function pointer structure */
87 struct rte_cryptodev_ops *rte_kasumi_pmd_ops;
88
89 #endif /* _RTE_KASUMI_PMD_PRIVATE_H_ */