18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2013-2016 Freescale Semiconductor Inc.
48c2ecf20Sopenharmony_ci * Copyright 2017-2018 NXP
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef _DPSECI_CMD_H_
88c2ecf20Sopenharmony_ci#define _DPSECI_CMD_H_
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/* DPSECI Version */
118c2ecf20Sopenharmony_ci#define DPSECI_VER_MAJOR				5
128c2ecf20Sopenharmony_ci#define DPSECI_VER_MINOR				3
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#define DPSECI_VER(maj, min)	(((maj) << 16) | (min))
158c2ecf20Sopenharmony_ci#define DPSECI_VERSION		DPSECI_VER(DPSECI_VER_MAJOR, DPSECI_VER_MINOR)
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci/* Command versioning */
188c2ecf20Sopenharmony_ci#define DPSECI_CMD_BASE_VERSION		1
198c2ecf20Sopenharmony_ci#define DPSECI_CMD_BASE_VERSION_V2	2
208c2ecf20Sopenharmony_ci#define DPSECI_CMD_ID_OFFSET		4
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define DPSECI_CMD_V1(id)	(((id) << DPSECI_CMD_ID_OFFSET) | \
238c2ecf20Sopenharmony_ci				 DPSECI_CMD_BASE_VERSION)
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define DPSECI_CMD_V2(id)	(((id) << DPSECI_CMD_ID_OFFSET) | \
268c2ecf20Sopenharmony_ci				 DPSECI_CMD_BASE_VERSION_V2)
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Command IDs */
298c2ecf20Sopenharmony_ci#define DPSECI_CMDID_CLOSE				DPSECI_CMD_V1(0x800)
308c2ecf20Sopenharmony_ci#define DPSECI_CMDID_OPEN				DPSECI_CMD_V1(0x809)
318c2ecf20Sopenharmony_ci#define DPSECI_CMDID_GET_API_VERSION			DPSECI_CMD_V1(0xa09)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define DPSECI_CMDID_ENABLE				DPSECI_CMD_V1(0x002)
348c2ecf20Sopenharmony_ci#define DPSECI_CMDID_DISABLE				DPSECI_CMD_V1(0x003)
358c2ecf20Sopenharmony_ci#define DPSECI_CMDID_GET_ATTR				DPSECI_CMD_V1(0x004)
368c2ecf20Sopenharmony_ci#define DPSECI_CMDID_RESET				DPSECI_CMD_V1(0x005)
378c2ecf20Sopenharmony_ci#define DPSECI_CMDID_IS_ENABLED				DPSECI_CMD_V1(0x006)
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define DPSECI_CMDID_SET_RX_QUEUE			DPSECI_CMD_V1(0x194)
408c2ecf20Sopenharmony_ci#define DPSECI_CMDID_GET_RX_QUEUE			DPSECI_CMD_V1(0x196)
418c2ecf20Sopenharmony_ci#define DPSECI_CMDID_GET_TX_QUEUE			DPSECI_CMD_V1(0x197)
428c2ecf20Sopenharmony_ci#define DPSECI_CMDID_GET_SEC_ATTR			DPSECI_CMD_V2(0x198)
438c2ecf20Sopenharmony_ci#define DPSECI_CMDID_SET_CONGESTION_NOTIFICATION	DPSECI_CMD_V1(0x170)
448c2ecf20Sopenharmony_ci#define DPSECI_CMDID_GET_CONGESTION_NOTIFICATION	DPSECI_CMD_V1(0x171)
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* Macros for accessing command fields smaller than 1 byte */
478c2ecf20Sopenharmony_ci#define DPSECI_MASK(field)	\
488c2ecf20Sopenharmony_ci	GENMASK(DPSECI_##field##_SHIFT + DPSECI_##field##_SIZE - 1,	\
498c2ecf20Sopenharmony_ci		DPSECI_##field##_SHIFT)
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci#define dpseci_set_field(var, field, val)	\
528c2ecf20Sopenharmony_ci	((var) |= (((val) << DPSECI_##field##_SHIFT) & DPSECI_MASK(field)))
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci#define dpseci_get_field(var, field)	\
558c2ecf20Sopenharmony_ci	(((var) & DPSECI_MASK(field)) >> DPSECI_##field##_SHIFT)
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_cistruct dpseci_cmd_open {
588c2ecf20Sopenharmony_ci	__le32 dpseci_id;
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define DPSECI_ENABLE_SHIFT	0
628c2ecf20Sopenharmony_ci#define DPSECI_ENABLE_SIZE	1
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistruct dpseci_rsp_is_enabled {
658c2ecf20Sopenharmony_ci	u8 is_enabled;
668c2ecf20Sopenharmony_ci};
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_cistruct dpseci_rsp_get_attributes {
698c2ecf20Sopenharmony_ci	__le32 id;
708c2ecf20Sopenharmony_ci	__le32 pad0;
718c2ecf20Sopenharmony_ci	u8 num_tx_queues;
728c2ecf20Sopenharmony_ci	u8 num_rx_queues;
738c2ecf20Sopenharmony_ci	u8 pad1[6];
748c2ecf20Sopenharmony_ci	__le32 options;
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci#define DPSECI_DEST_TYPE_SHIFT	0
788c2ecf20Sopenharmony_ci#define DPSECI_DEST_TYPE_SIZE	4
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define DPSECI_ORDER_PRESERVATION_SHIFT	0
818c2ecf20Sopenharmony_ci#define DPSECI_ORDER_PRESERVATION_SIZE	1
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistruct dpseci_cmd_queue {
848c2ecf20Sopenharmony_ci	__le32 dest_id;
858c2ecf20Sopenharmony_ci	u8 priority;
868c2ecf20Sopenharmony_ci	u8 queue;
878c2ecf20Sopenharmony_ci	u8 dest_type;
888c2ecf20Sopenharmony_ci	u8 pad;
898c2ecf20Sopenharmony_ci	__le64 user_ctx;
908c2ecf20Sopenharmony_ci	union {
918c2ecf20Sopenharmony_ci		__le32 options;
928c2ecf20Sopenharmony_ci		__le32 fqid;
938c2ecf20Sopenharmony_ci	};
948c2ecf20Sopenharmony_ci	u8 order_preservation_en;
958c2ecf20Sopenharmony_ci};
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_cistruct dpseci_rsp_get_tx_queue {
988c2ecf20Sopenharmony_ci	__le32 pad;
998c2ecf20Sopenharmony_ci	__le32 fqid;
1008c2ecf20Sopenharmony_ci	u8 priority;
1018c2ecf20Sopenharmony_ci};
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_cistruct dpseci_rsp_get_sec_attr {
1048c2ecf20Sopenharmony_ci	__le16 ip_id;
1058c2ecf20Sopenharmony_ci	u8 major_rev;
1068c2ecf20Sopenharmony_ci	u8 minor_rev;
1078c2ecf20Sopenharmony_ci	u8 era;
1088c2ecf20Sopenharmony_ci	u8 pad0[3];
1098c2ecf20Sopenharmony_ci	u8 deco_num;
1108c2ecf20Sopenharmony_ci	u8 zuc_auth_acc_num;
1118c2ecf20Sopenharmony_ci	u8 zuc_enc_acc_num;
1128c2ecf20Sopenharmony_ci	u8 pad1;
1138c2ecf20Sopenharmony_ci	u8 snow_f8_acc_num;
1148c2ecf20Sopenharmony_ci	u8 snow_f9_acc_num;
1158c2ecf20Sopenharmony_ci	u8 crc_acc_num;
1168c2ecf20Sopenharmony_ci	u8 pad2;
1178c2ecf20Sopenharmony_ci	u8 pk_acc_num;
1188c2ecf20Sopenharmony_ci	u8 kasumi_acc_num;
1198c2ecf20Sopenharmony_ci	u8 rng_acc_num;
1208c2ecf20Sopenharmony_ci	u8 pad3;
1218c2ecf20Sopenharmony_ci	u8 md_acc_num;
1228c2ecf20Sopenharmony_ci	u8 arc4_acc_num;
1238c2ecf20Sopenharmony_ci	u8 des_acc_num;
1248c2ecf20Sopenharmony_ci	u8 aes_acc_num;
1258c2ecf20Sopenharmony_ci	u8 ccha_acc_num;
1268c2ecf20Sopenharmony_ci	u8 ptha_acc_num;
1278c2ecf20Sopenharmony_ci};
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_cistruct dpseci_rsp_get_api_version {
1308c2ecf20Sopenharmony_ci	__le16 major;
1318c2ecf20Sopenharmony_ci	__le16 minor;
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci#define DPSECI_CGN_DEST_TYPE_SHIFT	0
1358c2ecf20Sopenharmony_ci#define DPSECI_CGN_DEST_TYPE_SIZE	4
1368c2ecf20Sopenharmony_ci#define DPSECI_CGN_UNITS_SHIFT		4
1378c2ecf20Sopenharmony_ci#define DPSECI_CGN_UNITS_SIZE		2
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_cistruct dpseci_cmd_congestion_notification {
1408c2ecf20Sopenharmony_ci	__le32 dest_id;
1418c2ecf20Sopenharmony_ci	__le16 notification_mode;
1428c2ecf20Sopenharmony_ci	u8 priority;
1438c2ecf20Sopenharmony_ci	u8 options;
1448c2ecf20Sopenharmony_ci	__le64 message_iova;
1458c2ecf20Sopenharmony_ci	__le64 message_ctx;
1468c2ecf20Sopenharmony_ci	__le32 threshold_entry;
1478c2ecf20Sopenharmony_ci	__le32 threshold_exit;
1488c2ecf20Sopenharmony_ci};
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#endif /* _DPSECI_CMD_H_ */
151