New upstream version 18.02
[deb_dpdk.git] / drivers / crypto / snow3g / rte_snow3g_pmd_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2017 Intel Corporation
3  */
4
5 #ifndef _RTE_SNOW3G_PMD_PRIVATE_H_
6 #define _RTE_SNOW3G_PMD_PRIVATE_H_
7
8 #include <sso_snow3g.h>
9
10 #define CRYPTODEV_NAME_SNOW3G_PMD       crypto_snow3g
11 /**< SNOW 3G PMD device name */
12
13 #define SNOW3G_LOG_ERR(fmt, args...) \
14         RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
15                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), \
16                         __func__, __LINE__, ## args)
17
18 #ifdef RTE_LIBRTE_SNOW3G_DEBUG
19 #define SNOW3G_LOG_INFO(fmt, args...) \
20         RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
21                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), \
22                         __func__, __LINE__, ## args)
23
24 #define SNOW3G_LOG_DBG(fmt, args...) \
25         RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
26                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), \
27                         __func__, __LINE__, ## args)
28 #else
29 #define SNOW3G_LOG_INFO(fmt, args...)
30 #define SNOW3G_LOG_DBG(fmt, args...)
31 #endif
32
33 #define SNOW3G_DIGEST_LENGTH 4
34
35 /** private data structure for each virtual SNOW 3G device */
36 struct snow3g_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 /** SNOW 3G buffer queue pair */
44 struct snow3g_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[SNOW3G_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 snow3g_operation {
63         SNOW3G_OP_ONLY_CIPHER,
64         SNOW3G_OP_ONLY_AUTH,
65         SNOW3G_OP_CIPHER_AUTH,
66         SNOW3G_OP_AUTH_CIPHER,
67         SNOW3G_OP_NOT_SUPPORTED
68 };
69
70 /** SNOW 3G private session structure */
71 struct snow3g_session {
72         enum snow3g_operation op;
73         enum rte_crypto_auth_operation auth_op;
74         sso_snow3g_key_schedule_t pKeySched_cipher;
75         sso_snow3g_key_schedule_t pKeySched_hash;
76         uint16_t cipher_iv_offset;
77         uint16_t auth_iv_offset;
78 } __rte_cache_aligned;
79
80
81 extern int
82 snow3g_set_session_parameters(struct snow3g_session *sess,
83                 const struct rte_crypto_sym_xform *xform);
84
85
86 /** device specific operations function pointer structure */
87 extern struct rte_cryptodev_ops *rte_snow3g_pmd_ops;
88
89
90
91 #endif /* _RTE_SNOW3G_PMD_PRIVATE_H_ */