crypto/snow3g: use IPsec library
[dpdk.git] / drivers / crypto / snow3g / snow3g_pmd_private.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2016-2019 Intel Corporation
3  */
4
5 #ifndef _SNOW3G_PMD_PRIVATE_H_
6 #define _SNOW3G_PMD_PRIVATE_H_
7
8 #include <intel-ipsec-mb.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         MB_MGR *mgr;
29         /**< Multi-buffer instance */
30 };
31
32 /** SNOW 3G buffer queue pair */
33 struct snow3g_qp {
34         uint16_t id;
35         /**< Queue Pair Identifier */
36         char name[RTE_CRYPTODEV_NAME_MAX_LEN];
37         /**< Unique Queue Pair Name */
38         struct rte_ring *processed_ops;
39         /**< Ring for placing processed ops */
40         struct rte_mempool *sess_mp;
41         /**< Session Mempool */
42         struct rte_mempool *sess_mp_priv;
43         /**< Session Private Data Mempool */
44         struct rte_cryptodev_stats qp_stats;
45         /**< Queue pair statistics */
46         uint8_t temp_digest[SNOW3G_DIGEST_LENGTH];
47         /**< Buffer used to store the digest generated
48          * by the driver when verifying a digest provided
49          * by the user (using authentication verify operation)
50          */
51         MB_MGR *mgr;
52         /**< Multi-buffer instance */
53 } __rte_cache_aligned;
54
55 enum snow3g_operation {
56         SNOW3G_OP_ONLY_CIPHER,
57         SNOW3G_OP_ONLY_AUTH,
58         SNOW3G_OP_CIPHER_AUTH,
59         SNOW3G_OP_AUTH_CIPHER,
60         SNOW3G_OP_NOT_SUPPORTED
61 };
62
63 /** SNOW 3G private session structure */
64 struct snow3g_session {
65         enum snow3g_operation op;
66         enum rte_crypto_auth_operation auth_op;
67         snow3g_key_schedule_t pKeySched_cipher;
68         snow3g_key_schedule_t pKeySched_hash;
69         uint16_t cipher_iv_offset;
70         uint16_t auth_iv_offset;
71 } __rte_cache_aligned;
72
73
74 extern int
75 snow3g_set_session_parameters(MB_MGR *mgr, struct snow3g_session *sess,
76                 const struct rte_crypto_sym_xform *xform);
77
78
79 /** device specific operations function pointer structure */
80 extern struct rte_cryptodev_ops *rte_snow3g_pmd_ops;
81
82
83
84 #endif /* _SNOW3G_PMD_PRIVATE_H_ */