1fe05eb567836086f22e153a3baf55d80401094b
[dpdk.git] / drivers / crypto / snow3g / snow3g_pmd_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2018 Intel Corporation
3  */
4
5 #ifndef _SNOW3G_PMD_PRIVATE_H_
6 #define _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 /** SNOW 3G PMD LOGTYPE DRIVER */
14 int snow3g_logtype_driver;
15
16 #define SNOW3G_LOG(level, fmt, ...)  \
17         rte_log(RTE_LOG_ ## level, snow3g_logtype_driver,  \
18                         "%s() line %u: " fmt "\n", __func__, __LINE__,  \
19                                         ## __VA_ARGS__)
20
21 #define SNOW3G_DIGEST_LENGTH 4
22 #define SNOW3G_MAX_KEY_SIZE  128
23
24 /** private data structure for each virtual SNOW 3G device */
25 struct snow3g_private {
26         unsigned max_nb_queue_pairs;
27         /**< Max number of queue pairs supported by device */
28 };
29
30 /** SNOW 3G buffer queue pair */
31 struct snow3g_qp {
32         uint16_t id;
33         /**< Queue Pair Identifier */
34         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
35         /**< Unique Queue Pair Name */
36         struct rte_ring *processed_ops;
37         /**< Ring for placing processed ops */
38         struct rte_mempool *sess_mp;
39         /**< Session Mempool */
40         struct rte_mempool *sess_mp_priv;
41         /**< Session Private Data Mempool */
42         struct rte_cryptodev_stats qp_stats;
43         /**< Queue pair statistics */
44         uint8_t temp_digest[SNOW3G_DIGEST_LENGTH];
45         /**< Buffer used to store the digest generated
46          * by the driver when verifying a digest provided
47          * by the user (using authentication verify operation)
48          */
49 } __rte_cache_aligned;
50
51 enum snow3g_operation {
52         SNOW3G_OP_ONLY_CIPHER,
53         SNOW3G_OP_ONLY_AUTH,
54         SNOW3G_OP_CIPHER_AUTH,
55         SNOW3G_OP_AUTH_CIPHER,
56         SNOW3G_OP_NOT_SUPPORTED
57 };
58
59 /** SNOW 3G private session structure */
60 struct snow3g_session {
61         enum snow3g_operation op;
62         enum rte_crypto_auth_operation auth_op;
63         sso_snow3g_key_schedule_t pKeySched_cipher;
64         sso_snow3g_key_schedule_t pKeySched_hash;
65         uint16_t cipher_iv_offset;
66         uint16_t auth_iv_offset;
67 } __rte_cache_aligned;
68
69
70 extern int
71 snow3g_set_session_parameters(struct snow3g_session *sess,
72                 const struct rte_crypto_sym_xform *xform);
73
74
75 /** device specific operations function pointer structure */
76 extern struct rte_cryptodev_ops *rte_snow3g_pmd_ops;
77
78
79
80 #endif /* _SNOW3G_PMD_PRIVATE_H_ */