New upstream version 18.02
[deb_dpdk.git] / drivers / crypto / dpaa2_sec / mc / fsl_dpseci_cmd.h
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2016-2017 NXP
5  *
6  */
7 #ifndef _FSL_DPSECI_CMD_H
8 #define _FSL_DPSECI_CMD_H
9
10 /* DPSECI Version */
11 #define DPSECI_VER_MAJOR                5
12 #define DPSECI_VER_MINOR                1
13
14 /* Command versioning */
15 #define DPSECI_CMD_BASE_VERSION         1
16 #define DPSECI_CMD_BASE_VERSION_V2      2
17 #define DPSECI_CMD_ID_OFFSET            4
18
19 #define DPSECI_CMD_V1(id) \
20         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION)
21 #define DPSECI_CMD_V2(id) \
22         ((id << DPSECI_CMD_ID_OFFSET) | DPSECI_CMD_BASE_VERSION_V2)
23
24 /* Command IDs */
25 #define DPSECI_CMDID_CLOSE              DPSECI_CMD_V1(0x800)
26 #define DPSECI_CMDID_OPEN               DPSECI_CMD_V1(0x809)
27 #define DPSECI_CMDID_CREATE             DPSECI_CMD_V2(0x909)
28 #define DPSECI_CMDID_DESTROY            DPSECI_CMD_V1(0x989)
29 #define DPSECI_CMDID_GET_API_VERSION    DPSECI_CMD_V1(0xa09)
30
31 #define DPSECI_CMDID_ENABLE             DPSECI_CMD_V1(0x002)
32 #define DPSECI_CMDID_DISABLE            DPSECI_CMD_V1(0x003)
33 #define DPSECI_CMDID_GET_ATTR           DPSECI_CMD_V1(0x004)
34 #define DPSECI_CMDID_RESET              DPSECI_CMD_V1(0x005)
35 #define DPSECI_CMDID_IS_ENABLED         DPSECI_CMD_V1(0x006)
36
37 #define DPSECI_CMDID_SET_RX_QUEUE       DPSECI_CMD_V1(0x194)
38 #define DPSECI_CMDID_GET_RX_QUEUE       DPSECI_CMD_V1(0x196)
39 #define DPSECI_CMDID_GET_TX_QUEUE       DPSECI_CMD_V1(0x197)
40 #define DPSECI_CMDID_GET_SEC_ATTR       DPSECI_CMD_V1(0x198)
41 #define DPSECI_CMDID_GET_SEC_COUNTERS   DPSECI_CMD_V1(0x199)
42
43 #define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION        DPSECI_CMD_V1(0x170)
44 #define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION        DPSECI_CMD_V1(0x171)
45
46 /* Macros for accessing command fields smaller than 1byte */
47 #define DPSECI_MASK(field)        \
48         GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1, \
49                 DPSECI_##field##_SHIFT)
50 #define dpseci_set_field(var, field, val) \
51         ((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field)))
52 #define dpseci_get_field(var, field)      \
53         (((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT)
54
55 #pragma pack(push, 1)
56 struct dpseci_cmd_open {
57         uint32_t dpseci_id;
58 };
59
60 struct dpseci_cmd_create {
61         uint8_t priorities[8];
62         uint8_t num_tx_queues;
63         uint8_t num_rx_queues;
64         uint8_t pad[6];
65         uint32_t options;
66 };
67
68 struct dpseci_cmd_destroy {
69         uint32_t dpseci_id;
70 };
71
72 #define DPSECI_ENABLE_SHIFT     0
73 #define DPSECI_ENABLE_SIZE      1
74
75 struct dpseci_rsp_is_enabled {
76         /* only the first LSB */
77         uint8_t en;
78 };
79
80 struct dpseci_rsp_get_attr {
81         uint32_t id;
82         uint32_t pad;
83         uint8_t num_tx_queues;
84         uint8_t num_rx_queues;
85         uint8_t pad1[6];
86         uint32_t options;
87 };
88
89 #define DPSECI_DEST_TYPE_SHIFT  0
90 #define DPSECI_DEST_TYPE_SIZE   4
91
92 #define DPSECI_ORDER_PRESERVATION_SHIFT 0
93 #define DPSECI_ORDER_PRESERVATION_SIZE  1
94
95 struct dpseci_cmd_set_rx_queue {
96         uint32_t dest_id;
97         uint8_t dest_priority;
98         uint8_t queue;
99         /* from LSB: dest_type:4 */
100         uint8_t dest_type;
101         uint8_t pad;
102         uint64_t user_ctx;
103         uint32_t options;
104         /* only the LSB */
105         uint8_t order_preservation_en;
106 };
107
108 struct dpseci_cmd_get_queue {
109         uint8_t pad[5];
110         uint8_t queue;
111 };
112
113 struct dpseci_rsp_get_rx_queue {
114         uint32_t dest_id;
115         uint8_t dest_priority;
116         uint8_t pad1;
117         /* from LSB: dest_type:4 */
118         uint8_t dest_type;
119         uint8_t pad2;
120         uint64_t user_ctx;
121         uint32_t fqid;
122         /* only the LSB */
123         uint8_t order_preservation_en;
124
125 };
126
127 struct dpseci_rsp_get_tx_queue {
128         uint32_t pad;
129         uint32_t fqid;
130         uint8_t priority;
131 };
132
133 struct dpseci_rsp_get_sec_attr {
134         uint16_t ip_id;
135         uint8_t major_rev;
136         uint8_t minor_rev;
137         uint8_t era;
138         uint8_t pad1[3];
139         uint8_t deco_num;
140         uint8_t zuc_auth_acc_num;
141         uint8_t zuc_enc_acc_num;
142         uint8_t pad2;
143         uint8_t snow_f8_acc_num;
144         uint8_t snow_f9_acc_num;
145         uint8_t crc_acc_num;
146         uint8_t pad3;
147         uint8_t pk_acc_num;
148         uint8_t kasumi_acc_num;
149         uint8_t rng_acc_num;
150         uint8_t pad4;
151         uint8_t md_acc_num;
152         uint8_t arc4_acc_num;
153         uint8_t des_acc_num;
154         uint8_t aes_acc_num;
155 };
156
157 struct dpseci_rsp_get_sec_counters {
158         uint64_t dequeued_requests;
159         uint64_t ob_enc_requests;
160         uint64_t ib_dec_requests;
161         uint64_t ob_enc_bytes;
162         uint64_t ob_prot_bytes;
163         uint64_t ib_dec_bytes;
164         uint64_t ib_valid_bytes;
165 };
166
167 struct dpseci_rsp_get_api_version {
168         uint16_t major;
169         uint16_t minor;
170 };
171
172 #define DPSECI_DEST_TYPE_SHIFT          0
173 #define DPSECI_DEST_TYPE_SIZE           4
174 #define DPSECI_CG_UNITS_SHIFT           4
175 #define DPSECI_CG_UNITS_SIZE            2
176
177 struct dpseci_cmd_set_congestion_notification {
178         uint32_t dest_id;
179         uint16_t notification_mode;
180         uint8_t dest_priority;
181         /* from LSB: dest_type: 4 units:2 */
182         uint8_t type_units;
183         uint64_t message_iova;
184         uint64_t message_ctx;
185         uint32_t threshold_entry;
186         uint32_t threshold_exit;
187 };
188
189 #pragma pack(pop)
190 #endif /* _FSL_DPSECI_CMD_H */