New upstream version 18.02
[deb_dpdk.git] / drivers / crypto / mrvl / rte_mrvl_pmd_private.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Marvell International Ltd.
5  *   Copyright(c) 2017 Semihalf.
6  *   All rights reserved.
7  *
8  *   Redistribution and use in source and binary forms, with or without
9  *   modification, are permitted provided that the following conditions
10  *   are met:
11  *
12  *     * Redistributions of source code must retain the above copyright
13  *       notice, this list of conditions and the following disclaimer.
14  *     * Redistributions in binary form must reproduce the above copyright
15  *       notice, this list of conditions and the following disclaimer in
16  *       the documentation and/or other materials provided with the
17  *       distribution.
18  *     * Neither the name of the copyright holder nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef _RTE_MRVL_PMD_PRIVATE_H_
36 #define _RTE_MRVL_PMD_PRIVATE_H_
37
38 #include "rte_mrvl_compat.h"
39
40 #define CRYPTODEV_NAME_MRVL_PMD crypto_mrvl
41 /**< Marvell PMD device name */
42
43 #define MRVL_CRYPTO_LOG_ERR(fmt, args...) \
44         RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n",  \
45                         RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \
46                         __func__, __LINE__, ## args)
47
48 #ifdef RTE_LIBRTE_PMD_MRVL_CRYPTO_DEBUG
49 #define MRVL_CRYPTO_LOG_INFO(fmt, args...) \
50         RTE_LOG(INFO, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
51                         RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \
52                         __func__, __LINE__, ## args)
53
54 #define MRVL_CRYPTO_LOG_DBG(fmt, args...) \
55         RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \
56                         RTE_STR(CRYPTODEV_NAME_MRVL_PMD), \
57                         __func__, __LINE__, ## args)
58
59 #else
60 #define MRVL_CRYPTO_LOG_INFO(fmt, args...)
61 #define MRVL_CRYPTO_LOG_DBG(fmt, args...)
62 #endif
63
64 /**
65  * Handy bits->bytes conversion macro.
66  */
67 #define BITS2BYTES(x) ((x) >> 3)
68
69 /** The operation order mode enumerator. */
70 enum mrvl_crypto_chain_order {
71         MRVL_CRYPTO_CHAIN_CIPHER_ONLY,
72         MRVL_CRYPTO_CHAIN_AUTH_ONLY,
73         MRVL_CRYPTO_CHAIN_CIPHER_AUTH,
74         MRVL_CRYPTO_CHAIN_AUTH_CIPHER,
75         MRVL_CRYPTO_CHAIN_COMBINED,
76         MRVL_CRYPTO_CHAIN_NOT_SUPPORTED,
77 };
78
79 /** Private data structure for each crypto device. */
80 struct mrvl_crypto_private {
81         unsigned int max_nb_qpairs;     /**< Max number of queue pairs */
82         unsigned int max_nb_sessions;   /**< Max number of sessions */
83 };
84
85 /** MRVL crypto queue pair structure. */
86 struct mrvl_crypto_qp {
87         /** SAM CIO (MUSDK Queue Pair equivalent).*/
88         struct sam_cio *cio;
89
90         /** Session Mempool. */
91         struct rte_mempool *sess_mp;
92
93         /** Queue pair statistics. */
94         struct rte_cryptodev_stats stats;
95
96         /** CIO initialization parameters.*/
97         struct sam_cio_params cio_params;
98 } __rte_cache_aligned;
99
100 /** MRVL crypto private session structure. */
101 struct mrvl_crypto_session {
102         /** Crypto operations chain order. */
103         enum mrvl_crypto_chain_order chain_order;
104
105         /** Session initialization parameters. */
106         struct sam_session_params sam_sess_params;
107
108         /** SAM session pointer. */
109         struct sam_sa *sam_sess;
110
111         /** Cipher IV offset. */
112         uint16_t cipher_iv_offset;
113 } __rte_cache_aligned;
114
115 /** Set and validate MRVL crypto session parameters */
116 extern int
117 mrvl_crypto_set_session_parameters(struct mrvl_crypto_session *sess,
118                 const struct rte_crypto_sym_xform *xform);
119
120 /** device specific operations function pointer structure */
121 extern struct rte_cryptodev_ops *rte_mrvl_crypto_pmd_ops;
122
123 #endif /* _RTE_MRVL_PMD_PRIVATE_H_ */