xref: /linux/drivers/crypto/caam/dpseci_cmd.h (revision 060ce503)
1f9cb74fdSHoria Geantă /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2f9cb74fdSHoria Geantă /*
3f9cb74fdSHoria Geantă  * Copyright 2013-2016 Freescale Semiconductor Inc.
4f9cb74fdSHoria Geantă  * Copyright 2017-2018 NXP
5f9cb74fdSHoria Geantă  */
6f9cb74fdSHoria Geantă 
7f9cb74fdSHoria Geantă #ifndef _DPSECI_CMD_H_
8f9cb74fdSHoria Geantă #define _DPSECI_CMD_H_
9f9cb74fdSHoria Geantă 
10f9cb74fdSHoria Geantă /* DPSECI Version */
11f9cb74fdSHoria Geantă #define DPSECI_VER_MAJOR				5
12f9cb74fdSHoria Geantă #define DPSECI_VER_MINOR				3
13f9cb74fdSHoria Geantă 
14f9cb74fdSHoria Geantă #define DPSECI_VER(maj, min)	(((maj) << 16) | (min))
15f9cb74fdSHoria Geantă #define DPSECI_VERSION		DPSECI_VER(DPSECI_VER_MAJOR, DPSECI_VER_MINOR)
16f9cb74fdSHoria Geantă 
17f9cb74fdSHoria Geantă /* Command versioning */
18f9cb74fdSHoria Geantă #define DPSECI_CMD_BASE_VERSION		1
19f9cb74fdSHoria Geantă #define DPSECI_CMD_BASE_VERSION_V2	2
20f9cb74fdSHoria Geantă #define DPSECI_CMD_ID_OFFSET		4
21f9cb74fdSHoria Geantă 
22f9cb74fdSHoria Geantă #define DPSECI_CMD_V1(id)	(((id) << DPSECI_CMD_ID_OFFSET) | \
23f9cb74fdSHoria Geantă 				 DPSECI_CMD_BASE_VERSION)
24f9cb74fdSHoria Geantă 
25f9cb74fdSHoria Geantă #define DPSECI_CMD_V2(id)	(((id) << DPSECI_CMD_ID_OFFSET) | \
26f9cb74fdSHoria Geantă 				 DPSECI_CMD_BASE_VERSION_V2)
27f9cb74fdSHoria Geantă 
28f9cb74fdSHoria Geantă /* Command IDs */
29f9cb74fdSHoria Geantă #define DPSECI_CMDID_CLOSE				DPSECI_CMD_V1(0x800)
30f9cb74fdSHoria Geantă #define DPSECI_CMDID_OPEN				DPSECI_CMD_V1(0x809)
31f9cb74fdSHoria Geantă #define DPSECI_CMDID_GET_API_VERSION			DPSECI_CMD_V1(0xa09)
32f9cb74fdSHoria Geantă 
33f9cb74fdSHoria Geantă #define DPSECI_CMDID_ENABLE				DPSECI_CMD_V1(0x002)
34f9cb74fdSHoria Geantă #define DPSECI_CMDID_DISABLE				DPSECI_CMD_V1(0x003)
35f9cb74fdSHoria Geantă #define DPSECI_CMDID_GET_ATTR				DPSECI_CMD_V1(0x004)
36*060ce503SAndrei Botila #define DPSECI_CMDID_RESET				DPSECI_CMD_V1(0x005)
37f9cb74fdSHoria Geantă #define DPSECI_CMDID_IS_ENABLED				DPSECI_CMD_V1(0x006)
38f9cb74fdSHoria Geantă 
39f9cb74fdSHoria Geantă #define DPSECI_CMDID_SET_RX_QUEUE			DPSECI_CMD_V1(0x194)
40f9cb74fdSHoria Geantă #define DPSECI_CMDID_GET_RX_QUEUE			DPSECI_CMD_V1(0x196)
41f9cb74fdSHoria Geantă #define DPSECI_CMDID_GET_TX_QUEUE			DPSECI_CMD_V1(0x197)
42f9cb74fdSHoria Geantă #define DPSECI_CMDID_GET_SEC_ATTR			DPSECI_CMD_V2(0x198)
43f9cb74fdSHoria Geantă #define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION	DPSECI_CMD_V1(0x170)
44f9cb74fdSHoria Geantă #define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION	DPSECI_CMD_V1(0x171)
45f9cb74fdSHoria Geantă 
46f9cb74fdSHoria Geantă /* Macros for accessing command fields smaller than 1 byte */
47f9cb74fdSHoria Geantă #define DPSECI_MASK(field)	\
48f9cb74fdSHoria Geantă 	GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1,	\
49f9cb74fdSHoria Geantă 		DPSECI_##field##_SHIFT)
50f9cb74fdSHoria Geantă 
51f9cb74fdSHoria Geantă #define dpseci_set_field(var, field, val)	\
52f9cb74fdSHoria Geantă 	((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field)))
53f9cb74fdSHoria Geantă 
54f9cb74fdSHoria Geantă #define dpseci_get_field(var, field)	\
55f9cb74fdSHoria Geantă 	(((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT)
56f9cb74fdSHoria Geantă 
57f9cb74fdSHoria Geantă struct dpseci_cmd_open {
58f9cb74fdSHoria Geantă 	__le32 dpseci_id;
59f9cb74fdSHoria Geantă };
60f9cb74fdSHoria Geantă 
61f9cb74fdSHoria Geantă #define DPSECI_ENABLE_SHIFT	0
62f9cb74fdSHoria Geantă #define DPSECI_ENABLE_SIZE	1
63f9cb74fdSHoria Geantă 
64f9cb74fdSHoria Geantă struct dpseci_rsp_is_enabled {
65f9cb74fdSHoria Geantă 	u8 is_enabled;
66f9cb74fdSHoria Geantă };
67f9cb74fdSHoria Geantă 
68f9cb74fdSHoria Geantă struct dpseci_rsp_get_attributes {
69f9cb74fdSHoria Geantă 	__le32 id;
70f9cb74fdSHoria Geantă 	__le32 pad0;
71f9cb74fdSHoria Geantă 	u8 num_tx_queues;
72f9cb74fdSHoria Geantă 	u8 num_rx_queues;
73f9cb74fdSHoria Geantă 	u8 pad1[6];
74f9cb74fdSHoria Geantă 	__le32 options;
75f9cb74fdSHoria Geantă };
76f9cb74fdSHoria Geantă 
77f9cb74fdSHoria Geantă #define DPSECI_DEST_TYPE_SHIFT	0
78f9cb74fdSHoria Geantă #define DPSECI_DEST_TYPE_SIZE	4
79f9cb74fdSHoria Geantă 
80f9cb74fdSHoria Geantă #define DPSECI_ORDER_PRESERVATION_SHIFT	0
81f9cb74fdSHoria Geantă #define DPSECI_ORDER_PRESERVATION_SIZE	1
82f9cb74fdSHoria Geantă 
83f9cb74fdSHoria Geantă struct dpseci_cmd_queue {
84f9cb74fdSHoria Geantă 	__le32 dest_id;
85f9cb74fdSHoria Geantă 	u8 priority;
86f9cb74fdSHoria Geantă 	u8 queue;
87f9cb74fdSHoria Geantă 	u8 dest_type;
88f9cb74fdSHoria Geantă 	u8 pad;
89f9cb74fdSHoria Geantă 	__le64 user_ctx;
90f9cb74fdSHoria Geantă 	union {
91f9cb74fdSHoria Geantă 		__le32 options;
92f9cb74fdSHoria Geantă 		__le32 fqid;
93f9cb74fdSHoria Geantă 	};
94f9cb74fdSHoria Geantă 	u8 order_preservation_en;
95f9cb74fdSHoria Geantă };
96f9cb74fdSHoria Geantă 
97f9cb74fdSHoria Geantă struct dpseci_rsp_get_tx_queue {
98f9cb74fdSHoria Geantă 	__le32 pad;
99f9cb74fdSHoria Geantă 	__le32 fqid;
100f9cb74fdSHoria Geantă 	u8 priority;
101f9cb74fdSHoria Geantă };
102f9cb74fdSHoria Geantă 
103f9cb74fdSHoria Geantă struct dpseci_rsp_get_sec_attr {
104f9cb74fdSHoria Geantă 	__le16 ip_id;
105f9cb74fdSHoria Geantă 	u8 major_rev;
106f9cb74fdSHoria Geantă 	u8 minor_rev;
107f9cb74fdSHoria Geantă 	u8 era;
108f9cb74fdSHoria Geantă 	u8 pad0[3];
109f9cb74fdSHoria Geantă 	u8 deco_num;
110f9cb74fdSHoria Geantă 	u8 zuc_auth_acc_num;
111f9cb74fdSHoria Geantă 	u8 zuc_enc_acc_num;
112f9cb74fdSHoria Geantă 	u8 pad1;
113f9cb74fdSHoria Geantă 	u8 snow_f8_acc_num;
114f9cb74fdSHoria Geantă 	u8 snow_f9_acc_num;
115f9cb74fdSHoria Geantă 	u8 crc_acc_num;
116f9cb74fdSHoria Geantă 	u8 pad2;
117f9cb74fdSHoria Geantă 	u8 pk_acc_num;
118f9cb74fdSHoria Geantă 	u8 kasumi_acc_num;
119f9cb74fdSHoria Geantă 	u8 rng_acc_num;
120f9cb74fdSHoria Geantă 	u8 pad3;
121f9cb74fdSHoria Geantă 	u8 md_acc_num;
122f9cb74fdSHoria Geantă 	u8 arc4_acc_num;
123f9cb74fdSHoria Geantă 	u8 des_acc_num;
124f9cb74fdSHoria Geantă 	u8 aes_acc_num;
125f9cb74fdSHoria Geantă 	u8 ccha_acc_num;
126f9cb74fdSHoria Geantă 	u8 ptha_acc_num;
127f9cb74fdSHoria Geantă };
128f9cb74fdSHoria Geantă 
129f9cb74fdSHoria Geantă struct dpseci_rsp_get_api_version {
130f9cb74fdSHoria Geantă 	__le16 major;
131f9cb74fdSHoria Geantă 	__le16 minor;
132f9cb74fdSHoria Geantă };
133f9cb74fdSHoria Geantă 
134f9cb74fdSHoria Geantă #define DPSECI_CGN_DEST_TYPE_SHIFT	0
135f9cb74fdSHoria Geantă #define DPSECI_CGN_DEST_TYPE_SIZE	4
136f9cb74fdSHoria Geantă #define DPSECI_CGN_UNITS_SHIFT		4
137f9cb74fdSHoria Geantă #define DPSECI_CGN_UNITS_SIZE		2
138f9cb74fdSHoria Geantă 
139f9cb74fdSHoria Geantă struct dpseci_cmd_congestion_notification {
140f9cb74fdSHoria Geantă 	__le32 dest_id;
141f9cb74fdSHoria Geantă 	__le16 notification_mode;
142f9cb74fdSHoria Geantă 	u8 priority;
143f9cb74fdSHoria Geantă 	u8 options;
144f9cb74fdSHoria Geantă 	__le64 message_iova;
145f9cb74fdSHoria Geantă 	__le64 message_ctx;
146f9cb74fdSHoria Geantă 	__le32 threshold_entry;
147f9cb74fdSHoria Geantă 	__le32 threshold_exit;
148f9cb74fdSHoria Geantă };
149f9cb74fdSHoria Geantă 
150f9cb74fdSHoria Geantă #endif /* _DPSECI_CMD_H_ */
151