brintos

brintos / linux-shallow public Read only

0
0
Text · 10.4 KiB · 6dcd9be Raw
336 lines · c
1/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */2/*3 * Copyright 2013-2016 Freescale Semiconductor Inc.4 * Copyright 2017-2018 NXP5 */6#ifndef _DPSECI_H_7#define _DPSECI_H_8 9/*10 * Data Path SEC Interface API11 * Contains initialization APIs and runtime control APIs for DPSECI12 */13 14struct fsl_mc_io;15 16/**17 * General DPSECI macros18 */19 20/**21 * Maximum number of Tx/Rx queues per DPSECI object22 */23#define DPSECI_MAX_QUEUE_NUM		1624 25/**26 * All queues considered; see dpseci_set_rx_queue()27 */28#define DPSECI_ALL_QUEUES	(u8)(-1)29 30int dpseci_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int dpseci_id,31		u16 *token);32 33int dpseci_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);34 35/**36 * Enable the Congestion Group support37 */38#define DPSECI_OPT_HAS_CG		0x00002039 40/**41 * struct dpseci_cfg - Structure representing DPSECI configuration42 * @options: Any combination of the following flags:43 *		DPSECI_OPT_HAS_CG44 * @num_tx_queues: num of queues towards the SEC45 * @num_rx_queues: num of queues back from the SEC46 * @priorities: Priorities for the SEC hardware processing;47 *		each place in the array is the priority of the tx queue48 *		towards the SEC;49 *		valid priorities are configured with values 1-8;50 */51struct dpseci_cfg {52	u32 options;53	u8 num_tx_queues;54	u8 num_rx_queues;55	u8 priorities[DPSECI_MAX_QUEUE_NUM];56};57 58int dpseci_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);59 60int dpseci_disable(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);61 62int dpseci_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);63 64int dpseci_is_enabled(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,65		      int *en);66 67/**68 * struct dpseci_attr - Structure representing DPSECI attributes69 * @id: DPSECI object ID70 * @num_tx_queues: number of queues towards the SEC71 * @num_rx_queues: number of queues back from the SEC72 * @options: any combination of the following flags:73 *		DPSECI_OPT_HAS_CG74 */75struct dpseci_attr {76	int id;77	u8 num_tx_queues;78	u8 num_rx_queues;79	u32 options;80};81 82int dpseci_get_attributes(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,83			  struct dpseci_attr *attr);84 85/**86 * enum dpseci_dest - DPSECI destination types87 * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode88 *	and does not generate FQDAN notifications; user is expected to dequeue89 *	from the queue based on polling or other user-defined method90 * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN91 *	notifications to the specified DPIO; user is expected to dequeue from92 *	the queue only after notification is received93 * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate94 *	FQDAN notifications, but is connected to the specified DPCON object;95 *	user is expected to dequeue from the DPCON channel96 */97enum dpseci_dest {98	DPSECI_DEST_NONE = 0,99	DPSECI_DEST_DPIO,100	DPSECI_DEST_DPCON101};102 103/**104 * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters105 * @dest_type: Destination type106 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type107 * @priority: Priority selection within the DPIO or DPCON channel; valid values108 *	are 0-1 or 0-7, depending on the number of priorities in that channel;109 *	not relevant for 'DPSECI_DEST_NONE' option110 */111struct dpseci_dest_cfg {112	enum dpseci_dest dest_type;113	int dest_id;114	u8 priority;115};116 117/**118 * DPSECI queue modification options119 */120 121/**122 * Select to modify the user's context associated with the queue123 */124#define DPSECI_QUEUE_OPT_USER_CTX		0x00000001125 126/**127 * Select to modify the queue's destination128 */129#define DPSECI_QUEUE_OPT_DEST			0x00000002130 131/**132 * Select to modify the queue's order preservation133 */134#define DPSECI_QUEUE_OPT_ORDER_PRESERVATION	0x00000004135 136/**137 * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration138 * @options: Flags representing the suggested modifications to the queue;139 *	Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags140 * @order_preservation_en: order preservation configuration for the rx queue141 * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'142 * @user_ctx: User context value provided in the frame descriptor of each143 *	dequeued frame;	valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained144 *	in 'options'145 * @dest_cfg: Queue destination parameters; valid only if146 *	'DPSECI_QUEUE_OPT_DEST' is contained in 'options'147 */148struct dpseci_rx_queue_cfg {149	u32 options;150	int order_preservation_en;151	u64 user_ctx;152	struct dpseci_dest_cfg dest_cfg;153};154 155int dpseci_set_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,156			u8 queue, const struct dpseci_rx_queue_cfg *cfg);157 158/**159 * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues160 * @user_ctx: User context value provided in the frame descriptor of each161 *	dequeued frame162 * @order_preservation_en: Status of the order preservation configuration on the163 *	queue164 * @dest_cfg: Queue destination configuration165 * @fqid: Virtual FQID value to be used for dequeue operations166 */167struct dpseci_rx_queue_attr {168	u64 user_ctx;169	int order_preservation_en;170	struct dpseci_dest_cfg dest_cfg;171	u32 fqid;172};173 174int dpseci_get_rx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,175			u8 queue, struct dpseci_rx_queue_attr *attr);176 177/**178 * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues179 * @fqid: Virtual FQID to be used for sending frames to SEC hardware180 * @priority: SEC hardware processing priority for the queue181 */182struct dpseci_tx_queue_attr {183	u32 fqid;184	u8 priority;185};186 187int dpseci_get_tx_queue(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,188			u8 queue, struct dpseci_tx_queue_attr *attr);189 190/**191 * struct dpseci_sec_attr - Structure representing attributes of the SEC192 *	hardware accelerator193 * @ip_id: ID for SEC194 * @major_rev: Major revision number for SEC195 * @minor_rev: Minor revision number for SEC196 * @era: SEC Era197 * @deco_num: The number of copies of the DECO that are implemented in this198 *	version of SEC199 * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented in this200 *	version of SEC201 * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented in this202 *	version of SEC203 * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are204 *	implemented in this version of SEC205 * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are206 *	implemented in this version of SEC207 * @crc_acc_num: The number of copies of the CRC module that are implemented in208 *	this version of SEC209 * @pk_acc_num:  The number of copies of the Public Key module that are210 *	implemented in this version of SEC211 * @kasumi_acc_num: The number of copies of the Kasumi module that are212 *	implemented in this version of SEC213 * @rng_acc_num: The number of copies of the Random Number Generator that are214 *	implemented in this version of SEC215 * @md_acc_num: The number of copies of the MDHA (Hashing module) that are216 *	implemented in this version of SEC217 * @arc4_acc_num: The number of copies of the ARC4 module that are implemented218 *	in this version of SEC219 * @des_acc_num: The number of copies of the DES module that are implemented in220 *	this version of SEC221 * @aes_acc_num: The number of copies of the AES module that are implemented in222 *	this version of SEC223 * @ccha_acc_num: The number of copies of the ChaCha20 module that are224 *	implemented in this version of SEC.225 * @ptha_acc_num: The number of copies of the Poly1305 module that are226 *	implemented in this version of SEC.227 **/228struct dpseci_sec_attr {229	u16 ip_id;230	u8 major_rev;231	u8 minor_rev;232	u8 era;233	u8 deco_num;234	u8 zuc_auth_acc_num;235	u8 zuc_enc_acc_num;236	u8 snow_f8_acc_num;237	u8 snow_f9_acc_num;238	u8 crc_acc_num;239	u8 pk_acc_num;240	u8 kasumi_acc_num;241	u8 rng_acc_num;242	u8 md_acc_num;243	u8 arc4_acc_num;244	u8 des_acc_num;245	u8 aes_acc_num;246	u8 ccha_acc_num;247	u8 ptha_acc_num;248};249 250int dpseci_get_sec_attr(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,251			struct dpseci_sec_attr *attr);252 253int dpseci_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,254			   u16 *major_ver, u16 *minor_ver);255 256/**257 * enum dpseci_congestion_unit - DPSECI congestion units258 * @DPSECI_CONGESTION_UNIT_BYTES: bytes units259 * @DPSECI_CONGESTION_UNIT_FRAMES: frames units260 */261enum dpseci_congestion_unit {262	DPSECI_CONGESTION_UNIT_BYTES = 0,263	DPSECI_CONGESTION_UNIT_FRAMES264};265 266/**267 * CSCN message is written to message_iova once entering a268 * congestion state (see 'threshold_entry')269 */270#define DPSECI_CGN_MODE_WRITE_MEM_ON_ENTER		0x00000001271 272/**273 * CSCN message is written to message_iova once exiting a274 * congestion state (see 'threshold_exit')275 */276#define DPSECI_CGN_MODE_WRITE_MEM_ON_EXIT		0x00000002277 278/**279 * CSCN write will attempt to allocate into a cache (coherent write);280 * valid only if 'DPSECI_CGN_MODE_WRITE_MEM_<X>' is selected281 */282#define DPSECI_CGN_MODE_COHERENT_WRITE			0x00000004283 284/**285 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to286 * DPIO/DPCON's WQ channel once entering a congestion state287 * (see 'threshold_entry')288 */289#define DPSECI_CGN_MODE_NOTIFY_DEST_ON_ENTER		0x00000008290 291/**292 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' CSCN message is sent to293 * DPIO/DPCON's WQ channel once exiting a congestion state294 * (see 'threshold_exit')295 */296#define DPSECI_CGN_MODE_NOTIFY_DEST_ON_EXIT		0x00000010297 298/**299 * if 'dpseci_dest_cfg.dest_type != DPSECI_DEST_NONE' when the CSCN is written300 * to the sw-portal's DQRR, the DQRI interrupt is asserted immediately301 * (if enabled)302 */303#define DPSECI_CGN_MODE_INTR_COALESCING_DISABLED	0x00000020304 305/**306 * struct dpseci_congestion_notification_cfg - congestion notification307 *	configuration308 * @units: units type309 * @threshold_entry: above this threshold we enter a congestion state.310 *	set it to '0' to disable it311 * @threshold_exit: below this threshold we exit the congestion state.312 * @message_ctx: The context that will be part of the CSCN message313 * @message_iova: I/O virtual address (must be in DMA-able memory),314 *	must be 16B aligned;315 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel316 * @notification_mode: Mask of available options; use 'DPSECI_CGN_MODE_<X>'317 *	values318 */319struct dpseci_congestion_notification_cfg {320	enum dpseci_congestion_unit units;321	u32 threshold_entry;322	u32 threshold_exit;323	u64 message_ctx;324	u64 message_iova;325	struct dpseci_dest_cfg dest_cfg;326	u16 notification_mode;327};328 329int dpseci_set_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,330	u16 token, const struct dpseci_congestion_notification_cfg *cfg);331 332int dpseci_get_congestion_notification(struct fsl_mc_io *mc_io, u32 cmd_flags,333	u16 token, struct dpseci_congestion_notification_cfg *cfg);334 335#endif /* _DPSECI_H_ */336