New upstream version 17.11-rc3
[deb_dpdk.git] / drivers / crypto / dpaa2_sec / mc / fsl_dpseci_cmd.h
1 /*-
2  * This file is provided under a dual BSD/GPLv2 license. When using or
3  * redistributing this file, you may do so under either license.
4  *
5  *   BSD LICENSE
6  *
7  * Copyright 2013-2016 Freescale Semiconductor Inc.
8  * Copyright 2016-2017 NXP.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
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 the
16  * documentation and/or other materials provided with the distribution.
17  * * Neither the name of the above-listed copyright holders nor the
18  * names of any contributors may be used to endorse or promote products
19  * derived from this software without specific prior written permission.
20  *
21  *   GPL LICENSE SUMMARY
22  *
23  * ALTERNATIVELY, this software may be distributed under the terms of the
24  * GNU General Public License ("GPL") as published by the Free Software
25  * Foundation, either version 2 of that License or (at your option) any
26  * later version.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGE.
39  */
40 #ifndef _FSL_DPSECI_CMD_H
41 #define _FSL_DPSECI_CMD_H
42
43 /* DPSECI Version */
44 #define DPSECI_VER_MAJOR                5
45 #define DPSECI_VER_MINOR                1
46
47 /* Command versioning */
48 #define DPSECI_CMD_BASE_VERSION         1
49 #define DPSECI_CMD_BASE_VERSION_V2      2
50 #define DPSECI_CMD_ID_OFFSET            4
51
52 #define DPSECI_CMD_V1(id) \
53         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION)
54 #define DPSECI_CMD_V2(id) \
55         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION_V2)
56
57 /* Command IDs */
58 #define DPSECI_CMDID_CLOSE              DPSECI_CMD_V1(0x800)
59 #define DPSECI_CMDID_OPEN               DPSECI_CMD_V1(0x809)
60 #define DPSECI_CMDID_CREATE             DPSECI_CMD_V2(0x909)
61 #define DPSECI_CMDID_DESTROY            DPSECI_CMD_V1(0x989)
62 #define DPSECI_CMDID_GET_API_VERSION    DPSECI_CMD_V1(0xa09)
63
64 #define DPSECI_CMDID_ENABLE             DPSECI_CMD_V1(0x002)
65 #define DPSECI_CMDID_DISABLE            DPSECI_CMD_V1(0x003)
66 #define DPSECI_CMDID_GET_ATTR           DPSECI_CMD_V1(0x004)
67 #define DPSECI_CMDID_RESET              DPSECI_CMD_V1(0x005)
68 #define DPSECI_CMDID_IS_ENABLED         DPSECI_CMD_V1(0x006)
69
70 #define DPSECI_CMDID_SET_RX_QUEUE       DPSECI_CMD_V1(0x194)
71 #define DPSECI_CMDID_GET_RX_QUEUE       DPSECI_CMD_V1(0x196)
72 #define DPSECI_CMDID_GET_TX_QUEUE       DPSECI_CMD_V1(0x197)
73 #define DPSECI_CMDID_GET_SEC_ATTR       DPSECI_CMD_V1(0x198)
74 #define DPSECI_CMDID_GET_SEC_COUNTERS   DPSECI_CMD_V1(0x199)
75
76 #define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION        DPSECI_CMD_V1(0x170)
77 #define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION        DPSECI_CMD_V1(0x171)
78
79 /* Macros for accessing command fields smaller than 1byte */
80 #define DPSECI_MASK(field)        \
81         GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1, \
82                 DPSECI_##field##_SHIFT)
83 #define dpseci_set_field(var, field, val) \
84         ((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field)))
85 #define dpseci_get_field(var, field)      \
86         (((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT)
87
88 #pragma pack(push, 1)
89 struct dpseci_cmd_open {
90         uint32_t dpseci_id;
91 };
92
93 struct dpseci_cmd_create {
94         uint8_t priorities[8];
95         uint8_t num_tx_queues;
96         uint8_t num_rx_queues;
97         uint8_t pad[6];
98         uint32_t options;
99 };
100
101 struct dpseci_cmd_destroy {
102         uint32_t dpseci_id;
103 };
104
105 #define DPSECI_ENABLE_SHIFT     0
106 #define DPSECI_ENABLE_SIZE      1
107
108 struct dpseci_rsp_is_enabled {
109         /* only the first LSB */
110         uint8_t en;
111 };
112
113 struct dpseci_rsp_get_attr {
114         uint32_t id;
115         uint32_t pad;
116         uint8_t num_tx_queues;
117         uint8_t num_rx_queues;
118         uint8_t pad1[6];
119         uint32_t options;
120 };
121
122 #define DPSECI_DEST_TYPE_SHIFT  0
123 #define DPSECI_DEST_TYPE_SIZE   4
124
125 #define DPSECI_ORDER_PRESERVATION_SHIFT 0
126 #define DPSECI_ORDER_PRESERVATION_SIZE  1
127
128 struct dpseci_cmd_set_rx_queue {
129         uint32_t dest_id;
130         uint8_t dest_priority;
131         uint8_t queue;
132         /* from LSB: dest_type:4 */
133         uint8_t dest_type;
134         uint8_t pad;
135         uint64_t user_ctx;
136         uint32_t options;
137         /* only the LSB */
138         uint8_t order_preservation_en;
139 };
140
141 struct dpseci_cmd_get_queue {
142         uint8_t pad[5];
143         uint8_t queue;
144 };
145
146 struct dpseci_rsp_get_rx_queue {
147         uint32_t dest_id;
148         uint8_t dest_priority;
149         uint8_t pad1;
150         /* from LSB: dest_type:4 */
151         uint8_t dest_type;
152         uint8_t pad2;
153         uint64_t user_ctx;
154         uint32_t fqid;
155         /* only the LSB */
156         uint8_t order_preservation_en;
157
158 };
159
160 struct dpseci_rsp_get_tx_queue {
161         uint32_t pad;
162         uint32_t fqid;
163         uint8_t priority;
164 };
165
166 struct dpseci_rsp_get_sec_attr {
167         uint16_t ip_id;
168         uint8_t major_rev;
169         uint8_t minor_rev;
170         uint8_t era;
171         uint8_t pad1[3];
172         uint8_t deco_num;
173         uint8_t zuc_auth_acc_num;
174         uint8_t zuc_enc_acc_num;
175         uint8_t pad2;
176         uint8_t snow_f8_acc_num;
177         uint8_t snow_f9_acc_num;
178         uint8_t crc_acc_num;
179         uint8_t pad3;
180         uint8_t pk_acc_num;
181         uint8_t kasumi_acc_num;
182         uint8_t rng_acc_num;
183         uint8_t pad4;
184         uint8_t md_acc_num;
185         uint8_t arc4_acc_num;
186         uint8_t des_acc_num;
187         uint8_t aes_acc_num;
188 };
189
190 struct dpseci_rsp_get_sec_counters {
191         uint64_t dequeued_requests;
192         uint64_t ob_enc_requests;
193         uint64_t ib_dec_requests;
194         uint64_t ob_enc_bytes;
195         uint64_t ob_prot_bytes;
196         uint64_t ib_dec_bytes;
197         uint64_t ib_valid_bytes;
198 };
199
200 struct dpseci_rsp_get_api_version {
201         uint16_t major;
202         uint16_t minor;
203 };
204
205 #define DPSECI_DEST_TYPE_SHIFT          0
206 #define DPSECI_DEST_TYPE_SIZE           4
207 #define DPSECI_CG_UNITS_SHIFT           4
208 #define DPSECI_CG_UNITS_SIZE            2
209
210 struct dpseci_cmd_set_congestion_notification {
211         uint32_t dest_id;
212         uint16_t notification_mode;
213         uint8_t dest_priority;
214         /* from LSB: dest_type: 4 units:2 */
215         uint8_t type_units;
216         uint64_t message_iova;
217         uint64_t message_ctx;
218         uint32_t threshold_entry;
219         uint32_t threshold_exit;
220 };
221
222 #pragma pack(pop)
223 #endif /* _FSL_DPSECI_CMD_H */